Cheatography
https://cheatography.com
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 directories in current directory. |
ls -a: List all the hidden files and directories. |
ls -l: List all the file and directories in longlist format with extra information. |
ls *.sh: List all the files in current directory with .sh format. |
ls -i: List all the files and directories with index number inodes. |
ls -d */: List only directories. |
Basic Linux
cp file1 file2:: to copy the content of file 1 to file2. |
cp -R Dir1 Dir2: to copy dir1 recursively 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 <private key of server > user@ip : connect to server |
ssh-keygen : to generate pub key /private key |
scp -i filename <private key of server> user@ip:/home/ubuntu/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_to_directory: 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 directory/folder with name newfolder |
mkdir newfolder1 newfolder2: make multiple folders/directories with name newfolder1 newfolder2 at once. |
mkdir .hiddenfolder: make a hidden folder/directoriy with name hiddenfolder. |
mkdir -p A/B/C: make nested directory |
mkdir /home/user/exampleDirectory: 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 insensitive) |
grep -r pattern dir: search recursively 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 default:user:permission 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. |
Network
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 |
4:read |
e.g: chmod 777 file1.txt will have read, write and executable permission. |
|