Using Ubuntu server, how does one add an existing user to the sudo group (which is the “administrators” group in Ubuntu), thus granting that user pretty much full rights on the box?
Turns out that the answer is pretty much the same way you add a user to any other group in Ubuntu. If the user has already been created via the adduser command earlier (for argument’s sake, you named him bob), you simply now run the following command from the terminal:
sudo usermod -a -G sudo bob
Nifty.
(Note, if logged in, that user must first log off and then back in again for this change to take effect.)
Ubuntu Server: How to See Group Members Tips, Tricks and Tutorials 12 JUN 2015
The scenario is this. Your file listing is showing you that a file belongs to a particular group, but now the next question that you have is what users are actually members of this group?
Well, getting this information via the command line terminal is pretty simple as it turns out – Just run the getent command:
getent group <GROUPNAME>
or
getent group <GROUPNAME> | awk -F: '{print $4}'
In case you aren’t familiar with getent:
“getent is a unix command that helps a user get entries in a number of important text files called databases. This includes the passwd and group databases which store user information – hence getent is a common way to look up user details on Unix. Since getent uses the same name service as the system, getent will show all information, including that gained from network information sources such as LDAP. The databases it searches in are: ahosts, ahostsv4, ahostsv6, aliases, ethers (Ethernet addresses), group, gshadow, hosts, netgroup, networks, passwd, protocols, rpc, services, and shadow.”
Easy peasy :)
Related Link: https://en.wikipedia.org/wiki/Getent
How to Add another Sudo User Account to an Ubuntu Server Tips, Tricks and Tutorials 25 AUG 2013
Adding a new sudo super powered user account to your Ubuntu Server is pretty simple, and more as a note to myself than anything else, here are the steps to do it.
[IMPORTANT: This has the potential to seriously damage your system if it goes wrong – mucking up the sudo command had grave consequences for any linux distro. Try it out in a test environment first if you can!]
First, add the new user account through the use of the useradd command. Note the added switches which create the user’s home directory in the specified location.
sudo useradd -d /home/newuseraccount -m newuseraccount
With the user created, next set his password using:
sudo passwd newuseraccount
(I like bash as my default shell, so you can follow these steps to do this if needed).
Now the fun part. While we can make use of the visudo command to directly edit the sudoers file (in the past this was the only way to do it), nowadays it is advised to rather make custom changes in an extra file, basically meaning that you can now easily upgrade your system without losing all of your carefully crafted user accounts. To do this, create a file in the /etc/sudoers.d directory and edit it.
sudo touch /etc/sudoers.d/sudo-custom sudo chmod 0440 /etc/sudoers.d/sudo-custom sudo nano /etc/sudoers.d/sudo-custom
Append the following line to add your new user account to the list of sudo accounts:
newuseraccount ALL=(ALL:ALL) ALL
Note we’ve gone and created a really powerful sudo account with the declaration above. You might want to temper it a bit by reading up on the various options available to you.
Done.
Ubuntu Subversion: How to Change a SVN User Account Password CodeUnit 04 FEB 2013
If you control access to your SVN repository via Apache authentication, then you’ll undoubtedly have a password file somewhere on your system, containing the list of all the users who have an account that can access your SVN repo.
The standard file used by Subversion for this task is located at /etc/subversion/passwd.
Now that we know that, changing a user account’s password used to access the SVN is relatively trivial, and achieved through the use of the Linux htpasswd function.
First, let’s grab a list of all user accounts currently with access to your SVN repository:
cat /etc/subversion/passwd
Now let’s change a user’s password by making use of the -m switch to specify a password change using MD5 encryption, where usertomodify is the username of the user you wish to affect.
sudo htpasswd -m /etc/subversion/passwd usertomodify
Done. Note that the call without a switch would attempt to add a new user account, with a -D switch would remove the specified user and with a -c switch would create a new user but overwrite your existing password file!
Nifty.
Ubuntu Subversion: How to Disable a SVN User Account CodeUnit 14 JAN 2013
If you control access to your SVN repository via Apache authentication, then you’ll undoubtedly have a password file somewhere on your system, containing the list of all the users who have an account that can access your SVN repo.
The standard file used by Subversion for this task is located at /etc/subversion/passwd.
Now that we know that, disabling, i.e. deleting a user account and thus preventing access to the SVN is relatively trivial, and achieved through the use of the Linux htpasswd function.
First, let’s grab a list of all user accounts currently with access to your SVN repository:
cat /etc/subversion/passwd
Now let’s delete a user by making use of the -D switch where usertodelete is the username of the user you wish to remove.
sudo htpasswd -D /etc/subversion/passwd usertodelete
Done. Note that the call without a switch would attempt to add a new user account, with a -m switch would prompt a password change, and with a -c switch would create a new user but overwrite your existing password file!
Nifty.
How to Create an User on an Ubuntu Server CodeUnit 10 OCT 2011
There are two commands which you can use to create an user account on an Ubuntu Server installation. The first command is the adduser command which is not very flexible but is user friendly in that it prompts you for data with each and every step in the creation process.
The other more flexible command is useradd. Simply calling it with the desired username as a parameter will create a user account, but without listing extra options this user account won’t have a password or even a home directory. One of the better ways of calling it then is as such:
sudo useradd -d /home/newuseraccount -m newuseraccount
sudo passwd newuseraccount
The above will add a new user on the system with the username “newuseraccount”. The -d option specifies where to create the home directory and the -m forces the creation of your specified directory. Note it copies files for the new home directory from the /etc/skel folder. Although we could have specified a password by using the -p option, it might be a better idea to stick with the classic passwd call to do this.
Nifty.
Ubuntu Subversion: How to Add a User to the SVN CodeUnit 08 JUL 2011
To add a SVN User to an Ubuntu Subversion SVN server is very simple. The first thing to do is to check the existence of the subversion passwd file, the default being /etc/subversion/passwd. This is the file containing user authentication details.
To check for its existence, run:
cat /etc/subversion/passwd
If it doesn’t exist you’ll need to create it as you add the first user account to your SVN, using he -c switch. Of course, if it does exist, don’t use the -c switch as this will overwrite your users file!
To add the first user and create the passwd file at the same time, run:
sudo htpasswd -c /etc/subversion/passwd user_name
This will prompt you to set a password for the user account.
From then on to add extra users, simply run:
sudo htpasswd /etc/subversion/passwd second_user_name
Nifty.
Ubuntu: How to Delete a MySQL User Account via the Terminal CodeUnit 19 JAN 2011
To delete a user account from a MySQL server instance, we need to make use of a DROP USER call to the mysql.user table.
First, fire up MySQL in your terminal and login as an administrator account with:
mysql -u root -p
You will be prompted for your root password before being granted access to the MySQL monitor.
Now to grab a list of available user accounts on the system. Running:
select user,host from mysql.user;
Once you have spotted the account you wish to remove, run the following query:
drop user 'username'@'localhost';
Simple and nifty.
Related Link: http://dev.mysql.com/doc/refman/5.1/en/drop-user.html
Ubuntu: How to Create a MySQL User Account via the Terminal CodeUnit 17 JAN 2011
To create a user account from a MySQL server instance, we need to make use of a CREATE USER call to the mysql.user table.
First, fire up MySQL in your terminal and login as an administrator account with:
mysql -u root -p
You will be prompted for your root password before being granted access to the MySQL monitor.
Now to grab a list of available user accounts on the system. Running:
select user,host from mysql.user;
If the user account that you wish to create doesn’t appear in that list, you are good to go. To create a new user account run the following query:
create user 'new-username'@'localhost' identified by 'password-for-new-account';
If you omit the @’localhost’ section, the user account will be generated with a host value of ‘%’. If you omit the identified by section, the user account will be created without a password (which is of course quite insecure).
Of course, this user isn’t linked to any databases yet, but this is simple to rectify with a:
grant all on mydatabase.* to useraccount@localhost
that will grant all rights for the user account to everything held in the mydatabase database. (Note that you generally don’t want to assign all rights, so will scale back as necessary in a real world example.)
Simple and nifty.
Related Link: http://dev.mysql.com/doc/refman/5.1/en/create-user.html