Professional Documents
Culture Documents
Important Commands For Linux Admin PDF
Important Commands For Linux Admin PDF
1) BASIC COMMANDS:
1. #Cat>file name: To create a file.
2. #Cat filename: To display the contents of a file
3. #Cat >>filename: To append the data in the already existed file
4. #touch <filename> <filename> <filename>: Creating multiple files at same time
5. #mkdir <dir name>: To create a directory
6. #cp <source filename> <destination directory in which to paste the file>: To copying file into directory
7. # cp rvfp <dir name> <destination name>: coping directories from one location to other location
8. #mv <dir name> <destination dir name>: Move a directory from one location to other location
9. #mv <old name> <new name>: To renaming a file
10. #rm filename or #rm f filename (without prompting): To removing a file
11. #ls: To search for all folders and files in a system
12. #grep root /etc/passwd: To see the information about a particular expression
13. #grep i kernel ktfile: To avoid case sensitive of the word
14. #grep nA2 wheel /etc/group: To display a word and 2 lines before the word
15. #grep -nB2 wheel /etc/group: To display a word and 2 lines after the word
16. #Less /etc/passwd: The less command is used to see the output line wise or page wise.
17. #more /etc/passwd: This command is used same as less command
18. # head /etc/passwd: It is used to display the top 10 lines of the file.
19. #tail /etc/passwd: It is used to display the last 10 lines of the file.
20. #sort filename: To display sorting order that is either numeric or alphabetical
21. #sort d ktfile: To sort the file according to numbers
22. #sed s/searchfor/replacewith/g filename: which is used to search a word in the file and replace it with
the word required to be in the output
23. #cat file1 file2 > file3: Copying of two content files into a single file
24. #ls l filename: To check list of file permissions to a file
25. #chmod ugo=rwx <file name>: Assigning full permissions to a file.
26. #chmod 764 ktfile (where 7 means rwx i.e. 4+2+1, rw=6 i.e. 4+2 and 1 indicates x: Assigning permissions
to a file in numerical mode(Absolute Method)
27. #umask: To check umask value
1|Page
Ramesh Ramineni
#chmod u+x ktfile (Adding execute permission to user only)
#chmod go-wx ktfile (Removing write and execute permissions from group and other)
#chmod go+wx ktfile (Adding write and execute permissions from group and other)
#chmod go=r ktfile (Giving only read permission to group and other)
3|Page
Ramesh Ramineni
4) USER AND GROUP ADMINISTRATION:
5|Page
Ramesh Ramineni
6|Page
Ramesh Ramineni
SOFTWARE MANAGEMENT:
1. #rpm qa: To check all the installed packages
2. #rpm q <package name>: To check whether a particular package is installed or not
3. #rpm ivh <package name>: To install a package
4. #rpm e < package name>: To remove or uninstall a package
5. #rpm qip <package name>: To see the info of package
6. #rpm qi < package name >: To see the info of installed package
7. #which cat: To check the package of a particular command
8. #rpm qf /bin/mount: To install a package forcefully
9. #rpm qlc <package name>: To see the configuration file for installed package
10. #rpm Uvh <package name>: To update a particular package
11. #yum list installed: To view installed packages in system
12. #yum localinstall finger* -y: To install a package by using yum
7|Page
Ramesh Ramineni
MANAGING INSTALL SERVICES:
1. #service <name of the service> status --- To check the status of the service
2. #service <name of the service> start --- To start the service
3. #service <name of the service > stop --- To stop a service
4. #service <name of the service> reload --- To reload the service
5. #service <name of the service> restart --- To restart the service
6. #chkconfig - -list: To check the status of all services availability
7. #chkconfig - - list <name of the service>: To check the status of particular service
8. #chkconfig vsftpd on: To make the service availability on
9. #chkconfig vsftpd off: To make the service availability off
10. #chkconfig - - level <1-6> <service> <on/off>: To make the service availablilty on, on a particular runlevel
MANAGING PROCESS:
1. #ps: To monitor the process
2. #ps a: To see total number of process running on the system
3. #ps u <user name>: To see the process of logged user
4. #ps x: To see which process are attached with some terminals
5. #ps aux : To see the offline process
6. #kill l : To see the list of signals
7. The most common signals used are
1 for reloading the process
9 for killing the process
15 for Terminating the process
20 for stopping the process
8. #kill <signal no> <process id>: To kill the signals
9. #nice n <nice value range (-20 to 19)> <command>: To set a priority of process
10. #top: To monitor all process
8|Page
Ramesh Ramineni
FTP SERVER:
NFS SERVER:
Profile for NFS:
o Package: nfs-utils
o Daemons: rpc.nfsd, rpc.mountd, rpc.statd, rpc.lockd, rpc.rquotad
o Script: /etc/init.d/nfs
o Port number: 2049
o Configuration File: /etc/exports
o Other imp files: /var/lib/nfs/etab, /var/lib/nfs/rmtab
10 | P a g e
Ramesh Ramineni
Client side configuration for NFS mounting:
Step1: Check and Install the NFS package if not installed
Step2: Start the NFS services
Step3: Check which directory is exported for this machine using show mount command
Step4: Make a directory and mount the NFS dir over it.
Step5: Add some data to it and check the same is updated on server side.
Note:- if you dont have DNS and you dont want use IP but want to use hostname instead, update hostname
with its ip in /etc/hosts file and then you can use hostname instead of IP
11 | P a g e
Ramesh Ramineni
SAMBA SERVER:
Profile for SAMBA:
o Usage: used for sharing files and directories in the network between different platforms,
like Linux-windows
o Package: SAMBA, SAMBA-common, SAMBA-client.
o Daemons: smbd, nmbd
o Script: /etc/init.d/smb, /etc/init.d/nmb
o Portno: 187 (net bios ns{name service}), 138 (net biosdgm {datagram})
o 139 (net bios-ssn{session service}), 445 (Microsoft ds{dist sys})
o File system: CIFS (common internet file system)
o Config file: /etc/samba/smb.conf
12 | P a g e
Ramesh Ramineni
7. We have to restart two services here
#smb and #nmb and make it add to enable after reboot
#service smb restart
#service nmb restart
13 | P a g e
Ramesh Ramineni
DNS SERVER:
14 | P a g e
Ramesh Ramineni
7. Add the address of DNS server in /etc/resolv.conf
Edit the /etc/resolv.conf and add the IP of DNS server
#vim /etc/resolv.conf
8. Restart the named service
#service named restart
Using host command to check resolution
Checking the DNS resolution with host command for both server as well as clients
#host <hostname>
Using host command with IP address of server as well as client
#host 192.168.10.95
#host 192.168.10.92 (or) 91, 93 any client
Use nslookup command with server and clients hostname and check it
#nslookup ktadm
Check the same thing with IP addresses
#nslookup 192.168.10.95
#nslookup 192.168.10.93
15 | P a g e
Ramesh Ramineni
WEB SERVER (APACHE):
Profile for Apache Server:
o Use: Hosting a web site.
o Package: httpd
o Port: 80/http, 443/https
o Configuration Files: /etc/httpd/conf/httpd.conf and /etc/httpd/conf.d/ssl.conf (https)
o Document Root: /var/www/html
o Daemon: httpd
o Script: /etc/initd/httpd
Steps to configure a simple web server:
1. The package for apache web server is httpd.
#yum install httpd* -y
2. Navigate to the configuration file for http i.e. /etc/httpd/conf/httpd.conf and copy the last 7
lines as shown below
#vim /etc/httpd/conf/httpd.conf
3. Navigate to the document root folder i.e. /var/www/html/ and create an index.html file which
will be accessed through a web browser
#vim /var/www/html/index.html
4. Open Firefox web browser and type the IP Address of the web server
http://192.168.10.95
5. To open the website from command line use the following command
#curl <IP/HOSTNAME of web server>
#curl 192.168.10.95
DNS configuration if you dont want to use IP address:
1. Open the DNS configuration file and add the canonical name as www, so that we can use our
domain as full fledge website.
#vim /var/named/kt.rlz
2. Restart the DNS services
#service named restart
16 | P a g e
Ramesh Ramineni
Important configuration files for linux:
Disk Identification:
Different type of disks will be having different initials in Linux
IDE drive will be shown as /dev/hda
SCSI drive will be shown as /dev/sda
Virtual drive will be shown as /dev/vda
Types of file systems used in RHEL 6:
S.NO EXT2 EXT3 EXT4
1. Stands for Second Stands for Third Stands for Fouth
Extended File System Extended File System Extended File System
2. It was introduced in It was introduced in It was introduced in
1993 2001 2008.
3. Does not have Supports Journaling Supports Journaling
journaling feature. Feature. Feature.
4. Maximum File size Maximum File Size Maximum File Size
can be from 16 GB to can be from 16 GB to can be from 16 GB to
2 TB 2 TB 16 TB
5. Maximum ext2 file Maximum ext3 file Maximum ext4 file
system size can be system size can be system size is 1 EB
from 2 TB to 32 TB from 2 TB to 32 TB (Exabyte). 1 EB =
1024 PB (Petabyte). 1
PB = 1024 TB
(Terabyte).
6. Cannot convert ext You can convert an All previous ext file
file system to ext2. ext2 file system to systems can easily be
ext3 file system converted into ext4
directly (without file system. You can
backup/restore). also mount an
existing ext3 f/s as
ext4 f/s (without
having to upgrade it).
17 | P a g e
Ramesh Ramineni
Some Important Points related to Users:
Users and groups are used to control access to files and resources
Users login to the system by supplying their username and password
Every file on the system is owned by a user and associated with a group
Every process has an owner and group affiliation, and can only access the resources its owner or group can
access.
Every user of the system is assigned a unique user ID number ( the UID)
Users name and UID are stored in /etc/passwd
Users password is stored in /etc/shadow in encrypted form.
Users are assigned a home directory and a program that is run when they login (Usually a shell)
Users cannot read, write or execute each others files without permission.
There are two important files a user administrator should be aware of.
1. "/etc/passwd"
2. "/etc/shadow"
Each of the above mentioned files have specific formats.
1. /etc/passwd
2. /etc/shadow
root:$1fdsfsgsdfsdkffefje:14757:0:99999:
7:::
The fields are as follows,
1. root = User name
2. :$1fdsfsgsdfsdkffefje = Encrypted password
3. 14757 = Days since that password was last changed.
4. 0 = Days after which password must be changed.
5. 99999 = Days before password is to expire that user is warned.
6. 7 = Days after the password is expires that the user is disabled.
7. A reserved field.
19 | P a g e