Home Linux Basic Commands in Linux

Basic Commands in Linux

by Priya Venkatesan

These Basic Linux commands will help you to navigate while you’re working in Linux OS.

List of basic commands:

  • pwd(print working directory)
  • ls(listing files and directory)
  • mkdir(make directory)
  • cd(change directory)
  • rmdir(remove directory)

1.pwd:

  • pwd stands for Print Working Directory.
  • It prints the path of the working directory, starting from the root.

Syntax:

$ pwd

2.ls:

  • ls stands for listing files and directories.
  • ls command is used to view the content of your present working directory. 

Syntax:

$ ls

        There are variation you can use with the ls command:

  • ls  -l
  • ls -a
  • ls -al
  • ls -R

a)ls -l:

  • It will list files and directories in a long format.
  • By using this command we can see the file permission, file size, time of modification and file or directory name.

Syntax:

$ ls<space>-l

b)ls -a:

  • By using this command we can list the hidden files and directories

Syntax:

$ ls<space>-a

 c)ls -al:

  • This command is used to long list the hidden file and directories with file type and access permission, file size, owner, time and date modification etc.,

Syntax:

$ ls<space>-al

d)ls -R:

  • It will list all the directories and files recursively as well.

Syntax:

$ ls<space>-R

3.mkdir: 

  • mkdir stands for make directory.
  • This command is used to create or make a new directory.

Syntax:

Here I am creating the directory name user2.

$ mkdir<space><directory name>

4.cd:

  • cd stands for change directory.
  • It is used to change the current working directory.

Syntax:

Here I am changing from current working directory(home directory “~$”) to welcome(~/) directory.

$ cd<space><directory name>

Different functionalities of cd command :

a)cd / :

  • This command is used to change from the current directory to the root directory.
  • The root directory is the first directory in your filesystem.

Syntax:

$ cd<space>/

b)cd .. :   

  • This command is used to move the directory one level up from the current directory.

Syntax:

Here I am changing from the rose sub-directory back to welcome directory.

$ cd<space>..
cd ...png

c)cd ~:

  • This command is used to change from the current directory to the home directory.
  • It is also similar to the cd command.

Syntax:

$ cd<space>~

5)rmdir :

  • rmdir stands for remove directory.
  • This command is used to remove empty directories from the filesystem.

Syntax:

Here I am removing the user2 directory . This user2 directory is empty(no such files or sub-directories).

$ mkdir<space><directory name>

a)rm -r:

  • It is used to remove the content of the directory and directory itself.

Syntax:

Here I am remove the dir2. This dir2 directory have a content of files(eg: file1 and file2 within the dir2 directory).

$ rm<space>-r<space><directory name>

I hope you understand the above article. Thank you for giving your valuable time.

You may also like