1

I want to login as user 'root' in bash shell, but do not know the password of it. Here I am talking about the user which i have found in passwd as below:

sudo cat /etc/passwd
root:x:0:0:root:/root:/bin/bash

So, my basic question is that can we able to login as 'root' user or not? if yes and some know about it, let me know.

Thank you.

2 Answers2

3

Yes, it is possible. Log in to your administrator account and then run sudo su root. Enter your password and then you are logged in as root.

(Usually the root prompt looks similar to this: root@computername:~# (note the # instead of the $))

NOTE: be careful when you do that, everything you command is done immediately without asking for a password (just in case you didn't know)

Instead of logging in to the root account you might want to use sudo and your command (e.g. sudo apt-get update).

EDIT: "[...] The [root] password is set to a special value which doesn't match any possible key combination." - fkraiem

Kai
  • 182
  • 7
  • "As far as I know there is no root password set." More accurately, the password is set to a special value which doesn't match any possible key combination. "No password" generally means you can login without a password. – fkraiem Jul 07 '14 at 14:45
  • Oh, thanks, good to know. May I quote you in my answer? – Kai Jul 07 '14 at 15:06
  • Sure. :) (Additional characters to reach the limit.) – fkraiem Jul 07 '14 at 15:27
  • Thanks :) Is the way I quoted you ok? – Kai Jul 08 '14 at 18:01
  • Yes, it's fine. – fkraiem Jul 08 '14 at 19:47
  • By the way, despite what its name implies, /etc/passwd does not contain password-related data. The passwords (in hashed form) are in /etc/shadow (you see that root's password looks different from that of a regular user). – fkraiem Jul 08 '14 at 19:52
  • Ah, I see. The root account has a '!' on my system in the password field which means that this user can not log in using a unix password (according to the manual page shadow(5)) – Kai Jul 08 '14 at 20:05
0

It is worth to note you can run commands as root by putting a sudo in front of it as well. For example:

sudo chown user:user filename

ryekayo
  • 581
  • I knew that sudo behave as root user. Even i would like to know how can i login as 'root' user. So, i have asked this. Thank you ('_'). – Harikrishna Jul 10 '14 at 12:08
  • Okie dokie, I only mention it because using sudo is safer than staying logged in as root – ryekayo Jul 10 '14 at 12:10