Changing directories with cd command

cd is the command used for changing directories on GNU/Linux. It is shorthand for change directory. Synopsis is give below:

cd [-L|[-P [-e]] [-@]] [dir]

cd .. will take you to parent directory. cd dirpath will change to the directory specified. dirpath can be an absolute path or a relative path. Absolute paths begin with a leaading /. cd - will take you to previous directory.

cd only changes the current directory to DIR. The default DIR is the value of the
HOME shell variable.

-L forces symbolic links to be followed.

-P makes cd use the physical directory structure without following symbolic links.

-e if the -P option is supplied, and the current working directory cannot be determined successfully, exit with a non-zero status

-@ on systems that support it, present a file with extended attributes as a directory containing the file attributes.

The default is to follow symbolic links, as if -L were specified. .. is processed by removing the immediately previous pathname component back to a slash or the beginning of DIR.

Leave a comment

Your email address will not be published. Required fields are marked *