Little Girl's Mostly Linux Blog

Users

Users

This page was last updated on September 07, 2009.

Add a user

To add a new user to your system, open a terminal window and type this command in a terminal window, replacing USERNAME with the name of the user:
sudo adduser USERNAME
Answer the questions that come up, giving the user a password, etc. This will create a /home/USERNAME directory for them on the system. Note that the password you assign for the user is only temporary. The user will be required to change the password immediately when he or she logs on for the first time.

Remove a user

To remove a user from your system, type this command in a terminal window, replacing USERNAME with the name of the user:
sudo deluser USERNAME

Check UID of a user

To check the UID (User ID represented by a number), look in the /etc/passwd file.

Assign a password to a user

To assign a password to a user, type this command in a terminal window, replacing USERNAME with the name of the user:
passwd USERNAME

Set Up A Common Folder For Users

By default all users have the ability to create and edit content in their own folders, but cannot alter the content of other users’ folders. If you’d like to create a folder in which more than one user can create and edit content, you’ll need to creat a common folder.

  1. Open a terminal window on the guest and create a new group called common by typing:
  2. sudo addgroup common
  3. Modify the user’s account, (-a) appending him or her to that (-G) group by typing this command, replacing USERNAME with the name of the user:
  4. sudo usermod -a -G common USERNAME
  5. Create the common directory by typing:
  6. sudo mkdir common
  7. Set its group to the common group by typing:
  8. sudo chgrp -R common common
  9. Set its permissions to 777 by typing:
  10. sudo chmod -R 777 common
  11. Set its groupID bit so that files created there will have the properties of the creator’s username and the common group by typing:
  12. sudo chmod g+s common
  13. Open the fstab file for editing by typing:
  14. sudo nano /etc/fstab
  15. Add access control list capability to the file system where common is located to control how files created in that directory inherit permissions. To do this, find the line for the drive where common is located. The line will contain ext3 and relatime. Make sure acl is included in the line as in this example:
  16.    / ext3 acl,relatime
  17. When you’re finished, press the Ctrl and o keys at the same time. Press the Enter key to accept the file name it automatically offers. Press the Ctrl and x keys at the same time to exit the editor.
  18. Reboot the machine to enable the acl setting by typing:
  19. sudo reboot
  20. Open a terminal window and turn on default (-d) rwx modification (-m) for the common group on all files created or modified in that directory by typing:
  21. sudo setfacl -d -m group:common:rwx common

Test The Common Folder

To test the common folder to be sure it’s set up properly:

  1. Open a terminal window.
  2. Change to the common directory by typing this command, replacing the path in this example with the path to the common folder you created:
  3. cd /home/common
  4. Create a test file by typing:
  5. touch test.txt
  6. Edit the new file by typing:
  7. nano test.txt
  8. Add a line of text and save the file.
  9. Save the file by pressing the Ctrl and o keys at the same time and then pressing the Enter key to accept the file name.
  10. Exit the editor by pressing the Ctrl and x keys at the same time.
  11. Change to a user who has access to the common folder by typing this command, replacing USERNAME with the name of the user:
  12. su USERNAME
  13. Provide the user’s password. If this is unknown, you will either need the user to test the access for you or you can use the instructions above to create a new user and give that user access to common, deleting the user when finished with the test.
  14. While logged in as the other user, type:
  15. nano test.txt

    You should see the line of text you originally typed into the file.

  16. Change the line of text in the file or add a new line to the file.
  17. Save the file by pressing the Ctrl and o keys at the same time and then pressing the Enter key to accept the file name.
  18. Exit the editor by pressing the Ctrl and x keys at the same time.
  19. Change back to your username by typing this command, replacing USERNAME with your username:
  20. su USERNAME
  21. View the text file by typing:
  22. cat test.txt

    You should see the changes you made to the file. If you don’t, go back through all the steps to make sure you did them properly.



Obligatory Happy Ending

And they all lived happily ever after. The end.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Comment:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: