LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to enable auto login as a root (https://www.linuxquestions.org/questions/linux-software-2/how-to-enable-auto-login-as-a-root-798323/)

PTrenholme 03-29-2010 12:27 PM

By way of clarification, I think that, when you said you want "to enable auto login as a root," what you actually meant (from your description) what that you want root to be displayed as one of the "user" choices when the display manager request you to log in to the window manager after the boot process is finished and the X-server is started. The fundamental problem with this is, I believe (but I may be wrong), that root's "home"directory is not in /home with all the other users. Instead, root has a separate, independent, "home" directory: /root.

Anyhow, I just did this (on a Fedora 12 system using KDM, so YMMV):
Code:

$ su -
Password:
# ln -s /root /home/root
# ls /home/

Peter  root

Then I went to the login manager and root was listed as an available user (after the "exclude user" check box was unchecked).

Note, however, that I did that by starting a terminal session as "root" with the su - command, which will not work on Ubuntu unless you unlock the root login (which you said you did.).

If you can start a "root" terminal session, you can (almost) always start a window manager session for "root" by entering the command startx -- :1, which starts a second X-server on tty8 with "root" already logged in. (It also leaves your non-root session on tty7 running. You can switch between those session with <ctrl>-<alt>-<F7> and <ctrl>-<alt>-<F8> key combinations.)

Note: For session switching to work, you need a /etc/X11/xorg.conf file that contains the following stanza:
Code:

Section "ServerFlags"
        Option      "DontZap" "off"
        Option      "DontVTSwitch" "off"
        Option      "HandleSpecialKeys" "Always"
EndSection


cimek 03-30-2010 03:54 PM

Thanks PTrenholme. You are right, Ubuntu is different and even easier in this particular case. You can set up new user called ROOT with full account and it's folder directly in "User and Accounts" manager from administration panel. But even then root still doesn't appear in the login and autologin list. And is no "exclude user"check box in there.
The problem is that root has been locked somewhere in the gdmsetup preferences and is excluded from any settings. I tried to alter custom.conf on my own but it says acces is danied. Even for a root. Is anything above the ROOT? Do we have "Super Root" or God Root" in the linux?
I have sent a message to the link above (thanx bret381) and still waiting for answer.
When have any news will post it here.

Skaperen 03-30-2010 04:18 PM

Everyone seems to be saying this is a very bad idea to make root autologin. I disagree when this involves autologging in on the physical console. I do agree that casual use of the computer with all root power enabled is a bad idea. My disagreement is regarding the autologin aspect. Certainly it is a VERY VERY bad idea to have root be password-less via net access (unless your goal is to make a "honey pot" system and you should not be doing that if you need to ask how to do this here).

If someone has physical access to the computer, the can probably boot any Live CD or Live USB flash drive of their choice, and be their own root, anyway. There is little protection by requiring a login on the console. This depends on the people in the environment. If you have clueless morons wandering around typing bad commands but who cannot figure out how to get into a computer with a Live CD, then maybe not autologging will be a good thing for you.

If you think you have locked your children out of your computer via a password, and these children can get a Live CD and get to your computer when you are not around, you better rethink the situation (I've heard of someone that runs his server inside a gun safe).

I have set up autologin to root before on a few distributions. I don't have the Ubuntu variation handy. I do this on Slackware by having an entry in /etc/inittab like:
Code:

c1:12345:respawn:/sbin/agetty -n -l /etc/autologin 38400 tty1 linux
where the file /etc/autologin is a script something like what I have:
Code:

#!/bin/bash
pid="$$"
dev=$( /usr/bin/find "/proc/${pid}/fd/0" -maxdepth 0 -type l -printf '%l\n' )
tty=$( echo "${dev}" | /usr/bin/cut -d / -f 3 )
speed=$( /usr/bin/stty -a | /usr/bin/head -1 | /usr/bin/cut -d ' ' -f 2 )
if [[ -x "/etc/autologin-${tty}-OK" ]]; then
        echo ""
        echo "Welcome to `exec uname -s` `exec uname -r`."
        echo ""
        echo "`exec uname -n` login: root"
        echo "Password:"
        cd /root
        export AUTOLOGIN=1
        export AUTOLOGIN_DEV="${dev}"
        export AUTOLOGIN_TTY="${tty}"
        export AUTOLOGIN_SPEED="${speed}"
        exec /bin/su -
fi
if [[ -c "${dev}" ]]; then
        exec /sbin/agetty "${speed}" "${tty}" linux
fi
echo "Unable to enable console ${dev}"
if [[ -x /bin/sleep ]]; then
        exec /bin/sleep 3600
fi
exec /usr/bin/sleep 3600

You can customize it to suit your needs. If you system (e.g. Ubuntu) does not use /etc/inittab, you'll need to find another way to fit this in. Grep around for files that have "getty" in them as they may be what gets run, or read, to perform login startups.

If the distribution has a Live CD available, you can also pick apart the Live CD to see how it is done in there.

If you want a graphical autologin, this goes beyond my experience. See the previous paragraph.

Quakeboy02 03-30-2010 06:32 PM

What are you doing that you have to be root/sudo so often that it's an aggravation?

John VV 03-30-2010 06:50 PM

Quote:

What are you doing that you have to be root/sudo so often that it's an aggravation?
i was thinking the same

now it is nice to be able to login as root every now and then ( restoring from back-up and things like that)

nautilus - gnome and dolphin - kde can be started from the terminal as root even though you might be loged in as a normal user

installing software is for the most part the main reason ( pacman,yum,... ) or configure ,make " su " make install

reading some log files like
/var/log/errors.log and iptables.log ( need to be root )

cimek 03-31-2010 06:53 PM

Thank you Skaperen. The file you described in Ubuntu is called GETTY. You can find it in

/sbin/getty

It's quite big file, I give it more attention later because I have found something in the other place. In fact it not fulfills exactly what I expected of it, but final effect is same.
The file which keep the secret is "custom.conf" but let's start from beginning.

In the new installed and updated system log in as a ordinary user.
Open terminal and type:
[sudo passwd root
when prompt type your password
when prompted type new root password
when prompted retype new root password

Then restart and log in as a ROOT.
Open "Users and Groups" in "administration tab"
Select "root" and go to "Advanced Settings".
Tick all possible "User Privileges".
Close and go to "Login Screen" in "administration" tab.
Click unlock, type password and mark "login as" option.
It doesn't matter that root is not listed, just leave it and click "close".
Open terminal and type:

gedit /etc/gdm/custom.conf

In Gedit window change settings to:

TimedLoginEnable=false
AutomaticLoginEnable=true
TimedLogin=user
AutomaticLogin=root
TimedLoginDelay=30
DefaultSession=gnome

Then save it, close gedit, and restart system.
If everything was going fine so far you should be directly loged to the system as ROOT and not even see "login" window.
Graphic is not the issue as I have what I wanted.

It's not big thing and solution came fairly easy. By me it's no point to keep it hidden in the bottom of the system, out of reach of other users. For people like me it's saves time and nerves and should be commonly accessible for every member of community in "login window". I made some suggestions to the proper people, hopefully it will be corrected in the future updates.

Thanks everyone for every little help.

doctor_ahmed 04-27-2010 11:26 AM

How did you solve it please
i'm interesting the same gole
i searched to much to fix it
if you have solve it please help me

i'm using ubuntu 9.10 and want to autologin as root instead typing choosing it from login menu and writing password every login

John VV 04-27-2010 01:13 PM

to clarify -- this is for "doctor_ahmed"
Quote:

i'm using ubuntu 9.10 and want to autologin as root instead typing choosing it from login menu and writing password every login
read the thread
DO NOT do that "root auto login "is not a good idea

devnull10 04-27-2010 01:25 PM

I think the OP understands that it is a bad idea, but his question was not "Is it a good idea to auto login as root" it was "How to enable auto login as root".

cimek 04-27-2010 01:41 PM

There is always plenty of of obsessive people on the every forum who care about your safety more than yourself. But don't worry, I am use my system only in root mode for months and have no problems with it, so you are free to use it your way. Just follow the instructions in previous post dated 01-04-10. Create root and edit "custom.conf".
Good Luck.

doctor_ahmed 04-27-2010 03:17 PM

thanks for rapid follow up
thanks again cimek because you can understand me
that's great thing that not write password any more

i alread do it 2 minutes after i wrote the first post
I've found the method at a turkish blog

Greet cimek i have not see your method at first time
it is the same method


All times are GMT -5. The time now is 10:50 AM.