Difference between revisions of "Automatic login to virtual console"

From ArchWiki
Jump to: navigation, search
(Killing X)
m (Virtual console: typo)
(27 intermediate revisions by 13 users not shown)
Line 3: Line 3:
 
[[es:Automatic login to virtual console]]
 
[[es:Automatic login to virtual console]]
 
[[it:Automatic login to virtual console]]
 
[[it:Automatic login to virtual console]]
{{Article summary start}}
+
{{Related articles start}}
{{Article summary text|Describes how to automatically log in to a virtual console.}}
+
{{Related|Display Manager}}
{{Article summary heading|Related}}
+
{{Related|Silent boot}}
{{Article summary wiki|Display Manager}}
+
{{Related|Start X at Login}}
{{Article summary wiki|Silent boot}}
+
{{Related articles end}}
{{Article summary wiki|Start X at Login}}
+
{{Article summary end}}
+
  
This article describes how to automatically log in to a ''virtual console'' at the end of the [[boot process]]. This article only covers console log-ins; methods for starting an [[Xorg|X server]] are described in [[Start X at Login]].
+
This article describes how to automatically log in to a [[Wikipedia:Virtual console|virtual console]] at the end of the [[boot process]]. This article only covers console log-ins; see [[Start X at Login]] for information about automatic login into [[Xorg]].
  
== Service ==
+
== Configuration ==
Create a new service file similar to {{ic|getty@.service}} by copying it to {{ic|/etc/systemd/system/}}:
+
  
# cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/autologin@.service
+
Configuration relies on systemd [[Systemd#Editing_provided_unit_files|drop-in files]] to override the default parameters passed to ''agetty''.
  
{{Note|{{ic|/etc/systemd/system/}} takes precedence over {{ic|/usr/lib/systemd/system/}}.}}
+
The configuration differs for virtual and serial consoles. In most cases you would want to setup up automatic login on virtual console, the one which device name is {{ic|tty''N''}}, where {{ic|''N''}} is a number. The configuration of the automatic login for the serial consoles will be slightly different. Device names of the serial consoles look like {{ic|ttyS''N''}}, where {{ic|''N''}} is a number.
  
Then change the {{ic|ExecStart}} line to include the {{ic|-a ''USERNAME''}} parameter:
+
=== Virtual console ===
  
{{hc|/etc/systemd/system/autologin@.service|
+
Create the following file (and the leading directories):
2=[Service]
+
''[...]''
+
ExecStart=-/sbin/agetty --noclear -a ''USERNAME'' %I 38400
+
''[...]''
+
  
[Install]
+
{{hc|/etc/systemd/system/getty@tty1.service.d/autologin.conf|2=
WantedBy=getty.target
+
[Service]
 +
ExecStart=
 +
ExecStart=-/usr/bin/agetty --autologin ''username'' --noclear %I 38400 linux
 
}}
 
}}
  
{{Tip|It is possible to change {{ic|1=Type=idle}} to {{ic|1=Type=simple}} and avoid delaying the execution of agetty until all jobs (state change requests to units) are completed. This option is more useful when [[Start X at Login|starting X automatically]]. See {{ic|man systemd.service}} for more info. {{Note|{{ic|1=Type=simple}} can cause systemd boot-up messages to pollute the login prompt.}}}}
+
{{Tip|The option {{ic|1=Type=idle}} will delay the service startup until all jobs (state change requests to units) are completed. When using {{ic|1=Type=simple}}, the service will be started immediately, but boot-up messages may pollute the login prompt. This option is particularly useful when [[Start X at Login|starting X automatically]]. To use this option, add {{ic|1=Type=simple}} into {{ic|autologin.conf}}.}}
{{Note|If you're using mingetty, simply replace /sbin/agetty to /sbin/mingetty}}
+
  
 +
If you want to use other ''tty'' than ''tty1'' see [[Systemd FAQ#Q:_How_do_I_change_the_number_of_gettys_running_by_default.3F|Systemd FAQ]].
  
Finally, you need to disable the old {{ic|getty@tty''X''.service}} for the specified tty and enable the new {{ic|autologin@tty''X''.service}}. For example,
+
=== Serial console ===
# systemctl daemon-reload
+
# systemctl disable getty@''tty1''
+
# systemctl enable autologin@''tty1''
+
# systemctl start autologin@''tty1''
+
  
{{Warning|If you are currently in an X session on the same tty configured in the service file, starting {{ic|autologin@tty''X''.service}} will kill your X server.}}
+
Create the following file (and the leading directories):
  
To avoid errors related to display-manager.service in dmesg, you should set the default target to multi-user instead of graphical:
+
{{hc|/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf|2=
# systemctl enable multi-user.target
+
[Service]
 
+
ExecStart=
===Killing X===
+
ExecStart=-/sbin/agetty --autologin ''username'' -s %I 115200,38400,9600 vt102
To kill X and prevent it from immediately reloading, stop the service.
+
}}
  
# systemctl stop autologin@tty1.service
+
==See also==
  
===See also===
+
* [[Systemd#Change_default_target_to_boot_into|Change default runlevel/target to boot into]]
* [[Systemd#Change_default_target_to_boot_into|Change default runlevel/target to boot into]].
+

Revision as of 12:30, 29 December 2013

This article describes how to automatically log in to a virtual console at the end of the boot process. This article only covers console log-ins; see Start X at Login for information about automatic login into Xorg.

Configuration

Configuration relies on systemd drop-in files to override the default parameters passed to agetty.

The configuration differs for virtual and serial consoles. In most cases you would want to setup up automatic login on virtual console, the one which device name is ttyN, where N is a number. The configuration of the automatic login for the serial consoles will be slightly different. Device names of the serial consoles look like ttySN, where N is a number.

Virtual console

Create the following file (and the leading directories):

/etc/systemd/system/getty@tty1.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin username --noclear %I 38400 linux
Tip: The option Type=idle will delay the service startup until all jobs (state change requests to units) are completed. When using Type=simple, the service will be started immediately, but boot-up messages may pollute the login prompt. This option is particularly useful when starting X automatically. To use this option, add Type=simple into autologin.conf.

If you want to use other tty than tty1 see Systemd FAQ.

Serial console

Create the following file (and the leading directories):

/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin username -s %I 115200,38400,9600 vt102

See also