Is DOS smarter?

4 risposte [Ultimo contenuto]
Darsh229
Offline
Iscritto: 12/07/2014

OK, here is the issue,

I am on the root (/), and if I want to go to the Documents folder, I type (cd / home/username/Documents), and I reach my destination. But If I typed (cd /home/username)then and hit Enter key, then I try to go to the Documents folder by typing (cd/ Documents) I receive "no such file or directory" message. Why??? This happens with all folders in the system, to write the full path or not. Am I missing something here?

quantumgravity
Offline
Iscritto: 04/22/2013

A '/' at the beginning of a path indicates an absolute location.
Hence,
"/Documents"
will look for a folder called "Documents" in your root folder no matter where you are at the moment.
Type
'cd /home/username/'
hit enter
type
'cd Documents/'
and you reach your destination too.

Darsh229
Offline
Iscritto: 12/07/2014

Thanks for clarification. So, it isn't about the smartness of DOS, it is me who still thinking like a DOS user!!!!
Thanks again Quantumgravity.

marioxcc
Offline
Iscritto: 08/13/2014

In several shells such as Bash you can use "~[USER]" as a shorthand for an user home directory (If USER is not specified, it defaults to you, the user as whom the shell is running). For instance, to change to your home directory you can do "cd ~" or just "cd" as "cd" defaults to it. To change to "bob" downloads directory, do "cd ~bob/Downloads". Note that having user directories as their username under "/home" is a common convention, but it's not always the case. Using the "~" syntaxis will give the correcect directory even when it's not in "/home".

Regards.

Darsh229
Offline
Iscritto: 12/07/2014

Thanks Marioxcc, that's a good tip too, appreciate it.