Success: ARRAY(0x6379f4e2df68)
Debug: Command reference enhanced with copy-to-clipboard functionality
A comprehensive guide to common Linux commands for system administrators and developers.
List directory contents
ls
List files and directories in the current directory
ls -l
List in long format with permissions, owner, size, and date
ls -la
List all files including hidden files (starting with .)
ls -lh
List with human-readable file sizes (KB, MB, GB)
Change directory
cd directory_name
Change to specified directory
cd ..
Move up one directory level
cd ~
Change to home directory
cd -
Change to previous directory
Print working directory
pwd
Display the current directory path
Make directory
mkdir directory_name
Create a new directory
mkdir -p parent/child/grandchild
Create nested directories (create parent directories as needed)
Remove directory
rmdir directory_name
Remove an empty directory
Search for files in a directory hierarchy
find /path -name "filename"
Find files with exact name
find /path -name "*.txt"
Find all .txt files
find /path -type f -mtime -7
Find files modified in the last 7 days
find /path -type f -size +10M
Find files larger than 10MB
Copy files and directories
cp file1 file2
Copy file1 to file2
cp -r dir1 dir2
Copy directory dir1 to dir2 recursively
cp -i file1 file2
Copy with confirmation before overwriting
Move or rename files
mv file1 file2
Rename file1 to file2
mv file1 /path/to/directory/
Move file1 to specified directory
mv -i file1 file2
Move with confirmation before overwriting
Remove files or directories
rm filename
Remove a file
rm -r directory
Remove a directory and its contents recursively
rm -f filename
Force removal without confirmation
rm -i filename
Interactive removal with confirmation
rm -rf
as it can delete entire directories without confirmation.
Create empty files or update timestamps
touch filename
Create an empty file or update timestamp of existing file
touch -a filename
Change only the access time
touch -m filename
Change only the modification time
Concatenate and display file contents
cat filename
Display file contents
cat file1 file2
Concatenate and display multiple files
cat -n filename
Display with line numbers
View file contents with pagination
less filename
View file with pagination (use space to scroll, q to quit)
less -N filename
View with line numbers
Display the beginning of a file
head filename
Display first 10 lines of a file
head -n 20 filename
Display first 20 lines of a file
Display the end of a file
tail filename
Display last 10 lines of a file
tail -n 20 filename
Display last 20 lines of a file
tail -f filename
Follow file updates in real-time (useful for log files)
Search for patterns in files
grep "pattern" filename
Search for pattern in file
grep -i "pattern" filename
Case-insensitive search
grep -r "pattern" directory
Recursive search in directory
grep -v "pattern" filename
Show lines that do NOT match the pattern
grep -n "pattern" filename
Show line numbers with matches
Stream editor for filtering and transforming text
sed 's/old/new/' filename
Replace first occurrence of 'old' with 'new' on each line
sed 's/old/new/g' filename
Replace all occurrences of 'old' with 'new'
sed -i 's/old/new/g' filename
Edit file in-place (save changes to file)
sed '5d' filename
Delete line 5
Pattern scanning and processing language
awk '{print $1}' filename
Print first column of each line
awk -F: '{print $1}' /etc/passwd
Print first column using : as field separator
awk '/pattern/ {print $0}' filename
Print lines matching pattern
awk '{sum+=$1} END {print sum}' filename
Sum values in first column
Print system information
uname -a
Print all system information
uname -r
Print kernel release
Report file system disk space usage
df -h
Show disk usage in human-readable format
df -i
Show inode information
Estimate file space usage
du -h
Show directory sizes in human-readable format
du -sh directory
Show total size of a directory in human-readable format
du -h --max-depth=1
Show sizes of directories one level deep
Display amount of free and used memory
free -h
Show memory usage in human-readable format
free -m
Show memory usage in megabytes
Display Linux processes
top
Show real-time process information (press q to quit)
top -u username
Show processes for specific user
Interactive process viewer
htop
Interactive process viewer with color (may need to be installed)
Report process status
ps
Show current user's processes
ps aux
Show all processes in BSD format
ps -ef
Show all processes in full format
ps aux | grep process_name
Find specific process
Terminate processes
kill PID
Terminate process with process ID
kill -9 PID
Force terminate process (SIGKILL)
killall process_name
Kill all processes with the given name
Put jobs in background
bg
Resume suspended job in background
bg %job_number
Resume specific job in background
Bring jobs to foreground
fg
Bring most recent background job to foreground
fg %job_number
Bring specific job to foreground
List active jobs
jobs
List all jobs
jobs -l
List jobs with process IDs
Run command immune to hangups
nohup command &
Run command that continues after you log out
Create a new user
sudo useradd username
Create a new user
sudo useradd -m -s /bin/bash username
Create user with home directory and bash shell
Modify user account
sudo usermod -aG groupname username
Add user to a group
sudo usermod -s /bin/bash username
Change user's shell
Delete a user account
sudo userdel username
Delete user account
sudo userdel -r username
Delete user account and home directory
Change user password
passwd
Change your own password
sudo passwd username
Change another user's password
Show who is logged in
who
Show who is logged in
who -a
Show all information
Print user and group information
id
Show current user's ID information
id username
Show specific user's ID information
Send ICMP ECHO_REQUEST to network hosts
ping hostname
Ping a host continuously (Ctrl+C to stop)
ping -c 4 hostname
Ping a host 4 times
Configure network interface
ifconfig
Display all network interfaces and IP addresses
ifconfig eth0
Display specific interface
ip addr
is preferred over ifconfig
.
Show/manipulate routing, devices, policy routing and tunnels
ip addr
Show IP addresses and network interfaces
ip link
Show network interfaces
ip route
Show routing table
Print network connections, routing tables, interface statistics
netstat -tuln
Show all listening ports
netstat -an
Show all connections
netstat -rn
Show routing table
ss
is preferred over netstat
.
Another utility to investigate sockets
ss -tuln
Show all listening ports
ss -ta
Show all TCP sockets
Non-interactive network downloader
wget URL
Download file from URL
wget -O filename URL
Download and save with specific filename
wget -c URL
Continue interrupted download
Transfer data from or to a server
curl URL
Display the content of URL
curl -o filename URL
Download and save with specific filename
curl -I URL
Fetch HTTP headers only
Advanced Package Tool
sudo apt update
Update package lists
sudo apt upgrade
Upgrade installed packages
sudo apt install package_name
Install a package
sudo apt remove package_name
Remove a package
apt search keyword
Search for packages
apt show package_name
Show package details
Yellowdog Updater Modified
sudo yum update
Update package lists and upgrade packages
sudo yum install package_name
Install a package
sudo yum remove package_name
Remove a package
yum search keyword
Search for packages
yum info package_name
Show package details
Dandified YUM
sudo dnf update
Update package lists and upgrade packages
sudo dnf install package_name
Install a package
sudo dnf remove package_name
Remove a package
Change file mode bits
chmod 755 filename
Set permissions to rwxr-xr-x
chmod +x filename
Add execute permission for all users
chmod -R 755 directory
Recursively change permissions
chmod u+w filename
Add write permission for owner
Change file owner and group
sudo chown user:group filename
Change owner and group
sudo chown -R user:group directory
Recursively change owner and group
Change group ownership
sudo chgrp group filename
Change group ownership
sudo chgrp -R group directory
Recursively change group ownership
Tape archive
tar -cvf archive.tar files
Create a tar archive
tar -xvf archive.tar
Extract a tar archive
tar -czvf archive.tar.gz files
Create a compressed tar archive (gzip)
tar -xzvf archive.tar.gz
Extract a compressed tar archive (gzip)
tar -cjvf archive.tar.bz2 files
Create a compressed tar archive (bzip2)
tar -xjvf archive.tar.bz2
Extract a compressed tar archive (bzip2)
Compress or expand files
gzip filename
Compress a file (creates filename.gz and removes original)
gzip -d filename.gz
Decompress a file
gzip -k filename
Compress a file but keep the original
Package and compress files
zip archive.zip files
Create a zip archive
zip -r archive.zip directory
Create a zip archive of a directory
unzip archive.zip
Extract a zip archive
unzip -l archive.zip
List contents of a zip archive