OS Fundamentals

Mastering Linux: 100+ Essential Commands for DevOps

Updated March 2024 | Bookmark this Cheat Sheet

Linux is the operating system of the Cloud. 90% of the world's servers run on Linux. Whether you are a Developer, DevOps Engineer, or SRE, you cannot survive without the terminal.

We have compiled the Ultimate 100+ Command List used by professionals daily, explained in very simple English.

1. File & Directory Operations

CommandUse Case
lsList files in the current folder.
ls -laList all files (including hidden ones) with details.
cd foldernameGo inside a folder (Change Directory).
cd ..Go back one step.
cd ~Go to your home folder.
pwdShow me "Where am I?" (Print Working Directory).
mkdir newfolderCreate a new folder.
mkdir -p a/b/cCreate nested folders (folder inside a folder).
rmdir folderDelete an empty folder.
rm -r folderDelete a folder and everything inside it.
touch file.txtCreate an empty file.
cp file1 file2Copy file1 to file2.
cp -r folder1 folder2Copy an entire folder.
mv file1 newlocMove a file (or Rename it).
rm file.txtDelete a file.
cat file.txtShow file content on screen.
less file.txtRead a large file page by page.
head file.txtShow only the first 10 lines.
tail file.txtShow only the last 10 lines.
tail -f log.txtWatch a file grow in real-time (Great for logs).

2. Permissions & User Management

CommandUse Case
chmod 777 fileGive Read/Write/Execute permission to everyone.
chmod +x script.shMake a file executable (so you can run it).
chown user:group fileChange the owner of a file.
useradd newuserCreate a new user account.
passwd newuserSet a password for the user.
userdel newuserDelete a user account.
groupadd devopsCreate a new group.
usermod -aG group userAdd a user to a group.
whoamiShow which user I am logged in as.
idShow my user ID and group IDs.
sudo commandRun a command as Administrator (Root).
su - userSwitch to another user account.
lastShow who logged in recently.

3. System Info & Hardware

CommandUse Case
topTask manager (Show CPU/RAM usage live).
htopA colorful, easier-to-read version of top.
df -hCheck disk space (Is hard drive full?).
du -sh folderCheck the size of a specific folder.
free -mCheck how much RAM is free.
uname -aShow OS and Kernel version.
hostnameShow the name of this computer.
lscpuShow CPU details (Cores, Speed).
lsblkList all storage devices attached.
uptimeHow long has the server been running?
dateShow current date and time.
calShow a calendar.
whoSee who else is logged in right now.

4. Networking

CommandUse Case
ping google.comCheck if internet is working.
ifconfigShow my IP address (Old way).
ip addrShow my IP address (Modern way).
curl urlGet data from a website in the terminal.
wget urlDownload a file from the internet.
netstat -tulpnShow which ports are open and listening.
ss -tulpnFaster version of netstat.
nslookup domainCheck the IP address of a domain.
dig domainDetailed DNS lookup.
ssh user@ipLog into a remote server securely.
scp file user@ip:/pathCopy a file to a remote server securely.
telnet ip portTest if a specific port is open on a server.
traceroute google.comTrace the path packets take to reach a site.

5. Search & Text Processing

CommandUse Case
grep "text" fileFind a word inside a file.
grep -r "text" .Find a word inside ALL files in a folder.
find / -name fileFind where a file is located on the drive.
locate fileQuickly find a file (using a database).
sort file.txtSort the lines of a file alphabetically.
uniq file.txtRemove duplicate lines (needs sorted file).
wc file.txtCount lines, words, and characters in a file.
diff file1 file2Show differences between two files.
sed 's/old/new/g' fileReplace word 'old' with 'new' in a file.
awk '{print $1}' filePrint only the first column of text.
head -n 5 fileShow first 5 lines.

6. Services & Processes

CommandUse Case
psList your current processes.
ps auxList EVERY process running on the system.
kill 1234Kill process with PID 1234.
killall nginxKill all processes named "nginx".
systemctl start nginxStart a service (e.g., Web Server).
systemctl stop nginxStop a service.
systemctl restart nginxRestart a service.
systemctl status nginxCheck if a service is running or failed.
systemctl enable nginxMake service start automatically on reboot.
bgSend a process to the background.
fgBring a background process to the foreground.

7. Zip, Tar & Archives

CommandUse Case
tar -cvf data.tar folderCreate a tar archive (Combine files).
tar -xvf data.tarExtract a tar archive.
tar -czvf data.tar.gzCreate a compressed archive (Zip it).
tar -xzvf data.tar.gzExtract a compressed archive.
zip data.zip folderCreate a standard .zip file.
unzip data.zipExtract a .zip file.
gzip fileCompress a single file.
gunzip file.gzDecompress a .gz file.

8. Shortcuts & Misc

CommandUse Case
historyShow last commands used.
!100Run command number 100 from history again.
clearClean the terminal screen (Shortcut: Ctrl+L).
exitLog out or close terminal.
man lsShow the manual (help) for "ls".
echo "Hello"Print "Hello" to the screen.
alias cls='clear'Create a custom shortcut command.
rebootRestart the computer.
shutdown nowTurn off the computer immediately.