TOP 30 MOST USEFUL COMMANDS IN LINUX

Linux is an open-source operating system based on the Linux Kernal. when you are using the command line interface you need to know about the basic commands to help you use your Linux Distribution because Linux command is a program that runs on the command line interface.

Here is the list of 30 basic Linux commands:

  1. ssh
  2. mkdir
  3. touch
  4. ls
  5. rm
  6. cd
  7. vi/vim/nano
  8. pwd
  9. mv
  10. cp
  11. cat
  12. grep
  13. zip
  14. unzip
  15. tar
  16. ps
  17. service
  18. df
  19. du
  20. chmod
  21. chown
  22. netstat
  23. ifconfig
  24. wget
  25. passwd
  26. top
  27. find
  28. history
  29. kill
  30. wc

Now we are explaining how to use these commands in the CLI terminal in Linux:

1. ssh command

This command’s name is Secure Shell. The ssh command allows you to connect to a Linux machine on the network with the use of the ssh protocol.

The basic syntax of this command is:

ssh username@hostname
ex:- ssh root@123.248.145.12

2. mkdir command

The proper name of this command is “make directory“. This command is used to create a new directory.

The basic syntax of this command is:

mkdir adminhint

Here “mkdir” is a command and “adminhint” is a newly created directory.

If you want to create multiple directories in a directory then use the following syntax:

mkdir -p adminhint/firstdir/secdir

-p = parent directory

3. touch command

This command is used to create a new empty file or change an existing file timestamp.

The syntax of this command is :

touch filename

4. ls command

This command is used to list files and directories in the current directory.

syntax of this command is:

ls

If you want to see all files and directories with details then use the following command:

ls -l

-l = long list

5. rm command

The real name of this command is remove. rm command used to remove files and directories from the terminal.

The format of this command is :

rm -rf file/directory

-r = recursive

-f = forcefully

6. cd command

The full name of this command is Change Directory. This command is used to go from one directory to another directory.

The syntax of this command is:

cd /path-of-your-directory

7. vi/vim/nano command

These commands are used to open and edit files on a Linux machine. You can open files and edit the content of any files with these commands.

The syntax of this command is:

vi filename
vim filename
nano filename

Then if you want to save this file use need to use “:wq!”

8. pwd command

This command is used to check your current working directory.

pwd

9. mv command

The real name of this command is move. This command is used to move files and directories from one path to another path.

mv source destination

10. cp command

The real name of this command is copy. This command is used to copy files and directories from one path to another path.

cp -rvp source destination

-r=with recursive

-v=with verbose

-p=with permission

Use these arguments with your requirement.

11. cat command

This command is mostly used to see the file’s content without opening the file but it’s used in different formats with different requirements.

When you want to see the file’s content without an open file then you can use the following command:

cat filename

If you want to copy a file’s content from file1 to file2 then use this command:

cat file1 > file2

If you want to merge more than one file with the same format into a new file:

cat *.txt > new-file

12. grep command

grep command is used to find a word from one or more than one files.

grep word filename

13. zip command

zip command is used to compress your files and directories.

zip -r filename.zip your-file

-r = recursive

14. unzip command

This command is used to extract your zipped file. Use the following syntax to extract the file:

unzip zippedfile.zip

15. tar command

Tar command is used to create and extract archived files in Linux. We can extract multiple different archive files using this command.

You can create an archive file with the following command:

tar -cvf file.tar source-files

-c = create

-v = verbose

-f = forcefully

If you want to extract this archived file then use the following command:

tar -xvf file.tar

-x = extract

-v = verbose

-f = forcefully

16. ps command

Ps command is used to check all running processes on the server.

You can check processes with the following command:

ps -aux

17. systemctl command

The systemctl command is used to start and stop services in the operating system.

you can use this command with the following :

systemctl start/restart/stop service-name
systemctl enable/disable service-name

18. df command

this command is used to get details of the mounted filesystem.

you can see details with the following command:

df -h

-h = human-readable

19. du command

If you want to check how much space a file or a directory covers up. You can run this command to identify which part of the system uses unnecessary storage.

You can use this command with the following :

du -sh your-file/your-dir

-s=to check the total size of a specified folder.

-h=To check the last modification date of the displayed folders and files.

20. chmod command

This command is used to set read, write and execute permissions to users, groups and others,

Now you can set your permission with the following format

read = 4

write = 2

execute = 1

With this format, you want to give permission to

users = read and write

group = read

others = read

then you can use the following command

chmod 644 file/directory

21. chown command

This command is used to set ownership to specific files and directories.

You can use this command with the following syntax:

chown user:group files/directories
ex:- chown root:root files/directories

22. netstat command

This command is used to check a list of ports that are used by different services.

You can use this command with the following syntax:

netstat -tunpl

-t = tcp

-u = udp

-n = numeric

-p = programs

-l = listening

23. ifconfig command

This command is used to check active IP address interfaces on this server.

use the following command:

ifconfig

24. wget command

This command is used to download files from a specific link to your server.
If you want to download files then you can use the following command:

wget https://your-file-url

25. passwd command

This command is used to change the password of the user with the following command:

passwd user

26. top command

This command is used to check the live view of the processing like memory usage, CPU usage, etc.

top -c

-c = will display the absolute path of the running process

27. find command

This command is used to find any file from the server.

Use the command with the following;

find dir-where-you-want-to-find -name file-name
ex:- find /root -name abc.txt

28. history command

This command is used to list previously executed commands.

you can use with following:

history

29. kill command

The kill command is used to stop all running processes which you want to stop.

You can use this command with the following:

kill -9 process-id

30. wc command

The real name of this command is word count. The use of this command is to find out the number of counts in a file and it used different formats with different arguments.

If you want to see counts of characters then use the following command:

wc -m your-file

-m = characters
If you want to see counts of words then use the following command:

wc -w your-file

-w = words

If you want to see counts of lines then use the following command:

wc -l your-file

-l = lines