DevOps Commands Cheat Sheet by M Nagasai
Table of Contents
• Basic Navigation and File Management
• pwd – Print Working Directory
• ls – List Directory Contents
• cd – Change Directory
• cat – Concatenate and Display Files
• mkdir , rmdir , cp , mv , rm , touch , ln – Other File/Directory Commands
• Permissions and Ownership
• chmod – Change File Permissions
• chown – Change File Owner
• chgrp – Change File Group
• umask – Default Permission Mask
• System Information and Monitoring
• top – Interactive Process Viewer
• ps – Report Process Status
• free – Display Memory Usage
• df – Disk Free Space
• du – Disk Usage of Files/Directories
• uptime – System Uptime
• who , w , id , uname – Other Info Commands
• Networking
• ping – Test Network Connectivity
• ip – Show/Manipulate Network Configuration
• netstat , ss – Network Connections and Statistics
• traceroute – Trace Network Path
• nslookup , dig – DNS Query Tools
• curl , wget – HTTP/FTP Clients
• route – Kernel Routing Table
• Searching and Text Processing
• grep – Search Text via Patterns
• sed – Stream Editor for Text
• awk – Pattern Scanning and Processing
• find – Search for Files
• sort , uniq , cut , wc – Text Filtering Utilities
• diff , cmp – File Comparison
• tr – Translate or Delete Characters
• Package Management
• apt (Debian/Ubuntu) – Install/Remove Packages
• yum / dnf (CentOS/RHEL) – Install/Update Packages
1
• rpm (RPM packages) – Query/Install RPMs
• dpkg (Debian packages) – Query/Install DEBs
• snap – Universal Linux Packages
• User Management
• useradd , usermod , userdel – Create/Modify/Delete Users
• groupadd , groupdel – Create/Delete Groups
• passwd – Change User Password
• whoami , id , sudo , su – User Identity and Privilege Commands
• Automation and Scheduling
• cron , crontab – Recurring Task Scheduler
• at – One-time Task Scheduler
• File Compression and Archiving
• tar – Archive and Compress Files
• gzip , gunzip – Gzip Compression
• bzip2 , bunzip2 – Bzip2 Compression
• zip , unzip – Zip Archive Utility
• xz – XZ Compression (LZMA2)
• 7z – 7-Zip (LZMA) Compression
• Remote Access and File Transfer
• ssh – Secure Shell (Remote Login)
• scp – Secure Copy (Files over SSH)
• sftp – Secure FTP (Interactive over SSH)
• rsync – Remote and Local File Sync
• System Administration
• systemctl – Control Systemd Services
• journalctl – View Systemd Logs
• shutdown , reboot – Halt or Restart System
• mount – Mount/Unmount Filesystems
• DevOps and Cloud Tools
• docker – Docker Container Management
• kubectl – Kubernetes CLI
• terraform – Infrastructure as Code CLI
• ansible – Automation Engine CLI
• aws – AWS CLI
• gcloud – Google Cloud SDK CLI
• Version Control
• git – Distributed Version Control
• Bash Scripting Basics
• echo , read – Output and Input in Scripts
• if , for , while , case , test – Control Structures
2
Basic Navigation and File Management
pwd
Purpose & Description: The pwd (print working directory) command displays the absolute path of the
current directory
Syntax: pwd
. It’s commonly used to confirm your present location in the filesystem hierarchy.
1
Options: By default pwd shows the full path. With -L or -P you can print logical or physical paths
(resolving symlinks) if needed.
Example: Running pwd might output something like /home/user/projects
1
, indicating you are in
the projects subdirectory.
Tip: Use echo $(pwd) to include the path in strings or scripts.
Interview Q: What does pwd do? – It prints the working directory (current directory path)
1
.
ls
Purpose & Description: The ls command lists files and directories. By default, it shows non-hidden items
in the current directory 2 . It’s one of the most frequently used commands for directory navigation.
Syntax: ls [options] [file_or_directory] 2
Common Options:
- -l : long listing (shows permissions, owner, size, date)
- -a : include hidden files (starting with . )
- -h : human-readable sizes (e.g. 1K, 234M)
- -t : sort by modification time
- -r : reverse order
For example, ls -lha shows all files (including hidden) with detailed info in human-readable sizes
3
.
Example: ls -l /var/log might output lines like:
-rw-r--r-- 1 root root 12345 May 12 08:23 syslog
drwxr-xr-x 2 syslog adm
4096 May 12 08:00 apt
(Note: example output for illustration; actual may vary.)
Complex Breakdown: You can combine flags, e.g. ls -ltr sorts by time, oldest first.
Interview Q: How do you view hidden files using ls ? – Use ls -a , which shows all files including those
starting with a dot
3
.
cd
Purpose & Description: The cd command changes the shell’s current working directory. For example,
cd /etc moves you into the /etc directory
Syntax: cd [directory]
4
.
4
Options: Typically none; cd - switches to the previous directory.
Example: cd ~/projects followed by pwd might show /home/user/projects .
Tip: cd ~ or just cd returns you to the home directory.
3
cat
Purpose & Description: cat concatenates and displays file contents
text files or combine files.
Syntax: cat [options] [file]...
5
. Commonly used to view short
5
Options:
- -n : number all output lines
- -b : number non-blank lines
- -A : display non-printing chars (e.g. newline as $ )
Example: cat file.txt prints the content of file.txt .
Tip: Use cat file1 file2 > combined to merge files.
Other Basic Commands ( mkdir , rmdir , cp , mv , rm , touch , ln )
• mkdir : Create directories. Syntax: mkdir [options] directory_name
6
. For example,
mkdir mydir makes a new folder. Use -p to create parent directories as needed.
• rmdir : Remove empty directories. Syntax: rmdir directory_name
empty.
• cp : Copy files or directories
8
7
. Errors if directory is not
. Syntax: cp [options] source target . Use -r to copy
directories recursively. E.g. cp -r dir1 backup_dir .
• mv : Move or rename files/directories
9
. Syntax: mv [options] source target . Use to
rename (e.g. mv old.txt new.txt ) or move to a different folder.
• rm : Remove files or directories 10 . Syntax: rm [options] file . Use -r to remove directories
recursively. Warning: rm -rf forces deletion without prompt, use with caution.
• touch : Create an empty file or update timestamp. Syntax: touch file . For example, touch
newfile.txt creates a blank file if it doesn’t exist.
• ln : Create links. Syntax: ln [options] source link_name . ln file link makes a hard
link; ln -s file link makes a symbolic link.
Each of these basic commands may be cited and explored similarly (refer to general Linux documentation
for details).
Permissions and Ownership
chmod
Purpose & Description: chmod changes file and directory permissions 11 . It uses a numeric mode or
symbolic letters (r, w, x).
Syntax: chmod [options] mode file_or_directory
11
Options:
- u/g/o/a : user/group/others/all (as symbolic mode)
- +/- : add or remove permissions
- -R : recursive into directories
For example, chmod 755 script.sh gives owner read/write/execute and others read/execute.
Complex Example: Symbolically, chmod u+r,g-w,o=x file adds read to user, removes write for group,
sets others to execute.
4
Interview Q: What does chmod 644 file.txt do? – Sets permissions to owner read/write, group read,
others read (no execute) 11 .
chown
Purpose & Description: chown changes file owner (and optionally group) 12 . Useful when transferring
files between users.
Syntax: chown [options] [new_owner][:new_group] file_or_directory
Example: sudo chown bob file.txt changes owner to user bob
13 . Add
12
:staff to change group
too.
Tip: Use chown -R user:group /dir to recursively change ownership of a directory.
chgrp
Purpose & Description: chgrp changes the group ownership of a file or directory 14 . It is similar to
chown but only for groups.
Syntax: chgrp [options] group file_or_directory
15
Example: sudo chgrp developers project.txt makes the file’s group developers .
umask
Purpose & Description: umask sets the default permission mask for new files/directories. It defines
permissions that should not be given. For example, a umask of 022 ensures new files are not writable by
group/others. It’s often used in shell profiles to enforce secure defaults 16 .
Syntax: umask [option] [mask] 16
Example: umask 027 makes new files readable by owner and group, but not by others.
System Information and Monitoring
top
Purpose & Description: top provides an interactive real-time view of running processes 17 . It shows
CPU/memory usage, process IDs, etc.
Syntax: top 17
Options: In top , press keys like M to sort by memory, P by CPU. -n option can make it non-interactive
for a given number of iterations.
Example: Running top on a busy server shows processes ordered by CPU usage, updating every few
seconds.
Interview Q: How can you exit top ? – Press q to quit.
ps
Purpose & Description:
ps
reports snapshot of current processes 18 . Without options, it shows
processes for the current shell.
Syntax: ps [options] 18
Common Options:
5
- -e or -A : show all processes.
- -f : full format (shows PPID, start time).
- -u user : show processes for a user.
For example, ps -ef lists all processes with details, similar to ps -aux .
Example: ps -u nginx shows processes owned by user nginx .
Interview Q: Difference between ps -ef and ps aux ? – Both list all processes; -ef is standard syntax,
aux is BSD style (with x including processes without controlling TTY) 18 .
free
Purpose & Description: free displays system memory (RAM and swap) usage 19 . It shows total, used,
and free memory.
Syntax: free [options]
Options: -h for human-readable (shows MB/GB) is common.
Example: free -h might output:
Mem:
Swap:
total
7.8G
2.0G
used
2.1G
0B
free
3.5G
2.0G
shared
200M
buff/cache
2.2G
available
5.1G
This shows RAM and swap status.
df
Purpose & Description: df shows free and used disk space for mounted filesystems 20 . Useful to check
if a disk/partition is full.
Syntax: df [options] [filesystem_or_directory]
20
Common Options:
- -h : human-readable sizes (e.g. 1K, 234M, 2G) 20 .
- -T : show filesystem type.
Example: df -h /home might show:
Filesystem
/dev/sda1
Size
100G
Used Avail Use% Mounted on
40G
60G 40% /home
This indicates /home has 60GB free.
du
Purpose & Description: du (disk usage) shows the space used by files and directories 21 . It’s often used
to find large directories.
Syntax: du [options] [path]
21
Common Options:
- -h : human-readable sizes
6
- -s : summarize total for each argument (instead of each subdir)
- -c : produce a grand total.
Example: du -sh /var/log might output 1.2G
/var/log , meaning the log directory uses
1.2GB 21 .
uptime
Purpose & Description: uptime shows how long the system has been running, number of users, and
load averages 22 .
Syntax: uptime
Example: uptime could output:
09:30:01 up 5 days,
3:12,
2 users,
load average: 0.15, 0.10, 0.05
This means the system’s been up 5 days, 3 hours 12 mins, with a low load.
Other Information Commands ( who , w , id , uname )
• who : Lists logged-in users and their login terminals/time. For example, who might show user1
pts/0 2025-05-13 09:00 (10.0.0.1) . It helps see who is on the system.
• w : Similar to who but shows what each user is doing (processes), plus system load. It’s a more
detailed view of user activity 23 .
• id : Prints user identity (UID, GIDs) for current or specified user 24 . E.g., id bob might show
uid=1001(bob) gid=1001(bob) groups=1001(bob),27(sudo) . Useful for scripts to check
privileges.
• uname : Shows system information. uname -a prints kernel name, hostname, kernel version,
architecture, etc 25 . E.g., Linux myhost 5.15.0-50-generic x86_64 .
Networking
ping
Purpose & Description: ping tests network reachability between hosts. It sends ICMP echo requests to a
host and waits for replies 26 . Useful for checking if a server is up or the network is working.
Syntax: ping [options] destination 26
Options: -c count to send a fixed number of packets (e.g. ping -c 4 google.com ).
Example: ping -c 3 8.8.8.8 might output statistics showing bytes, RTT (round-trip time), packet loss.
If packets come back, the host is reachable.
ip
Purpose & Description: ip is the modern replacement for older tools like ifconfig and route . It
shows and configures network interfaces, IP addresses, routes, etc 27 .
Syntax: ip [options] OBJECT [command] 27 , where OBJECT can be addr , link , route , etc.
Examples:
7
- ip addr show lists all network interfaces and their IP addresses.
- ip link set eth0 up brings interface eth0 up (enabled).
- ip route shows the routing table.
This powerful command can do almost everything about network config.
netstat , ss
Purpose & Description: netstat (deprecated on some systems) and ss show network connections and
listening ports.
- ss : The modern tool to display socket connections (replacing netstat ). For example, ss -tulpn
lists listening TCP/UDP ports and associated processes. It’s very fast.
- netstat : Older tool; netstat -tulpn shows similar info.
These are essential for troubleshooting open ports, network services, etc 28 .
traceroute
Purpose & Description: traceroute traces the path packets take to a remote host, listing all hops
(routers) along the way. It’s useful for diagnosing where network delays or failures occur 29 .
Syntax: traceroute [options] destination
Example: traceroute example.com might output each hop’s IP and latency. If it stops somewhere, that
router might be blocking or down.
Tip: On some systems the command is tracert (Windows) or requires traceroute package.
nslookup and dig
Purpose & Description: These are DNS lookup tools:
- nslookup : Queries DNS to find IP for a hostname or vice versa, using interactive or single-query mode
30 . E.g.,
nslookup linuxfoundation.org shows its IP address.
- dig : A more modern and detailed DNS query tool 31 . For example, dig +short google.com returns
Google’s IPs.
They help troubleshoot DNS issues by showing how names resolve.
curl and wget
Purpose & Description: curl and wget are command-line tools to download or transfer data over
network protocols (HTTP, FTP, etc.).
- curl is versatile for web APIs and supports many protocols. It can display output or save to file. “curl is a
powerful command-line tool for transferring data with URLs... one of the supported protocols (HTTP, HTTPS, FTP,
etc.)” 32 . Example: curl -O http://example.com/file.zip downloads a file.
- wget is primarily for non-interactive downloading of files from web/FTP. “wget (WWW get) is used to
download files from the Internet...” 33 . Example: wget http://example.com/file.zip .
Both support resuming downloads, recursive download, and are essential for retrieving resources.
8
route
Purpose & Description: The route command (legacy) displays or modifies the kernel’s IP routing table
34 .
For example, route -n shows how packets will be routed. On newer systems, ip route is
preferred (as part of ip tool).
Example: route -n might output default gateway (e.g. 0.0.0.0
192.168.1.1 ), indicating
where non-local traffic is sent.
Searching and Text Processing
grep
Purpose & Description: grep searches text using patterns (regular expressions) within files or input. It’s
extremely common for filtering output 35 .
Syntax: grep [options] pattern [file...]
35
Common Options:
- -i : case-insensitive
- -r : recursive through directories
- -v : invert match (show non-matching lines)
- -n : show line numbers
Example: grep -i "error" /var/log/syslog finds all lines containing “error” (case-insensitive).
sed
Purpose & Description: sed is a stream editor used to perform basic text transformations on an input
stream (files or piped data) 36 . It can substitute, delete, insert, or replace text.
Syntax: sed [options] script [file]
Common Usage: sed 's/old/new/' file.txt replaces first occurrence of “old” with “new” on each
line. With -i , edits in place. It’s very powerful for scripting and batch edits.
awk
Purpose & Description: awk is a scripting language designed for text processing and reporting 37 . It
operates on fields.
Syntax: awk 'pattern { action }' [file]
Example: awk '{ print $1 }' data.txt prints the first column of each line of data.txt . Often
used to extract or compute fields from text.
find
Purpose & Description: find searches the filesystem for files/directories matching criteria. It can filter by
name, type, date, size, and perform actions on matches 38 .
Syntax: find [path...] [conditions] [actions] 38
Example: find / -type f -name "*.conf" lists all .conf files. You can also -exec another
command on each found item.
9
Text Utilities: sort , uniq , cut , wc
• sort : Sort lines of text. E.g., sort data.txt sorts alphabetically. With -n numeric sort, -r
reverse. Useful for ordering data 39 .
• uniq : Filter or count duplicate lines (only adjacent duplicates). Often used after sort . E.g.,
sort list.txt | uniq removes duplicate lines 40 .
• cut : Extract columns or fields. E.g., cut -d: -f1 /etc/passwd prints usernames (delimiter
: ). It can cut by byte position or character as well 41 .
• wc : Word/line count. wc -l file counts lines, -w words, -c bytes. Example: wc -l /var/
log/syslog might output 12345 , showing number of lines. It’s often piped after grep to count
matches.
Compare Commands: diff , cmp
• diff compares two files line by line 42 , showing differences. Syntax: diff file1 file2 . It
outputs context of changes. Good for seeing what changed between versions.
• cmp compares files byte by byte 43 . If files differ, it reports the first difference. If no output, files
are identical. Less human-readable than diff , but useful in scripts to check equality.
Example: diff old.txt new.txt might show lines prefixed with < (from old) and > (from
new).
tr
Purpose & Description: tr (translate) translates or deletes characters from input 44 . It reads from stdin
and writes to stdout.
Syntax: tr [options] SET1 [SET2]
Example:
echo
"Hello
World"
|
tr
'[:upper:]'
'[:lower:]'
converts to lowercase. Or
tr -d ' ' < file removes spaces. It’s used in pipelines to clean or reformat text.
Package Management
apt / apt-get (Debian/Ubuntu): Used to install, update, and remove DEB packages. E.g., sudo apt
update then sudo apt install nginx . It handles dependencies.
yum / dnf (CentOS/RHEL/Fedora): Similar, for RPM-based distros. E.g., sudo yum install httpd .
rpm : Low-level RPM package manager (query or install single packages).
dpkg : Low-level Debian package tool ( dpkg -i file.deb ).
snap : Canonical’s universal package system ( sudo snap install package ).
For example, on Ubuntu, sudo apt install docker.io installs Docker. On CentOS, sudo yum
install docker-ce . The choice depends on distro 45 .
10
User Management
useradd , usermod , userdel
• useradd : Create a new user. For example, sudo useradd -m alice creates user alice with a
home directory 46 .
• usermod : Modify user properties (e.g., change home directory, add to group). E.g.,
sudo usermod -aG sudo alice adds alice to sudo group.
• userdel : Delete a user. E.g., sudo userdel -r bob removes user bob and their home
directory 47 .
groupadd , groupdel
• groupadd : Create a new group. Example: sudo groupadd developers
• groupdel : Remove a group. E.g., sudo groupdel developers
48 .
49 . Useful for managing
permissions.
passwd
Purpose: Change user password. For example, passwd alice prompts to set a new password for user
alice
50 . Only root or the user themselves can change it.
Syntax: passwd [user]
50 . Without arguments, changes current user’s password.
whoami , id , sudo , su
• whoami : Prints effective user name. Simply whoami outputs your username 51 . Handy in scripts
to confirm user identity.
• id : Shows current user’s UID and groups 24 (already mentioned).
• sudo : Run a command as root (or another user) 52 . Prefix any command with sudo to execute
with elevated privileges. For example, sudo apt update . Requires user to be in sudoers .
• su : Switch user. E.g., su - switches to root (asks for root password). su alice switches to user
alice. (Less used now in distributions favoring sudo .)
Automation and Scheduling
cron and crontab
Purpose & Description: Cron is the system service that runs scheduled tasks. crontab is the utility to
schedule jobs (scripts or commands) at specified times 53 .
Syntax: Cron jobs use a time format: MIN HOUR DAY MONTH DOW command . For example, 0 2 * * * /
usr/local/bin/backup.sh runs daily at 2am.
Example: To edit your cron jobs: crontab -e and add a line like 30 1 * * * /path/to/script.sh .
This uses the Cron daemon to automate repetitive tasks (backups, updates, etc.) 53 .
11
at
Purpose: The at command schedules a one-time task at a specified future time. For example, echo "/
path/to/script.sh" | at 03:00 schedules it at 3am. (Caveat: must have the at daemon running.) It’s
used for ad-hoc scheduling when cron (recurring) is not needed.
File Compression and Archiving
tar
Purpose & Description: tar creates and manipulates archive files (tarballs) 54 . It can also compress/
decompress archives.
Syntax: tar [options] archive_name files...
54
Common Usage:
- Create: tar czf archive.tar.gz directory/ (create gzip-compressed tar)
- List: tar tzf archive.tar.gz (list contents)
- Extract: tar xzf archive.tar.gz (extract).
Example: tar cf logs.tar /var/log/*.log makes an uncompressed archive. Add -z for gzip or j for bzip2.
Tip: The ‘z’, ‘j’, ‘J’ options for gzip, bzip2, xz, respectively.
gzip / gunzip
Purpose: Compress ( gzip ) or decompress ( gunzip ) files.
Syntax: gzip [options] file (replaces file with .gz file) 55 . gunzip file.gz restores it.
Example: gzip file.txt creates file.txt.gz and deletes original (default) 55 . Use gzip -k
file.txt to keep the original 56 .
bzip2 / bunzip2
Purpose: Higher compression tool than gzip.
Syntax: bzip2 file compresses file into file.bz2 , deleting original 57 . bunzip2 file.bz2
restores it.
Example: bzip2 -z data.csv compresses to data.csv.bz2
57 .
The -k option can keep the
original file.
zip / unzip
Purpose: Create ( zip ) or extract ( unzip ) zip archives.
Description: “zip command compresses files into a .zip archive, saving disk space and combining files” 58 .
Syntax: zip [options] archive_name.zip files... 59 . For example, zip mydocs.zip *.txt .
unzip : Extract. Syntax: unzip archive_name.zip
60 .
Example: zip -r backup.zip /home/user/ recursively zips a directory. unzip backup.zip extracts
it. Zip is cross-platform (Windows/Mac can open zip files).
12
xz
Purpose & Description:
xz
compresses files using the LZMA2 algorithm, often yielding higher
compression.
Syntax: xz file produces file.xz . Use xz -d file.xz or unxz to decompress.
Example: xz -z largefile compresses largefile to largefile.xz . The -k option keeps
original. (Famous for high compression in distributions, e.g. Linux kernel tarballs.)
7z
Purpose: 7z (from p7zip) is another high-compression tool (supports .7z archives, gzip, bzip2, etc.).
Usage: For example, 7z a archive.7z files... creates an archive. 7z x archive.7z extracts. It’s
not installed by default on all Linux, but often used in DevOps contexts.
Remote Access and File Transfer
ssh
Purpose & Description: ssh (Secure Shell) opens a secure encrypted terminal session on a remote
machine 61 . It also tunnels and transfers data.
Syntax: ssh [options] user@hostname .
Example: ssh alice@192.168.1.10 logs in as alice to that host. It uses encryption so your password/
traffic is secure.
Tip: Use SSH keys ( ssh-keygen ) for passwordless login. SSH also provides port forwarding (tunneling).
scp
Purpose & Description: scp (Secure Copy) transfers files securely over SSH 62 . It is basically “SSH for file
transfer”.
Syntax: scp [options] source user@host:dest or vice versa.
Example: scp /path/to/file.txt user@remote:/path/ copies file to remote. scp user@remote:/
path/file . pulls from remote.
Complex Example: Recursive copy: scp -r /local/dir user@remote:/dest copies entire directory.
Interview Q: How is scp different from ftp ? – scp encrypts all data (files and credentials) over SSH 62 ,
whereas FTP is unencrypted by default.
sftp
Purpose: sftp is an interactive file transfer program over SSH (like FTP but secure) 63 .
Usage: Run sftp user@host , then use commands like ls , get , put to transfer files. It’s often used
by scripts or users who prefer an FTP-like interface but with SSH security.
rsync
Purpose & Description:
efficiently
rsync
synchronizes files/directories between local and remote systems
64 . It uses a smart algorithm to transfer only differences, saving bandwidth.
13
Syntax: rsync [options] source destination
Example: rsync -avz /home/user/ alice@server:/backup/ copies /home/user/ to /backup/
on remote host, preserving attributes ( -a ) and compressing data ( -z ). It can resume partial transfers.
Interview Q: Why use rsync over scp? – Because rsync transfers only the changed blocks (delta transfer)
making it faster for incremental backups 64 .
System Administration
systemctl
Purpose & Description: systemctl controls the systemd init system, managing services and system
states 65 .
Syntax: systemctl [command] [unit] .
Common Commands:
start ,
stop ,
restart ,
enable
(at boot),
status . For example,
systemctl start nginx starts the nginx service; systemctl status sshd shows its status.
Example: systemctl enable httpd configures Apache to start on boot.
journalctl
Purpose & Description: journalctl views and queries the systemd journal (centralized logs) 66 . It’s
used to inspect system and service logs.
Syntax: journalctl [options] .
Usage: journalctl -u sshd shows logs for sshd service. journalctl -b shows current boot’s logs.
Example: journalctl -xe shows recent logs with priority error (useful for debugging failures).
shutdown , reboot
Purpose & Description:
- shutdown halts or powers off the machine safely 67 . It notifies users and processes, then brings the
system down.
- reboot is equivalent to shutdown -r now , rebooting the system immediately.
Syntax: shutdown [OPTIONS] [TIME] [MESSAGE]
67 . E.g.
shutdown -h now halts immediately,
shutdown +10 "Maintenance" schedules a shutdown in 10 minutes. Only root can execute.
Interview Q: How to cancel a scheduled shutdown? – Use shutdown -c
68 .
mount
Purpose & Description: Attach filesystems to the directory tree 69 . For example, mounting a USB drive at
/mnt/usb .
Syntax: mount -t type device directory (or see /etc/fstab).
Example: mount /dev/sdb1 /mnt/usb mounts the device. df -h can then show /mnt/usb usage.
Unmount: Use umount /mnt/usb to safely detach.
14
DevOps and Cloud Tools
docker
Purpose: CLI for managing Docker containers and images. E.g., docker run nginx starts an Nginx
container. Other subcommands:
docker
build ,
docker
ps ,
docker
exec , etc. (No citation
available.)
kubectl
Purpose: Kubernetes command-line tool. Controls Kubernetes clusters. E.g., kubectl get pods lists
pods. Other commands: apply , describe , logs , etc. (Configuration for K8s.)
terraform
Purpose & Description: terraform is the CLI for HashiCorp Terraform (Infrastructure as Code). “The
command line interface to Terraform is the
subcommands…”
Usage: Key commands include
terraform
command, which accepts a variety of
70 .
terraform
apply
terraform
init ,
plan ,
creates infrastructure as defined in
.tf
apply ,
destroy . For example,
files. It manages cloud resources
declaratively.
ansible
Purpose: CLI for Ansible automation. For ad-hoc tasks use ansible , for playbooks use ansibleplaybook . It automates configuration management across servers.
aws (AWS CLI)
Purpose: AWS command-line interface. Prefix AWS service commands, e.g., aws s3 ls to list S3 buckets.
It allows scripting of AWS service actions from shell.
gcloud (Google Cloud CLI)
Purpose: Google Cloud SDK CLI. E.g., gcloud compute instances list to list VMs. Manages GCP
resources from terminal.
(Details for these tools depend on their documentation; included here for completeness.)
Version Control
git
Purpose & Description: Git is a distributed version control system. It tracks changes in files and
coordinates work among developers. Commands include git clone , git commit , git push , etc.
For example, git commit -m "message" commits staged changes. (No citation used; well-known tool.)
15
Bash Scripting Basics
echo
Purpose & Description: echo prints text or variables to the screen 71 . It’s used in scripts to output
messages or results.
Syntax: echo [options] [string]
Example:
echo
"Hello,
$USER!"
71 .
might output
Hello,
alice! . Using
echo
-e
enables
interpreting backslashes (e.g. \n newline) 72 .
read
Purpose: Reads a line from standard input into a variable. Common in scripts for interactive input.
Syntax: read [options] variable . For example:
read -p "Enter your name: " NAME
echo "Hello, $NAME!"
prompts and reads user input into $NAME .
if , for , while , case , test
These are shell control structures (not separate executables):
- if / then / fi : Conditional execution. Example: if [ -f file ]; then echo "exists"; fi .
- for / do / done : Loop over items. Example: for file in *.txt; do echo "$file"; done .
- while / do / done : Loop with a condition. Example: while read line; do echo $line; done <
file .
- case / esac : Pattern matching. Example: case "$var" in hello) echo Hi;; *) echo Bye;;
esac .
- [ (test): Builtin to evaluate expressions. E.g. [ "$a" -gt 5 ] tests numeric comparison. Often used
in if .
These constructs form the basis of bash scripting logic.
Note: This cheat sheet summarizes common commands with examples. In practice, always refer to each
command’s --help or manual ( man ) for full syntax and options. The Q&A sections highlight typical
interview questions one might encounter about these commands.
Sources: Official documentation and tutorials on Linux commands 1 3 11 14
53
54
55
58
63
62
64
50
71 and related references in the Linux community.
16
22
73
23
19
20
21
1
2
4
5
6
7
8
9
10
11
12
13
17
18
20
21
25
26
27
33
35
38
42
45
46
47
50
51
52
Linux Commands All Users Should Know {Ultimate List}
https://phoenixnap.com/kb/linux-commands
3
Linux "ls" Command with Examples
https://www.atatus.com/blog/ls-command-in-linux-with-example/
14
15
chgrp command in Linux with Examples | GeeksforGeeks
https://www.geeksforgeeks.org/chgrp-command-in-linux-with-examples/
16
Umask command in Linux with examples | GeeksforGeeks
https://www.geeksforgeeks.org/umask-command-in-linux-with-examples/
19
Classic SysAdmin: Linux 101: 5 Commands for Checking Memory Usage in Linux - Linux Foundation
https://www.linuxfoundation.org/blog/blog/classic-sysadmin-linux-101-5-commands-for-checking-memory-usage-in-linux
22
Linux Uptime Command: Syntax, Options, Examples
https://phoenixnap.com/kb/linux-uptime
23
w Command in Linux with Examples {+Options & Syntax}
https://phoenixnap.com/kb/w-command-in-linux
24
id command in Linux with examples | GeeksforGeeks
https://www.geeksforgeeks.org/id-command-in-linux-with-examples/
28
SS Command In Linux {With Examples} | phoenixNAP KB
https://phoenixnap.com/kb/ss-command
29
Traceroute command and its options - ClouDNS Blog
https://www.cloudns.net/blog/traceroute-command-tracert/
30
How to Use the nslookup Command {10 Examples}
https://phoenixnap.com/kb/nslookup-command
31
dig Command in Linux with Examples | GeeksforGeeks
https://www.geeksforgeeks.org/dig-command-in-linux-with-examples/
Top 10 curl command options. curl is a powerful command-line tool… | by Bhupesh Choudhary |
Medium
32
https://medium.com/@bhaibhupesh10/top-10-curl-command-options-edb0cac3fb8e
34
6 Deprecated Linux Commands and Alternative Tools for Linux
https://www.tecmint.com/deprecated-linux-commands/
36
Sed Command in Linux/Unix With Examples | GeeksforGeeks
https://www.geeksforgeeks.org/sed-command-in-linux-unix-with-examples/
37
AWK command in Unix/Linux with examples | GeeksforGeeks
https://www.geeksforgeeks.org/awk-command-unixlinux-examples/
39
Linux sort Command with Examples
https://phoenixnap.com/kb/linux-sort
40
Uniq Command - Remove Duplicate Lines from a Linux Files
https://www.tecmint.com/remove-duplicate-lines-linux-files/
17
54
41
cut command in Linux with examples | GeeksforGeeks
https://www.geeksforgeeks.org/cut-command-linux-examples/
43
cmp Command in Linux with examples | GeeksforGeeks
https://www.geeksforgeeks.org/cmp-command-in-linux-with-examples/
44
tr command in Unix/Linux with examples | GeeksforGeeks
https://www.geeksforgeeks.org/tr-command-in-unix-linux-with-examples/
48
49
How to create, delete, and modify groups in Linux
https://www.redhat.com/en/blog/linux-groups
53
‘crontab’ in Linux with Examples | GeeksforGeeks
https://www.geeksforgeeks.org/crontab-in-linux-with-examples/
55
56
Gzip Command in Linux | GeeksforGeeks
https://www.geeksforgeeks.org/gzip-command-linux/
57
How to Compress and Decompress a .bz2 File in Linux
https://www.tecmint.com/linux-compress-decompress-bz2-files-using-bzip2/
58
59
60
ZIP command in Linux with examples | GeeksforGeeks
https://www.geeksforgeeks.org/zip-command-in-linux-with-examples/
61
SSH command usage, options, and configuration in Linux/Unix
https://www.ssh.com/academy/ssh/command
62
How to Securely Copy Files in Linux | scp Command | GeeksforGeeks
https://www.geeksforgeeks.org/scp-command-in-linux-with-examples/
63
SSH File Transfer Protocol (SFTP): Secure File Transfer Protocol
https://www.ssh.com/academy/ssh/sftp-ssh-file-transfer-protocol
64
Rsync by examples - A fast and versatile file copying tool.
https://overwriteit.com/rsync-by-examples-a-fast-and-versatile-file-copying-tool/
65
Manage Systemd Services with systemctl on Linux | DigitalOcean
https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
66
How To Use Journalctl to View and Manipulate Systemd Logs | DigitalOcean
https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs
67
68
shutdown command in Linux with Examples | GeeksforGeeks
https://www.geeksforgeeks.org/shutdown-command-in-linux-with-examples/
69
Linux mount Command with Examples {+How to Unmount a File System}
https://phoenixnap.com/kb/linux-mount-command
70
Terraform CLI overview | Terraform | HashiCorp Developer
https://developer.hashicorp.com/terraform/cli/commands
71
72
echo command in Linux with Examples | GeeksforGeeks
https://www.geeksforgeeks.org/echo-command-in-linux-with-examples/
73
who Command in Linux: Syntax, Options, Examples
https://phoenixnap.com/kb/linux-who-command
18
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )