Normally, you need to enter the login user name and password when starting and restarting Ubuntu, but here's how to automatically log in without entering the user name and password.
Ubuntu 20.10
GUI (Ubuntu Desktop) If you go to "Settings"> "Details"> "Users", there is an item called "Automatic login", so turn it from off to on. You will be prompted for a password.
How to "automatically log in" to the Ubuntu 18.04 LTS desktop
CUI (Ubuntu Server) Execute the following command.
$ sudo systemctl edit [email protected]
The editor (nano) will open, so copy and paste the following.
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin <USERNAME> %I $TERM
Type=idle
For <USERNAME>
, enter the user name of the user who wants to log in automatically. You can find the current username with the whoami
command.
By the way, some people may not be familiar with nano (as well as myself), so I will explain how to save the file for the time being.
Unlike Vim, nano doesn't have normal mode or insert mode, so just copy and paste the above when the editor opens.
Then press Ctrl + X
. You will be asked Save modified buffer?
, So press y
to save the file. When the message File Name to Write: ...
is displayed, press the return key to finish.
By the way, this file seems to be open only with nano. I tried with EDITOR = vim
but it opened in nano.
You should now be logged in automatically when you reboot. In the case of Ubuntu Server, I don't know if I have to connect the PC running Ubuntu Server to the monitor to check it properly.
It seems that a daemon that is normally started as a user will not start ** unless you log in as that user once after starting / restarting. For example, the PulseAudio daemon.
Daemons that are normally started by the user are distinguished from daemons that are started system-wide. For example, if you install PulseAudio [^ 1], there is no daemon file system wide, but a daemon file is usually provided for the user.
#Does not exist in system wide
$ systemctl status pulseaudio
Unit pulseaudio.service could not be found.
#Exists for normal users
$ systemctl --user status pulseaudio
● pulseaudio.service - Sound Service
Loaded: loaded (/usr/lib/systemd/user/pulseaudio.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-12-20 07:46:19 UTC; 3 days ago
TriggeredBy: ● pulseaudio.socket
Main PID: 1911 (pulseaudio)
CGroup: /user.slice/user-1000.slice/[email protected]/pulseaudio.service
└─1911 /usr/bin/pulseaudio --daemonize=no --log-target=journal
[^ 1]: For Ubuntu Desktop, it is installed from the beginning
Automatic login at startup is convenient when you want to automatically start these daemons at system startup / restart, not at user login.
In addition to the method introduced here, there are two possible methods when you want to automatically start such a daemon for normal users.
--How to disable a daemon for normal users and change it to start system-wide (with root privileges) --How to automatically start a daemon that originally runs with root privileges on behalf of a normal user
By the way, the second one is that it starts up like this.
ExecStart=/usr/bin/sudo -u <USERNAME> pulseaudio
I tried it with PulseAudio, but neither worked. He didn't expect PulseAudio to boot system-wide in the first place, so it didn't work [^ 2]. The method of substituting for a normal user also did not work because the daemon did not start.
[^ 2]: For the time being, the method of booting system-wide is officially explained ... Running PulseAudio as System-Wide Daemon
So, it seems safest to start the daemon for normal users as a normal user, and if you want to start the daemon automatically when the system starts, use automatic login.
How can I get autologin at startup working on Ubuntu Server 16.04.1?
Recommended Posts