Linux / Unix

Create non root user in Ubuntu Server

In order to create a new user, you need root access to the server. Once you are logged in as a root, you are ready to add the new user account. It is discouraged to use root account on regular bases that has ability to make very serious changes. The solution is to create alternative account with reduced scope of influence for daily tasks

Creating a New User

Following example creates new user peter:

# adduser peter

You will be asked few questions, starting with account user password. Enter a strong password, and fill remaining information.

Grant Administrative Privileges

New created account has regular user privileges, in order to perform admin task user peter requires administrative rights, let grant admin rights to the user.

As a root run following command:

# usermod -aG sudo peter

That’s it, now when you login as peter, use sudo for administrative tasks.

Author: Danyal
I'm a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.