Logo ← PostgreSQL Blog

Top 40 Linux Commands Every Engineer Should Know

Whether you’re a beginner getting your hands dirty or a seasoned sysadmin managing hundreds of servers, mastering the Linux command line is…

Top 40 Linux Commands Every Engineer Should Know

Whether you’re a beginner getting your hands dirty or a seasoned sysadmin managing hundreds of servers, mastering the Linux command line is a must.

Table of Contents

  • Application and Package Management
  • Console and Output Management
  • Environment Variables
  • File and Directory Operations
  • Networking Essentials
  • Process and System Control
  • Useful Lookup and Diagnostic Tools

Application and Package Management

which

Shows the full path of a command.

which clear

dnfyum

Installs, removes, and manages packages on RHEL-based systems.

sudo dnf install net-tools

rpm

Queries or installs RPM packages.

rpm -qa | grep ssh

apt

Manages packages on Debian/Ubuntu systems.

sudo apt install htop

Console and Output Management

cat

Displays the contents of a file.

cat /etc/system-release

less

Opens a scrollable view for long files.

less /var/log/messages

head

Shows the first lines of a file.

head -n 15 /etc/passwd

tail

Shows the last lines of a file.

tail -n 20 /var/log/secure

tail -f

Follows file output in real time.

tail -f /var/log/nginx/access.log

echo

Prints text or variable values.

echo $PATH

tee

Displays output and writes it to a file.

dmesg | tee /tmp/dmesg.log

clear

Clears the terminal screen.

clear

wc

Counts lines, words, and characters.

wc -l /var/log/messages

Environment Variables

export

Sets an environment variable.

export PATH=$PATH:/opt/tools

printenv

Prints environment variables.

printenv HOME

File and Directory Operations

ls

Lists files and directories.

ls -lah /var/www

cp

Copies files or directories.

cp file.txt /tmp/

mv

Moves or renames files.

mv old.txt new.txt

rm

Removes files or directories.

rm -rf /tmp/test

mkdir

Creates directories.

mkdir -p /data/backups

find

Searches for files based on patterns.

find /var/log -name "*.log"

chmod

Changes file permissions.

chmod 640 config.cfg

chown

Changes file owner or group.

chown root:root /etc/secure

Networking Essentials

ip

Shows or configures network interfaces.

ip addr show

ping

Tests network connectivity.

ping -c 4 8.8.8.8

ss

Displays active network connections.

ss -tulpn

curl

Transfers data from/to a server.

curl -I https://example.com

scp

Copies files securely over SSH.

scp backup.tar.gz user@host:/tmp/

Process and System Control

ps

Shows running processes.

ps aux | grep nginx

top

Displays real-time system usage.

top

kill

Stops a process using a signal.

kill -9 1234 # 1234 is PID That you want to kill

systemctl

Manages systemd services.

systemctl restart sshd

journalctl

Shows system logs.

journalctl -u patroni -n 100

uptime

Shows how long the system has been running.

uptime 

Useful Lookup and Diagnostic Tools

grep

Searches text patterns in files.

grep -R "ERROR" /var/log

awk

Processes text into fields and patterns.

awk '{print $1}' /etc/passwd

sed

Edits text in streams or files.

sed -i 's/old/new/g' file.txt

sort

Sorts lines of text.

sort users.txt

uniq

Removes duplicate lines.

sort list.txt | uniq

du

Shows disk usage.

du -sh /var/log/*