[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
slackbook:users [2012/09/09 14:36 (UTC)] – [Managing Users and Groups] updated document with original content and formatting mfillpotslackbook:users [2012/10/14 15:56 (UTC)] (current) – removed all bash flags mfillpot
Line 19: Line 19:
 very fine **//adduser//** shell script. very fine **//adduser//** shell script.
 **//adduser//** will prompt you to enter the details **//adduser//** will prompt you to enter the details
-of the new user you wish to creature and step you through the process+of the new user you wish to create and step you through the process
 quickly and easily. It will even create a password for the new user. quickly and easily. It will even create a password for the new user.
  
  
-<code>+<file>
 darkstar:~# adduser darkstar:~# adduser
  
Line 87: Line 87:
  
 Account setup complete. Account setup complete.
-</code>+</file>
  
  
Line 150: Line 150:
 ===== Other User and Group Tools ===== ===== Other User and Group Tools =====
  
-Several other tools exist for managing users and groups. Perhaps the most important one is passwd(1). This command changes a user account's password. Normal users may change their own passwords only, but root can change anyone's password. Also, root can lock a user account with the [-largument. This doesn't actually shutout the account, but instead changes the user's encrypted password to a value that can't be matched.+Several other tools exist for managing users and groups. Perhaps the 
 +most important one is **//passwd//**(1). This 
 +command changes a user account's password. Normal users may change 
 +their own passwords only, but root can change anyone's password. Also, 
 +root can lock a user account with the //-l// argument. This 
 +doesn't actually shutout the account, but instead changes the user's 
 +encrypted password to a value that can't be matched.
  
-The easiest way for modifying a user's information is the usermod(8) utility which is capable of modifying everything from group membership to home directories. A full listing of its features won't be given here, so check the man page. usermod is perhaps the best tool to use for modifying a user's group members. The [-s] and [-G] arguments accomplish this. 
  
-  darkstar:~# usermod --G wheel alan +The easiest way for modifying user's information is the 
-  darkstar:~# usermod -G wheel alan+**//usermod//**(8) utility which is capable of 
 +modifying everything from group membership to home directories. A full 
 +listing of its features won't be given here, so check the man page. 
 +**//usermod//** is perhaps the best tool to use for 
 +modifying a user's group members.  The //-s// and //-G// 
 +arguments accomplish this.
  
-It important to note the differences in the two commands above. The first command adds the user "alan" to the "wheel" group without modifying any other groups "alan" belongs to. The second command also makes "alan" a member of the "wheel" group, but also removes the user's membership from any other groups, something you will very rarely want to do! 
  
-Another useful tool is chsh(1) which changes user's default shell. Like passwd, normal users can only change their own shell, but the root user can change anyone's.+<code> 
 +darkstar:~# usermod --G wheel alan 
 +darkstar:~# usermod -G wheel alan 
 +</code>
  
-The last tool we're going to discuss is chfn(1). This is used to enter identifying information on the user such as his phone number and real name. This information is stored in the passwd(5) file and retrieved using finger(1). + 
 +It important to note the differences in the two commands above.  The 
 +first command adds the user //"alan"// to the "wheel" group without 
 +modifying any other groups //"alan"// belongs to. The second command also 
 +makes //"alan"// a member of the //"wheel"// group, but also removes the user'
 +membership from any other groups, something you will very rarely want 
 +to do! 
 + 
 + 
 +Another useful tool is **//chsh//**(1) which changes a 
 +user's default shell. Like **//passwd//**, normal 
 +users can only change their own shell, but the root user can change 
 +anyone's. 
 + 
 + 
 +The last tool we're going to discuss is 
 +**//chfn//**(1). This is used to enter identifying 
 +information on the user such as his phone number and real name. This 
 +information is stored in the ''passwd''(5) file and 
 +retrieved using **//finger//**(1).
  
 ===== Managing Users and Groups Manually ===== ===== Managing Users and Groups Manually =====
  
-Like most things in Slackware Linux, users and groups are stored in plain-text files. This means that you can edit all the details of a user, or even create a new user or group simply by editing these files and doing a few other tasks like creating the user's home directory. Of course, after you see how this is done you'll appreciate just how simple the included tools make this task.+Like most things in Slackware Linux, users and groups are stored in 
 +plain-text files. This means that you can edit all the details of a 
 +user, or even create a new user or group simply by editing these files 
 +and doing a few other tasks like creating the user's home directory. Of 
 +course, after you see how this is done you'll appreciate just how 
 +simple the included tools make this task
 + 
 + 
 +Our first stop is the ''/etc/passwd'' file. Here, all 
 +the information about a user is stored, except for (oddly enough) the 
 +user's password. The reason for this is rather simple. 
 +''/etc/passwd'' must be readable by all users on the 
 +system, so you wouldn't want passwords stored there, even if they are 
 +encrypted. Let's take a quick look at my entry in this file. 
 + 
 + 
 +<file> 
 + 
 +alan:x:1000:100:,,,:/home/alan:/bin/bash 
 +</file> 
 + 
 + 
 +Each line in this file contains a number of fields seperated by a 
 +colon. They are, from left to right: username, password, UID, GUID, a 
 +comment field, home directory, and shell. You'll notice that the 
 +password field for every entry is an <key>'x'</key>. That is 
 +because Slackware uses shadow passwords, so the actual encrypted 
 +password is stored in ''/etc/shadow''. Let's take a 
 +look there. 
 + 
 + 
 +<file> 
 + 
 +alan:$1$HlR?M3fkL@oeJmsdLfhsLFM*4dflPh8:14197:0:99999:7::: 
 +</file> 
 + 
 + 
 +The ''shadow'' file contains more than just the 
 +encrypted password as you'll notice. The fields here, again from left 
 +to right, are: username, encrypted password, last day the password was 
 +changed, days before the password may be changed again, how many days 
 +before the password expires, days that the account will be disabled 
 +after expiring, when the account was disabled, and a reserved field. 
 +You may notice on some accounts that the various //"days"// fields often 
 +include very large numbers. The reason for this is that Slackware 
 +counts time from the //"Epoch"// which is January 1, 1970 for historical 
 +reasons.
  
-Our first stop is the /etc/passwd file. Here, all the information about a user is stored, except for (oddly enough) the user's password. The reason for this is rather simple. /etc/passwd must be readable by all users on the system, so you wouldn't want passwords stored there, even if they are encrypted. Let's take a quick look at my entry in this file. 
  
-''alan:x:1000:100:,,,:/home/alan:/bin/bash''+To create a new user account, you'll just need to open these files 
 +using **//vipw//**(8). This will open 
 +''/etc/passwd'' in the editor 
 +defined by your VISUAL variable or your EDITOR variable if VISUAL isn'
 +defined. If neither is presentit will fall back to 
 +**//vi//** by default. If you pass the //-s// 
 +argument, it will open ''/etc/shadow'' instead. It's 
 +important to use **//vipw//** instead of using any 
 +other editor, because **//vipw//** will lock the 
 +file and prevent other programs from editing it right underneath your feet.
  
-Each line in this file contains a number of fields seperated by a colon. They are, from left to right: username, password, UID, GUID, a comment field, home directory, and shell. You'll notice that the password field for every entry is an x. That is because Slackware uses shadow passwords, so the actual encrypted password is stored in /etc/shadow. Let's take a look there. 
  
-''alan:$1$HlR?M3fkL@oeJmsdLfhsLFM*4dflPh8:14197:0:99999:7:::''+That isn't all you'll need to do however; you must also create the 
 +user's home directory and change the user's password using 
 +**//passwd//**.
  
-The shadow file contains more than just the encrypted password as you'll notice. The fields here, again from left to right, are: username, encrypted password, last day the password was changed, days before the password may be changed again, how many days before the password expires, days that the account will be disabled after expiring, when the account was disabled, and a reserved field. You may notice on some accounts that the various "days" fields often include very large numbers. The reason for this is that Slackware counts time from the "Epoch" which is January 1, 1970 for historical reasons.+====== Chapter Navigation ======
  
-To create a new user account, you'll just need to open these files using vipw(8). This will open /etc/passwd in the editor defined by your VISUAL variable or your EDITOR variable if VISUAL isn't defined. If neither is present, it will fall back to vi by default. If you pass the [-sargument, it will open /etc/shadow instead. It's important to use vipw instead of using any other editor, because vipw will lock the file and prevent other programs from editing it right underneath your feet.+**Previous Chapter: [[slackbook:printing|Printing]]**
  
-That isn't all you'll need to do however; you must also create the user's home directory and change the user's password using passwd. +**Next Chapter: [[slackbook:filesystem_permissions|Filesystem Permissions]]**
  
-=====Sources=====+====== Sources =====
 +<!-- If you copy information from another source, then specify that source --> 
 +  * Original source: [[http://www.slackbook.org/beta]] \\ 
 +<!-- Authors are allowed to give credit to themselves! --> 
 +  * Originally written by Alan Hicks, Chris Lumens, David Cantrell, Logan Johnson 
 +<!-- * Contrbutions by [[wiki:user:yyy | User Y]] -->
  
- * Original source: http://www.slackbook.org/beta/#ch_users (authors: Alan Hicks, Chris Lumens, David Cantrell, Logan Johnson)+<!-- Please do not modify anything below, except adding new tags.--> 
 +<!-- You must also remove the tag-word "template" below. Otherwise your page will not show up in the Table of Contents --> 
 +{{tag>slackbook users groups passwd}}
 slackbook:users ()