Close Menu
    What's Hot

    How to Auto Start a Program on Raspberry Pi? (4 Ways)

    8 September، 2024

    List of Best Hacking Software For Windows, Linux, and Mac OS X

    7 September، 2024

    The rpm command

    20 December، 2022

    Copy virtual machine to the new host

    20 December، 2022
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    keepuptechnologykeepuptechnology
    • Home
      • Linux
      • Network
      • raspberry pi
      • mqtt
      • esp8266
    • Linux

      List of Best Hacking Software For Windows, Linux, and Mac OS X

      7 September، 2024

      The rpm command

      20 December، 2022

      Copy virtual machine to the new host

      20 December، 2022

      Remove password from Virtual Machine Manager on Linux

      20 December، 2022

      How to create FAT32 USB drive on Linux

      20 December، 2022
    • Network

      Wifi Pineapple Mark V on TP-Link MR3020

      10 September، 2022
    • IOT
      • esp8266
      • mqtt
      • raspberry pi
    • All
      1. IOT
      2. raspberry pi
      3. Linux
      4. View All

      How to Auto Start a Program on Raspberry Pi? (4 Ways)

      8 September، 2024

      How to Install VMWare ESXi on a Raspberry Pi? (Step by step)

      20 December، 2022

      Getting started with Proxmox on Raspberry Pi (Virtualization server)

      20 December، 2022

      How To Create USB Rubber Ducky With Raspberry Pi Pico

      24 November، 2022

      How to Auto Start a Program on Raspberry Pi? (4 Ways)

      8 September، 2024

      How to Install VMWare ESXi on a Raspberry Pi? (Step by step)

      20 December، 2022

      Getting started with Proxmox on Raspberry Pi (Virtualization server)

      20 December، 2022

      How To Create USB Rubber Ducky With Raspberry Pi Pico

      24 November، 2022

      List of Best Hacking Software For Windows, Linux, and Mac OS X

      7 September، 2024

      The rpm command

      20 December، 2022

      Copy virtual machine to the new host

      20 December، 2022

      Remove password from Virtual Machine Manager on Linux

      20 December، 2022
    • Contact Us
    Subscribe
    keepuptechnologykeepuptechnology
    Home » How to Create a New User on Raspberry Pi?

    How to Create a New User on Raspberry Pi?

    0
    By admin on 26 September، 2022 raspberry pi
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Whatever your reason is, you may need to create a new user on Raspberry Pi. The procedure is not really intuitive for a beginner, so I will explain it in this tutorial. Here is the short answer if you are already familiar with Linux:

    • Open a terminal (or SSH connection).
    • Type the following command:
      sudo adduser <username>
    • Fill the information (home directory, password, etc.)
    • Done. The new user is ready to use.

    Don’t worry, I will now explain everything in details in this post, starting with the reasons why you’ll probably need to create a new user, then the step-by-step procedure, and finally, I’ll give you a few extra tips about users management on Raspberry Pi.

    Why will you need to create a new user?

    The pi user is one of the most brute-forced logins with root.
    Hackers have a list of commonly used logins and try mainly these ones.
    If possible, create a new user and disable the pi user to prevent this kind of attacks (I’ll show you how in the next part).

    Note: the pi user is no longer created by default on the latest Raspberry Pi OS versions. You’ll be asked to create the first user yourself, with a unique name and password, which is already way better.

    Multi users

    Another good reason, is for creating several users for different permissions or persons.

    You can also create an administrator user for you (don’t name it admin), and a standard user for the person that will use the Raspberry Pi with the basic permissions.

    Applications

    Finally, the last reason I see where you’ll need to create a new user is the installation of a new application.
    Some applications need a specific user to run.

    And, you can have something similar to manage the user of an application.
    For example, services like FTP, Samba or even an email server often use system users for their access.

    How to create a new user on Raspberry Pi?

    Whatever the reason that led you here, here is how to create a new user on Raspberry Pi :).

    Open a terminal

    If you are using a Desktop version of Raspberry Pi OS (or another Linux distribution for Raspberry Pi), you can simply open a terminal and follow the instructions below.

    I generally use SSH, to connect to my Raspberry Pi from my computer. It’s often easier and more comfortable. I have better accessories on my computer, and I can copy and paste commands directly. But do as you prefer, it doesn’t matter.

    Create the new user

    The user creation is based on only one command: adduser

    Here is how to create a new user:

    • Type the following command:
      sudo adduser <username>
      For example:
      sudo adduser patrick
    • You will need to answer a few questions:
    $ sudo adduser pat
    Adding user 'pat' ...
    Adding new group'pat' (1002) …
    Adding new user 'pat' (1002) with group'pat' …
    Creating home directory '/home/pat' ...
    Copying files from'/etc/skel' …
    New password:
    Retype new password:
    passwd: password updated successfully
    Changing the user information for pat
    Enter the new value, or press ENTER for the default
            Full Name []: FROMAGET
            Room Number []:
            Work Phone []:
            Home Phone []:
            Other []:
    Is the information correct? [Y/n]
    
    As soon as the wizard is completed, you can log in with the new username.
    But, the new user will have no particular permission.
    We’ll learn how to add permissions in the next paragraph.
    
    Permissions
    I’m not talking about the file permissions (maybe for another post), but about the user permissions (sudo or specific groups for example).
    Add the sudo right
    
    If you are following this tutorial to replace the pi user, you’ll probably look to add the sudo privilege to your new user.
    Here is how to do this:
    
        Type the following command:
        sudo adduser <username> sudo
    
        In my case:
        sudo adduser pat sudo
    
    $ sudo adduser pat sudo
     Adding user 'pat' to group'sudo' …
     Adding user pat to group sudo
     Done.
    
    That’s it, your new user is now allowed to user the sudo command.
    But there is still one difference with the pi user:
    The system will ask for your password every time you use the command.
    Sudo without password
    
    If you prefer to keep it as with the default pi user, you need to follow this procedure:
    
        You will need to create a new file under /etc/sudoers.d
        This file will allow the user of your choice to use sudo without password.
        You can create this file in only one command:
        echo '<username> ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/010_<username>-nopasswd
    
        For example:
        echo 'pat ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/010_pat-nopasswd
    
    That’s it, you can now use sudo without typing your password each time.
    
    Add the user to a group
    The other thing you’ll probably need to do after creating a new user, is to add it to some groups.
    
    You can do this with the adduser command too:
    sudo adduser <username> <group>
    
    For example:
    sudo adduser pat www-data
    
    

    Delete a user

    Once you have created your new users, you can delete the pi user (don’t forget to try the new admin user first).
    You can also use this command to delete useless users on your system.

    Here is the command syntax:
    sudo deluser --remove-home <username>
    The –remove-home is optional, as the name suggests it will delete the /home/<username> folder.

    So, if you want to delete the pi user without deleting the home folder, type this:
    sudo deluser pi

    Extra tips

    Before closing this post, here are a few extra tips to manage the users on Raspberry Pi.

    Skel

    The /etc/skel is used as a template directory (skeleton).
    Each time you create a new user on your system, the files in /etc/skel will be copied to the new home directory (/home/pat for example).

    pi@pizero:~ $ ls -latr /etc/skel
     total 20
     -rw-r--r--   1 root root  675 May 15  2017 .profile
     -rw-r--r--   1 root root  220 May 15  2017 .bash_logout
     -rw-r--r--   1 root root 3523 Nov 13  2018 .bashrc
     drwxr-xr-x   2 root root 4096 Nov 13  2018 .
     drwxr-xr-x 106 root root 4096 Dec 12 12:25 ..

    You can add new files here if you want to set each new user with custom files you create.

    List active users

    All the users you create are stored in the /etc/passwd file.
    So if you want to get the complete list of all users enabled on your system, you can just type:
    cat /etc/passwd

    The following command will do the same thing:
    getent passwd

    Manage sudo permissions

    And to conclude, you can manage more precisely the sudo permissions for each user on your system.
    In a previous part, I showed you a way to give all privileges to a specific user, but you can also edit the sudoers file to configure this as you want.

    Here is the command you can use to open this file:
    sudo visudo

    The file content looks like this:

    As you can see, the root has “ALL” privileges on the system.
    But you can be more specific, and give only one command to a user by using the following syntax:
    <username> ALL=(ALL) <command>
    For example:
    pat ALL=(ALL) /path/to/command

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email
    Previous ArticleHow to Set a New Hostname on Raspberry Pi (4 ways)
    Next Article How to Install MariaDB on Raspberry Pi? (MySQL Server)
    admin
    • Website

    Related Posts

    How to Auto Start a Program on Raspberry Pi? (4 Ways)

    8 September، 2024

    How to Install VMWare ESXi on a Raspberry Pi? (Step by step)

    20 December، 2022

    Getting started with Proxmox on Raspberry Pi (Virtualization server)

    20 December، 2022
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Subscribe to Updates

    Get the latest sports news from SportsSite about soccer, football and tennis.

    Keep Up Technologies. Articles and topics to keep up with computer science and technology
    We're social. Connect with us:

    Facebook X (Twitter) Instagram Pinterest YouTube
    Top Insights
    Get Informed

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    © 2025 Makrof. Designed by Makrof.

    Type above and press Enter to search. Press Esc to cancel.