Most frequently used Linux Commands

Now days it becomes important for common user even to know the basic commands over Linux terminal. To start work, you need to know the very basic commands to do operations. Here you can begin to open terminal with shortcut command ctrl + alt + t

pwd command

PWD command lets you now the current directory where you are.


cd command

cd command in Linux known as the change directory. It is used to move from the current directory to different directories. Double full stop ‘..’ after this command will bring back to the parent directory or one level up in directory.

cd directory/subdirectory

ls command

Used to list out all the files and directories. If add -a option, then hidden files and directories will even appear.

ls -a

rm command

Used to remove a directory or a file. Screenshot show it remove directory dir1 that includes hidden file and folder. Its syntax would be like:

rm [option] file/dir.


sudo rm -rf directory

cp command

Used to copy file from a directory to another directory. Syntax of this command is:

cp […file/directory-sources] [destination]


sudo cp hello1 ../dir2

find command

It is used to find files and directories and can also perform subsequent operations on them. Its syntax is:

find [where to start searching from] [expression determines what to find] [-options] [what to find]

You can use below command to list out all path of directories named with sting “dir”

find -type d -name "*dir*" -exec realpath {} \;

grep command

This command is used to search the matching patterns in a file. It is very important to find matched word or string though out the files exist in directories or sub-directories. Syntax is:



grep -rn . -r "mny"

sudo nano filename

To edit any file just type above command to edit the file. Once the changes are done you can exit by ctrl + x, then press Y to save modified buffer, and then at last press enter button.

sudo nano demo.txt

Directory file size

You can check size of the current directory. The dot at last in below command represent the current directory.

sudo du -sh .


Compress/Uncompressing a directory Or a file

The tar command on Linux is often used to create .tar.gz or .tgz archive files, also called “tarballs”. We see only the frequently used command rather than go in details.

Create Archive file

Below command you can use to compress the directory or a file.

tar -czvf archive-name.tar.gz /path/to/directory-or-file
  • -c: Create an archive.
  • -z: Compress the archive with gzip.
  • -v: Display progress in the terminal. Also known as “verbose” mode. Recommend to use it always.
  • -f: Allows to specify the filename of the archive.

Here “/path/to/directory-or-file” is the path of directory to compress. And compressed file you can see where you are in current directory. Instead of “/path/to/directory-or-file” you can use dot “.” to compress the current directory where are are currently and same compressed file will be created where you are.

While compress, you can exclude some directories by a –exclude switch like as below:

tar -czvf archive-name.tar.gz /dir/to/compress/ --exclude=/dir/to/compress/.cache --exclude=*.mp4

Check compressed content

tar -tvf [archive.tar]
  • “-t”/ “–list”: List out the content of the tar file
  • “-f”/ “–file”: Commanding the utility to use the file mentioned in the following argument
  • “-v”/ “–verbose”: Used to show up the detailed standard output

Uncompressing tar file

sudo tar -xzvf arc.tar.gz -C ./directory-where-to-extract/
  • “-x”/ “–extract”: Specify to extract archive file.

Check disk space

df, which stands for Disk Filesystem, is used to check disk space. You can check the available and used storage of file systems of your machine.

du -h


These are the very basic command that are used frequently to deal with terminal operations.

Leave a comment

Your email address will not be published. Required fields are marked *