Top 75 Linux Commands Every Regular User Must Know
As a regular Linux user, mastering these essential commands can greatly enhance your productivity and efficiency. Let's dive into the top 75 Linux commands with practical examples.
-
ls (List)
-
ls
- List files and directories in the current directory. -
ls -a
- List all files, including hidden ones. -
ls -l
- List files with detailed information (permissions, owner, size, etc.). -
ls -h
- List files with detailed information in human readable format.
-
-
pwd (Print Working Directory)
-
pwd
- Display the current working directory.
-
-
cd (Change Directory)
-
cd /path/to/directory
- Navigate to the specified directory. -
cd ..
- Move up one directory level. -
cd ~
- Navigate to your home directory. -
cd -
- Go back to the last directory.
-
-
mkdir (Make Directory)
-
mkdir new_directory
- Create a new directory. -
mkdir -p /path/to/nested/directories
- Create nested directories.
-
-
touch (Create File)
-
touch new_file.txt
- Create a new, empty file.
-
-
mv (Move)
-
mv file.txt /path/to/directory
- Move a file to a different directory. -
mv old_name.txt new_name.txt
- Rename a file.
-
-
cp (Copy)
-
cp file.txt /path/to/directory
- Copy a file to a different directory. -
cp -r directory1 /path/to/directory2
- Copy a directory and its contents.
-
-
rm (Remove)
-
rm file.txt
- Delete a file. -
rm -r directory
- Delete a directory and its contents (use with caution!).
-
-
cat (Concatenate)
-
cat file.txt
- Display the contents of a file. -
cat file1.txt file2.txt > combined.txt
- Combine two files into one.
-
-
echo (Print)
-
echo "Hello, World!"
- Print a string. -
echo $PATH
- Print the value of an environment variable.
-
-
clear
-
clear
- Clear the terminal screen.
-
-
man (Manual)
-
man ls
- Display the manual page for thels
command.
-
-
uname (System Information)
-
uname -a
- Display detailed information about the system.
-
-
whoami (User Information)
-
whoami
- Print the current user's username.
-
-
head (Show Top Lines)
-
head -n 10 file.txt
- Display the first 10 lines of a file.
-
-
tail (Show Bottom Lines)
-
tail -n 20 log.txt
- Display the last 20 lines of a file.
-
-
diff (Compare Files)
-
diff file1.txt file2.txt
- Compare the contents of two files.
-
-
cmp (Compare Files)
-
cmp file1.txt file2.txt
- Check if two files are identical byte-by-byte.
-
-
comm (Compare Files)
-
comm -13 file1.txt file2.txt
- Show lines unique to each file and common lines.
-
-
sort (Sort)
-
sort file.txt
- Sort the lines of a file in alphabetical order. -
sort -n file.txt
- Sort the lines of a file numerically.
-
-
tar (Archive)
-
tar -czf archive.tar.gz directory
- Create a compressed tar archive of a directory. -
tar -xzf archive.tar.gz
- Extract files from a compressed tar archive.
-
-
grep (Search)
-
grep "pattern" file.txt
- Search for a pattern in a file. -
ps aux | grep process_name
- Find processes containing a specific name.
-
-
ln (Create Link)
-
ln -s /path/to/file link_name
- Create a symbolic link to a file.
-
-
export (Set Environment Variables)
-
export PATH=$PATH:/new/path
- Add a new path to thePATH
environment variable.
-
-
zip (Compress Files)
-
zip archive.zip file1.txt file2.txt
- Create a ZIP archive with multiple files.
-
-
unzip (Extract Files)
-
unzip archive.zip
- Extract files from a ZIP archive.
-
-
ssh (Secure Shell)
-
ssh user@remote_host
- Connect to a remote system via SSH.
-
-
service (Manage Services)
-
service apache2 start
- Start the Apache web server service. -
service mysql status
- Check the status of the MySQL service.
-
-
ps (Process Status)
-
ps aux
- Display detailed information about running processes.
-
-
kill and killall (Terminate Processes)
-
kill 1234
- Terminate a process with the specified PID (1234). -
killall process_name
- Terminate all processes with a specific name.
-
-
df (Disk Usage)
-
df -h
- Display disk usage in a human-readable format.
-
-
mount (Mount File Systems)
-
mount /dev/sdb1 /mnt/usb
- Mount a USB drive to the/mnt/usb
directory.
-
-
chmod (Change Permissions)
-
chmod 755 file.sh
- Grant read, write, and execute permissions to the owner, and read and execute permissions to group and others.
-
-
chown (Change Ownership)
-
chown user:group file.txt
- Change the owner and group of a file.
-
-
ifconfig (Network Configuration)
-
ifconfig
- Display information about network interfaces and IP addresses.
-
-
traceroute (Trace Network Route)
-
traceroute example.com
- Trace the network path to a remote host.
-
-
wget (Web Get)
-
wget https://example.com/file.zip
- Download a file from a web server.
-
-
ufw (Uncomplicated Firewall)
-
ufw enable
- Enable the firewall. -
ufw allow 22
- Allow incoming connections on port 22 (SSH).
-
-
iptables (Firewall)
-
iptables -L
- List current firewall rules. -
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
- Allow incoming TCP connections on port 80 (HTTP).
-
-
apt, pacman, yum, rpm (Package Managers)
-
apt update && apt upgrade
(Ubuntu/Debian) - Update package lists and upgrade installed packages. -
pacman -Syu
(Arch Linux) - Synchronize package databases and upgrade installed packages. -
yum update
(CentOS/RHEL) - Update installed packages. -
rpm -ivh package.rpm
- Install an RPM package.
-
-
sudo (Escalate Privileges)
-
sudo command
- Run a command with superuser (root) privileges.
-
-
cal (Calendar)
-
cal
- Display the current month's calendar. -
cal 2024
- Display the entire year's calendar for 2024.
-
-
alias (Create Command Shortcuts)
-
alias ll='ls -l'
- Create an alias for thels -l
command.
-
-
dd (Data Duplicator)
-
dd if=/dev/zero of=/path/to/file bs=1M count=1024
- Create a 1GB file filled with zeros. -
dd if=/path/to/iso of=/dev/sdx
- Write an ISO image to a USB drive.
-
-
whereis (Locate Command)
-
whereis ls
- Find the binary, source, and manual page files for thels
command.
-
-
whatis (Command Description)
-
whatis ls
- Display a brief description of thels
command.
-
-
top (Process Monitor)
-
top
- Display real-time information about running processes and system resource usage.
-
-
useradd and usermod (User Management)
-
useradd new_user
- Create a new user account. -
usermod -aG sudo new_user
- Add an existing user to the sudo group.
-
-
passwd (Change Password)
-
passwd
- Change the password for the current user. -
passwd user_name
(as root) - Change the password for a specific user.
-
-
curl (Transfer Data)
-
curl https://example.com
- Fetch the contents of a URL. -
curl ifconfig.me
- Display your public IP address.
-
-
ping (Test Network Connectivity)
-
ping google.com
- Test connectivity to a remote host. -
ping -c 2 google.com
- Send 2 ping packets and stop.
-
netstat (Network Statistics)
netstat -tunlp
- Display listening network ports and associated processes.
-
rsync (Remote Sync)
-
rsync -avz /path/to/source /path/to/destination
- Sync files between directories locally or remotely.
-
-
scp (Secure Copy)
-
scp file.txt user@remote_host:/path/to/destination
- Copy files between hosts on a network.
-
-
find (Find Files)
-
find /path -name filename
- Search for files in a directory hierarchy.
-
-
locate (Locate Files)
-
locate filename
- Find the location of a file quickly.
-
-
chmod (Change File Permissions)
-
chmod 755 file.sh
- Change the permission of a file or directory.
-
-
chown (Change File Owner)
-
chown user:group file.txt
- Change the owner and group of a file.
-
-
su (Switch User)
-
su -
- Switch to the root user. -
su - username
- Switch to another user.
-
-
usermod (Modify User)
-
usermod -aG groupname username
- Add a user to a group.
-
-
groupadd (Add Group)
-
groupadd groupname
- Create a new group.
-
-
groups (List Groups)
-
groups username
- Display groups for a user.
-
-
last (Last Logins)
-
last
- Show a listing of last logged in users.
-
-
hostname (Show or Set Hostname)
-
hostname
- Show the system's hostname. -
hostname new_hostname
- Set the system's hostname.
-
-
history (Command History)
-
history
- Display the command history. -
!n
- Execute command number n from history.
-
-
crontab (Cron Jobs)
-
crontab -e
- Edit the cron jobs. -
crontab -l
- List the cron jobs.
-
-
bg (Background Jobs)
-
bg
- Resume a suspended job in the background.
-
-
fg (Foreground Jobs)
-
fg
- Bring a background job to the foreground.
-
-
jobs (List Jobs)
-
jobs
- List all jobs.
-
-
at (Schedule Tasks)
-
at 10:00
- Schedule a command to run at 10:00 AM. -
atq
- List the pending jobs of users.
-
-
basename (File Name)
-
basename /path/to/file
- Display file name without the directory path.
-
-
dirname (Directory Name)
-
dirname /path/to/file
- Display the directory path of a file.
-
-
file (File Type)
-
file filename
- Determine the file type.
-
-
watch (Execute/Watch Command)
-
watch -n 5 df -h
- Execute a program periodically, showing output fullscreen.
-
-
shutdown (Shutdown System)
-
shutdown -h now
- Shutdown the system immediately. -
shutdown -r now
- Reboot the system immediately.
-
With these 75 essential Linux commands under your belt, you'll be well-equipped to navigate the command line, manage files and processes, customize your system, and supercharge your productivity on the Linux operating system.
Happy Coding!!
Top comments (0)