About Linux FAQ

Browse More FAQs:

How can I log in as root?

Posted by Vivek Gite [Last updated: June 5, 2008]

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:

Discussion on This FAQ

  1. John Webb Says:

    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.

  2. Dr. Fak Says:

    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.

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.