LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Login as root in Linux system (https://www.linuxquestions.org/questions/linux-newbie-8/login-as-root-in-linux-system-4175481057/)

mike89 10-16-2013 11:32 AM

Login as root in Linux system
 
I wanted to know when is it necessary to log in as root in a Linux system, can anyone explain to me because I'm a newbie in Linux. I don't really understand about Linux because this is my first time using Linux in my VMware.

TroN-0074 10-16-2013 11:39 AM

Is this a homework question?
Anyway I think you will need to log in as root whenever you need to make changes to your system. I mean changes on the file system, users groups, installing or removing applications. for a regular session you can just log in as user and enjoy browsing away or watching videos or whatever.

good luck to you.

mike89 10-16-2013 12:00 PM

no, I really wanna know coz I just install Linux in Vmware and I register to main user in root but it say that I should make another user and sign in to root user not the home user....thats y I'm confuse.

TobiSGD 10-16-2013 12:02 PM

The root user is only used for system maintenace, like installing programs, updating the system or changing system-wide configurations. For normal use you should always use an unprivileged user.

TroN-0074 10-16-2013 12:03 PM

Yeah you should create a user and log in as user for most of your session, just because it is really easy to mess up your system if you are logged in as root all the time.

What Linux distro are you using and what version?

suicidaleggroll 10-16-2013 12:57 PM

Simple answer:
root is used to change files/dirs (or run programs that can change files/dirs) that affect more than just yourself. A regular user can do anything they want to their own files/settings, but as soon as they try to do something that would affect other users on the system, they're blocked. root is the only one that can get past this restriction and make global changes to the system (ignoring complicated group setups and custom permissions, etc).


More accurate answer:
Regular users must abide by the permissions of any files/dirs on the system. Each file has an owner and a group, and read/write/execute permission flags for the owner, other members of its group, and "everyone else". A regular user will only be able to read that file if they are the owner and the read flag is set for the owner, or if they're a member of the same group as the file and the read flag is set for the group, or if the read flag is set for "everyone else". Same goes for write and execute. If the flag isn't set, the user can't do anything about it (the only exception is that if the file is owned by the user, the user/owner can modify the permissions as they wish).

Root does not have to abide by the permissions of the files/dirs. Root can do anything it wants, it can read files belonging to somebody else, it can delete global system files that don't have write permission, etc. On the computer, root is god.

So to answer your question, root is used whenever your regular user doesn't have the permission to do what needs to be done. Whether that's changing a system config file, restarting a service, reformatting a hard drive, adding/deleting user accounts, etc.

jamison20000e 10-16-2013 01:08 PM

Then as a normal user you use su, sudo or GUI to run as root.

jefro 10-16-2013 04:29 PM

Most distros are tying to get users to stop logging in as root. All OS's should have been doing that from the start.

It may be still best to use a user with the least amount of privileges at all times. When some action that requires higher privileges then one can sudo to root or even su to a user that has the required access.

You'd su or sudo from a terminal or some gui's that have been made to run from some admin user and requires a root password.

From a best practice point of view, you reduce exposure as much as you can. Exposing your system to a level with unlimited rights could present a security issue. Behind scenes programs could take advantage in this instance.

Still I get lazy and run su. Some distro's may have broken apps and I may need to actually log on to a root user once in a great while.

khamsamay 10-17-2013 08:07 AM

I understand that you may user for windows before.
it is easy to think that when you log in as administrator on windows, windows not warn you
so you can easily install-delete all software or change the system files.
but when you are newbie on linux , Linux will warn you that when you log in as root user
you may change the system file without intention.

jamison20000e 10-17-2013 08:13 AM

not doing so probably eliminates lots of catastrophic failures and their need for help

DavidMcCann 10-17-2013 10:47 AM

Running as root also has the security risk that any malware can wind up anywhere on the system, because it's all accessible. You're not likely to get malware on Linux, but if ever you did, it's nice to know that it can't escape from /home!

ironhand41 10-17-2013 12:47 PM

From another newbie
 
I'm about a year into a dual-boot system (Win7 & Zorin 6.0) with the intention of leaving Winders behind forever now that I'm retired. I'm still getting my feet wet with Linux but in my experience you WILL need to do a few things as root. After wasting too much of my time when Linux would prevent me from opening particular files and folders (NOT system files, just files and folders I use in the normal course of a computing session) I taped a piece of paper to the bezel of my PC monitor that reads "root = gksudo nautilus." Typing that at the command line (or "bash" or whatever it is called in Linux) I can now quickly change the permissions of files and folders. So, I don't need a separate log-in account for root. The experts will caution you against running as root all or even most of the time and that is good advice. But I would rate the numerous occasions when Linux prevented me from opening files and folders because of the permissions issue, as one of the top three frustrations I've had with this new operating system. But I love it and enjoy the learning experience!

Cheers,

ironhand41

Zorin-OS 6 64bit/Win7x64 dual boot
SYX Venture A 1851 All-in-one PC; Model: SYX-GB-AEBN-SI: Genuine Intel® CPU i3-2120 @ 3.30 GHzx4:Ram 8 GiB DDR3.
SSD: Samsung 830; 512 GB
LCD 18.5": Resolution 1366x768.
802.11b/g/n Wireless.
Wired Verizon Fios Connection: 1000 Mb/s.

jamison20000e 10-17-2013 12:59 PM

Code:

man chown
man chmod


mike89 10-19-2013 02:03 PM

Something wrong again....maybe this is stupid question but how to solve problems created by a superuser

suicidaleggroll 10-19-2013 02:10 PM

Quote:

Originally Posted by mike89 (Post 5048710)
Something wrong again....maybe this is stupid question but how to solve problems created by a superuser

Depends on what was done. Somebody who doesn't know what they're doing as root could easily destroy a system to the point of needing to wipe it and reinstall from scratch.


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