Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have setup my ubuntu 12.04 LTS (unity) to auto login after the computer is turned on after a power outage. so that the web server installed keeps running. but also i have to lock the computer right after logging in so that no one can use it other than me. How would i do that.

gnome-screensaver-command -l does lock the computer. but manaully. i want it automated after login.

I dont want anyone to be using the computer other than me.

share|improve this question
The better option is to set your webserver to run at boot, regardless of whether anyone is logged in or not... – izx Jul 18 '12 at 18:38
@izx if its apache or nginx or lighttpd or one of the ones in the repo (except Node.js and maybe a few other backends), it should auto start at boot. See my answer. – Thomas Ward Jul 18 '12 at 18:45
@LordofTime: I imagined so, but wasn't sure if he was running something esoteric... :) Thanks, upvoted. – izx Jul 18 '12 at 18:47

When you install a web server, you don't need to "login" to run that web server.

Web servers such as apache or nginx start up at boot time with their parent process run by root (to bind to ports). Subsequent child processes are generally started with the user or group specified in the configs. Therefore, your computer can be on but not logged in, and your system will still run the web server. Remote administration can be done by SSH whether you're logged in via the GUI or not.

Therefore, there is no need for autologin to make the webserver work (unless its a weird Node.js or some other backend that needs to be manually started by a user).

share|improve this answer
thanks i did not know that. but anyway i would want it to lockup after auto login. i have managed it by inserting gnome-screensaver-command -l command in startup applications. it works till now. is it the right way. or is thr any better one – Saad Masood Jul 18 '12 at 18:54
That way you have there is a method, but you may want to just consider disabling autologin, given that web servers will normally just load at boot, thereby not needing autologin – Thomas Ward Jul 18 '12 at 19:51… answered here – dedunumax Jun 23 '15 at 4:09

Your Answer


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.