I created an Ubuntu server. Do I have a "root" user?

3

I always thought "root" was a default user created when you install basically any Linux. During installation, it asked me to choose a username, so I picked "devadmin". Is that my "root" user now?

orokusaki

Posted 2012-03-03T17:25:52.483

Reputation: 1 044

Answers

7

You have a single user, who can use sudo.

To become actually root:

sudo su

To HAVE a root account:

sudo passwd root 

(then type a new password, and that will be your new root account's password.)

Apache

Posted 2012-03-03T17:25:52.483

Reputation: 14 755

Is there any reason to make a root account? Also, with a root account do you still have to type sudo, or does root have all permissions without sudo-ing? – orokusaki – 2012-03-03T18:06:12.090

2

@orokusaki It's bad to run everything as root. You don't work as SYSTEM on Windows either. Your regular user is probably a sudoer (man sudo/man sudoers) though, so you can "become root" for specific administrative tasks limited in scope.

– Daniel Beck – 2012-03-03T18:31:26.640

1@DanielBeck: There is nothing wrong with having a root user on your computer. Sure, great power, comes with great responsibility. But you can do stupid things even with sudo. Or even as a single user. So it's not like you break anything. (And root is been around for ever. Only Ubuntu started this trend, to disable it and have a sudo instead.) – Apache – 2012-03-03T18:33:10.653

@orokusaki The root account always exists, but by default does not have a password (so you cannot actually log in to the system as root). The second command shown here first makes you impersonate root, and then sets a password. This'll allow you to log in as root, if you really want to (unless you have a very good reason, you probably don't). – Daniel Beck – 2012-03-03T18:33:23.673

3Note that sudo su can be replaced by sudo -s. Both open a root shell for the current user who must be a sudoer. – Daniel Beck – 2012-03-03T18:35:50.970

1@Shiki It might be true that only Ubuntu started it rather recently (and I seriously doubt it), but that doesn't mean using the root account like a regular user account isn't a bad idea. --no-preserve-root is also a pretty recent addition to rm. Chances are, given the question, orokusaki is not experienced enough to be aware of all the implications. It's only safe advice to say: Unless there's a very good reason, don't do it. – Daniel Beck – 2012-03-03T18:38:47.363

Thanks guys for all the comments. I've actually learned a lot from the answer and the comments here. – orokusaki – 2012-03-03T18:49:10.350

If I accidentally misnamed my user account during the initial installation, for example if I type "devdmin" instead of "devadmin", is there a way to change that account username?

The reason I ask is because I created an ubuntu server VM on VirtualBox, and when I mount a shared folder, it says it belongs to my misnamed initial user account, e.g. "devdmin". Now I have to use sudo to edit any of the files within the shared folder. – user1027169 – 2013-01-14T00:41:28.197

4

On every Linux system, there is a root account. It's safer to not use it for everyday tasks though, because careless typos on the command shell or bugs in software could otherwise seriously mess up your system.

The root account might not have a password, so you're not able to directly log in as root. But your primary user account is probably one of the sudoers, users able to use the sudo program to execute specific programs as root (sudo whoami) or, for longer administrative tasks requiring multiple steps, open a shell as root (sudo -s).

By running sudo passwd, you can set a password for root if you really need it, but it's likely that you don't and will just invite accidents like accidental file deletions.

Daniel Beck

Posted 2012-03-03T17:25:52.483

Reputation: 98 421

3

If you need a root shell for a longer time you could use the -s option with the sudo command:

Just type

sudo -s

to create a permanent root shell. And type

exit

to leave the root shell when you're done with your work.

l1zard

Posted 2012-03-03T17:25:52.483

Reputation: 933