2. Navigation
The command cd (change directory) is used to move from one directory
to another. The command pwd (print working directory) shows the
current location. The command ls (list) shows the content of the
current working directory.
-
Display the current working directory with
pwd(print working directory):pwd -
List the contents of a directory:
ls /ls /usrls -l /usr -
Change the current working directory:
cd /usrpwdlscd /usr/binpwdThe path
/usr/binis called absolute, since it shows the full path, starting from the root (/). -
Go to the directory one level up:
cd ..pwdTwo dots (
..) represent the parent of the current directory.By the way, a single dot (
.) represents the current directory:cd .pwd -
Use a relative path:
cd binpwdThe directory
binis relative to the current one (in this case/usr). -
Go to the previous current directory:
cd /var/logcd -cd - -
Go to the home directory:
cdcd ~The tilde (
~) represents the home directory of the current user.