DEV Community

Tawhid
Tawhid

Posted on • Updated on

Top 20 linux commands.

Linux.The os that makes servers,embedded systems,android phones etc.Linux is everywhere.It is free and open source.I use Linux(gnomeDE) for daily drive so I know a thing or two.Although Linux should be referred as GNU/Linux it is shortened as Linux only.Linux is an UNIX like OS so, most of the work is done through terminal/CLI.Linux is an essential skill.Today we will learn 20 commands to use to manipluate some works in linux.

1)clear command
clear is a standard operating system command which is used to clear the terminal screen. This command brings the command line on the top of the terminal. By pressing the ‘ctrl+L' shortcut key, you can also clear the terminal screen.

Syntax:

$ clear

2)exit command
This command is used to close the terminal window or exit the shell. It takes one more parameter which exits the terminal or a shell.

Also, use the shortcut key ‘ctrl+shift+w’ to close the shell or terminal window and ‘ctrl+shift+q’ for close all the terminal tabs.

Syntax:

$ exit [n]

3)echo command
The echo command is used to print the line of text or a string or a number. It prints the string that passes as an argument in the command.

Syntax:

$ echo [option] [string]

Different options used in an echo command

(a) ‘/b’: ‘/b’ is a backspace option used with a backslash interpreter
(b) ‘\t’: This option is used in a string for the horizontal tab spaces using the backslash interpreter ‘-e.’
(c) ‘\n’: ‘\n’ option is used to break a string or a line of text by using the backslash interpreter ‘-e.’
(d) ‘\v’: This option is used for the vertical tab space.
(e) ‘\c’: It is also used with the backslash interpreter ‘-e’ and produce no further string after it.
(f) ‘echo ’: This option ‘’ displays the files and directories as similar to the ‘ls’ command.

4)history command
The history command displays all previously used commands since the session was started.

Syntax:

$ history

5)pwd command
pwd stands for present working directory which shows the path of the working directory starting from the root.

Syntax:

$ pwd

6)cd command
The 'cd' command is used to change the current working directory into its child or parent directory or any other directory (home or root directory).

Syntax:

$cd [directory_name]

Different types of cd commands in Linux

(a) ‘cd ..’: This command is used to change the current directory to the parent directory.
(b) ‘cd/’: ‘cd/’ is used to move the user to the root directory.
(c) ‘cd~’: this command is used to change the current directory to home directory.
(d) cd dir1/dir2/dir3: This command is used to change a directory from the parent directory.

7)ls Command
The ls command shows the list of all the files and folders in the current working directory.

Syntax:

$ ls [option]

Options used with ls command

(a) ‘ls --version’: this option shows the version of ls.
(b) ‘ls~’: This option ‘ls~' shows the list of files and directories of the home directory.
(c) ‘-a’: It shows the list of all the files and directories with the hidden files started with the .dot symbol in the current directory.
(d) ‘-d */’: It is used to display only the list of directories.
(e) ‘-R’: This option of ls command displays the file of subdirectories also.

8) mkdir command
mkdir stands for make directory and it is used to create a new directory in a file system. It takes one or more argument as a directory name. It also creates multiple directories by passing their directory names in the command. By using this command, you can also set permission to the directory.

Syntax1:

$ mkdir [option] directory_name

Syntax2:

$ mkdir dir1 dir2 dir3 ... dirN
-By using the ‘ls' command, you can verify that the directory is successfully created or not.

9)rmdir command
It stands for remove directory.

This command is used to remove the existing empty directory from the file system and takes one more argument as a directory name. It removes each directory specified in the rmdir command.

Syntax1:

$ rmdir [option] directory_name

Syntax2:

$ rmdir dir1 dir2 dir3 ... dirN

10) cp command
The 'cp' command is used to copy the file or directory from one location (source) to another location (destination). This command takes at least two arguments as a file name. It can also copy more than one file in a single directory.

Syntax:

$ cp [option] Source Destination

-Copy the content of one file into the second file.
-‘-R’: This option copies all the files of source directory to the destination directory.

11)mv command
‘mv’ stands for move and is used to move one and more files and directories from one place to another directory or location in a Linux file system.

This command is also used to rename a file, folder, and directory by passing the old name of a file and new name as an argument.

To move directory
Syntax:

$ mv [option] source_directory destination_directory

12)touch command

The touch command is a standard command used in Linux for creating the empty files if not exits. It is also used to create, change and modify the timestamp (i.e., date and time) of the file. It takes at least one argument as a file name.

Syntax:

$ touch file_name

13)cat command
cat (concatenate) command reads the data from the file and displays the content of the file as an output on the terminal. It also helps to append the content of a text file to the end of another text file.

Display the content of a file
You can display the content of a file by passing the file name as an argument in a command line.

Syntax:

$ cat [option] file_name

14)ln command
ln command is used to link two files and directories in Linux.

There are two types of link:

Hard link: Hard links create links between two or more filenames with the same inode number. By default, the ln command creates a hard link between files. It links directly to data on disk or the physical data.

Soft Link: It is also known as symbolic link or symlink. Symbolic link or soft link does not directly link to the data on disk they relate to another link.

-Create a hard link
Syntax:

$ ln file1 link1

-Create a soft link/ symbolic link:

You can create a symbolic link or soft link by using the ‘-s.'

Syntax:

$ ln -s path_of_file_name link_name

15)date command
The ‘date’ command is used to display the current date and time of the system. A super-user can change the value of the system date and time.

Syntax:

$ date [option] [Format]

16) ps command
‘ps’ stands for ‘processes status,’ and this command is used to display the currently running processes with their process Identification number, i.e., PIDs along with some other information for each process depends on the different options.

Syntax:

$ ps [option]

(a) ‘-A or -e’: This option prints all the processes running in your Linux system.

17) whoami command
whoami is mainly the concatenation of the string “who” ,”am”,”i” and when this command is executed, then it displays the username of the current user.

Syntax:

$whoami [option]

18) passwd command
The passwd command changes the password of a user account in Linux. When you are changing the password, make sure that you are using a unique and strong password.

To change the password, run the following passwd command without any option:

Syntax:

$passwd

19) uname command
The uname command shows the information about the system, such as machine name, Operating system, and kernel.

Syntax:

$ uname [option]

(a) use -a for all info

20) apt command
The Debian based ‘apt’ command stands for Advanced Package Tool. Apt is a package manager for Debian based systems like Ubuntu, Kubuntu, Lubuntu, etc., that automatically and intelligently search, update, install, and resolves dependency of packages on Linux system from command line Interface.

Syntax:

$apt-get package_name

wohooo! We are done

Bonus Tips:
-Use --help after any command for it's usage/info
-Use --version after any command to know it's version

That's the end.A like would be appreciated ;)
Buy me a coffee

Top comments (2)

Collapse
 
igormelo profile image
Igor Melo

It is hard to notice the 1), 2), 3).
Consider setting it to bold, like
16) ps command

Collapse
 
dumboprogrammer profile image
Tawhid

alright!