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.
- Different file types in Linux
- File permission’s and ownership’s
- Special permissions (SUID,SGID,sticky bit)
- Linux Directory Structure explained
- 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 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
Please note that this can be changed by the system administrator.
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.
It is used to change the current directory. I.e, you can move through the directories of your Linux system.
The above command changes the current working directory to Desktop. You can check it using command pwd.
[email protected]:~/Desktop$ pwd
Think if you want to change the working directory to /usr/local/src/.
Change Current directory to parent directory.
Move to the previous working directory.
[email protected]:/usr/local$ cd –
cd without any argument moves the working directory straight to the user’s home directory.
That’s it. I will explain the next set of Linux commands in another post.