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.
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.
3. Enter the sudo password to unlock it.
4. Toggle the 'Automatic Login' button ON to enable automatic login in Ubuntu Desktop.
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.
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.
- 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.
- 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
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.
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:
- 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.
- Privacy Concerns: If you share your computer with others, automatic login means that anyone can access your personal files and potentially see private information.
- 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.
- Risk of Data Theft: If your computer is stolen, automatic login will give the thief immediate access to all your files and data.
- 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!

The Linux command line interface provides a wealth of text processing tools, one of the most powerful tools is the sed command. sed is the abbreviation of Stream EDitor, a multi-functional tool that allows complex processing of text files and streams. What is Sed? sed is a non-interactive text editor that operates on pipeline inputs or text files. By providing directives, you can let it modify and process text in a file or stream. The most common use cases of sed include selecting text, replacing text, modifying original files, adding lines to text, or removing lines from text. It can be used from the command line in Bash and other command line shells. Sed command syntax sed

Efficiently Counting Files and Folders in Linux: A Comprehensive Guide Knowing how to quickly count files and directories in Linux is crucial for system administrators and anyone managing large datasets. This guide demonstrates using simple command-l

Efficiently managing user accounts and group memberships is crucial for Linux/Unix system administration. This ensures proper resource and data access control. This tutorial details how to add a user to multiple groups in Linux and Unix systems. We

Linux Kernel is the core component of a GNU/Linux operating system. Developed by Linus Torvalds in 1991, it is a free, open-source, monolithic, modular, and multitasking Unix-like kernel. In Linux, it is possible to install multiple kernels on a sing

This brief guide explains how to type Indian Rupee symbol in Linux operating systems. The other day, I wanted to type "Indian Rupee Symbol (₹)" in a word document. My keyboard has a rupee symbol on it, but I don't know how to type it. After

Introduction In the realm of Linux, where the command line is often the compass by which we navigate, the efficient management of disk space is crucial. Whether you’re sailing through personal projects or steering the ship o
![Install Fedora Linux 41 Workstation [Step-by-Step Guide]](https://img.php.cn/upload/article/001/242/473/174149047084567.png?x-oss-process=image/resize,p_40)
This guide provides a comprehensive walkthrough for installing Fedora Linux 41 Workstation Edition. Let's get started! Table of Contents - Step 1: Prepare Your Fedora 41 Installation Media Step 2: Boot from the Fedora 41 Installation Media Step 3:

Linus Torvalds has released Linux Kernel 6.14 Release Candidate 6 (RC6), reporting no significant issues and keeping the release on track. The most notable change in this update addresses an AMD microcode signing issue, while the rest of the updates


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor

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),