Here’s a comprehensive list of Linux commands with descriptions and examples. This list covers most commonly used commands for file management, system monitoring, networking, and more.
ls
- List directory contents
- Example:
ls -l /home # List files in /home with details
cd
- Change directory
- Example:
cd /var/log # Move to /var/log directory
pwd
- Print working directory
- Example:
pwd # Show current directory path
mkdir
- Create a directory
- Example:
mkdir new_folder # Create a directory named new_folder
rmdir
- Remove an empty directory
- Example:
rmdir empty_folder # Remove empty_folder
rm
- Remove files or directories
- Example:
rm file.txt # Delete file.txt
rm -r folder # Recursively delete folder and its contents
cp
- Copy files or directories
- Example:
cp file.txt /backup # Copy file.txt to /backup
cp -r folder /backup # Copy folder recursively
mv
- Move or rename files or directories
- Example:
mv file.txt /backup # Move file.txt to /backup
mv old_name.txt new_name.txt # Rename file
touch
- Create an empty file or update file timestamp
- Example:
touch newfile.txt # Create newfile.txt
cat
- Display file content
- Example:
cat file.txt # Show content of file.txt
more
- View file content page by page
- Example:
more largefile.txt # View largefile.txt page by page
less
- View file content with backward navigation
- Example:
less largefile.txt # View file with backward navigation
head
- Display the first part of a file
- Example:
head -n 10 file.txt # Show first 10 lines of file.txt
tail
- Display the last part of a file
- Example:
tail -n 10 file.txt # Show last 10 lines of file.txt
tail -f logfile.log # Follow logfile.log in real-time
find
- Search for files or directories
- Example:
find /home -name "*.txt" # Find all .txt files in /home
grep
- Search text using patterns
- Example:
grep "error" logfile.log # Search for "error" in logfile.log
tar
- Archive files
- Example:
tar -cvf archive.tar folder # Create archive.tar from folder
tar -xvf archive.tar # Extract archive.tar
zip
/unzip
- Compress and extract files
- Example:
zip archive.zip file.txt # Compress file.txt into archive.zip
unzip archive.zip # Extract archive.zip
chmod
- Change file permissions
- Example:
chmod 755 script.sh # Set permissions to rwxr-xr-x
chown
- Change file ownership
- Example:
chown user:group file.txt # Change owner and group of file.txt
ps
- Display running processes
- Example:
ps aux # Show all running processes
top
- Display real-time system stats
- Example:
top # Show live system stats
htop
- Interactive process viewer (requires installation)
- Example:
htop # Interactive system monitoring
kill
- Terminate a process
- Example:
kill 1234 # Terminate process with PID 1234
kill -9 1234 # Forcefully terminate process
df
- Display disk space usage
- Example:
df -h # Show disk usage in human-readable format
du
- Display directory space usage
- Example:
du -sh /home # Show total size of /home
free
- Display memory usage
- Example:
free -h # Show memory usage in human-readable format
uname
- Display system information
- Example:
uname -a # Show all system information
uptime
- Show system uptime
- Example:
uptime # Display how long the system has been running
shutdown
- Shutdown or restart the system
- Example:
shutdown now # Shutdown immediately
shutdown -r now # Restart immediately
ping
- Test network connectivity
- Example:
ping google.com # Ping Google
ifconfig
- Configure or display network interfaces
- Example:
ifconfig # Show network interfaces
ip
- Advanced network configuration
- Example:
ip addr show # Display IP addresses
netstat
- Display network connections
- Example:
netstat -tuln # Show listening ports
ssh
- Connect to a remote server
- Example:
ssh user@192.168.1.1 # SSH into a remote server
scp
- Securely copy files between hosts
- Example:
scp file.txt user@192.168.1.1:/home # Copy file.txt to remote server
wget
- Download files from the web
- Example:
wget https://example.com/file.zip # Download file.zip
curl
- Transfer data from or to a server
- Example:
curl -O https://example.com/file.zip # Download file.zip
nslookup
- Query DNS records
- Example:
nslookup google.com # Lookup DNS for google.com
dig
- DNS lookup utility
- Example:
dig google.com # Query DNS information for google.com
useradd
- Add a new user
- Example:
useradd john # Create a new user named john
passwd
- Change user password
- Example:
passwd john # Set password for user john
usermod
- Modify user account
- Example:
usermod -aG sudo john # Add john to sudo group
userdel
- Delete a user
- Example:
userdel john # Delete user john
groupadd
- Add a new group
- Example:
groupadd developers # Create a new group named developers
groupdel
- Delete a group
- Example:
groupdel developers # Delete group developers
su
- Switch user
- Example:
su john # Switch to user john
sudo
- Execute commands as superuser
- Example:
sudo apt update # Run apt update as superuser
apt
- Package manager for Debian-based systems
- Example:
sudo apt update # Update package list
sudo apt install nginx # Install nginx
yum
- Package manager for RHEL-based systems
- Example:
sudo yum install httpd # Install Apache on RHEL
dnf
- Modern package manager for Fedora
- Example:
sudo dnf install nginx # Install nginx on Fedora
pacman
- Package manager for Arch Linux
- Example:
sudo pacman -S nginx # Install nginx on Arch
echo
- Display a line of text
- Example:
echo "Hello, World!" # Print "Hello, World!"
date
- Display or set the system date and time
- Example:
date # Show current date and time
history
- Display command history
- Example:
history # Show command history
man
- Display manual pages
- Example:
man ls # Show manual for ls command
alias
- Create command shortcuts
- Example:
alias ll='ls -la' # Create alias for ls -la
cron
- Schedule tasks
- Example:
crontab -e # Edit cron jobs
ln
- Create links between files
- Example:
ln -s /path/to/file link_name # Create symbolic link
diff
- Compare files line by line
- Example:
diff file1.txt file2.txt # Compare two files
This list covers most of the essential Linux commands.