How to use Linux shell file directory commands

What is Linux?

Linux is a popular open-source OSOperating System kernel with many distributions known as distros. Linux can be used by developers and other users for their daily work.

Because it requires technical knowledge and built-in commands to operate properly, it is mostly used by programmers.

Linux file directory commands

Some of the basic file directory commands used in Linux distributions are demonstrated in the figure below:

Some Linux terminal commands

pwd: present working directory

This command shows the current directory the user is working on. In the example below the pwd commands would help show the current directory the user is at, which is the root directory ~.


Alvan@Alvan:~$ pwd

mkdir: make directory

This is used to create a new directory for a user. In the example below, the mkdir command helps create a new directory with DIN on the current working directory.


Alvan@Alvan:~/Desktop$ mkdir DIN 

cp: copy command

We use this command to copy files, directories, or groups of files from a source address to a destination address.

In the example below, we have used the cp command to copy the latest.txt file from the Desktop directory to the Data directory.


Alvan@Alvan:~/Desktop$ cp latest.txt Data/

rm: to remove

We use this command to remove files and directories. The rm command is used to remove the latest.txt file in the Desktop directory.

The rm * latest.txt would remove every other file with the latest.txt file.


Alvan@Alvan:~/Desktop$ rm latest.txt

touch

This command is used to create or update a file. In the example below, the touch command creates a new file, latest.txt.


Alvan@Alvan:~/Desktop$ touch latest.txt

ls: list

This command would display the files contained in the directory you are currently at.

In the example below, the ls command gives a list of files in the Desktop directory.


Alvan@Alvan:~/Desktop$ ls

cd: change directory

This is used to move from one directory to another. In the example below, the cd command moves from the ~: root directory to the Downloads directory.


Alvan@Alvan:~$ cd Downloads

cd..: previous directory

This command takes the user to the previous directory. In the example below, the cd.. command takes the user from the Downloads directory to the ~: root directory.


Alvan@Alvan:~/Downloads$ cd..

Free Resources