Basic Linux command line question

:D:D:D
These are list of command i typed on opensuse terminal and evolve lots of doubt around ,that i can't answer.

COMMAND 1   linux-xavv:/ # cd
COMMAND 2   linux-xavv:~ # 

Does above command 1 and command two with red labelled sign make different meaning or same .

1

linux-xavv:/ # pwd
/

what does that (/) means in above

2

linux-xavv:/ # cd
linux-xavv:~ # pwd
/root

After clicking cd in command line . my working directory is changed to /root .
what is difference between question 1 and 2 . Am i a root or other user

3

linux-xavv:~ # su james
james@linux-xavv:/root> pwd
/root

even after entering a user as james. i still found my working directory is /root.
am i in root or in user James account.

4

james@linux-xavv:/root> cd..
james@linux-xavv:/> pwd
/

5

james@linux-xavv:/> su
Password: 
linux-xavv:/ # pwd
/

i return to root access and found / ..does that mean i am in root or any thing else

linux-xavv:/ #

Hi,

OK, there are various things going here that perhaps need explaining. About the simplest way I can think of tackling your questions is to start with explaining what each of these commands actually does, which might help you understand what you're seeing a bit better.

pwd
This command will print out what's called your current working directory. Your working directory is the directory in the filesystem that you're in at the moment. You change directories with the..

cd
command. cd changes directories, and nothing else. So it's the command you use to change your working directory, and navigate around the filesystem.

su
The switch user command. Nearly always used as a regular user to switch to assume the permissions of the root user. root is the super-user account - that is, the account on a UNIX system that (usually) has full access to all directories and parts of the system, and has permission to run all commands.

Next, I think it would be helpful for you to realise there's a clear distinction between users and directories. Broadly speaking, every user on a UNIX system has one directory on the system reserved for their own use, called their home directory. Typing cd on its own will take you back to this home directory in almost all circumstances. But this home directory needn't have the same name as the user, and can be anything at all. Likewise, any directory on the system can take any name. Every directory on the filesystem will be owned by one particular user and one particular group.

Now, when you use su , the default behaviour will be to leave you in whatever directory you happen to be in at the time, rather than to switch you to the home directory of the user you're wanting to become. If you want it to do that (and more besides), try using the syntax su - instead. This will execute the full login environment of the user you're switching to, and so you will find your current working directory will change to their home directory.

Anyway, hope all this helps you to understand a bit more clearly what's going on here.