Important Linux Commands Everyone Should Know
Important Linux Commands Everyone Should Know

Hamed Rohani
Introduction
As everyone knows, there are many bash commands that can serve specific needs, but knowing some of those commands are foundation for everything.
I would like to list those command first to give a big picture.
The ls Command
The
Usage Example
List all files and directories in the current directory
List all files, including hidden files, in the current directory
List files in the long format, showing details like permissions, owner, size, and modification date
List files in a specific directory
Example: Listing files in the current directory in long format including hidden files
The cd Command
The
Usage Example
Change to the home directory
Change to a specific directory
Move up one directory level
Move up two directory levels
Change to the previous directory
The mkdir Command
The
Usage Example
Create a single directory
Create multiple directories
Create a directory with parent directories
Example: Creating a nested directory structure
The rm Command
The
Usage Example
Remove a single file
Remove multiple files
Remove an empty directory
Remove a directory and its contents recursively
Force remove a directory and its contents without prompting for confirmation
Example: Removing a file and a directory with its contents
The cp Command
The
Usage Example
Copy a single file
Copy multiple files to a directory
Copy a directory and its contents recursively
Preserve the attributes of the files while copying
Provide verbose output showing the files being copied
Example: Copying a file and a directory with its contents
The mv Command
The
Usage Example
Move a file to a different directory
Move multiple files to a different directory
Rename a file
Move a directory and its contents to a different location
Rename a directory
Example: Moving a file and renaming a directory
The chmod Command
The
Usage Example
Change permissions to read, write, and execute for the owner, and read and execute for others
Change permissions to read and write for the owner, and read-only for others
Add execute permission for the owner
Remove write permission for the group
Set specific permissions using symbolic mode
Example: Changing permissions of a file and a directory
The grep Command
The
Usage Example
Search for a pattern in a file
Search for a pattern in multiple files
Perform a case-insensitive search
Display line numbers with matching lines
Search for a pattern recursively in a directory
Example: Searching for the word "example" in a file and a directory
The find Command
The
Usage Example
Find files by name
Find files by type (e.g., directories)
Find files by size (e.g., larger than 50MB)
Find files by modification time (e.g., modified in the last 7 days)
Find files and execute a command on each file
Example: Finding files named "example.txt" and directories named "example_directory"
The tar Command
The
Usage Example
Create a tar archive
Extract a tar archive
Create a compressed tar.gz archive
Extract a tar.gz archive
List the contents of a tar archive
Example: Creating and extracting a tar.gz archive
The vi Command
The
Usage Example
Open a file in vi
Basic Commands
Enter Insert Mode
Press
Save and Exit
While in Command mode, type
Exit Without Saving
While in Command mode, type
Save Without Exiting
While in Command mode, type
Example: Editing a file with vi
The cat Command
The
Usage Example
Display the contents of a file
Display the contents of multiple files
Concatenate multiple files into a single file
Append the contents of a file to another file
Display line numbers along with the file contents
Example: Displaying and concatenating files
The top Command
The
Usage Example
Start the top command
Display help within top
Press
Sort processes by memory usage
Press
Kill a process
Press
Quit top
Press
Example: Using top to monitor system processes
The ps Command
The
Usage Example
Display all running processes
Display detailed information about running processes
Display processes for the current user
Display processes in a hierarchical format
Display processes by a specific PID
Example: Displaying all processes and detailed information
The kill Command
The
Usage Example
Kill a process by PID
Forcefully kill a process using SIGKILL
Send a specific signal to a process (e.g., SIGHUP)
Kill multiple processes by their PIDs
Example: Killing a process
The du Command
The
Usage Example
Display the disk usage of a directory
Display the disk usage in a human-readable format
Display the total disk usage of a directory
Display disk usage for all files and directories in the current directory
Display disk usage for a specified depth of directories
Example: Displaying disk usage
The ifconfig Command
The
Usage Example
Display all network interfaces
Display a specific network interface
Enable a network interface
Disable a network interface
Assign an IP address to a network interface
Example: Displaying and configuring a network interface
The ping Command
The