Enabling Root user in Ubuntu

Now root user in Ubuntu is by default disabled. The reason for this is simple, if you login as root user and you did some horrendous or deleted some files in a hurry or by mistake your system might become unusable, but if you still would like to enable the root user and you know what you are doing then its straight forward. Open the terminal and add the following command

$  sudo passwd root

$ <you will be prompted to add the root password twice>

add the root password. Now this will enable the root user in command line interface. If you wish to login as the root from the main system you will have to add the following line

sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'

Adding a user to sudoers list

I had been tired of getting this error for a while in my Ubuntu machine “The user is not in the sudoers list. This error will be reported”. Now this was kind of getting over my nerves so I browsed the internet and got this solution. The sudoers list is available in /etc/sudoers so to edit it login as the root and then edit it by hitting the following command visudo. Now navigate the sudoers file and just under

root ALL=(ALL) ALL

add the following line for eg. if the user is testuser to be given sudo privileges

testuser ALL=(ALL) ALL

now save the file by hitting CTRL X and Y

Adding Users and Creating Home Directory in Ubuntu

So it turns out that if you just issue useradd command in your linux machine you will create a user but there will be no home directory. Th problem the added user will not be able to login in his home directory. He can login using cli but not otherwise. So here is how to create user home directory when adding a user

sudo useradd -d /home/testuser -m testuser

sudo passwd testuser


this is a as simple as that and another way is using the adduser command in which you can add more detail for the user like phone number and all.