For Course Enquiry -

+91 9985396677

Linux Basic Commands Every User Should Know

1) what is sudo in linux ?

Sudo (Super User DO) command in Linux is generally used as a prefix of some command that only superusers are allowed to run. If you prefix “sudo” with any command, it will run that command with elevated privileges or in other words allow a user with proper permissions to execute a command as another user, such as the superuser. This is the equivalent of “run as administrator” option in Windows.


sudo useradd - To add a new user

sudo passwd - Creating a password for the new user

sudo groupadd - To add a new group

sudo userdel - To delete the user

sudo groupdel - To delete the  group

sudo usermod -g - To add a user to a primary group

2) What is ls command?

This command displays all the contents in the present working directory.


$ ls

ls -> By mentioning the path after ls, the content in that path will be displayed

ls –a => Using ‘a’ flag, indexes all the hidden contents in the particular directory

ls –l => Using ‘l’ flag, indexes all the contents with its permissions, owner settings, and timestamp (long format)

3) What is cat command ?

Cat(concatenate) command is very frequently used command in Linux. It reads data from the file and gives their content as output. It helps us to create, view, concatenate files.

Syntax : 

$cat filename : It displays content of the given file 

$ cat > new file : It will create a new file

$cat file 1 > file 2 : It will copy file 1 data into file 2

$cat file 1 >> file 2 : It will copy file 1 data at the end of file 2

4) What is man command ?

The man command is one of the best Linux commands. This command is also known as the manual command. It is used to display the manual use of the given command. In other words, it is the meta-command of Linux. Entering the man command will display all the information about the command. 

For example:  $man ls  => It will display all the information about ls command.

5) What is mkdir command ?

mkdir command is used to make a directory or in other words, it used to create a directory. 

The following command will create a new folder called a test folder

$mkdir test

6) What is mv command ?

This command is used to move a file to another directory

$ mv /dir 1/work/myfile /dir2/new-work/newfile

7) What is sort command ?

This command displays the outcomes of a search either numerically or alphabetically. It also sorts file contents, files, and directories.


$ sort {filename}

sort -f => the flag does case insensitive sorting 

sort -r => the flag returns the results in reverse order

sort -n => the flag returns the results as per numerical order

8) What is grep command?

This command searches for a particular string/ word in a text file. It is similar to “Ctrl+F” but operated through CLI.

Syntax: $ grep {filename}

grep -n - Returns the matching strings along with their line number

grep -i - Returns the results for case insensitive strings

grep -c - Returns the number of lines in which the results matched the search string

grep -v - Returns the result of lines not matching the search string

9) What is tail command?

The tail command prints the last N number of information of the given info. Of course, it prints the last 10 lines of the predefined documents. In the event that you provide more than one file name, at that point information from each document goes before by its record name. 


tail [OPTION]... [FILE]...

tail -n 3 state.txt or tail -3 state.txt => -n for no. of lines

tail +25 state.txt

-c num: Prints the last ‘num’ bytes from the file specified.

10) What is cat command

This command could read, alter or concatenate text files. It also shows file contents.

Syntax:  $ cat {filename}

cat -n - It adds line numbers to all lines

cat -b - It adds line numbers to non-blank lines

cat -s - It squeezes blank lines into one line

cat –E - It shows $ at the end of line

11) What is chmod command?

The command is utilized to alter the access authorizations of files and directories.

Syntax: chmod {filename}

4 – read permission

2 – write permission

1 – execute permission

0 – no permission

12) What is chown command?

Various clients in the operating system have proprietorship and authorization to guarantee that the records are secure and put limitations on who can alter the contents of the documents. In Linux, there exist various clients who utilize the framework:

a) Every client has a few properties related to them, for example, a client ID and a home registry. We could add clients into a team to make the way toward dealing with clients in a simple manner.

b) A group can have at least zero clients. A predetermined client is related with a default group. It can likewise be an individual from different teams on the system also.

The chown command is utilized to aalter the file Owner or group. 

chown [OPTION]… –reference=RFILE FILE…

Example: To change owner of the file:
chown owner_name file_name
chown master file1.txt

Here, master is another user in the system. Consider that if you are user named user1 and you require to alter ownership to root (where your current directory is user1). You can use “sudo” before the syntax.
sudo chown root file1.txt

13) What is id command?

This command is utilized to discover client and group names and numeric IDs of the current client or some other client in the server. It is helpful to discover the accompanying data as shown below: 

a) Client name and genuine user id. 

b) Discover the particular Users UID. 

c) Display  the UID and all groups related with a client. 

d) Listing out all the groups a client has a place with. 

e) Show security setting of the current client.

Syntax: id [OPTION]… [USER]


-g: Print only the effective group id.

-G: Print all Group IDs.

-r: Prints real ID instead of numbers.

-n: Prints name instead of a number.

-u: Prints only the effective user ID.

–help: show help messages and exit.

–version: show the version information and exit.

14) What is ifconfig command

ifconfig(interface configuration) command is utilized to design the kernel occupant network interfaces. It is utilized at the boot time to organize the interfaces as required. From that point onward, it is typically utilized when required during investigating or when you need framework tuning. It is also utilized to allot the IP address and netmask to an interface or to empower or cripple a given interface.

Syntax: ifconfig [...OPTIONS] [INTERFACE]

Syntax: ifconfig -a

-a : It is used to show all the interfaces accessible, even if they are down.

Syntax: ifconfig -s

-s : Display a short list, instead of details.

15) What is cut command ?

Cut command is utilized for separating a part of a file utilizing segments and delimiters. If you need to list everything in a chosen section, utilize ‘- c’ with cut order. For instance, let's select the initial two columns from our demo1.txt document. 

cut -c1-2 demo1.txt

16) What is sed command ?

Sed is a text manager which can execute editing activities in a non-intuitive manner. The sed command gets its contribution from standard input or a document to play out the editing procedure on a record. 

It is an extremely ground-breaking utility and you could do a great deal of document controls utilizing sed. 

To replace  “ashok” in test.txt file to “Ashok IT”, you can do as:

sed 's/ashok/Ashok IT/' test.txt

17) What is dd command ?

dd is a command-line utility for Unix and Unix-like operating systems whose main role is to change over and duplicate records.

On Unix, gadget drivers for hardware, and exceptional gadget files, show up in the record system simply like typical files. 

dd commands can also be read and/or write from/to these documents, given that capacity is executed in their individual drivers 

Thus, dd can be utilized for undertakings like supporting the boot area of a hard drive, and getting a fixed measure of random information. 

The dd program can likewise perform transformations on the information as it is replicated, including byte request trading and change to and from the EBCDIC and ASCII  text encodings.

18) What is history command ?

history command is utilized to see the recently operated command. This component was not accessible in the Bourne shell. Slam and Korn uphold this element where each command executed is considered as an event and is related with an occasion number utilizing which they can be reviewed and altered whenever required. These commands are stored in a set of history records. In Bash shell history command shows the entire list of the commands.


$ history : To display the limited number of commands which are executed prior as follows:

$ history 10

19) What is find command ?

find command in UNIX is a command-line utility for strolling a file progressive system. It may very well be utilized to discover documents and indexes and perform the resulting procedure on them. It upholds searching by file, envelope, name, creation date, alteration date, proprietor and consents. By utilizing the '- executive' other UNIX commands could be operated on files or folders found.

Syntax :

$ find [where to start searching from]

[expression determines what to find] [-options] [what to find]

Options :

-ok CMD : It operates the same as -exec except the user is prompted first.

-inum N : It searches for files with inode number ‘N’.

-links N : It searches for files with ‘N’ links.

-exec CMD: The file being searched that meets the given criteria and returns 0 for as its exit status for accurate command execution.

20) What is diff Command ?

diff command is utilized to discover the distinction between two files. It investigations the documents and prints the lines that are not comparative. Let’s state that we have two documents, test and test1. Syntax –  diff test.txt test1.txt

21) What is free Command ?

In LINUX, there exists a command-line utility for this and that is free command that shows the aggregate sum of free space accessible alongside the measure of memory utilized and trade memory in the framework, and furthermore the buffers utilized by the kernel. 

Syntax: $free [OPTION]

Options for free command

-b, – -bytes :It shows the memory in bytes.

-k, – -kilo :It shows the amount of memory in kilobytes(default).

-m, – -mega :It shows the amount of memory in megabytes.

-g, – -giga :It shows the amount of memory in gigabytes

22) What is tr command ?

The tr command in UNIX is a command-line utility for translating  or erasing characters. It bolsters a scope of changes including capitalized to lowercase, pressing rehashing characters, erasing explicit characters and fundamental find and replace. It may be utilized with UNIX pipes to help more intricate interpretation. tr represents translate. 

Syntax: $ tr [flag] SET1 [SET2]


-c : parallels the collection of characters in string.i.e., functions apply to characters not in the provided set.

-d : delete the characters in the first set from the output.

-s : replaces the repeated characters listed in the set1 having single events

-t : truncates set1

23) What is telnet command?

Telnet aids to connect to a remote Linux computer and execute programs remotely and operate administration.


telnet hostname=”” or=””

Example: telnet localhost

24) What is kill command ?

kill command in Linux, is an underlying command that is utilized to end processes physically. This imparts a sign to a process that ends the process. In the event that the client doesn't indicate any sign that is to be sent alongside the kill command, at that point the default TERM signal is sent which ends the process.

kill -l :To show all the accessible signals you could utilize below command option:

Syntax: $kill -l

kill pid: To display how to utilize a PID using the kill command.

Syntax: $kill pid

25) What is curl command ?

The curl command is used to extract information from Uniform Resource Locators (URLs) or IP addresses. 

If it is not installed in our Linux environment then, first of all, we have to use apt-get command to install curl package.

Ex : $curl

26) What is groups command ?

This command describes the membership of a particular user. In other words, it tells which user belongs to which particular group. For example,

groups ashok

groups john

27) What is head command ?

The head command is used to display the first 10 lines of a particular file. If you want to read fewer lines then the extension -n can be used.

Ex: $head -filename

28) What is ping command?

This "ping" command is always used to check the network connection or to troubleshoot networking issues.

Ex :  $ping

29) What is locate command ?

We use this command to locate a file, just like the search command in Windows. Using the -i argument along with this command will make it case-insensitive, so we can search for a file even if we don’t remember its exact name.

To search for a file that contains two or more words, use an asterisk (*). For example, locate -i ashok*course command will search for any file that contains the word “ashok” and “course”, whether it is uppercase or lowercase.

30) What is find command ?

Similar to the locate command, using find also searches for files and directories. The difference is, we use the find command to locate files within a given directory.

As an example, find /home/ -name notes.txt command will search for a file called notes.txt within the home directory and its subdirectories.

Other variations when using the find are:

To find files in the current directory use, find . -name notes.txt

To look for directories use, / -type d -name notes. txt