Terminal doesn't go to /home/username/downloads [duplicate]
When I type cd /home
, terminal goes there but when I type cd /home/myusername/downloads
(or any address) terminal doesn't go there. It says no such file or directory
.
Can somebody tell me what causes this?
The core of this question: Directory names are case sensitive. Type cd /home/username/Downloads
instead of lowercase.
Additional information
Finding out directory names:
You can use ls
to list files and directories in any directory , to see their names. For instance, on a fresh install, you most likely would find the following directories
$ ls /home/newuser
Desktop/ Downloads/ Music/ Public/ Videos/
Documents/ examples.desktop Pictures/ Templates/
See how they are all capitalized? This is not the case with most of system directories, such as /etc
or /bin
. Traditionally, Unix/Linux commands and directories are all lower-case, though it's not a rule set in stone.
And by the way, there is dir
, same as in Windows' cmd, a command which performs the same action - listing files in your current working directory.
There is an alternative: many file managers support an Open Terminal Here or Open in Terminal option. Nautilus, the default file manager for Ubuntu, does not have this feature by default as of 14.04 LTS, however there is a plugin you can install to enable this feature or use some work arounds. Refer to this question and answers to it for more information on opening a terminal from the file manager.
Navigating in Terminal
In order to navigate around your home directory, there are two "shortcuts", one is cd $HOME/Downloads
and second is cd ~/Downloads
.
In the first case, $HOME
is an environment variable. If you run env | sort
or set | sort
you will see a long list of values sorted alphabetically, among which you will see a line HOME=/home/yourusername
. When you run cd $HOME/Downloads
the shell automatically expands $HOME
to mean /home/yourusername
and adds it to whatever else comes after $HOME
.
For the second case, ~
also automatically gets substituted with the path to your home directory. There is a historical reason for this particular character to represent the home directory
There are also a few tricks with cd
command to make navigation even easier. cd -
works kind of like a go back button in a browser; if you are in one directory but want to return from where you came and do not want to type full path, just enter cd -
. For instance, if I jumped from /home/Serg
to /etc
, I can go back to my home folder by using that cd -
command.
cd ..
will let you go up one directory. For example cd ..
from /home/Serg
will bring me up to /home
.
And what if you want to jump from anywhere back to your home directory ? Just run cd
by itself.
Hitting TAB will give you some suggestions on where to navigate, kind of works like auto-completion.
Occasionally you may want to enter a hidden directory with your settings, which will be initialized with a single dot, e.g. .config
in your home directory. You might want to list them with ls -a
. Of course you will need to type it exactly as it is listed , cd .config
And what if a directory has space or special characters in it? Again, use TAB button, or type everything by yourself, prepending spaces with backslash, e.g. cd Folder\ With\ Spaces\ In\ Name
Suggestion: Invest in a book with basic information on linux or shell programming. In my case, I found very helpful Ubuntu Linux Toolbox and Unix Shells by Example. The power of Linux lies exactly in command line.
And the most important tip - have fun with it all, love what you do!