How can I add a new user as sudoer using the command line?

1

After I add a user using adduser, I can’t see it via System->Administration->Users and Groups unless I logout and then login again. Is that normal?

Also, can I set a newly added user as a sudoer or do I have to change that only after adding it? How can I do that via the shell?

Finally, can I delete the original user that was created upon initial installation of Ubuntu, or is this user somehow ‘special’?

Answer #: 1

Just add the user to the sudo group:

sudo adduser sudo

The change will take effect the next time the user logs in.

This works because /etc/sudoers is pre-configured to grant permissions to all members of this group (You should not have to make any changes to this):

# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL

As long as you have access to a user that is in the same groups as your “original” user, you can delete the old one.

Realistically, there are also other groups your new user...

0 0
2

Command Syntax:

sudo adduser sudo

Change with your actual username. Above command creates a new user and add it in group named sudo. This group already have sudo privileges defined in /etc/sudoers files.

Example:

The following command will create a new user jack and add it to sudo group. If user already exist, it will simply add them to sudo group.

$ sudo adduser jack sudo

Add Existing User in sudo Group

You can also use the following command to add existing users to group sudo, where it will get full sudo privileges.

$ sudo usermod -aG sudo

Remove Existing User from sudo Group

The following command will remove user from group sudo. This will not remove user from system.

$ sudo gpasswd -d...
0 0
3

Introduction

One of the most basic tasks that you should know how to do on a fresh Linux server is add and remove users. When you create a new system, you are often (such as on DigitalOcean Droplets) only given the root account by default.

While running as the root user gives you a lot of power and flexibility, it is also dangerous and can be destructive. It is almost always a better idea to add an additional, unprivileged user to do common tasks. You also should create additional accounts for any other users you may have on your system. Each user should have a different account.

You can still acquire administrator privileges when you need them through a mechanism called sudo. In this guide we will cover how to create user accounts, assign sudo privileges, and delete users.

If you are signed in as the root user, you can create a new user at any time by typing:

If you are signed in as a non-root user who has been given sudo privileges, as...

0 0
4

Q. How do I add a new user using command line tools? What are command line option recommended.

A. You need to use useradd command, which is responsible for creating a new user or update default new user information

The useradd command creates a new user account using the values specified on the command line and the default values from the system. The new user account will be entered into the system files (/etc/passwd) as needed, the home directory (/home/username) will be created, and initial files copied, depending on the command line options.

Task: Add a user to the system

Syntax is as follows for useradd command:
useradd

By default user account is locaked, you need to setup a new password:
passwd

For example add a new user called tom and set password to jerry:
# adduser tom
# passwd tom

If you want to add a user to group read how to add a user user to group

List of common options:

-c...
0 0
5

Name

sudo, sudoedit - execute a command as another user

Synopsis

sudo -h | -K | -k | -V

sudo -v [-AknS] [-g group name | #gid] [-p prompt] [-u user name | #uid]

sudo -l[l] [-AknS] [-g group name | #gid] [-p prompt] [-U user name] [-u user name | #uid] [command]

sudo [-AbEHnPS] [-C fd] [-g group name | #gid] [-p prompt] [-r role] [-t type] [-u user name | #uid] [VAR=value] -i | -s [command]

sudoedit [-AnS] [-C fd] [-g group name | #gid] [-p prompt] [-u user name | #uid] file ...

Description

sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.

sudo supports a plugin architecture for security policies and input/output logging. Third parties can develop and distribute their own policy and I/O logging plugins to work seamlessly with the sudo front end. The default security policy is sudoers, which is configured via the file /etc/sudoers, or via...

0 0
6

In this tutorial we will cover how to add a new user on ubuntu with the command line. The following commands will work on a desktop system as well as a server. The commands can also be applied on most other Linux distributions as well.

In the following examples we will setup a new user called tony. We will set the account up with sudo privileges and add the account to a few groups.

We will be doing this all in a terminal. If you are not sure on how to open a terminal on you can take a look at one of the follow tutorials on how to do this. Let’s get started!

http://mixeduperic.com/linux/how-to-open-a-terminal-window-in-gnome-2.html

http://mixeduperic.com/linux/how-to-open-a-terminal-window-in-unity.html

How to create a user:

If you want to add a user to your system you can use the adduser command. Since this requires you to have root or admin privileges you will need to use sudo along with the command.

sudo adduser...

0 0
7

These are my own 'HowTo' notes - so usual disclaimer "use at your own risk".

Bare in mind that these are for the N54L, and the IPKG bootstrap that you download depends on what hardware you are running on, (see the wiki link in my last post to see which one you need).

IPKG
Installing IPKG
The ipkg package installer is required in order to be able to install various software packages outside of Synology’s repository, in particular the sudo package, and nano if you want an alternative editor.
Full instructions, for multiple platforms, are available HERE.
Below are a condensed set of instructions, suitable for the N54L i686 platform.
The files to install the ipkg are referred to as ‘bootstraps’.
1. Login via SSH as root.
2. Change to a temporary directory (e.g. /volume1/@tmp)
3. Download the bootstrap file to the NAS using the following command:

Code: Select all wget...
0 0
8

Add new user using the following command

sudo adduser newusername

Enter password for this username and fill fields if you wish

Confirm the information is correct and enter "y"

You have user added with very basic privileges.

You now need to set a user up with sudo access previlegies

We need to edit /etc/sudoers file as sudo

sudo visudo

Add new line under the following

root ALL=(ALL:ALL) ALL
newusername ALL=(ALL:ALL) ALL

Ctrl + x to save this file

Delete .tmp off the end of the file name so it reads /etc/passwd
Enter Y to confirm overwriting the file

Add username newusername to group sudo

usermod -a -G sudo newusername

To verify this run

cat /etc/group |grep...

0 0
9

Advanced users may need to add a user account to the sudoers file, which allows that user to run certain commands with root privileges. To greatly simplify what that means, these newly privileged user accounts will then be able to execute commands without getting permission denied errors or having to prefix a terminal command with sudo. This may be helpful (or necessary) for some complex situations, but it poses a security risk for others, thus this is not something that should be casually changed. Generally speaking, most users are better off using an admin account, using sudo on a per command basis, or enabling the root user. Nonetheless, directly modifying sudoers has plenty of usage situations for advanced individuals with in-depth knowledge of the command line, and it is for those more complex situations that we’ll focus on adjusting the sudoers file as described here.

The sudoers file is located at /etc/sudoers but, unlike /etc/hosts and many other system...

0 0
10

Linux System is much secured than any of its counterpart. One of the way to implement security in Linux is the user management policy and user permission. normal users are not authorized to perform any system operations.

If a normal user needs to perform any system wide changes he needs to use either ‘su‘ or ‘sudo‘ command.

Linux: su v/s sudo

NOTE – This article is more applicable to Ubuntu based distributions, but also applicable to most of the popular Linux distributions.

‘su’ Vs ‘sudo’

‘su‘ forces you to share your root password to other users whereas ‘sudo‘ makes it possible to execute system commands without root password. ‘sudo‘ lets you use your own password to execute system commands i.e., delegates system responsibility without root password.

What is ‘sudo’?

‘sudo‘ is a root binary setuid, which executes root commands on behalf of authorized users and the users need to enter their own password to execute system command...

0 0
11

Just add the user to the sudo group:

sudo adduser sudo

The change will take effect the next time the user logs in.

This works because /etc/sudoers is pre-configured to grant permissions to all members of this group (You should not have to make any changes to this):

# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL

As long as you have access to a user that is in the same groups as your "original" user, you can delete the old one.

Realistically, there are also other groups your new user should be a member of. If you set the Account type of a user to Administrator in Users Settings, it will be placed in at least all of these groups:

adm sudo lpadmin sambashare

Because your system configuration may vary, I suggest taking a look at the output of groups to see what groups are normally in...

0 0
12

The problem with the other suggestions is that

they only work when you have access to the corporate LAN (or VPN) you have to maintain the sudoers file on each and every computer all the time as a bonus, they didn't work for me - at all

Instead, I wanted something that

caches both the credentials and the sudo access is centrally managed

The actual solution is using SSSD and extending the AD schema. This way SSSD fetches sudo settings and user credentials periodically from AD and maintains a local cache of them. The sudo rules are then stored in AD objects, where you can restrict rules to computers, users and commands, even - all that without ever touching a sudoers file on the workstations.

The exact tutorial is way too long to explain here, but you can find the step-by-step guide and some scripts to help with automation here:

TL;DR:

Grab the latest release of sudo, get the doc/schema.ActiveDirectory file, then import it (make sure to modify...

0 0
13
Sudoer File Examples

Softpanorama main > Access Control in Operating Systems

Sudo provides a well documented sudoers file that is the first and pretty education example:

# Sample /etc/sudoers file. # # This file MUST be edited with the 'visudo' command as root. # # See the sudoers man page for the details on how to write a sudoers file. # ## # User alias specification ## User_Alias FULLTIMERS = millert, mikef, dowdy User_Alias PARTTIMERS = bostley, jwfox, crawl User_Alias WEBMASTERS = will, wendy, wim ## # Runas alias specification ## Runas_Alias OP = root, operator Runas_Alias DB = oracle, sybase ## # Host alias specification ## Host_Alias SPARC = bigtime, eclipse, moet, anchor:\ SGI = grolsch, dandelion, black:\ ALPHA = widget, thalamus, foobar:\ HPPA = boa, nag, python Host_Alias CUNETS = 128.138.0.0/255.255.0.0 Host_Alias CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0 Host_Alias SERVERS = master, mail, www, ns Host_Alias CDROM = orion, perseus,...
0 0
14

su (Switch User)

One of the features of Linux is the ability to change userid when logged into a system. This command su is sometimes referred to as superuser , however this is not completely correct. In the early days of UNIX it was only possible to change to the root user, which made for the superuser command however it is now possible to change to any user using the su command. It is more correct to refer to the command as the switch user command.

The switch user command su is used to change between different users on a system, without having to logout. The most common use is to to change to the root user, but it can be used to switch to any user depending upon the users settings. To switch to a different user other than root, then the username is used as the last option on the command.

It is also possible to change to another user by putting the username after the su command. There are two ways of switching users. By putting a '-' after the...

0 0
15

By Gary Newell

Updated August 22, 2016.

Introduction

New users to Linux, especially Ubuntu users, soon become aware of the sudo command.

It is highly likely however, that most users never get beyond the fact that when they see the words "permission denied" they know that if they try the command again with sudo it will probably work.

This guide reveals more information about the sudo command such as how to grant access to sudo by adding a user to the sudoers file.

About sudo

A common misconception about sudo is that it is used solely to provide root permissions to an ordinary user.

In fact the sudo command allows you to run a command as any user, with the default generally being the root user.

How To Grant User sudo Permissions

Ubuntu users probably take it for granted that they can always run the sudo command. The reason that this is possible is that during the installation stage a default user is...

0 0
16

You can use the -l flag to list your privileges.

-l[l] [command] If no command is specified, the -l (list) option will list the allowed (and forbidden) commands for the invoking user (or the user specified by the -U option) on the current host. If a command is specified and is permitted by sudoers, the fully-qualified path to the command is displayed along with any command line arguments. If command is specified but not allowed, sudo will exit with a status value of 1. If the -l option is specified with an l argument (i.e. -ll), or if -l is specified multiple times, a longer list format is used.

If you're not in the file, you should get the "not in the sudoers file" error you saw on the other...

0 0
17

This should get, under most normal situations, all normal (non-system, not weird, etc) users:

This is because on many linux systems, usernames above 1000 are reserved for unprivileged (you could say normal) users. Some info on this here:

A user ID (UID) is a unique positive integer assigned by a Unix-like operating system to each user. Each user is identified to the system by its UID, and user names are generally used only as an interface for humans.

UIDs are stored, along with their corresponding user names and other user-specific information, in the /etc/passwd file...

The third field contains the UID, and the fourth field contains the group ID (GID), which by default is equal to the UID for all ordinary users.

In the Linux kernels 2.4 and above, UIDs are unsigned 32-bit integers that can represent values from zero to 4,294,967,296. However, it is advisable to use values only up to 65,534 in order to maintain compatibility with systems...

0 0
18
gnome-session-quit dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1

(via DoR, see his answer to "Reboot without sudoer privileges?" for more dbus goodness!)

or alternatively, you can use

gnome-session-save --force-logout

--force-logout in contrast to just --logout will not ask the user to deal with unsaved documents and so on.

is this the easiest way? no simple one line command like sudo logout?? I will never remember all that.

Yes, there is a command called logout, but it concerns the Terminal. gnome-session-save is the program that actually quits the gnome-session, which you can of course kill, but that wouldn't qualify as logging out. :-)

Notice as well that these commands don't require you to be root.

You can always add an alias to your system if you want to have a shorter command.

Open ~/.bash_aliases with a text editor,...

0 0
19

Note: For help with configuring sudo privileges via its configuration file /etc/sudoers, please see Sudoers.

In Linux (and Unix in general), there is a SuperUser named root. The Windows equivalent of root is the Administrators group. The SuperUser can do anything and everything, and thus doing daily work as the SuperUser can be dangerous. You could type a command incorrectly and destroy the system. Ideally, you run as a user that has only the privileges needed for the task at hand. In some cases, this is necessarily root, but most of the time it is a regular user.

By default, the root account password is locked in Ubuntu. This means that you cannot login as root directly or use the su command to become the root user. However, since the root account physically exists it is still possible to run programs with root-level privileges. This is where sudo comes in - it allows authorized users (normally "Administrative" users; for further information please refer to...

0 0