Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

my system requires to run automatically at start up. so, i did write a simple module and registered it inside /inittab. it automatically runs at start up but the problem is when i turn on the computer it should automatically log on as a root.

is there any way to do this?

by the way im using 2.6.29 of the kernel version.

thanks in advance.

share|improve this question

migrated from Apr 18 '12 at 0:18

This question came from our site for professional and enthusiast programmers.

... Why would you write a module to log in as root? Wouldn't it be easier to just modify the startup scripts? – Ignacio Vazquez-Abrams Apr 17 '12 at 16:16
@IgnacioVazquez-Abrams: It doesn't sound like "module" is being used in the sense of "kernel module", since inittab is somehow involved. – Ben Voigt Apr 17 '12 at 17:31
@Daniel Andersson, i already tried this options and came with error: /bin/sh: exec: line 1: /sbin/login: not found so where is login file? – mashhur Apr 18 '12 at 7:55
You haven't told us which operating system (=distribution in this case) you are using, but an easy way to find the login binary is to run which login, which will most likely say /bin/login for you. – Daniel Andersson Apr 18 '12 at 8:00
up vote 0 down vote accepted

Since the way using the existing init fails, use the kernel's settings.

When you boot, add init=/bin/bash to your kernel command-line - this forces it to bypass Upstart and should give you a single user shell, since the kernel spawns bash off as the root user.

share|improve this answer
thanks new123456 :) your name and answer are cool! that is what im looking for. And if you know please tell me how to run a program after getting bash. Let's say in root folder, there is a "main" program that prints "Hello World" 100 times. when kernel starts and get's bash console main program should run. please any ideas! thanks. – mashhur Apr 20 '12 at 2:12
@mashur Automatically? Login and edit the program into~/.bashrc. So, for root, add /hello to the end of /root/.bashrc. – new123456 Apr 20 '12 at 3:07

If you set the runlevel to 1 and it is rhel/centos or similar distributions, and there is no other security systems set up, it will automatically log in as root. You then would have to start various services such as networking and programs yourself.

share|improve this answer
hello jhonshen64! thanks to your express answer :) and i did as u said but right here im lil bit confusing. after changing runlevel to 1: Enabling swap space: [ OK ] INIT: Entering runlevel: 1 Entering non-interactive startup Telling INIT to go to single user mode. init: /dev/initctl: No such file or directory INIT: no more processes left in this runlevel So, do these these messages telling me to write a char device driver named /dev/initctl and run my program through that driver? – mashhur Apr 18 '12 at 0:26
in order to do autorun i used init=/bin/bash and to run an application after getting logging on, wrote a runnable script (sysV script) PROBLEM SOLVED – mashhur Apr 25 '12 at 5:06

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.