4

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?

Zanna
  • 70,465
  • Can you give more information? Possibly some screenshots? If you just do cd /home/yourusername does it work? – Brian Sizemore Apr 22 '15 at 02:48
  • Yes it works if I only type that. – Berkay Buğra Saygi Apr 22 '15 at 02:49
  • if you type cd /home/yourusername and then press a couple of times, it should show you your possible options – Brian Sizemore Apr 22 '15 at 02:51
  • I've just tried it, it shows desktop or other options but when i type i still get same error – Berkay Buğra Saygi Apr 22 '15 at 02:55
  • It goes with things like /.local or /.mozilla but it doesn't go with folders – Berkay Buğra Saygi Apr 22 '15 at 03:02
  • Capitalization is important. /home/username/downloads shouldn't work (unless you created the directory). /home/username/Downloads should work (unless you deleted/renamed the directory) –  Apr 22 '15 at 04:18
  • 1
    Capitalization is important. /home/username/downloads shouldn't work (unless you created the directory). /home/username/Downloads should work (unless you deleted/renamed the directory). Also use ls to view the contents of the directory you're currently in (unless you do ls /path/to/other/directory). –  Apr 22 '15 at 04:19
  • There's a nice game by the MIT for UNIX shell practice: http://web.mit.edu/mprat/Public/web/Terminus/Web/main.html – s3lph Apr 22 '15 at 11:10

1 Answers1

6

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!

Zanna
  • 70,465
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • or type: ~/Downloads – chili555 Apr 22 '15 at 03:04
  • No problem. Dont forget to accept the answer. Chili, yup, that's simpler =) also $HOME/Downloads – Sergiy Kolodyazhnyy Apr 22 '15 at 03:06
  • I installed ubuntu couple of hours ago for the very first time, I'm new this terminal stuff and I got here when I try to install Nvidia driver. Btw how can I accept your answer? – Berkay Buğra Saygi Apr 22 '15 at 03:14
  • Gray check mark next to up down arrows on the left. When I come back home, I am going to improve my answer here, so it should help you navigate terminal easier – Sergiy Kolodyazhnyy Apr 22 '15 at 03:18
  • Thank you so much, I'm re-installing it though, I think I deleted something about x server and couldn't log in anymore I tried everything I can but didn't help. Btw what is the simplest way to install a graphic card drive? From a .run file. Or is there .deb or .rpm driver file which provided by nvidia? – Berkay Buğra Saygi Apr 22 '15 at 03:59
  • Personally, I have not much of idea bout nvidia or other graphics drivers. You can certainly post another question or look if somebody has already asked it here or elsewhere. Nvidia seems to use .run files, so you may need to call those from command line – Sergiy Kolodyazhnyy Apr 22 '15 at 06:08