I am new to Linux and Ubuntu and have tried changing to folders/directories with some difficulty.
Could someone explain why the following commands failed to change to the desired target folder/directory?
sharon@sharon:~$ cd Home
bash: cd: Home: No such file or directory
sharon@sharon:~$ cd /Home
bash: cd: /Home: No such file or directory
sharon@sharon:~$ cd Documents
sharon@sharon:~/Documents$ cd Downloads
bash: cd: Downloads: No such file or directory
sharon@sharon:~/Documents$ cd /Downloads
bash: cd: /Downloads: No such file or directory
sharon@sharon:~/Documents$
Best Answer
The filesystem is GNU/Linux is like a tree, except that the root is on top. :-) So you have structure like:
If you want to move inside the tree, one option is to use relative paths. If you are in
/home/sharon
, then typingcd Downloads
will work, because Downloads is an immediate child of your current directory. If you are in the subfolderDocuments
and want to change directory (cd
) toDownloads
, you have to go up (..
) and then toDownloads
. So the correct command would becd ../Downloads
.You could also enter an absolute path. So the
Downloads
folder is a subfolder ofsharon
which is a subfolder ofhome
which is … (you get the idea :-)) So you can also entercd /home/sharon/Downloads
wherever you are in the filesystem.~
always refers to the home directory of the current user (/home/sharon
in your case). If you entercd ~/Downloads
you'll land in yourDownloads
folder..
refers to the current directory, socd ./Downloads
is roughly equivalent tocd Downloads
...
means "parent directory"./
at the beginning of file path refers to the root directory.The next nice thing is tab expansion. If you enter
cd ~/Dow
Tab (last is pressing Tabulator key), the bash automatically expands it tocd ~/Downloads
.As the others said GNU/Linux is case sensitive. So it makes a difference if you enter
Home
,hOme
orhome
. Furthermore I hope that you see now that there is a difference between/home
andhome
. The first is adressed absolute while the last is relative to your current directory.