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 Answer
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.
-
1Consider a
touch myfilein your home directory if it helps orient you.2019-11-19 20:29:49 +00:00Commented Nov 19, 2019 at 20:29 -
1And that
$is part of your shell's prompt.2019-11-19 20:30:26 +00:00Commented 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)Michael Shoe– Michael Shoe2019-11-19 20:32:47 +00:00Commented Nov 19, 2019 at 20:32
-
1Yes 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.
lsis 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 usesudoto gain privileges when you need them.ctrl-alt-delor– ctrl-alt-delor2019-11-19 21:13:11 +00:00Commented Nov 19, 2019 at 21:13 -
Thank you @ctrl-alt-delor that makes sense.Michael Shoe– Michael Shoe2019-11-19 22:00:53 +00:00Commented Nov 19, 2019 at 22:00
~is short-hand for your home directory.