Professional Documents
Culture Documents
Linux Admin PDF
Linux Admin PDF
4. You will now be presented with a CD Check, I always skip this step… I live life on the edge when
it comes to media checking on Linux installs. However you might want to check the media.
5. You will now see some black and white text on your screen as your computer loads the
X11 environment for the CentOS install, after 30 seconds or so you will be presented with the
6. Select your Language, I am British (please no jokes about drinking tea on Twitter…) so I would
select English (English).
8. Storage type, as I am installing on my local hard drive I selected “Basic storage type” if you are
using iSCSI or similar technology now would be the time to set it up.
9. As this is a clean install and the drive has never been formatted before I got the
following Initialize drive warning, you might get the same if your drive (or virtual hard disk) is
brand new.
11. Set your root password, something sensible please… Don’t set weak dictionary passwords or
you will get hacked by a 13yr old russian super hackz0r… You might want to check out my guide
12. You will now be set with a bunch of options for your disk partitioning, as this is a new fresh
install I selected the option Create custom for creating own format.
14. Format warning, click on Format (this will delete your data.
15. You will now see a warning about writing the changes to disk, click on Write changes to disk.
16. Boot loader options, I left this as default you might want to set a boot loader password.
17. The next part is important selecting which programs to be install on the server follow the
screens .
Basic command
[root@server ~]# ls
[root@server ~]# ls -l
total 18656
To view list of files and folders with details human readable format
total 19M
To clear screen
[root@server ~]# ls -a
[root@server ~]#ls -R
./webmin-1.590/zones/images:
./webmin-1.590/zones/lang:
ca ca.UTF-8 de de.UTF-8 en
*************************
[root@server ~]# ls
*************************
[root@server ~]# ls
To create a directory
[root@server ~]# ls
[root@server ~]# ls
kumar1/:
total 4
kumar1/kumar2:
total 4
kumar1/kumar2/kumar3:
total 0
Changing directory
[root@server kumar]# ls
kumar2
Back to directory
[root@server ~]# cd ..
Removing a file
[root@server ~]# ls
[root@server ~]# ls
Copying a file
[root@server Desktop]# ls
[root@server Desktop]# cd ..
Rename a file
This is anand
This is kumar
This is kumar
anand:$6$hslH52Z5$OIyifFiYWz6xce1g5T9T.5bElOHYY1f2uWeuRaYgZTqazYJcEgoW
BgQEMyoj2LRLv432g82gZd7Am0az0KtmU/:15543:0:99999:7:::
anand2:$6$0yfKjYdK$UofWZugkLX/SXSJXqJap6Y/zgp2YNbCWLobbZOiAYYO4d5SAewI
97Du/GjFkeJAFAMMMHMjuU4zqkCsZ2xZ9O1:15546:0:99999:7:::
To get calendar
December 2011
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
To Clear history
[root@server ~]# df -h
q to quit
or
or
To restart computer
Editors:
Vi/VIM editor
Commands in vi editors
x delete character
nx delete n characters
X delete character before cursor
dw delete word
ndw delete n words
dd delete line
ndd delete n lines
D delete characters from cursor to end of line
r replace character under cursor
cw replace a word
ncw replace n words
C change text from cursor to end of line
o insert blank line below cursor
(ready for insertion)
O insert blank line above cursor
(ready for insertion)
J join succeeding line to current cursor line
nJ join n succeeding lines to current cursor line
u undo last change
U restore current line
New password:
u1:x:2001:2002::/home/u1:/bin/bash
u1:$6$E/UXqIAk$wCMbTNlmbAlM4Z8YHBIk8q3Dek0pDes/miMujoq2u.4v8KKPjSz80MT
VXGQ4Y/z2AyjCD/DFEmCEFCvLI1mto/:15546:0:99999:7:::
u1:x:2002:
u2:x:1000:1000::/marketing/u2:/bin/bash
u3:x:1500:1500::/marketing/u3:/bin/zsh
Log off from root user and log in as u1 user,u1 user should not log
in..
Log off from root user and log in as u1 user, change the password..
u100:x:2001:2002::/home/u1:/bin/bash
[u100@server ~]$exit
shiva1:x:2001:anand2,tom
shiva:x:2003:
uid=2001(u100) gid=2002(u1)
groups=2002(u1),2001(shiva1),2004(marketing)
deleting user
deleting a group
[root@server ~]#
Permissions
Note: permission can be assigned to files and folders not users and groups.
[root@server ~]# ls -l
:q!
[ramesh@server ~]$exit
:wq
[ramesh@server ~]$exit
[root@server ~]#
Stick bit
stick bit can be applied to folders only, which provides full access to all the users but only the user can
delete the files who is owner.
[root@server /]# cd ..
[root@server /]# ls -l
total 1536
logout
logout
U150 trying to remove 2.txt file which is under full permission folder for all users, but stick bit is applied.
Sudo users
We trust you have received the usual lecture from the local System
Basic networking
To view hostname
Assigning hostname
NETWORKING=yes
HOSTNAME=server.example.com
:wq!
[root@server network-scripts]# ls
DEVICE=eth0
NM_CONTROLLED=yes
ONBOOT=no
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
HWADDR=00:0c:29:22:0b:fe
PEERROUTES=yes
USERCTL=no
PEERDNS=yes
Assigning IP address
Using tool
Manually
Steep1 :
To check IP address
collisions:0 txqueuelen:1000
collisions:0 txqueuelen:0
or
[root@server ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
Assigning Another IP address to same network card which is known as virtual Ethernet card.
DEVICE=eth0:1
NM_CONTROLLED=yes
ONBOOT=no
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
NAME="System eth0:1"
Note: you can create 0-253 virtual IP address for one network card
root
There are three different ways you can install programs on Linux
1) Using .rpm
2) Yum
3) Source
1 using rpm
[root@localhost media]# ls
[root@localhost Packages]# ls
or
httpd-2.2.15-15.el6.centos.i686
httpd-2.2.15-15.el6.centos.i686
httpd-tools-2.2.15-15.el6.centos.i686
Installation Location
or
2) Using yum
[root@localhost /]#configure
[root@localhost /]#make
[root@localhost /]# ls
Job scheduling
1) cron tab
2) at
1) Cron tab
30 08 10 06 * /home/ramesh/full-backup.sh
0 22 * * * poweroff
:wq!
[root@server /]# crontab -l
30 08 10 06 * /home/ramesh/full-backup.sh
0 22 * * * poweroff
# crontab -ir
crontab: really delete root's crontab? n
• 30 – 30th Minute
• 08 – 08 AM
• 10 – 10th Day
• 06 – 6th Month (June)
• * – Every day of the week
• 0 – every minute
• 22 – 20 PM
• * – everyday
• * – every month
• * – Every day of the week
2) At Command
Adding a job
at> poweroff
press ctrl+d
at> <EOT>
Viewing jobs
[root@server /]# at -l
Removing a job 1
[root@localhost ~]# df -h
switch off the mode (command 'c') and change display units to
Command action
d delete a partition
Steep4 : creating file system for newly created /dev/sda6, /dev/sda7, /dev/sda8.
[root@localhost ~]# mkfs.ext2 /dev/sda6
[root@localhost dev6]# ls
lost+found
[root@localhost dev6]# cd ..
[root@localhost dev7]# ls
lost+found
[root@localhost dev7]# cd ..
[root@localhost dev8]# ls
lost+found
[root@localhost dev8]# cd ..
[root@localhost /]#
switch off the mode (command 'c') and change display units to
Steep4 : creating file system for newly created /dev/sda6, /dev/sda7, /dev/sda8.
[root@localhost ~]# mkfs.ext4 /dev/sda6
PV Name /dev/sda6
VG Name
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID abgRMn-cr4I-dyF0-ekY9-SaWm-CeyW-j5ifMS
PV Name /dev/sda7
VG Name
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID STQw3d-8ffF-D9Yq-9ji3-xGug-ADcD-FlgHIf
PV Name /dev/sda8
VG Name
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID RNbNM6-d4v7-qKfM-UVOb-76sa-qTsK-8OUCor
VG Name vg1
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
Total PE 104
Alloc PE / Size 0 / 0
VG UUID u1QKS0-5EiL-jghL-Owj9-0brg-QWD8-1zOooC
LV Name /dev/vg1/lv1
VG Name vg1
LV UUID ZzIF11-rkjv-inkb-UiFF-8i3l-YN9n-7qZ2ei
LV Status available
# open 0
Current LE 50
Segments 1
Allocation inherit
[root@localhost ~]# df -h
[root@localhost /]#
At last
RAID- 1/5
steep1: Creating 3 partitions sda5, sda6, sda7 which are 200M, 200M 100M.
Command action
l logical (5 or over)
Command action
l logical (5 or over)
Command action
l logical (5 or over)
Note: RAID 1 is mirroring, when configuring RAID 1 your HDD partitions size should be
same.
Steep2 : Creating mdadm for raid
[root@ns1 ~]# mdadm --create /dev/md0 --level=1 --raid-devices=2
/dev/sda6 /dev/sda7
mdadm: /dev/sda6 appears to contain an ext2fs file system
--metadata=0.90
Personalities : [raid1]
or
/dev/md0:
Version : 1.2
Raid Devices : 2
Total Devices : 2
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : 4488587c:00e56ff3:854194c1:0845c4fa
Events : 17
[root@ns1 ~]# df -h
[root@ns1 ~]# df -h
/dev/md0:
Version : 1.2
Raid Devices : 2
Total Devices : 2
Active Devices : 1
Working Devices : 1
Failed Devices : 1
Spare Devices : 0
UUID : 4488587c:00e56ff3:854194c1:0845c4fa
Events : 18
1 0 0 1 removed
Personalities : [raid1]
/dev/md0:
Version : 1.2
Raid Devices : 2
Total Devices : 1
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0
UUID : 4488587c:00e56ff3:854194c1:0845c4fa
Events : 21
1 0 0 1 removed
/dev/md0:
Version : 1.2
Raid Devices : 2
Total Devices : 2
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
UUID : 4488587c:00e56ff3:854194c1:0845c4fa
Events : 42
Personalities : [raid1]
[root@ns1 ~]#
RAID 5
Backups:
Backups software is used depends upon your requirement of the company. General
tools are used for backup in the market
1) veritas netbackup
2) tar
3) cpio
4) dd
5) bacula (network backup server)
6) Amanda (network backup server)
7) rsync (remote sync)
1) Tar tool
[root@localhost xyz]# cd ..
Or
/xyz/
/xyz/shiva1
/xyz/hyd2
/xyz/shiva
/xyz/hyd
Or
Or
Or
xyz/
xyz/shiva1
xyz/hyd2
xyz/shiva
xyz/hyd
[root@localhost /]#
To Unzip
/xyz/
/xyz/shiva1
/xyz/hyd2
/xyz/shiva
/xyz/hyd
1 block
1 block
/xyz
/xyz/shiva1
/xyz/hyd2
/xyz/shiva
/xyz/hyd
1 block
[root@localhost xyz]# cd ..
root@192.168.1.101's password:
./
hyd
hyd2
shiva
shiva1
[root@localhost dev8]# ls
To restore backup
Process management
[root@localhost /]# ps
[root@localhost /]#ps -e
[root@localhost /] top
2.6.32-220.el6.i686
killing a process
example
press ctrl + z
[root@localhost ~]# ps
[root@localhost ~]# ps
[root@localhost ~]# ps
B. Anand kumar
email : bandaru.anand@gmail.com
NFS server is used to share the data in to the network like Linux/Unix/ AIX/SUN environment.
[root@node2 anand]# ls
[root@node2 anand]# cd /
/anand 192.168.0.0/255.255.255.0(rw,sync)
/anand1 *(r,sync)
:wq!
Client Side:
[root@client/]# cd /shiva
[root@client/]#ls
Or
Steep2: By default in the main configuration file is black, so u need to copy from
/usr/share/doc/dhc*/dhcp.conf.sample
:wq!
Line 78 }
:wq!
[root@node2 /]#system-config-network-tui
Ok---save---save quit
Or
[root@node2 /]# ls
anonymous_enable=YES
local_enable=YES
# userlist_enable=YES
userlist_deny=NO
:wq!
Listen_port=40
:wq!
Steep 4: if you want block few users user, then add the user in /etc/vsftpd/ftpusers
u1
:wq!
ftp://u1@192.168.0.X
or
ftp://u1@192.168.0.X:40
You can also use some ftp client software like gftp, coreftp, leap ftp, fizalla etc
Or
Name (192.168.0.102:root): u1
Password:
ftp> ls
ftp> bye
221 Goodbye.
Samba Configuration
Samba is a service is used to share data from Linux/Unix to windows operating system.
Or
Steep2: create share folder in samba to share from windows (/shiva) and create some users to log in
from windows
Note: at last
[public-share]
path = /shiva
valid users = u1 u1
public = no
writable = yes
printable = no
:wq!
[public-share]
path = /shiva
read only = No
Ex:
Or
smb: \> ls
[root@node2 /]# ls
Or
NETWORKING=yes
HOSTNAME=node2.localdomain.com
:wq!
search localdomain.com
nameserver 192.168.1.7
Line 17 };
Line 35 };
Steep8: adding the forward and reverse look up zones to named group
$TTL 1D
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
In NS node2.localdomain.com.
node2 IN A 192.168.1.7
web IN A 192.168.1.9
mailser IN A 192.168.1.10
localdomain.com IN MX mailser
$TTL 1D
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS node2.localdomain.com.
7 IN PTR node2.localdomain.com.
9 IN PTR web.localdomain.com.
10 IN PTR mailserv.localdomain.com.
Note: when you’re checking DNS server you have to get quary 1 and
answer 1 must.
Apache is web server. In one web server we can host number of websites depending up on the capable
of server.
To host one web site we need One IP address, one name and one port number must.
Note: Before configuring Apache web server it is always bet practice to configure DNS server.
or
192.168.1.X www.localdomain.com
:wq!
Website location
:wq!
Syntax OK
<html>
<body>
</body>
</html>
:wq!
[root@node2 html]#
http://<ipaddress>
or
http://localdomain.com
Name based: we are going to host name based like www.localdomain.com, www.example.com,
www.example1.com and www.example2.com
Port based: Port based web site runs under port 100.
IP based hosting: We are going to create another virtual IP 192.168.1.XX, and www.example2.com
website runs on this ip address
192.168.1.X www.localdomain.com
192.168.1.X www.example.com
192.168.1.X www.example1.com
192.168.1.XX www.example2.com
:wq!
<VirtualHosting 192.168.1.x:80>
ServerAdmin root@example.com
ServerName www.example.com
DocumentRoot "/var/www/html/example"
</VirtualHosting>
:wq!
Syntax OK
listen 100
<VirtualHosting 192.168.1.x:80>
ServerAdmin root@example1.com
ServerName www.example1.com
DocumentRoot "/var/www/html/example1"
</VirtualHosting>
:wq!
Syntax OK
IP based hosting
Note: Follow network practical for how to create new virtual eathernet card.
<VirtualHosting 192.168.1.XX:80>
ServerAdmin root@example2.com
ServerName www.example2.com
DocumentRoot "/var/www/html/example2"
</VirtualHosting>
:wq!
Syntax OK
Type http://localdomain.com
http://example.com
http://example1.com:100
Installing webmin
When the network installer image has booted press the Esc key on the boot menu screen, enter the
following command at the boot: prompt and press the enter key
Pre requirements for Network installation: Copy all the data from dvd to a new folder. Configure NFS
server with shared folder.
Steep7: Follow remaining steeps from (steeps 8) onwards which given on top.