Top Basic Linux commands Everyone should know

Linux, a clone of UNIX is the most popular server OS. Knowledge of one is as good as knowing the other. Linux is an operating system or a kernel. It is distributed under an open source license. Hence, Linux is freely available. Its functionality list is quite like UNIX.

Some of the fundamental and common Linux commands with example usage are enlisted below:


1. Ls: The Is command lists the content of the current directory (or one that is specified). It can be used with the -1 flag to display additional information (permissions, owner, group, size, date and timestamp of last edit) about each file and directory in a list format. The -a flag allows the user to view files beginning with. (i.e. dotfiles).

2. cd: Using ed changes the current directory to the one specified. The user can use relative (i.e. cd directoryA) or absolute (Le. cd/home/pi/directoryA) paths.

3. pwd: The pwd command displays the name of the present working directory: on a Raspberry PL entering pwd will output something like /home/pl.

4. mkdir: To create a new directory the user can use mkdir. e.g. mkdir newDir would create the directory newDir in the present working directory.

5. rmdir: The user can use rmdir to remove empty directories. So, for example, rmdir oldDir will remove the directory oldDir only if it is empty.

6. rm: This command rm removes the specified file (or recursively from a directory when used with-r). User has to be careful while using this command.

7. cp: Using cp makes a copy of a file and places it at the specified location (similar to copy and paste). For example, cp -/TileA /home/otherUser/ would copy the file files from your home directory to that of the user other user (assuming you have permission to copy it there). This command can either take FILE FILE (cp fileA fileB), FILE DIR(cp fileA (directoryB) or DIR DIR (which recursively copies the contents of directories) as arguments

See also  All you need to know about .C extension file: How to open it?

8. mv: This command my moves a file and places it at the specified location (so where cp performs a “copy-paste, mv performs a cut-paste’). The usage is similar to cp command. So my-fileA /home/otherUser/ would move the file fileA from your home directory to that of the user otherUser. This command can either take FILE FILE (mv fileA fileB), FILE DIR (mv fileA (directoryB/) or DIR DIR (my /directoryB /directoryC) as arguments. Once the files and directories are created they can be renamed with this command.

The command touch sets the last modified time-stamp of the specified filets) or creates it if it does not already exist.

9. cat: The user can use carto list the contents of file(s).

eg. cat this file will display the contents of this File. Can be used to list the contents of multiple files, Le. cat”.txt will list the contents of all .txt files in the current directory.

10. head: The head command displays the beginning of a file. Can be used with -n to specify the number of lines to show (by default ten), or with-c to specify the number of bytes.

11. tail: The opposite of head, tail displays the end of a file. The starting point in the file can be specified either through b for 512 byte blocks, -c for bytes, or -n for number of lines.

12. chmod: This command chmod is normally use to change the permissions for a file. The chmod command can use symbols u (user that owns the file), g (the files group), and o (other users) and the permissions r (read), w (write), and x (execute). Using chmod u-x “filename” will add execute permission for the owner of the file.

13. Pipes: A pipe allows the output from one command to be used as the input for another command. The pipe symbol is a vertical line. For example, to only show the first ten entries of the is command it can be piped through the head command is head

See also  What is a Java file extension and how to open it?

14. Tree: Use the tree command to show a directory and all subdirectories and files indented as a tree structure.

15. &: Run a command in the background with &, freeing up the shell for future commands.


  • grep: Use grep to search inside files for certain search patterns. For example, grep “search”.txt will look in all the files in the current directory ending with txt for the string search. The grep command supports regular expressions which allows special letter combinations to be Included in the search.
  • awk: awk is a programming language useful for searching and manipulating text files.
  • find: The find command searches a directory and subdirectories for files matching certain Raspberry Pi, patterns,
  • whereis: Use whereis to find the location of a command. It looks through standard program locations until it finds the requested command.


Also Read, Get All information about the IoT use and IoT Trends

1. ping: The ping utility is usually used to check if communication can be made with another host. It can be used with default settings by just specifying a hostname (e.g. ping or an IP address (e.g. ping It can specify the number of packets to send with the -c flag.

2. nmap: nmap is a network exploration and scanning tool. It can return port and OS information about a host or a range of hosts. Running just nmap will display the options available as well as example usage.

3. hostname: The hostname command displays the current hostname of the system. A privileged (super) user can set the hostname to a new one by supplying it as an argument (e.g. hostname new-host).

4. ifconfig: Use ifconfig to display the network configuration details for the interfaces on the current system when run without any arguments (i.e. ifconfig). By supplying the command with the name of an interface (e.g. ethe or 10).

Leave a Comment