Login as root on the Ubuntu System
Desktop - Ubuntu

Login

On an Ubuntu system the first user created, in this example the user mike, is designed to be the administrator of the system so that user is placed in additional groups in order to perform the tasks of an administrator. You can see from the illustration that this first user will be able to use "sudo" and administrate commands, dialup options, the CD/DVD, removable media, printing, samba and all of the necessary commands in between.

 

cat /etc/group

adm:x:4:mike

dialout:x:20:mike

cdrom:x:24:mike

plugdev:x:46:mike

mike:x:1000:

lpadmin:x:112:mike

sambashare:x:113:mike

admin:x:114:mike

 

How does this impact login? Well, as a security precaution you will not be able to login as root, you must login as this first user with administrative privileges and then use the sudo command to elevate the privileges of this user to root in order to perform tasks that only root can perform. Here is an example:

 

fdisk -l

Command 'fdisk' is available in '/sbin/fdisk'

The command could not be located because '/sbin' is not included in the PATH environment variable.

This is most likely caused by the lack of administrative privileges associated with your user account.

fdisk: command not found

 

 

So again, as this administrative user, now add the full path for the command and see what happens...nothing.

/sbin/fdisk -l

 

The result of the output, nothing, indicates this user does not have the rights to execute the command. So now try this, note you will be asked to provide the password for this administrative user:

 

 

sudo /sbin/fdisk -l

[sudo] password for mike:

 

Disk /dev/sda: 30.0 GB, 30005821440 bytes

255 heads, 63 sectors/track, 3648 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x46ac46ac

 

Device Boot Start End Blocks Id System

/dev/sda1 * 1 13 96256 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 13 1228 9765888 83 Linux

/dev/sda3 1228 1350 976896 82 Linux swap / Solaris

/dev/sda4 1350 1958 4881409 5 Extended

/dev/sda5 1350 1958 4881408 83 Linux

 

Disk /dev/dm-0: 1000 MB, 1000341504 bytes

255 heads, 63 sectors/track, 121 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x9e93132d

 

Obviously the command works for this first user who is an administrator, only if the sudo command is used to escalate the privileges of this user to root in order to execute that one command. That works fine but as that administrative user, you will always need to type the full path to each command. There is an easier way.

 

If you are going to log into a server and perform hours of administration which only the root user can perform, it may be preferable to create a login for root so that on some occasions you do not have to use the sudo command. Here is how you can make that happen.

 

Login as the administrative user and access the root privileges.

 

sudo su

su -

passwd

 

Now you will be able to login as root if you are going to work at tasks for a long period of time that only root can perform. You will also not have to type the full path for commands as those directories are in the path of the root user.

 

Now, be aware that this technique goes around the default Ubuntu set up that will not allow anyone to login as root. However, if you use it carefully it can be done safely.

The Ubuntu system requires you to login as an administrative user to be able to execute commands that only root can execute. However, you can alter the system to allow root to login to perform hours of administration as root. This eliminates the requirement of typing the full path for commands.