More useful bash tricks for navigating your filesystem.

Posted: December 8, 2014. At: 12:31 PM. This was 3 years ago. Post ID: 7951
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

Navigating the Linux filesystem is very easy. The cd command is used to move to another directory. But there are other ways too.

To navigate back to the last directory you were in, type cd -. This will take you back to where you were before.

ubuntu /usr/share $ cd -

The cd ~ command will take you back to your home directory.

The user can also use the cd command by itself to go back to the home directory.

ubuntu /usr/share/debhelper $ cd
ubuntu ~ $

Using cd .. will take you back one directory.

ubuntu ~ $ cd ..
ubuntu /home $

To navigate to another directory, use this command.

[email protected]:~$ pushd Documents/
~/Documents ~

This is a good alternative to using cd all of the time. Using pushd shows the directory you navigated to, as well as the one you just left.

jason@jason-desktop:/usr/share/vte$ pushd ~/Documents/
~/Documents /usr/share/vte ~

When editing a command line in bash, use Ctrl-a to go to the start of the command and Ctrl-e to go to the end. Unless you are using mate-terminal. Then you may use home and end instead.

Here is yet another way to change directory.

ubuntu ~ $ PWD=$PWD/usr/share
ubuntu ~/usr/share $

This is an alternative to the cd command.

No comments have been made. Use this form to start the conversation :)

Leave a Reply