Skip to main content
Linux Commands

Linux commands explained – Part 1

In this tutorial I will explain about some basic Linux commands used to navigate through the file system. If you are new to Linux, I recommend you to go through the following articles to get a better idea of the stuff explained here.

  1. Different file types in Linux
  2. File permission’s and ownership’s
  3. Special permissions (SUID,SGID,sticky bit)
  4. Linux Directory Structure explained
  5. Linux wild cards explained

Linux Commands – Set 1

The first three commands to play with are – pwd (print working directory),ls (list files and directories), and cd (change directory).

pwd

PWD command helps you to identify the location of you in the Linux directory structure. I.e, it just prints your present working directory. When log on to a Linux system, the starting directory is always your home directory i.e /home/your_username.

[email protected]:~$ pwd
/home/admin

Please note that this can be changed by the system administrator.

ls

Ls command is used to list the contents of a directory. Check the syntax of this command below.

$ ls [path_to_the_directory]

If we didn’t specify any directory then the current wording directory is assumed.

[email protected]:~$ ls
Desktop test.py user.sh

This doesn’t give us any idea about the type of the files listed. But, please note that ls command comes with a bunch of options/arguments which help us to see the permissions,ownerships,created date,size etc of files. I have explained it in detail in another post.

cd

It is used to change the current directory. I.e, you can move through the directories of your Linux system.

[email protected]:~$ cd Desktop/
[email protected]:~/Desktop$

The above command changes the current working directory to Desktop. You can check it using command pwd.

[email protected]:~/Desktop$ pwd
/home/admin/Desktop

 

cd [directory]

Think if you want to change the working directory to /usr/local/src/.

[email protected]:~/Desktop$ cd /usr/local/src/
[email protected]:/usr/local/src$ pwd
/usr/local/src

 

cd..

Change Current directory to parent directory.

[email protected]:/usr/local/src$ cd ..
[email protected]:/usr/local$ pwd
/usr/local

 

cd –

Move to the previous working directory.

[email protected]:/usr/local$ cd –
/usr/local/src

 

cd

cd without any argument moves the working directory straight to the user’s home directory.

[email protected]:/usr/local/src$ cd
[email protected]:~$ pwd
/home/admin

That’s it. I will explain the next set of Linux commands in another post.

Rate this post

GeeksAlive

TheGeeksAlive is all about Linux, Server Administration, Web Hosting and other Open Source Technologies.