January 19, 2025

50+ Essential Linux Useful Commands List

January 19, 2025

50+ Essential Linux Useful Commands List

Master over 50 crucial Linux commands with detailed explanations, syntax, and practical examples. From basic file operations to advanced system administration, this comprehensive guide covers everything you need to know about Linux command-line operations.

Introduction

Today, I will provide you all useful linux command list. Linux commands are the foundation of efficient system administration and server management. This comprehensive guide covers more than 50 essential Linux commands that every system administrator, developer, and power user should know. 

From basic file operations to advanced system management, each command is explained with its syntax and practical examples.

Essential Linux Commands

Linux useful commands

pwd (Print Working Directory)​

Use: Displays current working directory path
Syntax: pwd
Example:

$ pwd
/home/user/documents

ls (List Directory Contents)

Use: Lists files and directories
Syntax: ls [options] [directory]
Example:

$ ls -la  # List all files with details
$ ls -lh  # List with human-readable sizes
$ ls -R   # List recursively

cd (Change Directory)

Use: Changes current directory
Syntax: cd [directory]
Example:

$ cd ~     # Go to home
$ cd ..    # Go up one level
$ cd -     # Go to previous directory

tree

Use: Displays directory structure
Syntax: tree [options] [directory]
Example:

$ tree -L 2  # Show 2 levels deep

cp (Copy)

Use: Copies files and directories
Syntax: cp [options] source destination
Example:

$ cp -r dir1 dir2  # Copy directory
$ cp -p file1 file2  # Preserve attributes

mv (Move)

Use: Moves/renames files
Syntax: mv [options] source destination
Examples:

$ mv file1 file2  # Rename file
$ mv -i * ../     # Move all files with prompt

rm (Remove)

Use: Removes files/directories
Syntax: rm [options] file(s)
Examples:

$ rm -rf dir/     # Force remove directory
$ rm -i file.txt  # Remove with prompt

mkdir (Make Directory)

Use: Creates directories
Syntax: mkdir [options] directory
Examples:

$ mkdir -p dir1/dir2  # Create parent directories
$ mkdir -m 755 dir    # Create with permissions

touch

Use: Creates empty files/updates timestamps
Syntax: touch [options] file(s)
Examples:

$ touch file.txt
$ touch -t 202401191200 file  # Set specific time

cat (Concatenate)

Use: Displays/combines file content
Syntax
: cat [options] file(s)
Examples:

$ cat file.txt
$ cat file1 file2 > file3

less

Use: Views file content page by page
Syntax: less [options] file
Example:

$ less -N file.txt  # Show line numbers
$ less /etc/updatedb.conf # Open a Text File
$ less -pERROR /etc/init/mysql.conf # Open File with Pattern Search
$ less -s welcome.txt # Remove Multiple Blank Lines
$ less welcome.txt aboutus.txt # Open Multiple Files
$ less +F /var/log/syslog # Real-Time Monitoring

head

Use: Shows first lines of file
Syntax: head [options] file
Example:

$ head -n 20 file.txt  # Show first 20 lines

tail

Use: Shows last lines of file
Syntax: tail [options] file
Examples:

$ tail -f log.txt  # Follow file updates
$ tail -n 50 file  # Last 50 lines

grep (Global Regular Expression Print)

Use: Searches text patterns
Syntax: grep [options] pattern [file(s)]
Examples:

$ grep -i "error" *.log  # Case-insensitive
$ grep -r "TODO" ./      # Recursive search

sed (Stream Editor)

Use: Text stream manipulation
Syntax: sed [options] 'command' file
Examples:

$ sed 's/old/new/g' file.txt
$ sed -i '1d' file.txt  # Delete first line

awk

Use: Text processing tool
Syntax: awk [options] 'pattern {action}' file
Example:

$ awk '{print $1}' file.txt  # Print first column

tar

Use: Archives files
Syntax: tar [options] archive files
Examples:

$ tar -cvzf archive.tar.gz files/ # Create tar.gz file
$ tar -xvzf archive.tar.gz # Extract tar file

gzip

Use: Compresses files
Syntax: gzip [options] file(s)
Example:

$ gzip file.txt

zip/unzip

Use: Creates/extracts ZIP archives
Syntax: zip [options] zipfile files
Examples:

$ zip -r archive.zip directory/
$ unzip archive.zip

uname

Use: Shows system information
Syntax: uname [options]
Example:

$ uname -a  # All system info

top

Use: Shows running processes
Syntax: top [options]
Example:

$ top 
$ top -u username  # User specific processes

htop

Use: Interactive process viewer
Syntax: htop [options]
Example:

$ htop 
$ htop --sort-key PERCENT_CPU

ps (Process Status)

Use: Shows process information
Syntax: ps [options]
Examples:

$ ps aux  # All processes
$ ps -ef  # Full process info

df (Disk Free)

Use: Shows disk space usage
Syntax: df [options]
Example:

$ df -h  # Human readable sizes

du (Disk Usage)

Use: Shows file space usage
Syntax: du [options] [file(s)]
Example:

$ du -sh */  # Directory sizes

26. free

Use: Shows memory usage
Syntax: free [options]
Example:

$ free -h  # Human readable

useradd

Use: Creates new user
Syntax: useradd [options] username
Example:

$ sudo useradd -m -s /bin/bash username

sudo (Superuser Do)

Use: Executes as superuser
Syntax: sudo command
Example:

$ sudo apt-get install phpmyadmin # Install PHPMyAdmin
$ sudo service apache2 restart # Restart Apache2 Server
$ sudo service apache2 start # Start Apache2 Server
$ sudo service apache2 stop # Stop Apache2 Server
$ sudo service apache2 status # Check Apache2 Status

passwd

Use: Changes password
Syntax: passwd [options] [username]
Example:

$ sudo passwd username

chown (Change Owner)

Use: Changes file ownership
Syntax: chown [options] owner:group file(s)
Example:

$ sudo chown user:group file.txt

chmod (Change Mode)

Use: Changes file permissions
Syntax: chmod [options] mode file(s)
Examples:

$ chmod 755 script.sh
$ chmod +x file.sh

ping

Use: Tests network connectivity
Syntax: ping [options] host
Example:

$ ping -c 4 google.com

netstat

Use: Shows network statistics
Syntax: netstat [options]
Example:

$ netstat -tuln  # Active listening ports

ss (Socket Statistics)

Use: Investigates sockets
Syntax: ss [options]
Example:

$ ss -ltn  # Listening TCP sockets

curl

Use: Transfers data from/to servers
Syntax: curl [options] URL
Example:

$ curl -O https://example.com/file

wget

Use: Downloads files from web
Syntax: wget [options] URL
Example:

$ wget -c https://example.com/file

ifconfig/ip

Use: Configures network interface
Syntax: ip [options] object command
Examples:

$ ip addr show
$ ifconfig eth0

ssh (Secure Shell)

Use: Remote system access
Syntax: ssh [options] user@host
Example:

$ ssh -p 2222 user@server.com

scp (Secure Copy)

Use: Copies files over SSH
Syntax: scp [options] source destination
Example:

$ scp file.txt user@server:/path

kill

Use: Terminates processes
Syntax: kill [options] PID
Example:

$ kill -9 1234  # Force kill

pkill

Use: Kills processes by name
Syntax: pkill [options] pattern
Example:

$ pkill -f firefox

killall

Use: Kills processes by name
Syntax: killall [options] name
Example:

$ killall -9 process_name

nice

Use: Sets process priority
Syntax: nice [options] command
Example:

$ nice -n 10 command

nohup

Use: Runs command immune to hangups
Syntax: nohup command &
Example:

$ nohup ./script.sh &

apt (Advanced Package Tool)

Use: Debian package management
Syntax: apt [options] command
Examples:

$ sudo apt update # Update package list
$ sudo apt upgrade # Upgrade installed packages
$ sudo apt autoremove # Remove unnecessary packages

dpkg

Use: Debian package manager
Syntax
: dpkg [options] action
Example:

$ dpkg -i package.deb

yum/dnf

Use: RPM package management
Syntax: yum [options] command
Example:

$ sudo yum install package

snap

Use: Universal Linux packages
Syntax: snap [options] command
Example:

$ sudo snap --version # Check snap version
$ sudo snap list # List installed snaps
$ sudo snap find "media player" # To search for snaps with ‘media player’ in either their names or descriptions, type snap find "media player" into your terminal:
$ sudo snap install <package_name> # Install snap >> See above examples
$ sudo snap install skype # Install Skype
$ sudo snap refresh # Update all snap packages
$ sudo snap refresh <package_name> # Update specific snap package 
$ sudo snap remove <package_name> # Remove a snap

systemctl

Use: Controls systemd services
Syntax: systemctl [options] command service
Examples:

$ sudo systemctl start service
$ sudo systemctl stop service
$ sudo systemctl restart service
$ sudo systemctl enable service
$ sudo systemctl disable service

journalctl

Use: Query systemd journal
Syntax: journalctl [options]
Example:

$ journalctl -u service -f

crontab

Use: Schedules tasks
Syntax: crontab [options]
Example:

$ crontab -e  # Edit cron jobs

at

Use: Schedules one-time task
Syntax: at time
Example:

$ at now + 1 hour

Conclusion

This comprehensive list of 50+ Linux commands covers the most essential tools for system administration and daily operations. While these commands form a solid foundation, Linux offers many more specialized commands and options.

To become proficient:

  1. Practice these commands regularly
  2. Read man pages for detailed information
  3. Combine commands to create powerful operations
  4. Stay updated with new tools and features

Remember that mastering these commands takes time and practice. Start with the basic commands and gradually incorporate more advanced ones into your workflow. Use the man pages (man command) and help options (command --help) to learn more about specific commands and their options.

For system administrators, it’s crucial to understand not just how to use these commands, but also their implications on system security and performance. Always test commands in a safe environment before using them on production systems.

Keep this guide as a reference, and continue exploring the vast capabilities of Linux command-line operations. Happy system administration!

Thank you for reading this article. Happy system administration!

Share on:
Share on:
LinkedIn
Email
Facebook
Reddit
Twitter
WhatsApp
Skype
Print

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

Recent posts

LogicRays Blogs

Read other latest blogs on technology, trending, Web & Mobile App, E-Commerce related etc.
We recommend
Featured posts

Table of Contents