2

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
  • 1
    Yes 100% correct, and ~ is short-hand for your home directory. Commented Nov 19, 2019 at 21:09

1 Answer 1

5

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.

5
  • 1
    Consider a touch myfile in your home directory if it helps orient you. Commented Nov 19, 2019 at 20:29
  • 1
    And that $ is part of your shell's prompt. Commented Nov 19, 2019 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) Commented Nov 19, 2019 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. Commented Nov 19, 2019 at 21:13
  • Thank you @ctrl-alt-delor that makes sense. Commented Nov 19, 2019 at 22:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.