Common Linux Commands
Here is a list of 50 commonly used Linux commands along with brief descriptions and example usages:
pwd (Print Working Directory):
Displays the current working directory.
Example:
pwd
ls (List Directory Contents):
Lists files and directories in the current directory.
Example:
ls
cd (Change Directory):
Changes the current directory.
Example:
cd /path/to/directory
touch (Create Empty File):
Creates an empty file.
Example:
touch filename.txt
mkdir (Make Directory):
Creates a new directory.
Example:
mkdir new_directory
rm (Remove):
Removes files and directories.
Example:
rm filename.txt
orrm -r directory
cp (Copy):
Copies files and directories.
Example:
cp file.txt newfile.txt
orcp -r dir1 dir2
mv (Move/Rename):
Moves or renames files and directories.
Example:
mv file.txt new_directory/
ormv oldname.txt newname.txt
cat (Concatenate and Display):
Displays the content of a file.
Example:
cat file.txt
more/less (View Text File):
Displays the content of a text file page by page.
Example:
more file.txt
orless file.txt
head (Display Beginning of a File):
Shows the first few lines of a file.
Example:
head -n 10 file.txt
(displays the first 10 lines)
tail (Display End of a File):
Shows the last few lines of a file.
Example:
tail -n 10 file.txt
(displays the last 10 lines)
grep (Global Regular Expression Print):
Searches for text patterns in files.
Example:
grep "pattern" file.txt
find (Find Files and Directories):
Searches for files and directories in a directory hierarchy.
Example:
find /path/to/search -name "*.txt"
chmod (Change File Permissions):
Modifies file permissions.
Example:
chmod 644 file.txt
(sets read and write for owner, read for group and others)
chown (Change File Owner):
Changes the owner of a file.
Example:
chown user:group file.txt
ps (Process Status):
Displays information about running processes.
Example:
ps aux
top (Monitor System Activity):
Provides real-time system resource usage statistics.
Example:
top
kill (Terminate a Process):
Terminates a running process by process ID.
Example:
kill PID
tar (Tape Archive):
Archives and extracts files.
Example:
tar -cvf archive.tar files/
(create archive),tar -xvf archive.tar
(extract archive)
df (Disk Free):
Displays disk space usage.
Example:
df -h
du (Disk Usage):
Shows disk usage of files and directories.
Example:
du -sh /path/to/directory
free (Memory Usage):
Displays system memory usage.
Example:
free -h
ifconfig (Network Configuration):
Displays and configures network interfaces.
Example:
ifconfig
ping (Network Ping):
Tests network connectivity to a host.
Example:
ping google.com
ssh (Secure Shell):
Connects to remote servers securely.
Example:
ssh user@hostname
scp (Secure Copy):
Copies files securely between hosts.
Example:
scp file.txt user@hostname:/path/
wget (Web Get):
Downloads files from the internet.
Example:
wget URL
curl (Client for URLs):
Transfers data from or to a server.
Example:
curl URL
nano (Text Editor):
Opens a terminal-based text editor.
Example:
nano filename.txt
vim (Text Editor):
Opens the Vim text editor.
Example:
vim filename.txt
grep (Global Regular Expression Print):
Searches for text patterns in files.
Example:
grep "pattern" file.txt
sort (Sort Lines of Text):
Sorts lines of text files.
Example:
sort file.txt
uniq (Unique Lines):
Filters out duplicate lines in a sorted file.
Example:
sort file.txt | uniq
sed (Stream Editor):
Performs text transformations on an input stream.
Example:
sed 's/old/new/' file.txt
awk (Text Processing Tool):
Processes text data and generates reports.
Example:
awk '{print $1}' file.txt
date (Display or Set Date and Time):
Displays or sets the system date and time.
Example:
date
cal (Display Calendar):
Displays a calendar.
Example:
cal
shutdown (Shutdown/Reboot System):
Shuts down or reboots the system.
Example:
shutdown -h now
(shut down immediately)
useradd (Add User):
Adds a new user to the system.
Example:
sudo useradd newuser
passwd (Change Password):
Changes a user's password.
Example:
passwd username
groups (List Groups):
Lists groups a user belongs to.
Example:
groups username
who (Show Who is Logged On):
Displays information about users currently logged in.
Example:
who
uptime (System Uptime):
Shows how long the system has been running.
Example:
uptime
hostname (Display or Set Hostname):
Displays or sets the system's hostname.
Example:
hostname
history (Command History):
Shows the command history for the current user.
Example:
history
chmod (Change File Permissions):
Modifies file permissions.
Example:
chmod 644 file.txt
chown (Change File Owner):
Changes the owner of a file.
Example:
chown user:group file.txt
alias (Create Command Aliases):
Creates shortcuts for frequently used commands.
Example: `alias ll ='ls -l'` (creates an alias "ll" for "ls -l")
history (Command History):
Displays the command history for the current user.
Example:
history
Please note that these are just basic examples, and many of these commands have additional options and capabilities that can be explored by using the man
command to access the manual pages (e.g., man ls
, man grep
). Additionally, some commands may require superuser privileges and should be used with caution.
Last updated