Information Technology News
UID and GID: the basics of Linux user admin | UID and GID: the basics of Linux user admin |
|
| by David M Williams | |
| Friday, 14 September 2007 | |
|
Page 3 of 3 The useradd program
Featured Whitepaper
5 Best Practices for Smartphone Support
Secondly, the user must be given a home directory which corresponds exactly with the home directory specified in /etc/passwd. The permissions and ownership of this directory must be set such that it belongs to the user and his or her group, and that the user can read and write to their own home directory. The following commands fit the bill: mkdir /home/fred
That’s the real deal. For those who are adverse to shell commands and text file editing, It’s far from being the only way. Linux provides a command called useradd which automates the entire process. useradd adds the relevant entries to /etc/passwd, /etc/shadow and /etc/group, and will make a directory with permissions set appropriately. The useradd program will also take files from a directory called /etc/skel and copy these into the new directory. So, any files that should be given to a new user – such as login files to set up environment variables – should be set up in that folder.
Of course, if you want to restrict the user’s access on your system, then you should not give them a login shell – but rather something else like /bin/false – and also perhaps not even a valid home directory. You could set the home directory to /tmp or some other shared area with unimportant data. However, even after this, there may still be other files in the system that belong to the phantom UID once known as user, such as e-mail in /var/mail or temporary files in /tmp. The userdel command won’t remove these or look for them. Locate these files and inspect them. Then make a decision to either remove or back up, or whether to change their ownership to another, still current, user, depending on privacy and importance. Changing account creation defaults
The home directory prefix and the login shell can be changed to default to any specific value for all future users that may be created. The current defaults are listed in /etc/default/useradd, or can be dumped to the screen via useradd –D. You're not stuck with what the program thinks are sensible options!
The defaults can be overridden by using these same flags with the useradd command when creating a new account, should that ever be necessary. That’s the fundamentals of user management. In many ways this has been basic information. Yet, in another, it’s not basic. This is the arcane happenings of the mouse clicks, menus and icons that make today’s operating system work. Understanding this makes you a better Linux admin and user. |
| < Next story in category | Previous story in the category > |
|---|


Tags





