How to Add and Remove Users on Ubuntu 22.04 Command Line

How to Add and Remove Users on Ubuntu 22.04 Command Line

Add and remove users on Linux ubuntu 22.04; Through this tutorial, we will learn how to add and remove new users on linux ubuntu 22.04 system using command line or terminal.

How to Add and Remove Users on Ubuntu 22.04 Command Line

Steps to add/create and remove/delete new user linux ubuntu 22.04 system using command line or terminal with sudo adduser new-user and sudo deluser:

  • Step 1 – Ubuntu Create a new user account
  • Step 2 – Add the new user to the sudo group
  • Step 3 – Test sudo user account
  • Step 4 – Removing a User from on Ubuntu Command Line

Step 1 – Ubuntu Create a new user account

Execute the following command on command line to add or create new sudo user on ubuntu:

adduser username

Note that:- replace username with the user name that you want to create.

Once the user has been added; the Prompt box will appear to set and confirm the new user password.

Step 2 – Add the new user to the sudo group

Use the following command to add the user you created to the sudo group use the usermod command:

usermod -aG sudo username

Step 3 – Test sudo user account

Now, Use the following command to switch to the newly created user:

su - username

Use sudo to run the whoami command:

sudo whoami

Is the user have sudo access then the output of the whoami command will be “root”:

root

Step 4 – Removing a User from on Ubuntu Command Line

Execute the the deluser command on the command line to remove a user from ubuntu:

sudo deluser username

The above-given command will not remove the user files.

If you want to delete the user and its home directory and mail spool, use the --remove-home flag:

sudo deluser --remove-home username

Conclusion

Through this tutorial, we have learned how to add and remove new users on the linux ubuntu 22.04 system.

Recommended Linux Ubuntu Tutorials

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *