Log In as root from Unity GUI on Ubuntu 16.04 (But Don’t Do This)
Security Disclaimer:
There is a PROFOUND argument AGAINST enabling the root user among the extremely seasoned Linux and Ubuntu communities. This guide is PURELY intended only for use for a research, testing or home use environment on a machine (even virtual) that doesn’t contain sensitive information. NEVER USE THIS ON A COMPANY OR PRODUCTION NETWORK. EVER. NOT EVEN ON A VIRTUAL MACHINE.
For example: You having a testing or staging environment that is within your internal network at work or home, perhaps even running as a Virtual Machine (VM). You want the ability to access this environment remotely from any web browser or mobile device. Having the Unity GUI installed provides many tools for editing databases with feature rich clients like Navicat or editing code with advanced debugging tools on IDE’s like NetBeans or even SublimeText. You can also get a better view of all your Git branches with better organized and color coded clients like Git GUI or SmartGit. The benefits to having quick access to a GUI that rides on a system integral to your development process can really come in handy, and provide easy access and configuration, even if it is only for your personal use.
TL;DR – NEVER USE THIS ON A COMPANY OR PRODUCTION NETWORK. EVER. NOT EVEN ON A VIRTUAL MACHINE. THIS IS FOR RESEARCH PURPOSES ONLY.
Why use the bloated Unity Linux desktop? Why not use something more lightweight?
There really isn’t a great answer to give here for any additional nerd cred. Using a “known only to a chosen few” desktop that is ultra lightweight might be more ideal for performance. But the Unity Desktop for Linux has a very significant and profound advantage that most other Ubuntu Desktops do not:
Familiarity
Whether you are running a few little test servers from an Ubuntu Desktop installation, or you are adding a Desktop GUI to an Ubuntu Server Installation, if your system is only accessible to internal network users having root enabled should not be a security issue unless you are dealing with highly sensitive data. Oh, you’re just running a Laravel, Ember.js or WordPress Multisite test server with a Virtual Machine for experimentation or presentation? Perfect. Save yourself some headache & keystrokes by logging in as root to fix and tweak certain applications. Everyone loves ‘sudo’, but if it’s not going to make me a sandwich, I’d like to go and eat lunch sometimes. Hopefully this tutorial will save you enough time to enjoy the rare and elusive “lunch break” those folks in IT seem to enjoy for a large part of the day…
Here we go:
The permanent way is:
1:
Open a terminal windows and set-up a root password:
1 |
sudo passwd root |
Retype your choosen password, twice:
You should get the response:
1 |
root password successfully set. |
2:
Go to:
1 |
cd /usr/share/lightdm/lightdm.conf.d/ |
Use your editor (e.g. gedit, nano, vim, etc) and type:
1 |
gedit 50-ubuntu.conf |
Add the following line to the file:
1 |
greeter-show-manual-login=true |
Save file (eg: “save” or Ctrl+S>Ctrl+x, etc)
Reboot or shut down Linux and then start again.
You will now be given a greeter which will allow you to log in directly as root. This will occur every time you log in from now on.
However, in most cases log-in as an ordinary user and then use a shell and type:
1 |
su |
This will ask for the root password. Enter it and you should be logged in as root and no longer need to use the sudo
prefix to your commands that require elevated privileges.
I ran into the issue of seeing the “GUI showstopper” error in a prompt:
1 |
"mesg: ttyname failed : Inappropriate ioctl for device" |
This was a relatively simple fix from the root users profile configuration
1) Open /root/.profile
1 |
nano /root/.profile |
2) Comment or Remove the offensive line mentioning mesg
1 |
#mesg n || true |
3) Replace it with:
1 |
tty -s && mesg n |
The contents of the file will look something like this when you are done:
1 2 3 4 5 6 7 8 9 10 11 |
# ~/.profile: executed by Bourne-compatible login shells. if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fi fi #mesg n || true #comment the line above, and add the line below tty -s && mesg n |
Next: Shut down (or reboot).
You will now be given a greeter which will allow you to log in directly as root. This will occur every time you log in from now on.
Conclusion
You be able to login from the welcome login screen as any added “non-hidden” user for the Unity Desktop, but you will also have the ability to login with root and other users you may need to test various permissions and applications with.
This is NOT safe or secure, as any applications that you run in the desktop environment may have escalated privileges that could provide a back door for malicious actors.
Maybe it’ll save you “in a pinch” or tip you off to a “hack” or security breach by trying this AT HOME ONLY. Test this in a Virtual Machine first, and/or reverse the steps here to reset the designed levels of security for your desktop environment. This “trick” is only useful for testing and research purposes (pen testing, short lived VMs, never connected to a production or company network EVER).