Linux Commands Cheat- Sheet
---# User information---
- who : login name of user , date and time of login and remote host name of user .
- whoami : it displays system's user name .
- id : it displays the user identification
- groups : it displays the groups for which the user is belonging to .
- users : Display the username of all users currently logged on the system
- clear
- lastlog : The lastlog command is used to find the details of a recent login of all users .
- sudo(Super User Do ) : Allows a regular user to run the programs with the security privileges of a superuser or root.
Note : 5 Ways to login into your root account
- sudo -i
- sudo -s
- sudo su -
- su -root
- su - :- Works fine with CentOs
---Files & Directory((folders)) commands ---
Note : / is your root directory . ~ is your home directory .
- cd : change directory .
- cd ~ : change directory to home
- cd / : change directory to root . Note : cd / : - does it mean we are in root user ? Answer : - no, we are changing the directory to root level. Kind of C drive for windows we are moving to the base location .
- cat > filename :- This command creates a file in the current directory .
- cat filename :- displays the content of the file .
- cat f1 f2 >f3 : This command joins the content of two files and stores it in the third file. If the third file does not exist, it is first created and then the joined content is stored.
move file1.txt file2.txt : The command in the right changes the name of the file file1 to file2
pwd : It prints present working directory
- ls : to list directories .
- touch : create a file . eg :- touch devops.txt
- mkdir : to make directories
- rmdir : to remove files and directories . -p that refers for the parent (which means remove directory along with it's ancestors) -v verbose will give output for the processed directory
--- Installing Packages ---
- yum install package_name : Install package with help of yum command
- yum info package_name : this is going to diplay brief detail about a package
- yum remove package_name : this is going to remove the package
- Installing a package from a localfile ./filename But there can be a challange in installing from the localfile as first you will need to change the permission of the file using chmod commands .
---File Permission Commands---
There are 3 types of people who can use a file and each type has 3 types of access to the file.

Also, the access that we want to give to each of them is of three types:
- Read(r)
- Write (w)
- Execute (x)
One important thing to note here is that before these 9 slots of the user, group and others (read, write and execute permissions), there is also one another slot. This slot is for special files. For instance, if you something as drwxr--r--, here ‘d’ shows that it is a directory of which you are viewing the permissions. Further, rwx means that the user has all the three permissions where as r-- means that the group has only read permission and the write and execute permissions are not there with the group. The same is the case for others (another r--).
chmod : The chmod command stands for “change-mode” which means that using this command, we can change the mode in which some user is able to access the file. This command is used to change the file permissions.
There are numeric codes for each permission. They are as follows:
- r (read) = 4
- w (write) = 2
- x (execute) = 1
- No permissions = 0
eg : chmod 666 devops.txt Here, we have written 6 thrice because of applying the permissions to user, group and others. So, read and write permissions are applied to the user, group and others (666) for the file devops.txt.
---Disk Usage commands---
du pathofdirectory : To find out the disk usage summary
du -h pathofdirectory : This will bring up your information in human readable format
du -sh nameofdirectory : This is to find out total disk usage
ah -sh nameofdirectory : Total usage of all the files , disks and directories .
eg : du -h /home du stands for disk usage h stands for human readable
the output will be in Mbs/Kbs .
---System & harware information---
(These commands are helpful in the cloud Architecture eg : which machine is running onto the cloud instance , knowing there configuration etc .)
- uname -a : a here is for all
- uname -s : to know the kernal name
- uname -r : print kernal release version
- uname -m : Print Architecture
- uname -o : print your operating system name .