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

by Keith Dsouza | Translate | Print
Friday, 05th Sep 2008 | Share


Share How to Go Back To Previous Directory and Home Directory in Linux Shell or Putty? on Twitter Share How to Go Back To Previous Directory and Home Directory in Linux Shell or Putty? on Facebook Save How to Go Back To Previous Directory and Home Directory in Linux Shell or Putty? To Delicious Favorites Stumble How to Go Back To Previous Directory and Home Directory in Linux Shell or Putty? Share How to Go Back To Previous Directory and Home Directory in Linux Shell or Putty? on Digg Get Instant Updates as RSS Feeds from Techie Buzz

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

No Responses so far | Share Your Opinions!

Leave a Comment

Note: We discourage users from using keywords in their names while posting comments, most of them get caught by spam, also it really would be more fruitful in knowing people who comment by their real name, rather than by using a name no one relates to. In future we reserve the right to delete comments from users using a name other than their own.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>