Linux Basics Commands
CAT: used to create a new file and it is used to open an existing file
*to create a new file using cat: cat > filename
*to open an existing file using cat: cat filename
*to add data to already existed file: cat >> filename
Vi: it is used to create a file and to edit a file
*to open a new file: vi filename
Then press enter, it will show an empty file, to edit data press “i” for insert mode, after completion of
editing text to save the file, press Esc+:wq!
*to open an existing file also: vi filename
Touch: it used to create multiple empty files
*to create multiple empty files: touch file1 file2 file3
*to list the files: ls and ll
* to remove a file: rm file1 file2…….
*to rename a file name: mv old_filename New_filename
*to copy a file from location to another: cp source_path Destination_path
*to nullify a file: > filename (if you run this command, it will make the file empty – data in that file will
be erased)
Creating a Directory:
*to create a new directory: mkdir dir_name
* to go into the directory: cd dir_name
* remove a directory: rm -r dir_name
*to rename a directory name: mv old_Dirname New_Dirname
*to check the present working location: pwd
File System Hierarchy:
/boot: it stores system bootable files
/opt: it is optional directory, it stores 3rd party softwares
/bin: it contains the commands used by all users
/sbin: it contains the commands used by super user (root)
/home: it is home directory for users
/var: it contains all variable files (ex: logs)
/etc: it contains all configuration files
User Administration:
*to create an user: useradd username
adduser username
*to remove an existing user: userdel -r username (if you are using “-r” option while removing an user, it
will delete the user’s home directory also)
*to switch from one user to another user: sudo su username
*to set a password for user: passwd username
*after adding, user information will store in /etc/passwd file
*after setting password, password information will store in /etc/shadow file
Group Administration:
*to create a new group: groupadd group_name
*to remove a group: groupdel group_name
*to add user to a group: usermod -aG group_name user_name (G - for primary group, g - for
secondary group)
Filter Commands:
*grep: it is used on file, used to filter the file with any keyword: cat filename | grep -i Keyword
*head: it will show the top 10 lines of a file: cat filename | head
Head filename
*tail: it will show bottom 10 lines of a file: cat filename | tail
tail filename
Disk, CPU, Memory utilization:
*to check the disk utilization: df -h
* to check the CPU utilization: top (in top command, you can check CPU, load average and memory
utilization % also )
iostat
*to check the memory: free -m (or free -h)
*to check the file/directory size: du -sh *
Package management:
*package installation can be done by two ways: using yum and rpm
YUM: Yellowdog updater modified
*to install package using yum: yum install package_name
*to uninstall package: yum uninstall package_name
*to remove package: yum remove package_name
*to check the package information: yum info package_name
RPM: Redhat package Manager
*to install a package: rpm -ivh package_name
*to uninstall a package: rpm -Uvh package_name
*to remove a package: rpm -e package_name
*to check the package information: rpm -qa package_name
NOTE: to check the previous package installation history: yum history
File/Directory permissions:
Permissions will be in below format
rwxrwxrwx: here we can devide into 3parts like user, group, others (rwx rwx rwx)
*default directory permissions are: 755
*default file permissions are: 644
*directory full permissions are: 777
*full permissions for file is: 666
*to change the permissions for file or directory: chmod u,g,o+w file/dir_name (here we are giving
write(w) permission to users,groups,others)
chmod 777 firle/die_name
*to change the ownership to a file/directory: chown username file/dir_name
ITIL: ITIL Process (Information Technology Infrastructure Library)
*event management- scheduling meetings with clients/teams, clients data, tickets follow up (L1 support)
*incident management: any abnormal event occurs on server, we call it as an incident
*problem management: any incident occurring repeatedly on server, we can treat it as problem. we
need to find out the RCA and do permanent fix
*change management: for any hardware replacements, any configuration changes, OS updates, package
installations we need to create a CHANGE REQUEST
SLA:
p1-Critical, immediate
p2-High, with in 24hrs
p3-Medium, 7days
p4-Low, 14days