what's the difference ~ # and / #?

alfian

New Member
hello linuxers,

what's the difference ~ # and / #?

I use the terminal command: su - for ~ #

and

I use in the terminal command: su
for /#

please explain me, many thanks.
 


dos2unix

Active Member
What the prompt looks like doesn't really matter that much. Although I do set different prompts for different users, so I know who I am logged in as.

You probably don't realize it, but what really changes your prompt here is the dash "-".

su (without a dash)
will change you to another user, but you don't get that person's environmental variables.

su - (with a dash) will not not only switch you to another user, but it will give you their environmental variables as well.

There can do dozens of these environmental variables.
But in your case, the home directory is one of them.

cd ~ always puts in the home directory of whoever you are logged in as.

Usually when you su - you automatically go the home directory of that user.
Usually when you su (no dash) you stay in the same directory you were in before.
It appears you were in / (root).

You can always type "pwd" (print working directory)
to test this.
 
Last edited:

Members online


Top