LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Root Confusion (https://www.linuxquestions.org/questions/linux-newbie-8/root-confusion-443320/)

kajensen 05-10-2006 12:40 AM

Root Confusion
 


I understand that some functions can be executed in the GUI and others via the terminal and some in both.

What about signing into the terminal as root? Does this mean that if I then go to an app which I want to move to the trash with my mouse that I am still functioning as root user? Meaning, if I leave the terminal am I still logged on as root user? By "leave" I mean minimize, so that the task appears in queue in Nautilus.

When I boot I have the choice of entering my root password. Is this what I do when I want to function as root in the GNOME GUI??

Please clarify. Thanks for your help.

nadroj 05-10-2006 01:26 AM

you should never log into the GUI as the root user.. use root for as little as possible--its specifically for system administration ONLY! you could render your OS install useless if used improperly.

always log into your GUI as your normal user account.. when you need the root account for, say, installing a program, then open up a terminal and use 'su' to switch to root user temporarily, or 'sudo'.

if you open a terminal program while in your GUI, and switch user to root, it only applies to what you do in that window... if you minimize it (or dont) and switch to another task, you are still using your account that you initially logged into the GUI with. if you use 'su', make sure to use 'exit' when your done.

also note the prompt in terminal windows... '$' represents a normal user.. '#' represents su/root and is a warning to be careful.

hope this clears things up a little

J.W. 05-10-2006 01:53 AM

nadroj'a advice is good. Basically, you want to run as a regular using account all the time, except in limited, rare situations where you must be root (such as when you are installing new packages). With regards to your question, if you start a terminal session aka console session aka command line session, you should just use your regular user account. Running as root is a poor idea, as the chances of accidentally performing (unrecoverable) actions is pretty high - all it takes is to run an "rm" command from the wrong directory, and you could trash your entire system.

Overall, stay in regular user mode, and if you need to switch to root, use "su", and immediately switch back to your regular user as soon as you're done

SweetLou 05-10-2006 02:34 AM

Quote:

Originally Posted by nadroj
if you open a terminal program while in your GUI, and switch user to root, it only applies to what you do in that window... if you minimize it (or dont) and switch to another task, you are still using your account that you initially logged into the GUI with. if you use 'su', make sure to use 'exit' when your done.

Not quite true, but mostly true. You can as root open a program an use that as root outside of the terminal window. For example I often open Nautilus as root from the terminal when I know I will be moving, editing, etc files. I will find the file in Nautilus and then open gedit to edit it.

reddazz 05-10-2006 02:57 AM

Quote:

Originally Posted by SweetLou
Not quite true, but mostly true. You can as root open a program an use that as root outside of the terminal window. For example I often open Nautilus as root from the terminal when I know I will be moving, editing, etc files. I will find the file in Nautilus and then open gedit to edit it.

I think nandroj was referring to an entirely CLI based session (thats my intepretation from his post). Obviously if you start GUI apps as root in your normal user login, they will always be running as root until you terminate them.

pixellany 05-10-2006 07:54 AM

In spite of the good advice to not log in to the GUI as root, note that you CAN do that....

To clarify several answers: any application--including the GUI dekstop--is opened by a user. Thus, when you log in to the GUI, you establish the user for the environment + anything opened later. When you become root in a terminal, it only applies to what you do in the terminal.

By opening an app as root (from the terminal), you can create a situation where you have GUI root privileges for that app--but still not for other things running on your desktop.

Bottom Line: Be careful!!!!

nadroj 05-10-2006 12:59 PM

Quote:

Originally Posted by SweetLou
Not quite true, but mostly true. You can as root open a program an use that as root outside of the terminal window. For example I often open Nautilus as root from the terminal when I know I will be moving, editing, etc files. I will find the file in Nautilus and then open gedit to edit it.

yes, of course you can use a GUI app (or any app!) as root launched through the terminal. ie 'vi' is a program.. just like Nautilus. i can use 'vi' as root and whatever i do in 'vi' will be done with the root user and it's privledges. same with nautilus. i can launch that app from the console as root, and i will then be using nautilus as root.. so i can go ahead and delete any file i want to and wont get messages saying i dont have rights to.
i didnt (or at least didnt meant to) imply that you cant launch GUI apps as root. sorry

kajensen 05-17-2006 03:32 PM



If I am in a terminal session as root and then do something with my mouse in GNOME (e.g. delete a file), am I still functioning as root in my GNOME (GUI) session?

I read your posts carefully but I think there was confusion on this point.

And if I'm at a terminal as root how do I return to normal user? By typing exit??

reddazz 05-17-2006 03:37 PM

If you have logged in as a normal user, then start a terminal and switch to root, any mouse clicks you make are still done as a normal user. You exit the root session by entering "exit", "logout" or CTRL-D. If you are logged into a terminal as root and you start a gui app, then that app will have root privileges even if you are logged in as a normal user.

pixellany 05-17-2006 10:33 PM

Quote:

Originally Posted by reddazz
If you have logged in as a normal user, then start a terminal and switch to root, any mouse clicks you make are still done as a normal user. You exit the root session by entering "exit", "logout" or CTRL-D. If you are logged into a terminal as root and you start a gui app, then that app will have root privileges even if you are logged in as a normal user.

Maybe it will help to realize that--as far as your machine knows--you are two different people. Person #1 is logged in to the GUI with normal privileges, Person #2 has root privileges in the terminal. In fact, these two people could be doing things simultaneously---with no knowledge of what the other is doing. You could give the mouse to one and the keyboard to the other---and both be running things, changing files, whatever. What make it interesting is that #2 (root)--running in the terminal--could open a text editor which would appear on #1's GUI screen. As you can see, this quickly becomes convoluted.
Bottom line---keep your multiple personalities under control.....;)


All times are GMT -5. The time now is 09:43 AM.