How can I log in as root?
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
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Can I create another root user account in Linux / UNIX?
- Find Out Linux Kernel Modules ( Drivers ) Location / Directory
- Linux / UNIX find the smallest directories or files in current directory
- What is My root Password for MySQL Database Server?
- Howto: Prevent root user from being able to log in via SSH service
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: change user id, how to log in as root, how to log in as root user, how to log on as root, how to login as root, log as root, log in as root, log on as root, login as root, login root, permissions, root login, su command, sudo command



September 9th, 2007 at 11:09 pm
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.
September 13th, 2007 at 7:38 pm
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.