Basic Linux Commands for Beginners

A detailed list of frequently used Linux commands

Photo by Jesus Kiteque on Unsplash

For a new user, the Linux environment is not as user-friendly as Windows. It would take some time to become familiar with the terminal and terminal commands. I remember myself struggling to even traverse through the directories and doing a google search for everything.

Here is a list of some basic Linux commands that would be useful for beginners.


A. To Create a File

touch file_name

For example, if we want to create a text file named mytext, then: touch mytext.txt

B. To Edit a File

nano file_name

After editing the file, use ctrl + x to save the changes that you made. (you have to do everything using the keyboard on this text editor, even traversal)

To install nano: sudo apt install nano

C. To View a File

less file_name

Using the less command we can view the entire file. But, if we want to view only the first few lines, we can use:

head file_name

D. To Concatenate/Combine Files

Suppose we have two files file1.txt and file2.txt, and we want to combine these two files into a single file named file3.txt,

cat file1.txt file2.txt > file3.txt

We can also append one file to another. For example, if we want to append file1.txt to file2.txt,

cat file1.txt >> file2.txt

E. To Move Files

If we want to move a single file,

mv file_path destination_path

In the following example, we are moving file1.txt to the newfolder

F. To move multiple files at the same time,

mv file1_path file2_path destination_path

To move all the files of a specific type, we can use *.file_format . In the following example, we are moving all the .txt files (file1, file2 and file3) to the newfolder.

G. To Copy Files

Simply replace mv with cp. The syntax is similar to mv command.

H. To Delete Files

rm file_name


A. To Create a Directory

mkdir directory_name

B. To Remove a Directory

rm -r directory_name

C. To View Directory Size

To view the disk usage of a directory,

du directory

To view the file sizes in the human-readable format with units,

du -h directory

D. To Rename a Directory

There is no specific command in Linux to rename a directory. Instead, we have to use the move command. Suppose you need to rename directory_1 to directory_2,

mv directory_1 directory_2


A. To Extract Compressed Files

  • To extract .gz format:
gzip -d file.gz

This command will uncompress the file but will remove the original .gz file. To keep the original file,

gzip -dk file.gz

To extract all .gz files in a folder:

for f in *.gz; do gzip -d $f; done
  • To extract .zip format:


A. To view all the files and directories in the current location:


B. To go to a specific directory:

cd directory_path

I hope you find this article useful!!!

A Computer Science Research Student who loves to do Research, Write and Travel

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store