Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.

Gallery

Contacts

411 University St, Seattle, USA

+1 -800-456-478-23

Linux/Debian/Ubuntu 100 Essential Commands

A practical reference of 100 essential Linux commands commonly used by Linux administrators, developers, DevOps engineers, and server operators.

The commands cover:

  • File and directory management
  • Text processing
  • Archives and compression
  • Networking
  • Process management
  • Services and logs
  • System information
  • Storage and filesystems
  • Scheduling and automation

Commands marked with * may require installing an additional package depending on your Linux distribution.


1. File and Directory Commands

ls

List files and directories.

ls

Useful options:

ls -l
ls -a
ls -lh
ls -lah
  • -l — detailed listing
  • -a — include hidden files
  • -h — human-readable file sizes

pwd

Display the current working directory.

pwd

Example output:

/home/user/projects

cd

Change the current directory.

cd /var/log

Go to the home directory:

cd ~

Go up one directory:

cd ..

Return to the previous directory:

cd -

mkdir

Create directories.

mkdir myfolder

Create nested directories:

mkdir -p /opt/apps/myapp/data

rmdir

Remove an empty directory.

rmdir oldfolder

It only works when the directory is empty.


touch

Create an empty file or update a file's timestamp.

touch file.txt

Create several files:

touch file1.txt file2.txt file3.txt

cp

Copy files or directories.

cp source.txt destination.txt

Copy a directory recursively:

cp -r source-directory destination-directory

Preserve file attributes:

cp -a source destination

mv

Move or rename files and directories.

Rename a file:

mv old.txt new.txt

Move a file:

mv file.txt /tmp/

rm

Remove files or directories.

rm file.txt

Remove a directory recursively:

rm -r directory

Force removal:

rm -rf directory

Be extremely careful with rm -rf, especially when running commands as root.


cat

Display file contents.

cat file.txt

Combine files:

cat file1.txt file2.txt

Redirect into another file:

cat file1.txt file2.txt > combined.txt

less

View a file interactively.

less /var/log/syslog

Useful keys:

Space       Next page
b           Previous page
/word       Search
n           Next match
q           Quit

head

Show the beginning of a file.

head file.txt

Show the first 20 lines:

head -n 20 file.txt

tail

Show the end of a file.

tail file.txt

Follow a log file continuously:

tail -f /var/log/syslog

Show the last 100 lines:

tail -n 100 file.txt

2. Text Editors

nano

Simple terminal text editor.

nano file.txt

Common shortcuts:

Ctrl + O    Save
Ctrl + X    Exit
Ctrl + W    Search
Ctrl + K    Cut line
Ctrl + U    Paste

vim

Powerful modal text editor.

vim file.txt

Basic commands:

i           Insert mode
Esc         Command mode
:w          Save
:q          Quit
:wq         Save and quit
:q!         Quit without saving

3. Shell Output and Redirection

echo

Print text or variables.

echo "Hello Linux"

Print a variable:

echo "$HOME"

Write into a file:

echo "Hello" > file.txt

Append instead:

echo "Another line" >> file.txt

tee

Write output to both the terminal and a file.

echo "Hello" | tee file.txt

Append:

echo "Another line" | tee -a file.txt

Useful when working with sudo:

echo "example" | sudo tee /etc/example.conf

4. Finding Files

find

Search files and directories.

Find by name:

find /var -name "*.log"

Case-insensitive:

find /var -iname "*.LOG"

Find directories:

find / -type d -name "docker"

Find files larger than 1 GB:

find / -type f -size +1G

locate *

Search for files using an indexed database.

locate nginx.conf

On Debian/Ubuntu, plocate is commonly used:

sudo apt install plocate

updatedb *

Refresh the database used by locate.

sudo updatedb

stat

Display detailed file metadata.

stat file.txt

Shows information such as:

  • File size
  • Permissions
  • Owner
  • Group
  • Access time
  • Modification time
  • Inode

file

Determine a file's type.

file archive.tar.gz

Example:

archive.tar.gz: gzip compressed data

5. Disk Usage and Links

du

Show disk usage.

du -sh /var/log

Show sizes of directories:

du -h --max-depth=1 /var

df

Show filesystem usage.

df

Human-readable:

df -h

Show filesystem types:

df -hT

ln

Create hard or symbolic links.

Hard link:

ln source.txt link.txt

Symbolic link:

ln -s /opt/app/app.conf /etc/app.conf

6. Permissions and Ownership

chmod

Change permissions.

chmod 644 file.txt

Make a script executable:

chmod +x script.sh

Common permissions:

755    rwxr-xr-x
644    rw-r--r--
700    rwx------
600    rw-------

chown

Change ownership.

sudo chown user file.txt

Change owner and group:

sudo chown user:group file.txt

Recursive:

sudo chown -R user:group /opt/myapp

chgrp

Change group ownership.

sudo chgrp developers file.txt

7. Command Discovery and Documentation

which

Show the executable found in PATH.

which nginx

Example:

/usr/sbin/nginx

man

Read command manual pages.

man ls

Search manuals:

man -k network

Quit with:

q

8. Text Processing

grep

Search text.

grep "error" app.log

Case-insensitive:

grep -i "error" app.log

Recursive:

grep -r "database" /etc/

Show line numbers:

grep -n "error" app.log

awk

Process structured text.

awk '{print $1}' file.txt

Example with /etc/passwd:

awk -F: '{print $1}' /etc/passwd

sed

Stream editor used for text transformations.

Replace text:

sed 's/old/new/' file.txt

Replace all occurrences:

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

Edit a file in place:

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

cut

Extract fields or columns.

cut -d: -f1 /etc/passwd

Extract characters:

cut -c1-10 file.txt

sort

Sort text.

sort file.txt

Numeric:

sort -n numbers.txt

Reverse:

sort -r file.txt

uniq

Remove adjacent duplicate lines.

sort file.txt | uniq

Count duplicates:

sort file.txt | uniq -c

tr

Translate or remove characters.

Convert lowercase to uppercase:

echo "linux" | tr 'a-z' 'A-Z'

Remove characters:

echo "a-b-c" | tr -d '-'

wc

Count lines, words, and bytes.

wc file.txt

Lines only:

wc -l file.txt

Words:

wc -w file.txt

xargs

Convert input into command arguments.

find . -name "*.tmp" -print0 | xargs -0 rm

Another example:

echo "file1 file2 file3" | xargs touch

split

Split large files.

Split into 100 MB pieces:

split -b 100M large-file.bin part-

Split by line count:

split -l 1000 file.txt part-

paste

Merge files line by line.

paste file1.txt file2.txt

Specify a delimiter:

paste -d, file1.txt file2.txt

diff

Compare files.

diff file1.txt file2.txt

Unified format:

diff -u file1.txt file2.txt

Compare directories:

diff -r directory1 directory2

patch

Apply changes from a patch file.

patch < changes.patch

A patch is commonly generated using:

diff -u old.txt new.txt > changes.patch

9. Archives and Compression

tar

Create and extract archives.

Create:

tar -cvf backup.tar directory/

Extract:

tar -xvf backup.tar

Create gzip-compressed archive:

tar -czvf backup.tar.gz directory/

Extract gzip archive:

tar -xzvf backup.tar.gz

gzip

Compress files.

gzip file.txt

Produces:

file.txt.gz

gunzip

Decompress gzip files.

gunzip file.txt.gz

zip *

Create ZIP archives.

zip archive.zip file.txt

Recursive:

zip -r archive.zip directory/

unzip *

Extract ZIP archives.

unzip archive.zip

Extract to a specific directory:

unzip archive.zip -d /tmp/archive

10. File Synchronization and Remote Copy

rsync *

Synchronize files efficiently.

rsync -av source/ destination/

Remote synchronization:

rsync -av /data/ user@server:/backup/

Commonly used form:

rsync -avh --progress source/ destination/

scp

Copy files over SSH.

Upload:

scp file.txt user@server:/tmp/

Download:

scp user@server:/tmp/file.txt .

Copy directories:

scp -r directory user@server:/tmp/

ssh

Connect to a remote server.

ssh [email protected]

Specify a port:

ssh -p 2222 [email protected]

Run a remote command:

ssh user@server "uptime"

11. Network Commands

curl

Transfer data using HTTP, HTTPS, and other protocols.

curl https://pocketx.app

Follow redirects:

curl -L https://pocketx.app

Show response headers:

curl -I https://pocketx.app

Download a file:

curl -O https://example.org/file.tar.gz

wget

Download files.

wget https://example.org/file.iso

Resume an interrupted download:

wget -c https://example.org/file.iso

ping

Test host connectivity.

ping 8.8.8.8

Send four packets:

ping -c 4 8.8.8.8

traceroute *

Display network hops to a destination.

traceroute 8.8.8.8

mtr *

Combine ping and traceroute.

mtr 8.8.8.8

Generate a report:

mtr -rw 8.8.8.8

ip

Manage network interfaces, addresses, and routes.

Show addresses:

ip addr

Short form:

ip a

Show routes:

ip route

Show interfaces:

ip link

ss

Inspect sockets.

Show listening sockets:

ss -tuln

Show associated processes:

sudo ss -tulpn

Show established TCP connections:

ss -tn state established

ethtool *

Inspect network interfaces.

sudo ethtool eth0

Can show:

  • Link speed
  • Duplex mode
  • Link status
  • Driver capabilities

dig *

Perform DNS queries.

dig pocketx.app

Query an A record:

dig pocketx.app A

Query MX records:

dig pocketx.app MX

Use a specific DNS server:

dig @1.1.1.1 pocketx.app

nmap *

Scan hosts and ports.

nmap 192.168.1.10

Scan specified ports:

nmap -p 22,80,443 192.168.1.10

Service detection:

nmap -sV 192.168.1.10

Only scan systems and networks you are authorized to test.


tcpdump *

Capture network traffic.

sudo tcpdump

Specific interface:

sudo tcpdump -i eth0

Specific port:

sudo tcpdump -i eth0 port 443

Write packets to a file:

sudo tcpdump -i eth0 -w capture.pcap

12. Process Management

ps

Display processes.

ps

Common administrator usage:

ps aux

Search using grep:

ps aux | grep nginx

top

Interactive process monitor.

top

Shows:

  • CPU usage
  • RAM usage
  • Load
  • Processes
  • Uptime

htop *

Enhanced interactive process monitor.

htop

Often installed with:

sudo apt install htop

pgrep

Find process IDs.

pgrep nginx

Include command names:

pgrep -a nginx

pkill

Send a signal to processes matching a name.

pkill nginx

Force kill:

pkill -9 nginx

Use SIGKILL only when normal termination does not work.


kill

Send signals by PID.

kill 1234

Default:

SIGTERM

Force kill:

kill -9 1234

killall

Send signals to all matching processes.

killall nginx

nice

Start a process with adjusted scheduling priority.

nice -n 10 command

Nice values normally range from:

-20    Highest priority
19     Lowest priority

Increasing priority with negative values generally requires elevated privileges.


renice

Change the priority of an existing process.

renice 10 -p 1234

strace

Trace system calls made by a process.

Run a program:

strace ./application

Attach to an existing process:

sudo strace -p 1234

Useful for diagnosing:

  • File access problems
  • Permission errors
  • Network calls
  • Missing files
  • Unexpected system calls

jobs

Display shell jobs.

jobs

Start something in the background:

sleep 300 &

Then:

jobs

13. Scheduling Commands

crontab

Manage scheduled cron jobs.

Edit:

crontab -e

List:

crontab -l

Example:

0 2 * * * /usr/local/bin/backup.sh

This runs every day at 02:00.

Cron format:

Minute Hour Day Month Weekday Command

at

Schedule a one-time command.

at 23:00

Then enter:

/usr/local/bin/backup.sh

Press:

Ctrl+D

to finish.

The at package/service may need to be installed first.


14. Services and Logs

systemctl

Manage systemd units and services.

Check status:

systemctl status nginx

Start:

sudo systemctl start nginx

Stop:

sudo systemctl stop nginx

Restart:

sudo systemctl restart nginx

Enable at boot:

sudo systemctl enable nginx

Enable and immediately start:

sudo systemctl enable --now nginx

service

Traditional compatibility command for managing services.

sudo service nginx status

Restart:

sudo service nginx restart

On modern systemd-based distributions, systemctl is generally preferred.


journalctl

Read systemd logs.

journalctl

Logs for a service:

journalctl -u nginx

Follow logs:

journalctl -u nginx -f

Logs from current boot:

journalctl -b

Recent errors:

journalctl -p err

15. System Information

uname

Display kernel and system information.

uname

Show everything:

uname -a

Kernel version:

uname -r

Architecture:

uname -m

hostnamectl

Display hostname information.

hostnamectl

Set hostname:

sudo hostnamectl set-hostname server01

date

Display current date and time.

date

Custom format:

date "+%Y-%m-%d %H:%M:%S"

UTC:

date -u

uptime

Show uptime and system load.

uptime

Example:

16:45:01 up 12 days, 3:21, 2 users, load average: 0.15, 0.20, 0.18

who

Show logged-in users.

who

w

Show logged-in users and their activity.

w

It also displays system load information.


last

Display login history.

last

Show reboot history:

last reboot

16. Memory, CPU, and Performance

free

Show memory usage.

free

Human-readable:

free -h

vmstat

Display system performance statistics.

vmstat

Refresh every second:

vmstat 1

Shows information about:

  • Processes
  • RAM
  • Swap
  • I/O
  • CPU

iostat *

Display CPU and disk I/O statistics.

iostat

Extended disk statistics:

iostat -xz 1

On Debian/Ubuntu, it is provided by sysstat:

sudo apt install sysstat

dmesg

Read kernel messages.

dmesg

Human-readable timestamps:

dmesg -T

Search for errors:

dmesg -T | grep -i error

Kernel restrictions may require:

sudo dmesg

watch

Run a command repeatedly.

watch df -h

Run every second:

watch -n 1 free -h

Highlight changes:

watch -d ip addr

lsof

List open files and the processes using them.

lsof

Find what is using port 8080:

sudo lsof -i :8080

Find processes using a file:

sudo lsof /var/log/app.log

17. Storage and Filesystems

lsblk

List block devices.

lsblk

Show filesystem information:

lsblk -f

Example:

NAME   FSTYPE MOUNTPOINT
sda
├─sda1 ext4   /
└─sda2 swap   [SWAP]

blkid

Display block device UUIDs and filesystem types.

sudo blkid

Useful when configuring:

/etc/fstab

fdisk

Manage partition tables.

List disks:

sudo fdisk -l

Open a disk:

sudo fdisk /dev/sdb

Incorrect partitioning commands can permanently destroy data.

Although historically associated mainly with MBR partitioning, modern fdisk versions can also work with GPT partition tables.


parted

Partition management utility with GPT support.

sudo parted /dev/sdb

Display disks:

sudo parted -l

mkfs

Create a filesystem.

Create ext4:

sudo mkfs.ext4 /dev/sdb1

Create XFS:

sudo mkfs.xfs /dev/sdb1

Formatting a partition destroys its existing filesystem and data.


mount

Mount a filesystem.

sudo mount /dev/sdb1 /mnt/data

Show current mounts:

mount

For persistent mounts, configure:

/etc/fstab

umount

Unmount a filesystem.

sudo umount /mnt/data

Or:

sudo umount /dev/sdb1

Check processes preventing unmount:

sudo lsof /mnt/data

swapon

Enable swap.

Show configured swap:

swapon --show

Enable a swap partition:

sudo swapon /dev/sdb2

Enable a swap file:

sudo swapon /swapfile

lscpu

Display CPU information.

lscpu

Shows information such as:

  • CPU architecture
  • Logical CPUs
  • Cores
  • Threads
  • Sockets
  • Virtualization support
  • CPU model
  • Cache information

18. Quick Reference Table

# Command Purpose
1 ls List files and directories
2 pwd Show current directory
3 cd Change directory
4 mkdir Create directories
5 rmdir Remove empty directories
6 touch Create files/update timestamps
7 cp Copy files/directories
8 mv Move or rename files
9 rm Remove files/directories
10 cat Display file contents
11 less Page through files
12 head Show beginning of file
13 tail Show end of file
14 nano Simple text editor
15 vim Advanced text editor
16 echo Print text/variables
17 tee Duplicate command output
18 find Search filesystem
19 locate* Indexed file search
20 updatedb* Update locate database
21 stat File metadata
22 file Identify file type
23 du Directory/file disk usage
24 df Filesystem usage
25 ln Create links
26 chmod Change permissions
27 chown Change owner
28 chgrp Change group
29 which Locate executable
30 man Command documentation
31 grep Search text
32 awk Process structured text
33 sed Transform text
34 cut Extract columns
35 sort Sort lines
36 uniq Remove/count duplicates
37 tr Translate characters
38 wc Count lines/words/bytes
39 xargs Build command arguments
40 split Split files
41 paste Merge lines
42 diff Compare files
43 patch Apply patches
44 tar Archive files
45 gzip Compress files
46 gunzip Decompress gzip
47 zip* Create ZIP files
48 unzip* Extract ZIP files
49 rsync* Synchronize files
50 scp Secure remote copy
51 ssh Remote shell
52 curl Transfer data
53 wget Download files
54 ping Test connectivity
55 traceroute* Trace network path
56 mtr* Live route diagnostics
57 ip Network configuration
58 ss Socket information
59 ethtool* NIC configuration
60 dig* DNS queries
61 nmap* Network scanner
62 tcpdump* Packet capture
63 ps List processes
64 top Process monitor
65 htop* Enhanced process monitor
66 pgrep Find process IDs
67 pkill Signal processes by name
68 kill Signal process by PID
69 killall Signal named processes
70 nice Start with priority
71 renice Change process priority
72 strace Trace system calls
73 jobs Show shell jobs
74 crontab Recurring schedules
75 at One-time schedules
76 systemctl Manage systemd
77 service Service compatibility command
78 journalctl Systemd logs
79 uname Kernel/system information
80 hostnamectl Hostname management
81 date Date/time
82 uptime Uptime/load
83 who Logged-in users
84 w Logged-in user activity
85 last Login history
86 free Memory usage
87 vmstat System performance
88 iostat* Disk I/O statistics
89 dmesg Kernel messages
90 watch Repeat commands
91 lsof Open files/processes
92 lsblk Block devices
93 blkid Filesystem UUID/type
94 fdisk Partition editor
95 parted GPT/partition editor
96 mkfs Create filesystem
97 mount Mount filesystem
98 umount Unmount filesystem
99 swapon Enable swap
100 lscpu CPU information

19. Optional Packages

Some commands may not be installed by default.

For Debian/Ubuntu systems:

sudo apt update
sudo apt install -y \
    plocate \
    zip \
    unzip \
    rsync \
    traceroute \
    mtr-tiny \
    ethtool \
    dnsutils \
    nmap \
    tcpdump \
    htop \
    sysstat \
    lsof \
    parted \
    at \
    strace

Package names differ between Linux distributions.


20. Useful Administrator Command Combinations

Check storage:

df -h
lsblk -f
du -sh /var/*

Check memory:

free -h

Check CPU:

lscpu
top

Check listening ports:

sudo ss -tulpn

Check what is using a port:

sudo lsof -i :8080

Check a service:

systemctl status nginx

Follow its logs:

journalctl -u nginx -f

Check network configuration:

ip addr
ip route

Test DNS:

dig pocketx.app

Test connectivity:

ping -c 4 pocketx.app

Trace network problems:

mtr -rw pocketx.app

Find large files:

find / -type f -size +1G 2>/dev/null

Find a process:

pgrep -a nginx

Monitor a command continuously:

watch -n 2 'df -h'

21. Safety Notes

Several Linux commands can modify or permanently destroy system data. Pay particular attention to:

rm -rf
mkfs
fdisk
parted
chmod -R
chown -R
kill -9

Before running destructive storage commands, verify the target device:

lsblk

Before deleting a directory, inspect it:

ls -lah /path/to/directory

Whenever possible, allow a process to terminate normally:

kill PID

before resorting to:

kill -9 PID

Summary

These 100 commands provide a strong foundation for everyday Linux administration.

The commands you will likely use most frequently are:

ls        cd        pwd       cp
mv        rm        cat       less
grep      find      tail      chmod
chown     df        du        free
ps        top       ssh       scp
curl      ip        ss        systemctl
journalctl          lsblk     mount

Learning these commands together with Linux permissions, pipes, redirection, systemd, networking, and filesystem concepts covers a large portion of routine Linux server administration.

Leave a comment

Your email address will not be published. Required fields are marked *