Skip to content

Files

Latest commit

6f5a971 · Jan 7, 2025

History

History
519 lines (326 loc) · 7.45 KB

File metadata and controls

519 lines (326 loc) · 7.45 KB

Comprehensive-list-of-Linux-commands

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.


File and Directory Operations

  1. ls - List directory contents
  • Example:
ls -l /home  # List files in /home with details
  1. cd - Change directory
  • Example:
cd /var/log  # Move to /var/log directory
  1. pwd - Print working directory
  • Example:
pwd  # Show current directory path
  1. mkdir - Create a directory
  • Example:
mkdir new_folder  # Create a directory named new_folder
  1. rmdir - Remove an empty directory
  • Example:
rmdir empty_folder  # Remove empty_folder
  1. rm - Remove files or directories
  • Example:
rm file.txt  # Delete file.txt
rm -r folder  # Recursively delete folder and its contents
  1. cp - Copy files or directories
  • Example:
cp file.txt /backup  # Copy file.txt to /backup
cp -r folder /backup  # Copy folder recursively
  1. 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
  1. touch - Create an empty file or update file timestamp
  • Example:
touch newfile.txt  # Create newfile.txt
  1. cat - Display file content
  • Example:
cat file.txt  # Show content of file.txt
  1. more - View file content page by page
  • Example:
more largefile.txt  # View largefile.txt page by page
  1. less - View file content with backward navigation
  • Example:
less largefile.txt  # View file with backward navigation
  1. head - Display the first part of a file
  • Example:
head -n 10 file.txt  # Show first 10 lines of file.txt
  1. 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
  1. find - Search for files or directories
  • Example:
find /home -name "*.txt"  # Find all .txt files in /home
  1. grep - Search text using patterns
  • Example:
grep "error" logfile.log  # Search for "error" in logfile.log
  1. tar - Archive files
  • Example:
tar -cvf archive.tar folder  # Create archive.tar from folder
tar -xvf archive.tar  # Extract archive.tar
  1. zip / unzip - Compress and extract files
  • Example:
zip archive.zip file.txt  # Compress file.txt into archive.zip
unzip archive.zip  # Extract archive.zip
  1. chmod - Change file permissions
  • Example:
chmod 755 script.sh  # Set permissions to rwxr-xr-x
  1. chown - Change file ownership
  • Example:
chown user:group file.txt  # Change owner and group of file.txt

System Monitoring and Management

  1. ps - Display running processes
  • Example:
ps aux  # Show all running processes
  1. top - Display real-time system stats
  • Example:
top  # Show live system stats
  1. htop - Interactive process viewer (requires installation)
  • Example:
htop  # Interactive system monitoring
  1. kill - Terminate a process
  • Example:
kill 1234  # Terminate process with PID 1234
kill -9 1234  # Forcefully terminate process
  1. df - Display disk space usage
  • Example:
df -h  # Show disk usage in human-readable format
  1. du - Display directory space usage
  • Example:
du -sh /home  # Show total size of /home
  1. free - Display memory usage
  • Example:
free -h  # Show memory usage in human-readable format
  1. uname - Display system information
  • Example:
uname -a  # Show all system information
  1. uptime - Show system uptime
  • Example:
uptime  # Display how long the system has been running
  1. shutdown - Shutdown or restart the system
  • Example:
shutdown now  # Shutdown immediately
shutdown -r now  # Restart immediately

Networking

  1. ping - Test network connectivity
  • Example:
ping google.com  # Ping Google
  1. ifconfig - Configure or display network interfaces
  • Example:
ifconfig  # Show network interfaces
  1. ip - Advanced network configuration
  • Example:
ip addr show  # Display IP addresses
  1. netstat - Display network connections
  • Example:
netstat -tuln  # Show listening ports
  1. ssh - Connect to a remote server
  • Example:
ssh user@192.168.1.1  # SSH into a remote server
  1. scp - Securely copy files between hosts
  • Example:
scp file.txt user@192.168.1.1:/home  # Copy file.txt to remote server
  1. wget - Download files from the web
  • Example:
wget https://example.com/file.zip  # Download file.zip
  1. curl - Transfer data from or to a server
  • Example:
curl -O https://example.com/file.zip  # Download file.zip
  1. nslookup - Query DNS records
  • Example:
nslookup google.com  # Lookup DNS for google.com
  1. dig - DNS lookup utility
  • Example:
dig google.com  # Query DNS information for google.com

User and Permission Management

  1. useradd - Add a new user
  • Example:
useradd john  # Create a new user named john
  1. passwd - Change user password
  • Example:
passwd john  # Set password for user john
  1. usermod - Modify user account
  • Example:
usermod -aG sudo john  # Add john to sudo group
  1. userdel - Delete a user
  • Example:
userdel john  # Delete user john
  1. groupadd - Add a new group
  • Example:
groupadd developers  # Create a new group named developers
  1. groupdel - Delete a group
  • Example:
groupdel developers  # Delete group developers
  1. su - Switch user
  • Example:
su john  # Switch to user john
  1. sudo - Execute commands as superuser
  • Example:
sudo apt update  # Run apt update as superuser

Package Management

  1. apt - Package manager for Debian-based systems
  • Example:
sudo apt update  # Update package list
sudo apt install nginx  # Install nginx
  1. yum - Package manager for RHEL-based systems
  • Example:
sudo yum install httpd  # Install Apache on RHEL
  1. dnf - Modern package manager for Fedora
  • Example:
sudo dnf install nginx  # Install nginx on Fedora
  1. pacman - Package manager for Arch Linux
  • Example:
sudo pacman -S nginx  # Install nginx on Arch

Miscellaneous

  1. echo - Display a line of text
  • Example:
echo "Hello, World!"  # Print "Hello, World!"
  1. date - Display or set the system date and time
  • Example:
date  # Show current date and time
  1. history - Display command history
  • Example:
history  # Show command history
  1. man - Display manual pages
  • Example:
man ls  # Show manual for ls command
  1. alias - Create command shortcuts
  • Example:
alias ll='ls -la'  # Create alias for ls -la
  1. cron - Schedule tasks
  • Example:
crontab -e  # Edit cron jobs
  1. ln - Create links between files
  • Example:
ln -s /path/to/file link_name  # Create symbolic link
  1. diff - Compare files line by line
  • Example:
diff file1.txt file2.txt  # Compare two files

This list covers most of the essential Linux commands.