1

I can cd /usr/, but why doesn't ls -a or ls -d or ls -d */ show me that the usr directory is there?

I have already seen this question, but ls -d */ yields ls: cannot access */: No such file or directory

1 Answer 1

4

You would see the usr directory if your current directory is /. Your home directory, abbreviated as ~, is probably not the root directory but something like /home/adam.

When you call cd /usr, you’re using an absolute path, as indicated by the leading slash. This call behaves the same wherever you execute it from.

When you call cd usr, you tell cd to change into the usr directory that is in the current working directory. Because it’s relative, it behaves differently for every directory.

ls -a (and friends) without further arguments (or arguments lacking a leading slash) also work relative to the current working directory.

You can see your current working directory’s full path with the pwd command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.