Working as root all the time is risky: one wrong command can damage the whole system. Create a normal user for your daily work and give it sudo, so that it can run single commands as root when needed. The same steps give other people their own login. Tested on Ubuntu 26.04 LTS; run the commands as root.
1. Add a User
adduser bob
adduser asks for a password and some optional details (name, room and so on; press Enter to skip them). It creates the home folder /home/bob.
2. Give the User sudo
usermod -aG sudo bob
-aG adds the group sudo and keeps the other groups. Check it:
sudo -l -U bob
It must end with (ALL : ALL) ALL. A user without the group gets is not allowed to run sudo. The new group applies from the user's next login.
The user now puts sudo in front of commands that need root and enters their own password:
sudo apt update sudo whoami
The second command prints root. sudo -i opens a root shell until you type exit.
3. Log In as the New User
ssh bob@your-server-IP
To log in with a key instead of the password, copy the key for this user as described in Log In to Your Linux Server With an SSH Key. When your user with sudo works, you can switch off direct root logins over SSH: create /etc/ssh/sshd_config.d/20-no-root.conf with PermitRootLogin no, check with sshd -t and apply with systemctl reload ssh. Test a new login as your user before you close the old window.
4. Change, Lock or Remove a User
passwd bob # set a new password passwd -l bob # lock the password passwd -u bob # unlock it gpasswd -d bob sudo # take sudo away deluser --remove-home bob # remove the user and the home folder
passwd -S bobshows the state:Lfor locked,Pfor a usable password. A locked password stops password logins; a user with an SSH key can still log in, so remove the key too (/home/bob/.ssh/authorized_keys) if you want to stop all access.- Before you remove a user, copy what you need from
/home/bob:--remove-homedeletes it.
To give someone access to files only, without a terminal, see Give Someone SFTP Access to One Folder Only.