When I log into a server running Ubuntu 18.04.3 (LTS) x64 and run ls nothing shows and there is a ~$ at the end of the command prompt. When I type cd / the prompt changes to /$ and I can see many more directories listed. When I login am I initially in the home directory of the user and then by using cd / am I changing to the root directory of the system?

  • 1
    Yes 100% correct, and ~ is short-hand for your home directory. – ctrl-alt-delor Nov 19 '19 at 21:09

Correct. You are in the user's home directory when you see ~$ and the "top level" or "root" directory when you see /$. Use pwd to "print working directory". This will show you the results of the two different paths. A trick to get back to your default home directory ~$ is to simply type cd and press enter.

| improve this answer | |
  • 1
    Consider a touch myfile in your home directory if it helps orient you. – Jeff Schaller Nov 19 '19 at 20:29
  • 1
    And that $ is part of your shell's prompt. – Jeff Schaller Nov 19 '19 at 20:30
  • The user I'm logged in as has root privileges. If I was logged in as a user without these privileges would I be able to get to the "root" directory? Or is this just the users root directory.(Not sure if this is even a thing) – Michael Shoe Nov 19 '19 at 20:32
  • 1
    Yes you can go to the root directory as anyone, but you will not be able to write/change/create any files there. There are many files that you need to be able to read e.g. ls is in /usr/bin/ls. Also if you operate as root user (even if you know what you are doing) you will mess up, and break something. Add a new user, and use that. Then use sudo to gain privileges when you need them. – ctrl-alt-delor Nov 19 '19 at 21:13
  • Thank you @ctrl-alt-delor that makes sense. – Michael Shoe Nov 19 '19 at 22:00

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.