search
HomeSystem TutorialLINUXHow To Enable Automatic Login In Ubuntu Desktop And Server

In this guide, we'll walk you through the steps to enable automatic login in Ubuntu desktop and server editions. This convenient feature allows you to bypass the login screen on Ubuntu Desktop, allowing direct access to your desktop environment. In Ubuntu Server, it eliminates the need to manually enter your credentials every time.

Warning: Automatic login can pose a security risk as anyone who has physical access to your server can simply turn it on to gain access. Be sure to consider the potential security implications before enabling this feature.

Before configuring Ubuntu automatic login, let's take a brief moment to understand the concept of TTY.Understanding this will provide essential context for the steps ahead.

Table of Contents

What is TTY?

TTY, short for teletypewriter, is a term that originated from the early days of Unix when users connected to computers via physical teletype machines. Today, TTY generally refers to a terminal device, which can be a physical console, a virtual console, or a pseudoterminal (like terminal emulator programs).

To find out which TTY you are currently logged in on in Ubuntu, you can use the tty command. This command prints the file name of the terminal connected to standard input.

tty

Sample output:

/dev/tty1

In this example, the user is logged into tty1. Your actual output may be different depending on which TTY or terminal emulator you're currently using.

The tty1 part refers to the first virtual console. On a typical Ubuntu system, there are six virtual consoles that are accessible by pressing the Ctrl Alt F1 to F6 keys. tty1 corresponds to Ctrl Alt F1, tty2 corresponds to Ctrl Alt F2, and so on.

If you are using a terminal emulator within a graphical environment (like the GNOME Terminal or xterm), the tty command will likely print something like /dev/pts/0 or similar, because each terminal window you open gets its own pseudoterminal.

Now that you have a basic understanding of TTY, we can dive into the simple steps required to enable autologin on your Ubuntu system. All the steps provided below are tested in Ubuntu 22.04 LTS desktop and server editions.

Enable Automatic Login in Ubuntu Desktop

1. Press the Super key (the Windows key). This will open the GNOME Activities window. Type 'Settings' into the search bar and click on the 'Settings' button.

How To Enable Automatic Login In Ubuntu Desktop And Server

2. Scroll down to the bottom and click the 'Users' button. This will open the Users section. Click 'Unlock' button on the top right corner.

How To Enable Automatic Login In Ubuntu Desktop And Server

3. Enter the sudo password to unlock it.

How To Enable Automatic Login In Ubuntu Desktop And Server

4. Toggle the 'Automatic Login' button ON to enable automatic login in Ubuntu Desktop.

How To Enable Automatic Login In Ubuntu Desktop And Server

From now on, you should be able to login automatically in your Ubuntu desktop, without entering the user's password.

To disable Automatic login, just follow the same procedure. Go to Settings -> Users. Unlock the Users section and toggle 'Automatic Login' button OFF to disable Ubuntu autologin feature.

Enable Autologin in Ubuntu Server from Commandline

If you're using Ubuntu Server, typically it doesn't come with a graphical user interface (GUI) by default and uses a command-line interface. Therefore, the concept of auto-login for a GUI-based desktop environment doesn't apply here.

However, if you want to set up automatic login to the command-line console (TTY) that you see after booting your server, you can follow these steps:

1. First, open the /etc/systemd/logind.conf file in a text editor as sudo or root user. Here we'll use nano:

sudo nano /etc/systemd/logind.conf

2. In the opened file, look for a line that starts with #NAutoVTs=. Uncomment it by removing the # at the beginning of this line. After the = sign, enter the number of TTYs you want to be logged in automatically. For example, NAutoVTs=6 would auto-login the first 6 TTYs.

3. Next, look for a line that starts with #ReserveVT= and uncomment it by removing the #. After the = sign, put the number of the first TTY that you want to skip auto-login for. So, if you want to auto-login TTYs 1-6, you would put ReserveVT=7 to start reserving from the 7th TTY.

How To Enable Automatic Login In Ubuntu Desktop And Server

The two directives "NAutoVTs" and "ReserveVT" are configurations related to the systemd-logind service, which handles user logins in a Linux system and are typically found in the logind.conf file.

  1. NAutoVTs: This directive sets the number of virtual terminals (VTs) to allocate by default that systemd-logind will manage. This does not mean that no more than this number of VTs can exist, just that systemd-logind will not automatically allocate more than this. The virtual terminals are allocated on-the-fly as they are needed.
  2. ReserveVT: This directive sets the number of the first virtual terminal that shall unconditionally be reserved for a getty. This means that no graphical login (like a desktop manager) can allocate this terminal. If this is set to 0, no terminal is unconditionally reserved.

Essentially, these directives control how many virtual terminals are allocated and managed by systemd-logind and which ones are reserved for certain types of usage.

4. Press CTRL O followed by CTRL X to save the file and exit the text editor.

5. Now, you need to create a service to auto-login your user. To do so, create a directory named "getty@tty1.service.d" under /etc/systemd/system/ location.

sudo mkdir /etc/systemd/system/getty@tty1.service.d/

Replace tty1 with tty2, tty3, etc., in the command above for each TTY that you want to auto-login.

Use the following command to create a service for the first TTY:

sudo nano /etc/systemd/system/getty@tty1.service.d/override.conf

6. In the opened file, paste the following lines:

[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin <strong><mark>ostechnix</mark></strong> %I $TERM
Type=idle

How To Enable Automatic Login In Ubuntu Desktop And Server

Replace ostechnix with your actual username. Save the file and exit.

Let us break down the above code and see what each option does.

  • [Service]: This is a section that specifies the behavior of the service itself. The directives inside this section will control how the service starts and stops, its timeout values, and more.
  • ExecStart=: This directive specifies the command to run when the service starts. The equal sign followed immediately by nothing is a way to reset the list of commands to run, in case it was set in another file that this service file is overriding.
  • ExecStart=-/sbin/agetty --noissue --autologin ostechnix %I $TERM: The new command to run when the service starts. Here, /sbin/agetty is being called with several parameters. agetty opens a tty port, prompts for a login name, and invokes the /bin/login program. The --noissue parameter prevents display of the /etc/issue file before the login prompt. --autologin ostechnix logs in the user ostechnix automatically. %I is a specifier that systemd replaces with the instance name (the tty in this case). $TERM is an environment variable defining the type of the terminal.
  • Type=idle: This directive tells systemd to wait until all jobs are dispatched before it starts the service. This ensures that the service won't start until the system is idle, freeing up resources.

7. Repeat steps 5-7 for each TTY that you want to auto-login.

8. Finally, reboot your server to apply the changes:

sudo reboot

After rebooting, your server should automatically log in to the specified TTYs.

How To Enable Automatic Login In Ubuntu Desktop And Server

You don't need to manually enter the username and password every time.

To disable the Ubuntu server automatic login feature, simply reverse the procedure. Comment out all the lines that you previously uncommented and remove any lines that you added.

Why We Should Not Enable Automatic Login in Ubuntu or Any Other Linux?

While enabling automatic login in Ubuntu can be convenient, there are several reasons why it may not be a good idea for certain users:

  1. Reduced Control: Automatic login means that the system will always log in as the default user. This can be a problem on systems with multiple users.
  2. Privacy Concerns: If you share your computer with others, automatic login means that anyone can access your personal files and potentially see private information.
  3. Potential for Unauthorized Changes: With automatic login enabled, anyone can potentially change system settings, install or uninstall software, or make other changes that could affect your use of the computer.
  4. Risk of Data Theft: If your computer is stolen, automatic login will give the thief immediate access to all your files and data.
  5. Forget Password: You might forget the password if you don't type it yourself for a certain period of time.

Therefore, while automatic login can provide convenience, you should carefully consider these potential risks before deciding to enable Ubuntu automatic login feature.

Similar Read: How To Enable Automatic Login In Fedora Linux

Conclusion

Ubuntu's automatic login feature offers a convenient way to bypass the need for entering user credentials every time the system boots up. This feature can be useful for single-user systems or for scenarios where quick access is paramount.

You should also know the potential security implications before enabling the autologin feature in Ubuntu or in any other Linux distributions. Enabling automatic login can expose your personal data to anyone with physical access to your computer, reduce control over multi-user systems, and potentially lead to unauthorized changes or data theft.

Related Read:

  • How To Switch Between TTYs Without Using Function Keys In Linux

The above is the detailed content of How To Enable Automatic Login In Ubuntu Desktop And Server. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to Manage Firewalld and UFW for Linux SecurityHow to Manage Firewalld and UFW for Linux SecurityMay 12, 2025 am 10:56 AM

Linux systems rely on firewalls to safeguard against unauthorized network access. These software barriers control network traffic, permitting or blocking data packets based on predefined rules. Operating primarily at the network layer, they manage

How to Check If Your Linux System is a Desktop or LaptopHow to Check If Your Linux System is a Desktop or LaptopMay 12, 2025 am 10:48 AM

Determining if your Linux system is a desktop or laptop is crucial for system optimization. This guide outlines simple commands to identify your system type. The hostnamectl Command: This command provides a concise way to check your system's chassis

How to Increase TCP/IP Connections in LinuxHow to Increase TCP/IP Connections in LinuxMay 12, 2025 am 10:23 AM

Guide to adjust the number of TCP/IP connections for Linux servers Linux systems are often used in servers and network applications. Administrators often encounter the problem that the number of TCP/IP connections reaches the upper limit, resulting in user connection errors. This article will guide you how to improve the maximum number of TCP/IP connections in Linux systems. Understanding TCP/IP connection number TCP/IP (Transmission Control Protocol/Internet Protocol) is the basic communication protocol of the Internet. Each TCP connection requires system resources. When there are too many active connections, the system may reject new connections or slow down. By increasing the maximum number of connections allowed, server performance can be improved and more concurrent users can be handled. Check the current number of Linux connections limits Change settings

How to Convert SVG to PNG in Linux TerminalHow to Convert SVG to PNG in Linux TerminalMay 12, 2025 am 10:21 AM

SVG (Scalable Vector Graphics) files are ideal for logos and illustrations due to their resizability without quality loss. However, PNG (Portable Network Graphics) format often offers better compatibility with websites and applications. This guide d

How to Create Your Own Android and iOS Apps with LiveCodeHow to Create Your Own Android and iOS Apps with LiveCodeMay 12, 2025 am 10:10 AM

LiveCode: A Cross-Platform Development Revolution LiveCode, a programming language debuting in 1993, simplifies app development for everyone. Its high-level, English-like syntax and dynamic typing enable the creation of robust applications with ease

How to Reset a USB Device from the Linux TerminalHow to Reset a USB Device from the Linux TerminalMay 12, 2025 am 10:07 AM

This guide provides a step-by-step process for resetting a malfunctioning USB device via the Linux command line. Troubleshooting unresponsive or disconnected USB drives is simplified using these commands. Step 1: Identifying Your USB Device First, i

How to Set a Temporary Static IP Address on LinuxHow to Set a Temporary Static IP Address on LinuxMay 12, 2025 am 10:06 AM

Temporarily setting a static IP address on Linux is invaluable for network troubleshooting or specific session configurations. This guide details how to achieve this using command-line tools, noting that the changes are not persistent across reboots

51 Lesser-Known Linux Commands for Power Users51 Lesser-Known Linux Commands for Power UsersMay 12, 2025 am 09:51 AM

Linux is known for its powerful set of command-line tools that allow users to interact with the system efficiently. While many Linux users are familiar with common commands such as ls, cd, or grep, there are also few lesser-known but extremely useful commands and shortcuts that can simplify and increase productivity. We are excited to share our latest five articles on "less known Linux commands" with over 50 commands you may not know about. You may also like: 11 little-known practical Linux commands – Part 1 10 little-known Linux commands – Part 2 10 little-known Linux commands – Part 3 10 little-known valid Linux commands

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool