How can I run everything as root
I have dual booted to lubuntu (with Windows XP) and everytime and then I'm getting asked for my password. How do I run everything as root and not ask a password again? Ideally I wanted to run nginx but it has permission denied issues:
apathetic@ubuntu:~$ service nginx start
Starting nginx: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2012/08/03 20:06:25 [warn] 4762#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2012/08/03 20:06:25 [emerg] 4762#0: open() "/var/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed
It's a bad idea to run everything as root.
For things that actually need to be run as root (which includes service nginx start
), the best way is to use sudo
:
sudo service nginx start
By default, this will ask for your password if you haven't entered it in the last 15 minutes.
You can configure /etc/sudoers
to let you run commands as root without entering your password using NOPASSWD
. man sudoers
for details.
(The visudo
command is the recommended way to edit /etc/sudoers
.)
If you insist on executing commands directly as root, you can launch a root shell with
sudo bash
or
sudo -i
(equivalent to sudo --login
).
My advice: Don't do this. Typing sudo
for every command that actually needs root access helps remind you not to use it unnecessarily. It's very easy to shoot yourself in the foot.
you can use the sudo command, at the front of your command string to run something as root;
i.e. #sudo service nginx start
If you want to run as root "all the time" (not a great idea), you can set a password for the root user (sudo passwd) and then login, or su to root.
If you are just looking to run this service as root "all the time" then you can add it to /etc/rc.local and this will start the service as root at boot time?
I hope that this helps.