You can use Linux command cd with – (hyphen) option to get back to the previous working directory.
1 2 3 4 5 6 7 8 |
pwd ## currently in user home directory (/home/user) mkdir -p mydir1/mydir2/mydir3 ## create three directory one inside another in order cd mydir1/mydir2/mydir3 ## navigate to mydir1/mydir2/mydir3 path relative to /home/user/ pwd ## returns /home/user/mydir1/mydir2/mydir3 cd - ## returns to previous working directory (/home/user) pwd ## returns /home/user cd -- ## returns back to the directory from where cd - was last executed pwd ## returns /home/user/mydir1/mydir2/mydir3 |