kernel - Autologin as root or as any other user in Linux in console mode

05
2014-04
  • mashhur

    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.

  • Answers
  • new123456

    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.

  • johnshen64

    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.


  • Related Question

    In Linux, is working as su the same as working as root?
  • Yarin

    I thought that using su as a regular user made you root temporarily, but encountered an issue where I get "bash: usermod: command not found" when I try to perform a usermod with su, whereas the command definitely exists when I log in as root.

    Are super user and root different things? If so, what limitations should I be aware of?


  • Related Answers
  • David Z

    There's no difference between "the super user" and "root". But the thing is, su (which actually stands for "switch user", I believe) doesn't entirely emulate the environment you would get if you logged in directly as root. For instance, usually when you run su, environment variables from your current shell are carried over to the subshell in which you're logged in as root. (Except for PATH; see the man page for details)

    To get around this, you can use the -l (or --login) option to su, which will attempt to duplicate the environment you would get if you actually logged in as root.