0

I have configured Ubuntu Server for my needs, and basically everything is working as I want. I'm new to Linux, but learned a lot using and interpreting different guides, however, this particular problem gives me headache. As I don't want to mess up permissions, etc, I would like to ask for your help.

I use latest Webmin. I can easily create a new user (I also used command line with my default user as well). I can login with ssh with ssh test@ip, I have the user's home dir, but I just can't execute any commands, like ls, ifconfig, nothing. I read that I should use relative paths, etc. but what I want is to achieve that the new user has the same abilities as default like the user a configured on installing Ubuntu, and use as default. I read also that a bash needs to be configured with some PATH variables, but I don't understand that part.

My default user that works perfectly well is 'server'. Let's say I create a new user 'test'. Can zou guide me step-by-step how next?

Also, if I want that the new user 'test' has access to my files created by user 'server' and also 'server' to the files created by user 'test' I need to add user 'test' to the group of user 'server'?

Many thanks!

4

The correct way to create new user is by using the adduser binary (it covers everything from user password to group and home folder creation, thanks to @muru @Takkat for pointing this out, Man Page of the command):

 ubuntu@ip:/$ sudo adduser testuser
 Adding user `testuser' ...
 Adding new group `testuser' (1003) ...
 Adding new user `testuser' (1002) with group `testuser' ...
 Creating home directory `/home/testuser' ...
 Copying files from `/etc/skel' ...
 Enter new UNIX password:
 Retype new UNIX password:
 passwd: password updated successfully
 Changing the user information for testuser
 Enter the new value, or press ENTER for the default
         Full Name []: 
         Room Number []:
         Work Phone []:
         Home Phone []:
         Other []:
 Is the information correct? [Y/n] Y

This will create the user named testuser and give them their own home directory in /home/testuser. The files in the new home directory are copied from the /etc/skel folder, which contains default home directory files. If you wanted to set default values for your users, you would do so by modifying or adding files in that directory. If you want your new user to have same environment as server user just copy these files from server home directory to testuser home directory (make sure after you copy them that each one of them have testuser as owner chown testuser:testuser .bash_profile etc.):

.bash_profile .bashrc .inputrc .mkshrc .profile

And yes, if you want both users to have access to their files and folder you have to add each of them to the other users group:

adduser server testuser
adduser testuser server

What the user can access is determined of the folder/file permissions for that group (for example in order user testuser to read and write file test.txt in server's home folder it has to have at least permissions of 760). You can view the permissions by excuting

$ ls -al
drwxrwxr-x   3 server server    4096 Jun 14 10:11 test.txt

Permissions

6
  • @Takkat according to the link that you have provided there is no real difference between two commands, despite the fact the adduser is more user friendly. It is stated that adduser uses the binary of useradd, So I really do not see your point or what was the downvote for. I have explained everything in detail. – Sh1d0w Apr 7 '15 at 6:55
  • -1 for using useradd -G without -a - a silly error that simply wouldn't happen if you listened and used adduser. adduser also creates a skeleton home directory, which useradd doesn't. – muru Apr 7 '15 at 7:33
  • @muru Ok guys, I was not aware of that. I have changed the answer. If you see another way to improove it a bit, please let me know. – Sh1d0w Apr 7 '15 at 7:40
  • Better. +1. Occasionally we do get a user who lost sudo access because they used useradd -G without the -a, or some other similar problem. At this point, given adduser exists and does a very good job, covering useradd, passwd and chfn, I see no reason to directly use useradd. – muru Apr 7 '15 at 7:44
  • Thank you for this detailed answer, it clarified all my doubts and now everything is working fine as it should! One more question: are there any default groups that the new user should be added to (like adm) or it depends what I want to achieve? – gurabli Apr 8 '15 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.