Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
share|improve this question
4  
It's a bad idea running everything as root. It ruins security.And i don want to give bad advice. There is a very good reasons that Linux is quite secure and that services run under their own users. –  tomodachi Aug 4 '12 at 0:25
2  
You don't want to do that. There is a way to temporarily become root to run certain commands, called "sudo" for commandline programs, or "gksudo" for graphical programs. In your case, use `sudo service nginx start", which will require your password. –  Marty Fried Aug 4 '12 at 0:33
2  
does a bad idea have to mean you have to downvote? –  Pineapple Under the Sea Aug 4 '12 at 0:43
    
Duplicate of: askubuntu.com/questions/135428/… –  david6 Aug 4 '12 at 1:28

2 Answers 2

up vote 5 down vote accepted

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

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.

share|improve this answer
2  
Keith is exactly right. If you have a few things you need to do at some time, and simply must save a few keystrokes, you can enter sudo bash and keep the shell open just to do what you need to do. The use of sudo has evolved as a "best practice" after demand from administrators and users who have made countless awful mistakes over the last few decades. –  John S Gruber Aug 4 '12 at 1:44

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.

share|improve this answer
    
No need to set a password for root; sudo bash gives you a root shell. –  Keith Thompson Aug 4 '12 at 4:32
    
Well I dont know. Ive always set a passwort for root. Eg. if your new user password is lost or forgotten, or you couldnt log into your account for whatever reason you could repair this issue, when having activate the root user. Its a second chance. I dont see no obvious reason not to set root password. But I know its almost a religious discussion with good argument on both sides ;-) –  gemue2010 Aug 4 '12 at 6:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.