Top 20 Linux commands


ls

Lists files and directories in the current directory. Example: ls -l to show detailed information.

cd

Changes the current working directory. Example: cd /home/user/Documents to change to the Documents directory.

pwd

Prints the current working directory. Example: pwd to print the current directory.

mkdir

Creates a new directory. Example: mkdir new_directory to create a directory named new_directory.

rm

Removes files or directories. Example: rm file.txt to remove a file named file.txt.

cp

Copies files or directories. Example: cp file.txt /home/user/Documents to copy the file file.txt to the Documents directory.

mv

Moves or renames files or directories. Example: mv file.txt new_file.txt to rename the file file.txt to new_file.txt.

touch

Creates a new empty file. Example: touch file.txt to create a file named file.txt.

cat

Prints the contents of a file to the console. Example: cat file.txt to display the contents of file.txt.

grep

Searches for a pattern in a file. Example: grep "hello" file.txt to search for the word “hello” in the file file.txt.

tar

Creates or extracts compressed archives. Example: tar -cvf archive.tar directory to create an archive of a directory.

wget

Downloads files from the internet. Example: wget https://example.com/file.txt to download a file named file.txt from the website example.com.

top

Shows system processes and their resource usage. Example: top to show the top processes using system resources.

ps

Shows the currently running processes. Example: ps aux to show all running processes on the system.

kill

Sends a signal to terminate a process. Example: kill 1234 to send a termination signal to the process with ID 1234.

chmod

Changes the permissions of a file or directory. Example: chmod 755 file.txt to give read, write, and execute permissions to the owner and read and execute permissions to others.

chown

Changes the owner and group of a file or directory. Example: chown user:group file.txt to change the owner to user and the group to group for the file file.txt.

ssh

Connects to a remote server using Secure Shell protocol. Example: ssh user@remote_server to connect to a remote server with the username user.

scp

Copies files between two systems over SSH. Example: scp file.txt user@remote_server:/home/user/Documents to copy the file file.txt to the Documents directory on a remote server.

ifconfig

Shows network interface information. Example: ifconfig to show information about all network interfaces on the system.