Wednesday, January 8, 2014

Useful trick for changing directories in nix

So most people know the basics of the "cd" command.


  • It will take a relative path argument (cd directory)
  • It will take absolute path arguments (cd /home/mark/directory)
  • It will take ".." to move up one directory (cd ..)

In the case where you were previously in a directory not directly above or below you, this can be a pain to get back to where you were. The little known option that will save you is the hyphen argument. This is pretty useful when you are deep in the system and need to get back to where you were. 


$pwd
  /home
$cd /var/log/
$pwd
  /var/log
$cd -
  /home


No comments:

Post a Comment