Show Menu

Linux Cheat sheet Cheat Sheet (DRAFT) by

Linux commands for DevOps engineers

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Listing commands

ls: List all the files and direct­ories in current directory.
ls -a: List all the hidden files and direct­ories.
ls -l: List all the file and direct­ories in longlist format with extra inform­ation.
ls *.sh: List all the files in current directory with .sh format.
ls -i: List all the files and direct­ories with index number inodes.
ls -d */: List only direct­ories.

Basic Linux

cp file1 file2:: to copy the content of file 1 to file2.
cp -R Dir1 Dir2: to copy dir1 recurs­ively to dir2.
mv file1 file2: rename­/move file 1 to file 2

ssh commands

ssh -p port user@host : connect to host on port as user
ssh -i <pr­ivate key of server > user@ip : connect to server
ssh-keygen : to generate pub key /private key
scp -i filename <pr­ivate key of server> user@i­p:/­hom­e/u­bun­tu/dir : to tranfer file from local to server

system info

date: to display the date
time: to display the time
whoami: display the current user
W: who is online
uptime:shows current uptime
df: display the amount of free space in file system.
du:display the amount of disk used in file system.
ps: display current active process
top: display all running process
kill pid:kill the process

Directory Commands

pwd: present working directory
cd path_t­o_d­ire­ctory: change path to specific directory.
cd: change path to home directory.
cd ..: change directory to one step back.
cd -: go to last working directory.
cd ../..: change directory to two step back.
mkdir newfolder: make direct­ory­/folder with name newfolder
mkdir newfolder1 newfolder2: make multiple folder­s/d­ire­ctories with name newfolder1 newfolder2 at once.
mkdir .hidde­nfolder: make a hidden folder­/di­rec­toriy with name hidden­folder.
mkdir -p A/B/C: make nested directory
mkdir /home/­use­r/e­xam­ple­Dir­ectory: make directory at a specific location.
mkdir day{1..5}: to create multiple files from day 1 till day5.

searching commands

grep [options] pattern [file_­name]: search for a pattern in file
grep -i user file1.txt: search for all the line in file file1.txt which contain user, User (-i is insens­itive)
grep -r pattern dir: search recurs­ively for pattern in dir
command | grep pattern : search for pattern in the output of command

Access Control List (ACL)

getfacl file_name: to view the access control of file.
sefacl defaul­t:u­ser­:pe­rmi­ssion file_name: to modify the access control to file.
setfacl -m u:root:rwx File1.txt: will provide the read, write, execute access control to root user.

Basic Linux Commands

cat filename : To view what's written in a file.
chmod 777 foldername: To change the access permission of file.
history: to check which you have run till now.
rmdir foldername: to remove a directory.
rm filename: to remove a file.
vi filename: to create a file and view content.
head -3 filename: to show only top 3 lines of file.
tail -3 filename: to show only bottom 3lines of file.
diff file1 file2: to show the difference between two files.
chown owner_name file_name: to change the owner of file.
chgrp group_name file_name: to change the group of the file.


ping hostname: ping the host and output results
hostname -i : Displays local IP address
wget file_name : download file

File Permission

w: write - 2
r:read - 4
x:execute - 1
0: no permission
1: execute
2: write
e.g: chmod 777 file1.txt will have read, write and executable permis­sion.