DEV Community

loading...

BASH : NAVIGATING THE FILESYSTEM

5anthosh profile image Santhosh Kumar ・2 min read

This post was originally published on my blog, find original post here

We'll see about how we can navigate around the file system using bash commands.

First thing, we need to know is where we are in the file system.
We call that directory as current directory or working directory.

To find out the working directory, we can use pwd command.

santhosh@ubuntu:~$ pwd
/home/santhosh

Full form of pwd is Print Working Directory .
Lot of bash commands are abbreviations. So it is easy to remember.

we can see the files and folders are under the current directory by using the ls command.

santhosh@ubuntu-18-04:~$ ls 
Dev     Documents    Downloads

ls is short for list.

We can also provide arguments to bash commands which makes it more powerfull.

to see the hidden files, use ls -a

santhosh@ubuntu-18-04:~$ ls -a
Dev     Documents   Downloads .bash_history  

Refer the manual of ls for more arguments

We can move around the system using cd command.

santhosh@ubuntu-18-04:~$ cd Documents
santhosh@ubuntu-18-04:~/Documents$ _

To move to parent directory

santhosh@ubuntu-18-04:~/Documents$ cd ..
santhosh@ubuntu-18-04:~$ _

..(double dot) is reference to the parent directory.

.(single dot) is reference to the current directory.

~ is reference to the home directory.

/ is reference to the root directory.

if we run cd command without any argument, we will move to the home directory irrespective of working directory.

Command line can autocomplete our command and paths with tab key. You can try it yourself.

Discussion

pic
Editor guide