Webtech logo

Linux Command Reference

Essential commands for navigating, managing, and understanding Linux systems.

Linux field guide

Browse common commands for files, system information, users, networking, packages, processes, storage, text processing, archives, and shell scripting.

Use responsibly: Commands that change files, users, permissions, packages, or processes should be run only when you understand their effect and have the required authorization.

File & Directory Management

ls

List files in a directory.

pwd

Show the current working directory.

cd /path

Change to a directory.

mkdir newdir

Create a new directory.

rm file.txt

Delete a file.

rm -r folder

Delete a folder and its contents.

cp file1 file2

Copy a file.

mv file1 file2

Move or rename a file.

File Viewing & Editing

cat file.txt

Display file contents.

less file.txt

View a file one page at a time.

head file.txt

Show the first 10 lines of a file.

tail file.txt

Show the last 10 lines of a file.

nano file.txt

Edit a file in Nano.

vim file.txt

Edit a file in Vim.

System Information

uname -a

Show system and kernel information.

whoami

Show the current username.

df -h

Show disk usage in human-readable format.

du -sh folder

Show the size of a folder.

free -h

Show memory usage in human-readable format.

uptime

Show system uptime and load averages.

top

Monitor processes in real time.

htop

Interactive process monitoring.

User & Permissions

adduser mahek

Add a new user.

passwd mahek

Change a user's password.

chmod 755 file

Change file permissions.

chown user file

Change file ownership.

groups

Show the groups the current user belongs to.

id

Show user ID and group ID.

Networking

ping host

Test connectivity to a host.

curl url

Fetch data from a URL.

wget url

Download a file from the web.

ip addr

Show IP addresses and interfaces.

ifconfig

Show network interfaces; older command.

netstat -tuln

Show listening TCP and UDP ports.

ss -tuln

Modern replacement for netstat to show listening ports.

ssh user@host

Connect to a remote host over SSH.

scp file user@host:/path

Copy a file to a remote host over SSH.

Package Management

Ubuntu and Debian package commands.

sudo apt update

Update package lists.

sudo apt upgrade

Upgrade installed packages.

sudo apt install nmap

Install a package.

sudo apt remove pkg

Remove a package.

dpkg -l

List installed packages.

Process Management

ps aux

Show running processes.

kill PID

Stop a process by its ID.

killall name

Stop processes by name.

jobs

Show background jobs in the current shell.

fg %1

Bring job 1 to the foreground.

bg %1

Resume job 1 in the background.

Disk & Storage

mount /dev/sda1 /mnt

Mount a disk partition.

umount /mnt

Unmount a mounted filesystem.

fdisk -l

List disk partitions.

lsblk

List block devices.

blkid

Show block device attributes.

Search & Filters

find /path -name file.txt

Search for a file by name.

locate file.txt

Quickly find files using the locate database.

grep "text" file.txt

Search for text inside a file.

egrep "pattern" file.txt

Search using extended regular expressions.

awk '{print $1}' file.txt

Process text by columns.

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

Replace text in a file.

Archiving & Compression

tar -cvf archive.tar folder

Create a tar archive.

tar -xvf archive.tar

Extract a tar archive.

gzip file.txt

Compress a file with gzip.

gunzip file.txt.gz

Decompress a gzip file.

zip archive.zip file.txt

Create a zip archive.

unzip archive.zip

Extract a zip archive.

Shell & Scripting

echo "Hello World"

Print text to the terminal.

history

Show command history.

alias ll='ls -la'

Create a shortcut command.

bash script.sh

Run a Bash script.

sh script.sh

Run a shell script.

No matching commands found.