Open In App

Basic Shell Commands in Linux: Complete List

Last Updated : 08 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Anyone using Linux should become an expert in the essential shell commands, as they form the backbone of working with the Linux terminal. These commands enable you to navigate the system, manage files, handle processes, and configure settings effectively.

The Linux shell serves as an interface for users to interact with the operating system. Mastering its commands can greatly enhance your efficiency, whether you’re a system administrator or a developer. In this guide, we’ll introduce some of the most fundamental Linux commands, covering file management, system monitoring, and command syntax, along with practical examples. By the end, you’ll have the knowledge needed to perform everyday tasks confidently in the Linux command-line environment.

Basic-Shell-Commands-in-Linux_-Complete-List
Basic Shell Commands in Linux

What are Shell Commands in Linux?

A shell in Linux is a program that serves as an interface between the user and the operating system. It accepts commands from the user, interprets them, and passes them to the operating system for execution. The commands can be used for a wide range of tasks, from file manipulation to system management.

Some of the essential basic shell commands in Linux for different operations are:

  • File Management -> cp, mv, rm, mkdir
  • Navigation -> cd, pwd, ls
  • Text Processing -> cat, grep, sort, head
  • System Monitoring -> top, ps, df
  • Permissions and Ownership -> chmod, chown, chgrp
  • Networking - > ping, wget, curl, ssh, scp, ftp
  • Compression and Archiving - > tar, gzip, gunzip, zip, unzip
  • Package Management - > dnf, yum, apt-get
  • Process Management -> kill, killall, bg, killall, kill

Basic Shell Commands for File and Directory Management

CommandDescriptionExample
lsLists files and directoriesls
cdChanges the current directorycd /home/user/Documents
pwdDisplays the current directory pathpwd
mkdirCreates a new directorymkdir new_directory
rmRemoves files or directoriesrm file.txt
cpCopies files or directoriescp file1.txt file2.txt
mvMoves or renames files and directoriesmv old_name new_name
touchCreates an empty file or updates file timestampstouch newfile.txt

Examples:

1. List files in a directory:

ls

2. Change directory:

cd/home/user

3. Create a new directory:

mkdir new_directory

4. Copy a file from one location to another:

cp source.txt destination.txt

5. Remove a file:

rm file.txt

Text Processing Commands in Linux

CommandDescriptionExample
catDisplays the contents of a filecat file.txt
grepSearches for a pattern in a filegrep "error" log.txt
sortSorts the contents of a filesort file.txt
headDisplays the first few lines of a filehead file.txt
tailDisplays the last few lines of a filetail file.txt
wcCounts the lines, words, and characters in a filewc file.txt

Examples:

1. Display the contents of a file:

cat file.txt

2. Search for a pattern in a file:

grep "error" file.txt

3. Sort the contents of a file:

sort file.txt

4. Display the first 10 lines of a file:

head file.txt

5. Display the last 10 lines of a file:

tail file.txt

File Permissions and Ownership Commands

CommandDescriptionExample
chmodChanges file permissionschmod 755 file.txt
chownChanges file owner and groupchown user:group file.txt
chgrpChanges file group ownershipchgrp group file.txt

Examples:

1. Change permissions of a file:

chmod 755 file.txt

2. Change the owner of a file:

chown user:group file.txt

System Monitoring and Process Management Commands

CommandDescriptionExample
topDisplays real-time system information (CPU, memory)top
psDisplays the list of running processesps aux
killTerminates a process by its IDkill 1234
dfDisplays disk space usagedf -h

Examples:

1. View running processes:

ps aux

2. Display real-time system statistics:

top

3. Kill a process by its ID:

kill 1234

4. Check disk space usage:

df -h

Networking Shell Commands

CommandDescriptionExample
pingChecks the network connection to a serverping example.com
wgetRetrieves files from the webwget http://example.com/file.zip
curlTransfers data from or to a servercurl http://example.com
sshOpens SSH client (remote login program)ssh [email protected]
scpSecurely copies files between hostsscp file.txt [email protected]:/path/
ftpTransfers files using the File Transfer Protocolftp ftp.example.com

Examples

1. Check the network connection to a server:

  • Command: ping
  • Example: ping example.com

2. Retrieve files from the web:

  • Command: wget
  • Example: wget http://example.com/file.zip

3. Transfer data from or to a server:

  • Command: curl
  • Example: curl http://example.com

4. Open SSH client (remote login program):

5. Securely copy files between hosts:

6. Transfer files using the File Transfer Protocol:

  • Command: ftp
  • Example: ftp ftp.example.com

Advanced Shell Commands

CommandDescriptionExample
findSearches for files and directoriesfind /home/user -name "*.txt"
tarArchives files into a tarball (.tar) or extracts themtar -cvf archive.tar file1.txt file2.txt
sshConnects to a remote machine via SSHssh user@remote_host

Examples:

1. Find files in a directory:

find /home/user -name "*.txt"

2. Create a tarball archive:

tar -cvf archive.tar file1.txt file2.txt

3. Connect to a remote machine using SSH:

ssh user@remote_host

Using Shell Command Piping

You can combine multiple commands by piping their output. In short, it allows the output of one command to be used as the input for another command.

Examples:

1. View the top 10 processes:

ps aux | head -n 10

2. Search and sort a log file:

grep "error" log.txt | sort

Conclusion

Mastering the basic shell commands in Linuxis among the essential things to know so that you can perform a seamless system navigation, learn how to manage files efficiently, and perform other operations. By learning these commands, you can easily enhance your Linux skills and get a better insight over the system.


Next Article

Similar Reads