Use the pushd command, which is more convenient than the cd command, to instantly return to the original directory.

When you want to move the directory with the cd command and return to the original directory, it's almost annoying to type something like cd ../ hoge ... In such a case, knowing the pushd command and popd command as a set is convenient because you can instantly return to the original directory.

Move directory with pushd command

If you want to move from directory ~ / user / dir1 to directory ~ / user / dir2, use the pushd command in the same way as the cd command.

~/user/dir1$ pushd ~/user/dir2
~/user/dir2 ~/user/dir1

You have moved to the directory ~ / user / dir2.

~/user/dir2$

Up to this point, it is the same as the cd command. Now use the popd command to return to the original directory ~ / user / dir1.

Return to the original directory with the popd command

Just hit popd.

~/user/dir2$ popd
~/user/dir1

In an instant I returned to the directory ~ / user / dir1.

~/user/dir1$

Caution

The pushd and popd commands are mainly used on the command line and in the bush-only environment and cannot be used on FreeBSD or Solairs.

in conclusion

I've been using the cd command to move directories all the time, so I tend to just use the cd command, but from now on I'll switch to the pushd command.

Recommended Posts

Use the pushd command, which is more convenient than the cd command, to instantly return to the original directory.
How to return to the previous directory with the Bash cd command
Install django-extensions and use runserver_plus, which is more convenient than runserver
[Linux] How to use the echo command
How to use the Linux grep command
3 best ways to use the less command
The translation command (TUI) made by chilling is too convenient, so use it!
It is more convenient to use csv-table when writing a table with python-sphinx
Mia Nanasawa's face is (No'□ `) No Noise processing is applied to return to the original beautiful face
The command to generate RFC bibtex is convenient, so deliver it to all X students
I realized that it is nonsense to use the module without thinking because it is convenient.
[Statistics for programmers] There is more than one way to calculate the average value