Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Newly Created User Cannot Log in to Linux Graphical Desktop: A Step-by-Step Fix

Tech May 11 5

Creating Users in Linux and Enabling Graphical Login

Many Linux beginners encounter a problem after creating a new user: they can switch to the user in a terminal but cannot log in to the graphical desktop. This usually happens because the user is created without a proper home directory or sufficient permissions for the display manager.

Environment Preparation

First, gain root privileges (temporarily) with:

sudo su root

Creating the User Correctly

The command pair:

useradd testname
passwd testname

only creates a basic user entry. To allow graphical login, the user needs a home directory and the correct ownership.

Recommended User Creation Commands

  1. Create a user with a home directory:
useradd -d /home/testname -m testname
  • -d /home/testname specifies the home directory path.
  • -m ensures the directory is created if it does not exist.
  1. (Optional) Add the user to the root group immediately:
useradd -d /home/testname -m testname -g root

Verify the User's Groups

groups testname

Completely Remove a User (if needed)

userdel -r testname   # -r removes the home directory as well

Setting the Password

passwd testname

Enter the new passwodr twice. Note that the input will not be echoed for security reasons.

Granting sudo Access (Optional but Recommended)

Even if the user is in the root group, they may not have sudo privileges. To enable sudo:

sudo su root
visudo   # or vim /etc/sudoers

Look for the line:

root    ALL=(ALL:ALL) ALL

Add a new line below it:

testname    ALL=(ALL:ALL) ALL

Save and exit (:wq! in vim).

Logging In

After completing these steps, log out of your current session (or restart the display manager) and try logging in with the new user account. You should now see the graphical desktop.

Troubleshooting Tips

  • Ensure the home directory exists and is owned by the user:
chown -R testname:testname /home/testname
  • If the display manager still refuses login, check /var/log/lightdm.log or /var/log/gdm3/ for specific errors.
  • Always use useradd with -m when creating users intended for interactive use.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.