Linux Command Reference
Complete DevOps Edition
Covers: System • Files • Permissions • Networking • Monitoring • Scripting • Services
Sections marked ★ NEW contain topics added for DevOps readiness
1. System Information & Boot
1.1 Basic System Info
whoami Display current username
who Show logged-in users, reboot time & date
uname Display OS / kernel details
uname -r Show kernel version
uname -a Show ALL info: OS, kernel, hostname, architecture (most
useful in DevOps)
hostname Show system hostname
hostname -I Show IP address assigned to the host
date Display current date & time
uptime How long the system has been running
uptime -s Show system start time
history Show command history
last Show last login users
last reboot List all system reboot history
last -x shutdown List all system shutdown history
1.2 Package Management
sudo apt install Install a package (new version)
sudo apt remove Remove a package
sudo apt update Refresh local package database
sudo apt upgrade Upgrade all installed packages
sudo reboot Reboot the system
sudo shutdown now Shutdown immediately (use 'now' flag)
sudo shutdown -h now Halt and shutdown immediately
1.3 Help & Documentation
help Built-in shell command guide
man Manual documentation pages
man -k Search manual pages by keyword
1.4 Key Concepts
• Kernel — Bridge between hardware and software; core of the OS that controls hardware.
• Shell — Lets users interact with the OS using commands (bash, sh, zsh).
• Terminal — Where you type Linux commands.
• Root directory (/) — Top-level directory of the filesystem.
• Home directory (~) — User's personal folder (e.g. /home/username).
• Root user — Administrator account with full system privileges.
• Swap space — When RAM is full, a dedicated partition or swap file on disk is used as virtual RAM.
• Internal commands — Built into the shell (cd, pwd, echo). No separate file needed.
• External commands — Stored as separate programs (ls, cp, grep).
• Alias — Shortcut for commands. e.g. alias ll='ls -l'
• $PATH variable — Tells the system where to find executable commands. Use: echo $PATH
2. File & Directory Management
2.1 Navigation
pwd Print Working Directory — see where you are
cd Change to directory
cd or cd ~ Go to home directory
cd .. Go one level back (parent folder)
cd ../.. Go two levels back
cd - Go to the last directory you were in
cd . Stay in current directory
2.2 Listing Files
ls List current directory (simplest form)
ls -l Long listing — 7 columns (most used)
ls -lh Long listing in human-readable format (KB, MB, GB)
ls -lt Sort by time — latest to oldest
ls -lrt Sort by time — oldest to latest (reverse)
ls -a Show all files including hidden (dot files)
ls -s List by size
ls -d */ List only directories
2.3 Creating & Deleting Files
touch Create a file
touch Create multiple files
touch / Create a file inside another directory
rm Delete a file
rm Delete multiple files
rm -f Force delete without prompt
2.4 Creating & Deleting Directories
mkdir Create a directory
mkdir Create multiple directories
mkdir / Create directory inside another directory
mkdir -p / Create parent + child directory at once
rmdir Delete an empty directory
rm -r Delete directory recursively
rm -rf Force delete directory recursively (use with caution!)
2.5 Move & Copy
mv Rename a file or directory
mv Move file or directory
mv Move multiple files to a directory
cp Copy file
cp -r Copy directory recursively
cp -i Ask before overwriting
cp *.txt Copy all .txt files using wildcard
2.6 Find Command (Private Investigator)
Syntax: find | f=file d=dir l=link
find -empty Find all empty files/dirs/links
find -empty -type f Find empty files only
find ! -empty -type f Find non-empty files
find . -name '*.txt' Find files ending with .txt
find . -type f -name 'abc*' Find files starting with abc
find . -perm 777 Find files with 777 permission
find . -user Find files by owner
find . -type f -size +2k Files greater than 2KB
find . -type f -size +2k -size -4k Files between 2KB and 4KB
find . -mmin -10 Files modified less than 10 mins ago
find . -cmin -10 Files changed less than 10 mins ago
find . -amin -10 Files accessed less than 10 mins ago
find . -mtime +2 Files modified more than 2 days ago
find . -mtime +2 -exec rm {} \; Delete files older than 2 days
find . -maxdepth 2 -name '*.log' Search only 2 levels deep
Size units: c=bytes k=KB M=MB G=GB | Time flags: -mmin(modified) -cmin(changed) -amin(accessed)
2.7 Links
Hard Link — An additional name for an existing file. Both share the same inode (index node). Changes in original reflect
in link. Works even if original is renamed or deleted.
ln Create a hard link
Soft Link (Symbolic Link) — A pointer to a file. Does NOT share the same inode. Breaks if original is renamed or
deleted.
ln -s Create a soft/symbolic link
inode = index node — stores metadata: file size, owner, permissions, timestamps.
2.8 Disk & Storage
★ NEW Added for DevOps
lsblk List block devices (disks and partitions)
fdisk -l Detailed disk partition info
mount Mount a filesystem
umount Unmount a filesystem
cat /etc/fstab View permanent mount configuration
/etc/fstab defines filesystems that are automatically mounted at boot.
3. File Viewing
3.1 cat — Display File Content
cat Display file content
cat -n Display with line numbers
cat -b Line numbers only where content is present
cat -s Suppress multiple blank lines to single blank line
cat Display multiple files together
3.2 head — Display First Lines
Displays first 10 lines by default.
head Display first 10 lines
head -n 40 Display first 40 lines
head -n -10 Display all lines EXCEPT last 10
head View multiple files
3.3 tail — Display Last Lines
Displays last 10 lines by default.
tail Display last 10 lines
tail -15 Display last 15 lines
tail -n +10 Display all lines except first 10 (from line 10 onwards)
tail -f /var/log/syslog Live log monitoring (follows file in real-time)
3.4 Head & Tail Combined Patterns
# Print first & last line
head -1 [Link] && tail -1 [Link]
# Print lines 11 to 20 (exclude last 5, exclude first 10)
head -n -5 [Link] | tail -n +10
# Print lines 5 to 15
head -n 15 [Link] | tail -n 11
3.5 more & less — Page-by-Page Viewing
more View file page by page (older, can't scroll up easily)
less Advanced pager — scroll up/down, search, doesn't load all
into memory
less key controls: Space=next page b=scroll up /word=search g=top G=bottom q=quit
3.6 locate & updatedb — Fast File Search
locate Fast file search using a pre-built database
updatedb Update the locate database
diff Show exact line differences between two files
4. Output & Redirection
4.1 echo Command
echo Display a message on the terminal
echo > Write text to file (OVERWRITES existing content)
echo >> Append text to file (keeps existing content)
echo -e "Hello\nWorld" Use -e for special characters like \n (newline)
4.2 Redirection Operators
★ NEW Added for DevOps
command > file Redirect stdout to file (overwrite)
command >> file Redirect stdout to file (append)
command 2> file Redirect stderr to file
command 2>&1 Redirect stderr to stdout (combine both)
command &> file Redirect both stdout AND stderr to file
command > /dev/null Discard output completely (the black hole)
command < file Use file as input to command
4.3 Pipe Operator |
Connects the OUTPUT of one command to the INPUT of another. Data flows left to right.
head | tail -1 Display exactly the 10th line
head -20 | tail -5 Display lines 16 to 20
head -9 | tail -1 Display exactly the 9th line
cat file | tail -2 Display last 2 lines
ls | wc -l Count number of files in directory
ps -aux | grep nginx Find a specific process
4.4 tee Command
Used with pipe: reads input and copies to terminal AND one or more files simultaneously.
ls | tee [Link] Show ls output on screen AND save to file
cat [Link] | tee [Link] Copy content of f1 to f2 (replaces f2)
tail -5 [Link] | tee -a [Link] Append last 5 lines of [Link] to [Link]
tree | tee -a Append tree output to file
5. File Editing — vi Editor
5.1 vi Modes
Command Mode (Normal) — Default when file opens. Keys act as commands, not typed text.
Insert Mode — Type text normally. Press i to enter, Esc to exit.
Last Line Mode (:) — Enter by pressing : in command mode. Used to save, quit, search.
Note: If file exists, vi opens it. If not, vi creates and opens it.
5.2 Command Mode (Esc)
i Enter Insert mode at cursor
dd Delete current line
5dd Delete 5 lines from cursor
yy Copy (yank) current line
p Paste copied/deleted line
u Undo last action
gg Go to top of file
G Go to bottom of file
77G Go to line 77
A Move to end of current line (insert mode)
x Delete character under cursor
/ Search forward for pattern (n for next)
? Search backward for pattern
5.3 Last Line Mode (:)
:wq Save and quit
:q! Quit WITHOUT saving
:set nu Show line numbers
:s/old/new/ Replace first occurrence on current line
:s/old/new/g Replace all occurrences on current line
:%s/old/new/g Replace all occurrences in entire file
:%s/old/new/gi Replace all — case insensitive
:5s/old/new/g Replace all occurrences on line 5
:5,$s/old/new/g Replace from line 5 to last line
:3s/old/new/ Replace first occurrence on line 3
% = entire file | s = search | g = global (all occurrences) | i = case insensitive | $ = last line
6. The Big Three Text Processors
6.1 grep — Search in Closed Files
Syntax: grep [options]
grep Search for pattern in file
grep -n Show line numbers with matches
grep -i Case-insensitive search
grep -v Invert — show lines NOT matching
grep -w Exact whole word match only
grep -o Show only the matching part (not full line)
grep -c Count total matching lines
grep -r Recursive search in directories
grep -l List filenames containing match only
grep -e -e Search multiple patterns
grep -n -i Line numbers + case insensitive
6.2 sed — Edit Closed Files (Streaming Editor)
Syntax: sed [options] 'command'
Print
sed -n '10p' file Print line 10
sed -n '5,10p' file Print lines 5 to 10
sed -n '4p;7p' file Print lines 4 and 7
sed -n '/pattern/ p' file Print lines matching pattern
sed -n '/pattern/ Ip' file Print matching lines — case insensitive
Delete
sed '3d' file Delete line 3
sed '1,5d' file Delete lines 1 to 5
sed '/pattern/ d' file Delete lines matching pattern
sed -e '3,10d' -e '14,20d' file Delete multiple ranges
Search & Replace
sed 's/old/new/' file Replace first match per line
sed 's/old/new/g' file Replace all matches per line
sed 's/old/new/2' file Replace only 2nd occurrence per line
sed 's/old/new/Ig' file Replace all — case insensitive
sed -i 's/old/new/g' file Save changes in-place to file
sed '5s/old/new/g' file Replace all matches on line 5 only
sed '2,6s/old/new/g' file Replace matches on lines 2 to 6
sed '6,$s/old/new/g' file Replace from line 6 to last line
sed -z 's/old/new/6' file Replace only 6th occurrence in whole file
sed -e 's/a/b/g' -e 's/c/d/g' f Multiple replacements at once
6.3 awk — Data Extraction from Structured Files
Syntax: awk 'pattern { action }' filename | NR=Row Number NF=Number of Fields(columns) $NF=Last column
awk '{print $1,$3}' file Print 1st and 3rd column
awk '{print NR,$2}' file Print row number and 2nd column
awk '{print NF,$6}' file Print total columns and 6th column
awk 'END{print NR}' file Print total number of rows/lines
awk 'NF>0 {print $3}' file Print 3rd column — skip empty lines
awk '/pattern/' file Print all lines matching pattern
awk '/pattern/ {print}' file Print lines matching pattern (explicit)
awk -F',' '{print $1}' file Use comma as field separator (for CSV)
6.4 wc — Word Count
wc Show lines, words, and bytes count
wc -l Count lines only
wc -w Count words only
wc -m Count characters only
wc -c Count bytes only
wc -L Show length of longest line
6.5 sort, uniq, cut, tr — Supporting Tools
★ NEW Added for DevOps
sort Sort lines alphabetically
sort -r Sort in reverse order
sort -n Sort numerically
sort -u Sort and remove duplicates
uniq Remove consecutive duplicate lines
uniq -c Count occurrences of each line
sort file | uniq -c Count all duplicate lines (common pattern)
cut -d',' -f1 file Extract column 1 from comma-separated file
cut -d':' -f1 /etc/passwd Extract usernames from passwd file
tr 'a-z' 'A-Z' Convert lowercase to uppercase
tr -d '\n' Delete newlines
7. Permissions & Administration
7.1 User Management
sudo adduser Create a new user
sudo deluser Delete a user
sudo passwd Change user password
sudo su Switch to another user (exit to return)
sudo usermod -u Change user ID
sudo usermod -l Rename a user
sudo usermod -L Lock a user account
sudo usermod -U Unlock a user account
id Show user details including groups
groups Show which groups a user belongs to
cat /etc/passwd Check if user was created
7.2 Group Management
sudo addgroup Create a group
sudo delgroup Delete a group
sudo groupmod -n Rename a group
sudo usermod -aG Add user to group (keep other groups)
sudo gpasswd -d Remove user from group
cat /etc/group Check if group was created
7.3 File Permissions — chmod
Permissions: r(read)=4 w(write)=2 x(execute)=1 | 3 groups: user | group | others
ls -l first character: - = file d = directory l = symbolic link
# Octal mode examples:
sudo chmod 777 file # rwxrwxrwx — full permissions for all
sudo chmod 755 file # rwxr-xr-x — common for scripts/dirs
sudo chmod 644 file # rw-r--r-- — common for files
sudo chmod 600 file # rw------- — private files (SSH keys)
# Symbolic mode:
chmod u+x [Link] # Add execute for owner
chmod g-w [Link] # Remove write from group
chmod a=r [Link] # Set read-only for everyone
chmod o-rwx file # Remove all permissions from others
7.4 Ownership — chown & chgrp
Syntax: sudo chown [user][:group]
sudo chown Change file owner
sudo chown : Change group only
sudo chown : Change both user and group
sudo chown -R Change ownership recursively
sudo chgrp Change group ownership only
8. System Monitoring & Processes
8.1 Memory & Disk
free Quick snapshot of RAM usage (in KiB)
free -h Memory usage in human-readable format (MB/GB)
df Show available/free disk space on filesystems
df -h Disk free in human-readable format
du Show disk usage of files and directories
du -h Disk usage in human-readable format
du -h Disk usage for a specific directory
du -sh /* Disk usage summary for each root directory
8.2 CPU & Real-Time Monitoring
top Real-time CPU, memory, and process information
htop Interactive, prettier version of top (may need install)
lscpu Show detailed CPU information
iostat Show disk I/O performance
8.3 Process Management — ps
ps shows running processes at the moment the command is executed (snapshot, not live).
ps -aef All processes for all users — detailed format
ps aux All processes including background — user-oriented format
ps -fu Processes of a specific user
pgrep Get PID of a process by name
pidof Show process ID by exact name
8.4 Kill Processes
kill Send termination signal to a process
kill -9 Force kill (cannot be ignored)
kill $(pgrep nginx) Kill process by name in one command
killall Kill all processes with given name
8.5 Background & Job Control
★ NEW Added for DevOps
command & Run command in background
nohup command & Run command immune to hangups (survives logout)
jobs Show background jobs
bg Resume a stopped job in background
fg Bring background job to foreground
wait Wait for all background jobs to finish
lsof -i : Find what process is using a specific port
lsof -p Show files opened by a process
8.6 System Logs
journalctl View all system logs
journalctl -xe Detailed error logs
journalctl -u Logs for a specific service
journalctl -f Follow logs live (like tail -f)
tail -f /var/log/syslog Live logs — Ubuntu
tail -f /var/log/syslog | grep ERROR Live error monitoring pattern
/var/log/ is the main log directory. Key files: syslog, [Link], [Link], dmesg
9. Service Management — systemctl
★ NEW Critical DevOps topic — you will use this every day
systemd is the init system on modern Linux. systemctl is the command to manage services/daemons.
9.1 Service Control
systemctl start Start a service immediately
systemctl stop Stop a running service
systemctl restart Stop then start a service
systemctl reload Reload config without stopping service
systemctl status Check current status of service
9.2 Boot-Time Configuration
systemctl enable Auto-start service on system boot
systemctl disable Prevent service from starting on boot
systemctl is-enabled Check if service is enabled for boot
systemctl is-active Check if service is currently running
9.3 Listing & System State
systemctl list-units --type=service List all running services
systemctl list-units --failed List failed units
systemctl daemon-reload Reload systemd config after editing service files
systemctl poweroff Shutdown the system
systemctl reboot Reboot the system
# Common DevOps workflow: restart nginx and check status
sudo systemctl restart nginx
sudo systemctl status nginx
# Enable a service to start on boot AND start it now
sudo systemctl enable --now nginx
10. Cron Jobs — Task Scheduling
★ NEW Critical DevOps topic — used for automation and scheduled tasks
10.1 Crontab Commands
crontab -e Edit your cron jobs (opens in default editor)
crontab -l List current user's cron jobs
crontab -r Remove ALL cron jobs (use carefully!)
crontab -u -l List cron jobs for a specific user
10.2 Cron Syntax
# Format: minute hour day month weekday command
# 0-59 0-23 1-31 1-12 0-7
#
# Special characters:
# * = any/every value
# , = list of values (1,3,5)
# - = range (1-5)
# / = step values (*/5 = every 5)
# Examples:
0 2 * * * /scripts/[Link] # Every day at 2:00 AM
*/5 * * * * /scripts/[Link] # Every 5 minutes
0 0 * * 0 /scripts/[Link] # Every Sunday midnight
30 8 1 * * /scripts/[Link] # 1st of every month at 8:30 AM
0 9-17 * * 1-5 /scripts/[Link] # Every hour 9-5, Mon-Fri
10.3 Special Shortcuts
@reboot /scripts/[Link] # Run once at system startup
@hourly /scripts/[Link] # Run every hour
@daily /scripts/[Link] # Run every day at midnight
@weekly /scripts/[Link] # Run every week
@monthly /scripts/[Link] # Run every month
Cron output goes to mail by default. Redirect to log: command >> /var/log/[Link] 2>&1
11. Environment Variables
★ NEW Important for DevOps — config, secrets, and tool paths are all managed via env vars
printenv List all environment variables
env Similar to printenv — list all env vars
echo $VAR Print value of specific variable
echo $PATH Show all command search paths
export VAR=value Set environment variable for current session
unset VAR Remove/delete an environment variable
source ~/.bashrc Reload shell configuration file
source ~/.bash_profile Reload bash profile
# View common system variables
echo $HOME # Home directory path
echo $USER # Current username
echo $SHELL # Current shell in use
echo $HOSTNAME # System hostname
# Set a variable permanently (add to ~/.bashrc):
echo 'export MY_VAR=hello' >> ~/.bashrc
source ~/.bashrc
12. Networking & File Transfer
12.1 Connectivity Testing
ping Check if a host is alive/reachable
ping [Link] Test internet connectivity
ping [Link] Ping Google DNS directly
traceroute Trace network path to destination
nslookup DNS lookup — get IP from domain name
dig Detailed DNS query information
12.2 Network Information
ip addr Show IP addresses (modern command)
ifconfig Show network interfaces (older, may need install)
hostname Show system hostname
hostname -I Show IP address of the host
route -n Show routing table
ss -tuln Show listening ports (modern — preferred over netstat)
netstat -tuln Show listening ports (older, deprecated on some distros)
netstat -a Show all network connections and listening ports
lsof -i : Find what process is using a specific port
Prefer ss over netstat — netstat is deprecated in many modern Linux distros.
12.3 Telnet — Port Connectivity Test
Syntax: telnet | Port 80=HTTP Port 443=HTTPS Port 22=SSH
telnet [Link] 80 Test if port 80 on [Link] is open
telnet 443 Test HTTPS port connectivity
telnet 22 Test SSH port availability
12.4 SSH — Remote Access
ssh @ Connect to a remote server
ssh -i [Link] @ Connect using a specific key file (AWS/cloud)
ssh-keygen Generate an SSH key pair (id_rsa & id_rsa.pub)
ssh-copy-id @ Copy public key to remote server for passwordless login
ssh -L 8080:localhost:80 user@host Port forwarding — tunnel remote port to local
★ NEW SSH key-based auth — critical for DevOps/cloud access
# ~/.ssh/config — create aliases for frequent servers
Host myserver
HostName [Link]
User ubuntu
IdentityFile ~/.ssh/[Link]
# Then simply use:
ssh myserver
12.5 Firewall
★ NEW Added for DevOps
ufw status Check firewall status (Ubuntu)
ufw allow 22 Allow SSH port
ufw allow 80 Allow HTTP port
ufw enable Enable the firewall
iptables -L List all firewall rules
12.6 SCP — Secure Copy
scp = secured copy over SSH. Think: scp
scp @: Copy local file TO remote server
scp @: Copy file FROM remote server to local
scp -r @: Copy entire directory to remote (recursive)
12.7 rsync — Efficient File Transfer
More efficient than scp — only transfers new/changed files (incremental backup).
rsync -avz @: Sync local to remote server
rsync -avz @: Sync remote to local
Options: -a=archive(preserve permissions) -v=verbose -z=compression
12.8 wget & curl
wget Download a file from the internet
wget -O Download and save with custom filename
wget -c Resume an interrupted download
curl Fetch data from a URL (API testing, raw data)
curl -o Save curl output to a file
curl -I Fetch HTTP headers only
curl -X POST -d '{"key":"val"}' Send POST request (API testing)
wget = downloader (saves files). curl = communicator (talks to APIs, shows raw data).
13. Archiving & Compression
13.1 gzip / gunzip
gzip works on individual files only, NOT directories. Saved as .gz
gzip Compress a file (original file is replaced by .gz)
gunzip Decompress a .gz file
gzip -k Compress but KEEP original file intact
gzip -r Compress each file inside directory individually
zcat View contents of compressed file without extracting
gzip -l Show compression ratio and sizes
13.2 tar — Tape Archive
tar archives multiple files/dirs into one. Add -z to also compress with gzip.
# Options: -c=create -x=extract -t=list -z=gzip -v=verbose -f=filename
tar -cvf [Link] file1 file2 dir1 # Create archive (no compression)
tar -czvf [Link] file1 dir1 # Create compressed archive
tar -xvzf [Link] # Extract compressed archive
tar -tvf [Link] # List contents without extracting
tar -czvf [Link] /etc /home # Archive multiple dirs
14. Shell Scripting Basics
★ NEW Critical DevOps skill — automate everything
14.1 Script Structure
#!/bin/bash
# The shebang line above tells the OS to use bash to run this script
# Make script executable:
chmod +x [Link]
# Run the script:
./[Link]
bash [Link]
14.2 Variables & Input
NAME='DevOps' # Assign variable (no spaces around =)
echo $NAME # Use variable with $
echo ${NAME} # Safer way to reference variable
read -p 'Enter name: ' USER_INPUT # Get input from user
echo "Hello $USER_INPUT"
14.3 Special Variables
$1, $2, $3 Positional arguments passed to script
$0 Name of the script itself
$# Number of arguments passed
$@ All arguments as separate words
$? Exit status of last command (0=success, non-zero=failure)
$$ PID of the current script/process
14.4 Conditionals
if [ $NAME == 'root' ]; then
echo 'You are root'
elif [ $NAME == 'admin' ]; then
echo 'You are admin'
else
echo 'Regular user'
fi
# File checks:
if [ -f /etc/hosts ]; then echo 'File exists'; fi
if [ -d /home ]; then echo 'Dir exists'; fi
if [ -z "$VAR" ]; then echo 'Variable is empty'; fi
14.5 Loops
# For loop
for i in 1 2 3 4 5; do
echo "Number: $i"
done
# For loop over files
for file in /var/log/*.log; do
echo "Processing: $file"
done
# While loop
COUNT=0
while [ $COUNT -lt 5 ]; do
echo "Count: $COUNT"
COUNT=$((COUNT + 1))
done
14.6 Functions
greet() {
echo "Hello, $1!"
}
greet 'DevOps' # Call function with argument
# Check exit status after a command
if [ $? -eq 0 ]; then
echo 'Last command succeeded'
fi
15. DevOps Quick Reference — Common Patterns
★ NEW Real-world command combinations you'll use constantly
15.1 Process & Port Management
# Find and kill a process by name
kill $(pgrep nginx)
# Find what process is using port 8080
lsof -i :8080
ss -tuln | grep 8080
# Run a script and keep it running after logout
nohup ./[Link] > [Link] 2>&1 &
15.2 Log Analysis
# Watch logs live, filter for errors only
tail -f /var/log/[Link] | grep ERROR
# Count how many times each error appears
grep ERROR /var/log/[Link] | sort | uniq -c | sort -rn
# Find logs from last 5 minutes
find /var/log -name '*.log' -mmin -5
15.3 Disk & System Health
# Disk usage sorted by size (find what's eating disk space)
du -sh /* 2>/dev/null | sort -rh | head -20
# Check disk free space
df -h
# Check memory
free -h
15.4 File Search & Text Processing
# Find all .log files and search for 'ERROR' inside them
find /var/log -name '*.log' -exec grep -l 'ERROR' {} \;
# Extract unique IP addresses from a log file
grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' [Link] | sort | uniq -c | sort -rn
# Replace a config value in-place
sed -i 's/port=8080/port=9090/g' [Link]
15.5 Service & Deployment
# Restart a service and check if it came up
sudo systemctl restart nginx && sudo systemctl status nginx
# Enable service to start on boot AND start it now
sudo systemctl enable --now nginx
# Check if a port opened after starting a service
ss -tuln | grep ':80'
# Tail service logs in real-time
journalctl -u nginx -f
15.6 SSH & Remote Ops
# Copy SSH key to server for passwordless login
ssh-keygen -t rsa -b 4096
ssh-copy-id ubuntu@[Link]
# Sync local folder to remote server
rsync -avz ./app/ ubuntu@[Link]:/var/www/app/
# Run a command on remote server without interactive login
ssh user@host 'sudo systemctl restart app'
End of Linux Command Reference — DevOps Edition
Sections 9 (systemctl), 10 (cron), 11 (env vars), 14 (scripting), 15 (patterns) are newly added for DevOps.