Short answer: don't do that.
If you want to run several commands as root, you can use sudo su -
to get a root shell. This is useful if you're doing system maintenance, I personally do this when administering servers.
Other than that, it's a good habit to use sudo
if and only if it's really necessary. This is both for security reasons and you're less likely to mess up your system.
If you find it annoying that you have to type your password too often, you could do a couple of things:
Extend the timeout for sudo
Edit /etc/sudoers
(always use this command, never edit it any other way!):
sudo visudo
Find the line similar to this one:
Defaults env_reset
Change it like so:
Defaults env_reset,timestamp_timeout=30
This will make sudo
ask for your password only if you haven't used sudo
for 30 minutes.
Tell sudo
not to ask password for specific commands
On one of my systems I use mount
very often and it usually requires root permissions. For convenience, I've set up sudo
so it doesn't require password for the mount
command if you're in the "wheel" group. To achieve this, add a line as such to /etc/sudoers
, again, using sudo visudo
:
%wheel ALL=(ALL) NOPASSWD: /usr/bin/mount
Change /usr/bin/mount
to whatever command you wish.
If you really, really, really want to use root as your normal user, and you understand the risks, use this tutorial. But again, you could also do it right.
sudo su
to be in a root shell without enabling the root account login.