Q. How do I log in as the root user under Linux / UNIX operating system?
A. Under Linux, UNIX and *BSD root user act as superuser. Root user is the conventional name of the user who has all rights or permissions. The root user can do many things an ordinary user cannot, such as changing the ownership of files, mounting disk, formatting and restating new file system and binding to ports numbered below 1024 etc (see Supperuser/Rootuser at wikipedia).
Generally, it is not good practice for anyone to use root as their normal user account, because of security risks. Therefore, you use a normal user account instead. You need to use the su command to switch to root. Sudo command also provides same facility in secure manner.
su command
su command is use to change user ID or become super-user during a login session.
su command syntax
su - {user-name}
If invoked without a user-name, su defaults to becoming the super user. The user will be prompted for a password, if appropriate.
To log in as root user type following command (you need to supply root user password):
$ su -
Sample output:
Password: ******* #
Once logged in, your prompt should change from $ to #. To log in as another user (called vivek) type following command (you need to supply vivek user password):
$ su - Vivek
Password:
Remote root login over ssh session
Simply use ssh client as follows:
$ ssh root@remote-server.com
$ ssh root@remote-server-ip-address
$ ssh root@220.1.2.3
Most system disable direct remote root login over ssh session. First login as normal user and then switch to root using su command:
$ ssh vivek@remote-server.com
$ su -
sudo command
sudo is a program for Linux / BSD / Unix-like computer operating systems that allows users to run programs with the security privileges of another user normally the superuser (root). By default, sudo will prompt for a user password but it may be configured to require the root password or no password at all. Apple Mac OS X and Ubuntu Linux and many other oses used sudo command for many administrative tasks. For example, to login as root under Ubuntu Linux, type:
$ sudo bash
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -


{ 16 comments… read them below or add one }
I have installed ubuntu and always log in as user. I have read the HOW TOO’s but I am confused by the comment ‘Make sure you use the root password.’ How can you use a root password when you haven’t got one (I think) because the only password I use is the password I gave when I installed Ubuntu (dapper Drake). Is this a root password also if you say it’s root as time of login. If you have to have a seperate login root password – How do you get it? Thanks john6.
By default, the root account password is locked in Ubuntu. This means that you cannot login as root directly or use the su command to become the root user. However, since the root account physically exists it is still possible to run programs with root-level privileges.
Hmmm, lets see Can not log in as : \ SU Thought Ubuntu is open source The only why you can adjust the Kernel is as root. what they hiddin willis.
opp’s should have read more of the reply’s. but as a openBSD user never really had this issue.
Thank you very much for this help!
To all the latin people…..here is the answer in spanish:
Escriban “su -” para cambiar al root. Les pedira la clave del root.
Escriban “su – gon” para cambiar al usuario llamado gon. Les pedira la clave.
Thanks again.
Cheers.
John.
You can change your root password by typing in console” sudo passwd root ” By doing this i had to enter my user password then set a new root password and repeat it.
Thanks
thnx. by default there is no password for root, hve to get by typing ”sudo passwd root”.
Thanks for this article and to AIS/fahim for the additional information about how to change the root password! Just what I was looking for.
AIS, thanks a lot
The question is still unanswered.
To login as root is very convenience and very important for some applications. Without it, you may not be able to run those programs at all. Su is good but with great limitation.
So if anyone who know the answer, please help. We do not need advise about workaround.
After 5 minutes of browsing on the Internet, I found it is very easy to make the changes so you can login as root from GUI. This is for Fedora 11:
First, (dangerous?) you must su and login as root then cd to /etc/pam.d
There are two files: gdm and gdm-password. Use your editor and
Comment this statement for both files:
# auth required pam_succeed_if.so user != root quiet
Save and logout. Try login as root. You should be.
After login as root and play around, I found the above changes were not enough. Thanks to my-guides.net, I found the last piece that fixed the problem.
You need to edit another file: /etc/PolicyKit/PolicyKit.conf
and add
between .
That will do the job.
The missing statement between <config></config> is
<match user=”root”><return result=”yes” /><match>
Thanks a tonnnnn Gregory. Somehow I could never find the answer for this , instead of getting ridiculed for wanting this. :)
Thanks for command “sudo passwd root” !!