How to Go Back To Previous Directory and Home Directory in Linux Shell or Putty?

We have been using Putty to access Linux servers for quite some time, and we have shared several Linux Tips in the past, here is another tip that should be useful for many users.

If you used cd to change the directory in Linux you can easily go back to the previous directory by using a command. For example you were in /usr/keith/my/inner/directory/which/is/so/deep and you use the command cd /var/www you can go back to the previous directory without having to type in the entire directory path by using the command cd .

If you want to go back to your default home directory from any directory, type in either cd ~or simply cd, this should take you to your home directory.

Bonus Tips: If you want to find the exact directory you are in type the command pwd". If you want to navigate to a sub-folder in your home directory you can use the ~ sign to replace the path to your home directory, so cd /home/keith/dir1 and cd ~/dir1 should take you to the same directory.

You can also use auto-completion for file and directory names by using the tab key, if there are more than one files or folders matching the text you typed in, you will be shown a list of entries to choose from.

  • Share

Related Topics Similar to This Article: »

Recent Activity: »

Read More On:

Comment Using Facebook

One Response to this Article | Share your Opinions/Comments

We moderate comments to prevent spam. Moderation is done within few hours. Please try and stay on topic and refrain from using abusive language. If you think there is a problem with this post, please email the post author or send us an email at tips@techie-buzz.com with the URL and the problem you see and we will rectify it as soon as we can.

  1. Geeves on March 17th, 2010 at 6:00 am #

    Don’t forget about “!$” which gives you the last argument. so:
    mkdir ReallyLondDirectoryName
    cd !$

    Is the same as doing:
    mkdir ReallyLondDirectoryName
    cd ReallyLondDirectoryName