Every one who works with Linux has heard the phrase, “Don’t login as root user”. Some of us ask many questions as to why this is the case? Why can’t I just login as root? Why should you avoid root and create a sudo account to use for administrative tasks? Let’s explain it here to see whether you can be convinced as well:
1. Running as root, mistakes become more costly and painful. When you make a blunder – a typo or something, and run a dangerous command as root, the damage is done. The unforgiving Linux won’t even ask if you are sure you want to do what you are doing. You’ll just run the mistake with full power. If you used a non-root user, you may be prompted to enter more things like a password. This additional mental engagement may be the difference between a hazard and smooth operations. And trust me, this mistakes do happen – sooner or later.
2. If you run a program as root you are at risk of handing a faulty program or malicious code full power to damage your system. If someone gets you to run/compile a malicious code as root in your server, the damage that results is catastrophic. Also, should a program have a bug, say a miscoding allows it to erase the entire /etc folder and you have it running as root, you will simply clear the /etc folder – which is probably the most important directory in the Linux file system.
3. Also, there is the concern of root being a very common user name. This makes it an obvious and easy target for brute force attacks. Having a server accessed using alternative username provides a bit of additional security. Instead of giving the attacker an easier time to guess the password only, you can make his work harder by choosing a different login username as well.
Basically, not logging in as root is an added layer of protection in your system. A protection against attackers and against yourself.