MiTpython

Loading...
🌐 Loading...
Contact Chat
00:00:00 Loading...
🌡️ Loading... Loading weather... 💧 Loading... 💨 Loading...
Loading timezone...

Top 100 Linux Commands

A comprehensive guide to essential Linux commands for beginners and experienced users alike. These commands are organized by category to help you find what you need quickly.

ls

File Management
ls [options] [directory]
Lists files and directories in the current directory or specified location.
ls -la List all files (including hidden) in long format with details
ls -lh List files with human-readable sizes

cp

File Management
cp [options] source destination
Copies files or directories from source to destination.
cp file.txt backup/ Copy file.txt to the backup directory
cp -r dir1/ dir2/ Copy directory dir1 and its contents to dir2 recursively

mv

File Management
mv [options] source destination
Moves or renames files and directories.
mv file.txt newname.txt Rename file.txt to newname.txt
mv file.txt ~/Documents/ Move file.txt to the Documents directory

rm

File Management
rm [options] file(s)
Removes (deletes) files or directories.
rm file.txt Delete file.txt
rm -rf directory/ Delete directory and its contents forcefully

touch

File Management
touch [options] file(s)
Creates an empty file or updates the access and modification times of an existing file.
touch newfile.txt Create a new empty file named newfile.txt
touch -a file.txt Update only the access time of file.txt

cat

File Management
cat [options] [file(s)]
Concatenates and displays file contents.
cat file.txt Display contents of file.txt
cat file1.txt file2.txt > combined.txt Combine two files into one

head

File Management
head [options] [file(s)]
Display the beginning of files.
head -n 10 file.txt Show first 10 lines of file

tail

File Management
tail [options] [file(s)]
Display the end of files.
tail -f /var/log/syslog Follow log file in real-time

less

File Management
less [options] file
View file contents page by page.
less large_file.txt View large file with pagination

nano

File Management
nano [options] [file]
Simple text editor for the command line.
nano newfile.txt Create or edit a text file

vim

File Management
vim [options] [file]
Advanced text editor with multiple modes.
vim script.sh Edit a shell script

mkdir

Directory
mkdir [options] directory(s)
Creates one or more directories.
mkdir newfolder Create a directory named newfolder
mkdir -p parent/child/grandchild Create nested directories including any necessary parent directories

cd

Directory
cd [directory]
Changes the current working directory.
cd /home/user/documents Change to the documents directory
cd .. Move up one directory level
cd ~ Go to home directory

rmdir

Directory
rmdir [options] directory(s)
Removes empty directories.
rmdir emptyfolder Remove the directory named emptyfolder (if empty)
rmdir -p parent/child/grandchild Remove nested directories if empty

uname

System
uname [options]
Displays system information.
uname -a Print all system information
uname -r Print the kernel release

date

System
date [options] [+format]
Displays or sets the system date and time.
date Show current date and time
date +"%Y-%m-%d" Display date in YYYY-MM-DD format

free

System
free [options]
Display amount of free and used memory.
free -h Show memory usage in human readable format

uptime

System
uptime [options]
Show how long the system has been running.
uptime Display system uptime and load

lsof

System
lsof [options]
List open files and processes.
lsof -i :80 Show processes using port 80

dmesg

System
dmesg [options]
Print or control kernel ring buffer.
dmesg | grep error Show kernel error messages

ps

Process
ps [options]
Reports a snapshot of current processes.
ps aux Display all running processes in BSD format
ps -ef Display all running processes in standard format

kill

Process
kill [options] pid(s)
Terminates or sends signals to processes.
kill 1234 Terminate process with PID 1234
kill -9 1234 Force kill process with PID 1234

top

Process
top [options]
Displays and updates sorted information about processes.
top Show real-time process activity
top -u username Show processes for a specific user

htop

Process
htop [options]
Interactive process viewer and system monitor.
htop Launch interactive process viewer

nice

Process
nice [options] command
Run a program with modified scheduling priority.
nice -n 10 ./script.sh Run script with lower priority

renice

Process
renice priority [options] identifier
Alter priority of running processes.
renice -n 5 -p 1234 Change priority of process ID 1234

whoami

User
whoami
Displays the current username.
whoami Print the current user's username

passwd

User
passwd [options] [username]
Changes user password.
passwd Change your own password
sudo passwd username Change another user's password (as root)

useradd

User
useradd [options] username
Create a new user account.
useradd -m username Create user with home directory

userdel

User
userdel [options] username
Delete a user account.
userdel -r username Delete user and their home directory

usermod

User
usermod [options] username
Modify user account settings.
usermod -aG sudo username Add user to sudo group

apt

Package
apt [options] command
Advanced Package Tool, package management system used by Debian and its derivatives.
sudo apt update Update package lists
sudo apt install package_name Install a package

yum

Package
yum [options] command
Yellowdog Updater Modified, package manager for RPM-based distributions.
sudo yum update Update all packages
sudo yum install package_name Install a package

chmod

Permissions
chmod [options] mode file(s)
Changes file mode (permissions).
chmod 755 file.sh Give read, write, execute to owner; read, execute to group and others
chmod +x script.sh Add execute permission for all users

chown

Permissions
chown [options] user[:group] file(s)
Changes file owner and group.
sudo chown user1 file.txt Change the owner of file.txt to user1
sudo chown -R user1:group1 directory/ Change owner and group of directory and its contents recursively

find

Search
find [path] [expression]
Searches for files in a directory hierarchy.
find /home -name "*.txt" Find all .txt files in /home directory
find . -type f -mtime -7 Find files modified in the last 7 days

grep

Search
grep [options] pattern [file(s)]
Searches for patterns in files.
grep "search term" file.txt Search for "search term" in file.txt
grep -r "search term" directory/ Search recursively through directory

tar

Compression
tar [options] [file(s)]
Archives files and directories.
tar -cvf archive.tar files/ Create a tar archive of files/ directory
tar -xvf archive.tar Extract a tar archive

gzip

Compression
gzip [options] file(s)
Compresses or expands files.
gzip file.txt Compress file.txt (creates file.txt.gz)
gzip -d file.txt.gz Decompress file.txt.gz

ping

Network
ping [options] host
Sends ICMP ECHO_REQUEST to network hosts.
ping google.com Ping google.com continuously
ping -c 4 8.8.8.8 Ping Google's DNS server 4 times

ifconfig

Network
ifconfig [options] [interface]
Configures or displays network interface parameters.
ifconfig Display information for all interfaces
ifconfig eth0 Display information for eth0 interface

nslookup

Network
nslookup [hostname|IP]
Query DNS records.
nslookup google.com Look up DNS information for google.com

dig

Network
dig [options] domain
DNS lookup utility.
dig +short example.com Get IP address for domain

traceroute

Network
traceroute [options] host
Print the route packets trace to network host.
traceroute google.com Show route to google.com

df

Disk
df [options]
Reports file system disk space usage.
df -h Show disk space in human-readable format
df -i Show inode information

du

Disk
du [options] [file(s)]
Estimates file space usage.
du -sh directory/ Show total size of directory in human-readable format
du -h --max-depth=1 Show sizes of immediate subdirectories

fdisk

Disk
fdisk [options] device
Manipulate disk partition table.
sudo fdisk -l List all disk partitions

mount

Disk
mount [options] device dir
Mount a filesystem.
mount /dev/sdb1 /mnt Mount device to directory

umount

Disk
umount [options] dir|device
Unmount a filesystem.
umount /mnt Unmount filesystem at /mnt

sudo

Admin
sudo [options] command
Executes a command as another user, typically the superuser.
sudo apt update Run apt update as root
sudo -u username command Run command as the specified user

systemctl

Admin
systemctl [options] command [unit(s)]
Controls the systemd system and service manager.
sudo systemctl start service-name Start a service
sudo systemctl status service-name Check the status of a service

locate

Search
locate [options] pattern
Find files by name quickly.
locate *.jpg Find all .jpg files in database

which

Search
which [options] command
Locate a command's executable.
which python3 Find path to python3 executable

whereis

Search
whereis [options] name
Locate binary, source, and manual page files.
whereis bash Find bash binary and manual locations

zip

Compression
zip [options] zipfile files
Package and compress files.
zip -r archive.zip folder/ Create zip archive of folder

unzip

Compression
unzip [options] file[.zip]
Extract compressed ZIP files.
unzip archive.zip Extract zip archive

bzip2

Compression
bzip2 [options] filenames
Compress or decompress files using Burrows-Wheeler block sorting.
bzip2 large_file Compress file using bzip2

hostname

System
hostname [options]
Show or set system's host name.
hostname Display current hostname

history

System
history [options]
Show command history.
history | grep ssh Show SSH-related commands from history

alias

System
alias [name[=value]]
Create command aliases.
alias ll='ls -la' Create alias for detailed list

nohup

Process
nohup command [args]
Run command immune to hangups.
nohup ./script.sh & Run script in background, immune to hangups

jobs

Process
jobs [options]
List active jobs.
jobs -l List jobs with process IDs

bg

Process
bg [job_spec]
Put jobs in background.
bg %1 Resume job 1 in background

fg

Process
fg [job_spec]
Bring jobs to foreground.
fg %2 Bring job 2 to foreground

netcat

Network
nc [options] host port
Networking utility for reading/writing network connections.
nc -l 1234 Listen on port 1234

tcpdump

Network
tcpdump [options]
Dump network traffic.
tcpdump -i eth0 Capture packets on eth0 interface

iptables

Network
iptables [options] command chain rule
Administration tool for IPv4 packet filtering and NAT.
iptables -L List all firewall rules

mkfs

Disk
mkfs [options] device
Build a Linux filesystem.
mkfs.ext4 /dev/sdb1 Create ext4 filesystem

fsck

Disk
fsck [options] device
Check and repair a Linux filesystem.
fsck /dev/sda1 Check filesystem for errors

lsblk

Disk
lsblk [options]
List block devices.
lsblk -f Show filesystem information

service

Admin
service name command
Run a System V init script.
service apache2 restart Restart Apache web server

journalctl

Admin
journalctl [options]
Query the systemd journal.
journalctl -u nginx.service Show Nginx service logs

chroot

Admin
chroot [options] newroot [command]
Run command or shell with special root directory.
chroot /mnt/newroot /bin/bash Start shell with new root directory

crontab

Admin
crontab [options]
Maintain crontab files for individual users.
crontab -e Edit your cron jobs

at

Admin
at time
Execute commands at a specified time.
at 2:30pm Schedule command execution for 2:30 PM

ln

File Management
ln [options] target link_name
Create links between files.
ln -s target link Create symbolic link

file

File Management
file [options] file
Determine file type.
file image.jpg Show file type information

stat

File Management
stat [options] file
Display file or filesystem status.
stat file.txt Show detailed file information

rsync

Network
rsync [options] source destination
Fast, versatile file copying tool.
rsync -av source/ dest/ Synchronize directories

telnet

Network
telnet [host [port]]
User interface to TELNET protocol.
telnet localhost 80 Connect to local web server

awk

Search
awk 'pattern {action}' file
Pattern scanning and text processing language.
awk '{print $1}' file.txt Print first field of each line

sed

Search
sed [options] command [file]
Stream editor for filtering and transforming text.
sed 's/old/new/g' file.txt Replace text in file

watch

System
watch [options] command
Execute a program periodically, showing output.
watch -n 1 free -m Monitor memory usage every second

time

System
time command
Run programs and summarize system resource usage.
time ls -R / Measure execution time of command

tee

System
tee [options] file
Read from standard input and write to files and standard output.
echo "test" | tee file.txt Write output to file and screen

w

System
w [options] [user]
Show who is logged on and what they are doing.
w Display information about logged-in users

last

System
last [options] [username]
Show listing of last logged in users.
last -n 5 Show last 5 logins

who

System
who [options]
Show who is logged on.
who -H Show header line

dd

File Management
dd [operands]
Convert and copy a file.
dd if=/dev/zero of=file.txt count=1 bs=1M Create a 1MB file filled with zeros

sort

File Management
sort [options] [file(s)]
Sort lines of text files.
sort -n numbers.txt Sort numbers numerically

uniq

File Management
uniq [options] [input [output]]
Report or omit repeated lines.
sort file.txt | uniq -c Count occurrences of lines

route

Network
route [options]
Show / manipulate the IP routing table.
route -n Show routing table in numeric form

host

Network
host [options] name [server]
DNS lookup utility.
host google.com Look up DNS records for google.com

pgrep

Process
pgrep [options] pattern
Look up processes based on name and attributes.
pgrep -l nginx Find and list nginx processes

pkill

Process
pkill [options] pattern
Signal processes based on name and attributes.
pkill -9 firefox Force kill all firefox processes

strace

System
strace [options] command
Trace system calls and signals.
strace ls Show system calls made by ls command

wc

File Management
wc [options] [file(s)]
Print newline, word, and byte counts.
wc -l file.txt Count lines in file

diff

File Management
diff [options] files
Compare files line by line.
diff file1.txt file2.txt Show differences between two files

patch

File Management
patch [options] [originalfile [patchfile]]
Apply a diff file to an original.
patch < patchfile.diff Apply patch to files

logger

System
logger [options] message
Enter messages into the system log.
logger "System backup completed" Log a message to syslog