michael@who-cares:~$
The symbol ~
after the who-cares:
is the current directory. ~
actually means the person's home directory. In this case, that's /home/michael
.
michael@who-cares:~$ cd Downloads
michael@who-cares:~/Downloads$
Looks for Downloads
in the current directory, then makes that the current directory.
michael@who-cares:~/Downlaods$ cd /var
michael@who-cares:/var$
Since this directory started with a /
, that means look in the root directory for the directory var
. For those coming from windows, the root directory is the equivalent to C:\
. Directories starting with /
are called "absolute directories" and directories that don't are called "relative directories"
michael@who-cares:/var cd lib/dbus
michael@who-cares:/var/lib/dbus$
The /
in the middle means do cd lib
and once that's done cd dbus
in one command.
michael@who-cares:/var/lib/dbus$ cd .
michael@who-cares:/var/lib/dbus$
.
actually means "the current directory". The command cd .
is basically useless, but .
is useful for other things.
michael@who-cares:/var/lib/dbus$ cd ..
michael@who-cares:/var/lib$
..
actually means "the parent of the current directory". As such, cd ..
means "navigate one directory up".
michael@who-cares:/var/lib$ cd ../log/apt
michael@who-cares:/var/log/apt$
.
and ..
can also be part of the /
chain. Also, there's no limit to how long it can be.
michael@who-cares:/var/log/apt$ cd /dev/bus
michael@who-cares:/dev/bus$
The /
chain can even exist when the directory starts at root.
michael@who-cares:/dev/bus$ cd /
michael@who-cares:/$
cd /
takes you to the root directory. I wonder what happens if you type cd ..
here... (don't worry. It's safe)
michael@who-cares:/$ cd home
michael@who-cares:/home$ cd michael
michael@who-cares:~$
Every user has a directory for their stuff inside the home directory. If current directory is under the home directory, that part of the name, in this case /home/michael
, it's replaced with ~
.
michael@who-cares:~$ cd sys
michael@who-cares:/sys$ cd ~/Desktop
michael@who-cares:~/Desktop$ cd ~/..
michael@who-cares:/home$
~
can also be part of the /
chain. It can even be in the same chain as ..
. If the directory starts with ~
, it's an absolute directory just like if it starts with /
.
Last thing to try: type cd
with no directory after.