Linux Systems Administrators - Users

26 538 0
Linux Systems Administrators - Users

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter Users Introduction Before anyone can use your system, they must have an account This chapter examines user accounts and the responsibilities of the Systems Administrators with regards to accounts By the end of this chapter you should: · · · · · · be aware of the process involved in creating and removing user accounts be familiar with the configuration files that UNIX uses to store information about accounts know what information you must have to create an account understand the implications of choosing particular usernames, user ids and passwords be aware of special accounts including the root account and the implications of using the root account have been introduced to a number of public domain tools that help with account management Other resources Other material which discusses user and authentication related material includes: · · Guides The Linux Installation and Getting Started Guide has a section (4.6) on user management The Linux Systems Administrators Guide’s chapter 11 also discusses managing user accounts The Linux Administration Made Easy Guide also provides some discussion of account related issues in its chapter The customisations and usage guides that come with your Linux distribution also cover account management issues What is a UNIX account? A UNIX account is a collection of logical characteristics that specify who the user is, what the user is allowed to and where the user is allowed to it These characteristics include a: · · · · · · · login (or user) name password numeric user identifier or UID default numeric group identifier or GID Many accounts belong to more than one group but all accounts have one default group home directory login shell possibly a mail alias Page 231 · · mail file collection of startup files Login names The account of every user is assigned a unique login (or user) name The username uniquely identifies the account for humans The operating system uses the user identifier number (UID) to uniquely identify an account The translation between UID and the username is carried out reading the /etc/passwd file (/etc/passwd is introduced below) Login name format On a small system, the format of login names is generally not a problem since with a small user population it is unlikely that there will be duplicates However on a large site with hundreds or thousands of users and multiple computers, assigning a login name can be a major problem With a larger number of users it is likely that you may get a number of people with names with similar components, like David Jones, Darren Jones The following is a set of username guidelines They are by no means hard and fast rules, but using some or all of them can make life easier for yourself as the Systems Administrator, or for your users · · · · · · Unique This means usernames should be unique not only on the local machine but also across different machines at the same site A login name should identify the same person and only one person on every machine on the site This can be very hard to achieve at a site with a large user population, especially if different machines have different administrators The reason for this guideline is that under certain circumstances it is possible for people with the same username to access accounts with the same username on different machines There is an increasing trend for global logons One username/password will get users into all of the systems they need for a given organisation Up to characters UNIX will ignore or disallow login names that are longer This is dependent on which platform you are using Lowercase Numbers and upper case letters can be used Login names that are all upper case should be avoided, as some versions of UNIX can assume this to mean your terminal doesn't recognise lower case letters and every piece of text subsequently sent to your display is in uppercase Easy to remember A random sequence of letters and numbers is hard to remember and so the user will be continually have to ask the Systems Administrator "what's my username?" No nicknames A username will probably be part of an email address The username will be one method by which other users identify who is on the system Not all the users may know the nicknames of certain individuals A fixed format There should be a specified system for creating a username Some combination of first name, last name and initials is usually the best Setting a policy allows you to Page 232 automate the procedure of adding new users It also makes it easy for other users to work out what the username for a person might be Passwords An account's password is the key that lets someone in to use the account A password should be a secret collection of characters known only by the owner of the account Poor choice of passwords is the single biggest security hole on any multi-user computer system As a Systems Administrator, you should follow a strict set of guidelines for passwords (after all, if someone can break the root account's password, your system is going bye-bye) In addition you should promote the use of these guidelines amongst your users Password guidelines An example set of password guidelines might include: · · · · · · · · · · · use combinations of upper and lower case characters, numbers and punctuation characters don't use random combinations of characters if they break the following two rules be easy to remember If a user forgets their password they can't use the system - guess whom they come and see? Furthermore, the user SHOULD NOT have to write their password down be quick to type One of the easiest and most used methods for breaking into a system is simply watching someone type in their password It is harder to if the password is typed in quickly a password should be at least characters long The shorter a password, is the easier it is to break Some systems will not allow passwords shorter than a specified length a password should not be any longer than to 10 characters Most systems will look as if they are accepting longer passwords but they simply ignore the extra characters The actual size is system specific, but between eight and ten characters is generally the limit not use words from ANY language Passwords that are words can be cracked (you'll see how later) not use combinations of just words and numbers Passwords like hello1 are just as easy to crack as hello use combinations of words separated by punctuation characters, or acronyms of uncommon phrases/song lines They should be easy to remember but hard to crack for example b1gsh1p change passwords regularly But not so often that you forget which password is currently set never reuse passwords The UID Every account on a UNIX system has a unique user or login name that is used by users to identify that account The operating system does not use this name to identify the account Instead each account must be assigned a unique user identifier number (UID) when it is created The UID is used by the operating system to identify the account UID guidelines Page 233 In choosing a UID for a new user, there are a number of considerations to take into account including: · · · choose a UID number between 500 and 32767 (or 60000) Numbers between and 499 are reserved by some systems for use by system accounts Different systems will have different possible maximum values for UID numbers Around 32000 and 64000 are common upper limits When you use the supplied utilities to create users, they will allocate a valid UID as part of the process UIDs for a user should be the same across machines Some network systems (for example NFS) require that users have the same UID across all machines in the network, otherwise they will not work properly you may not want to reuse a number Not a hard and fast rule Every file is owned by a particular user id Problems arise where a user has left and a new user has been assigned the UID of the old user What happens when you restore from backups some files that were created by the old user? The file thinks the user with a particular UID owns it The new user will now own those files, even though the username has changed Home directories Every user must be assigned a home directory When the user logs in, it is this home directory that becomes the current directory Typically all user home directories are stored under the one directory Many modern systems use the directory /home Older versions used /usr/users The names of home directories will match the username for the account For example, a user jonesd would have the home directory /home/jonesd In some instances, it might be decided to further divide users by placing users into different sub-directories For example, all staff accounts may go under /home/staff while students are placed under /home/students These separate directories may even be on separate partitions Login shell Every user account has a login shell A login shell is simply the program that is executed every time the user logs in Normally it is one of the standard user shells such as Bourne, csh, bash etc However it can be any executable program One common method used to disable an account is to change the login shell to the program /bin/false When someone logs into such an account, /bin/false is executed and the login: prompt reappears Dot files A number of commands, including vi, the mail system and a variety of shells, can be customised using dot files A dot file is usually placed into a user's home directory and has a filename that starts with a (dot) These files are examined when the command is first executed and modifies how it behaves Dot files are also known as rc files As you should've found out by doing one of the exercises from the previous chapter, rc is short for "run command" and is a left over from an earlier operating system Commands and their dot files Page 234 Table 10.1 summarises the dot files for a number of commands The FAQs for the newsgroup comp.unix.questions has others Shell dot files These shell dot files, particularly those executed when a shell is first executed, are responsible for: · · setting up command aliases Some shells (for example bash) allow the creation of aliases for various commands A common command alias for old MS-DOS people is dir, usually set to mean the same as the command ls -l setting values for shell variables like PATH and TERM Filename Command ~/.cshrc /bin/csh Executed every time C shell started ~/.login /bin/csh Executed after cshrc when logging in with C shell as the login shell /etc/profile /bin/sh Executed during the login of every user that uses the Bourne shell or its derivatives ~/.profile /bin/sh Located in user's home directory Executed whenever the user logs in when the Bourne shell is their login shell ~/.logout /bin/csh ~/.bash_profile /bin/bash Located in user's home directory Executed whenever the user logs in when the Bourne Again shell (bash) is their login shell ~/.bash_logout /bin/bash Executed just prior to the system logging the user out (when bash is the login shell) ~/.bash_history /bin/bash Records the list of commands executed using the current shell ~/.bashrc /bin/bash bash shell configuration file – run every time a bash shell is started (not just when you Explanation Executed just prior to the system logging the user out (when the csh is the login shell) login) ~/.forward incoming mail ~/.viminfo Vi Used to forward mail to another address or a command Used to set options for use in vi Table 10.1 Dot files Page 235 Skeleton directories Normally all new users are given the same startup files Rather than create the same files from scratch all the time, copies are usually kept in a directory called a skeleton directory This means when you create a new account you can simply copy the startup files from the skeleton directory into the user's home directory The standard skeleton directory is /etc/skel It should be remembered that the files in the skeleton directory are dot files and will not show up if you simply use the command ls /etc/skel You will have to use the -a switch for ls to see dot files Exercises 10.1 10.2 Examine the contents of the skeleton directory on your system (if you have one) Write a command to copy the contents of that directory to another Hint: It's harder than it looks Use the bash dot files to create an alias dir that performs the command ls -al The mail file When someone sends mail to a user, that mail message has to be stored somewhere so that it can be read Under UNIX, each user is assigned a mail file All user mail files are placed in the same directory When a new mail message arrives it is appended onto the end of the user's mail file The location of this directory can change depending on the operating system being used Common locations are: · · /usr/spool/mail · · /usr/mail /var/spool/mail This is the standard Linux location /var/mail All mail in the one location On some sites, it is common for users to have accounts on a number of different computers It is easier if all the mail for a particular user goes to the one location This means that a user will choose one machine as their mail machine and want all their email forwarded to their account on that machine There are at least two ways by which mail can be forwarded: · · the user can create a forward file in their home directory (see Table 10.1) the Systems Administrator can create an alias Mail aliases If you send an e-mail message that cannot be delivered (for example you use the wrong address), typically the mail message will be forwarded to the postmaster of your machine There is usually no account called postmaster, postmaster is a mail alias When the mail delivery program gets mail for postmaster it will not be able to find a matching username Instead it will look up a specific file, under Linux /etc/aliases This file will typically have an entry like Page 236 postmaster: root This tells the delivery program that anything addressed postmaster should actually be delivered to the user root Take a look at the /etc/aliases file on your system for other aliases Site aliases Some companies will have a set policy for e-mail aliases for all staff This means that when you add a new user, you also have to update the aliases file For example The Central Queensland University has aliases set up for all staff An e-mail with an address using the format Initial.Surname@cqu.edu.au will be delivered to that staff member's real mail address In my case the alias is d.jones@cqu.edu.au The main on-campus mail host has an aliases file that translates this alias into my actual e-mail address jonesd@jasper.cqu.edu.au Linux mail The following exercise requires that you have mail delivery working on your system You can test whether or not email is working on your system by starting one of the provided email programs (for example mail or pine) and send yourself an email message You this by using only your username as the recipient address (no @) If it isn't working, refer to the documentation from Red Hat on how to get email functioning Exercises 10.3 Send a mail message from the root user to your normal user account using a mail program of your choice 10.4 Send a mail message from the root user to the address notHere This mail message should bounce (be unable to be delivered) You will get a returned mail message Have a look at the mail file for postmaster Has it increased? 10.5 Create an alias for notHere and try the above exercise again If you have installed sendmail, the following steps should create an alias: - login as root - add a new line containing notHere: root in the file /etc/aliases - run the command newaliases Page 237 Account configuration files Most of the characteristics of an account mentioned above are stored in two or three configuration files All these files are text files Each account has a one-line entry in the file with each line divided into a number of fields using colons Table 10.2 lists the configuration files examined and their purpose By default, Linux systems use the shadow utilities suite to provide a more secure method of storing passwords This method stores passwords in the /etc/shadow file rather than in /etc/passwd On some platforms, the shadow file will exist but its filename will be different Why shadow password files are more secure is explained later in the chapter File Purpose The password file, holds most of an account characteristics including username, UID, GID, GCOS information, login shell, home directory and in some cases the password /etc/passwd The shadow password file, a more secure mechanism for holding the password, common on modern systems /etc/shadow The group file, holds characteristics about a system's groups including group name, GID and group members /etc/group /etc/gshadow The /etc/gshadow file is readable only by the root user, and contains an encrypted password for each group, as well as group membership and administrator information Table 10.2 Account configuration files /etc/passwd is the main account configuration file Table 10.3 summarises each of the fields in the /etc/passwd file On systems that not use shadow passwords, the encrypted password will be stored in the /etc/passwd file /etc/passwd Field Name Purpose login name The user's login name encrypted password * Encrypted version of the user's password (or an x if shadow passwords are in use) UID number The user's unique numeric identifier default GID The user's default group id GECOS information home directory login shell * No strict purpose, usually contains full name and address details, sometimes called the comment field The absolute path to the directory in which the user is placed when they log in The program that is run when the user logs in not on systems with a shadow password file Table 10.3 /etc/passwd Page 238 Exercises 10.6 Examine your account's entry in the /etc/passwd field What is your UID, GID? Where is your home directory and what is your login shell? Everyone can read /etc/passwd Every user on the system must be able to read the /etc/passwd file This is because many of the programs and commands a user executes must access the information in the file For example, when you execute the ls -l command, part of what the command must is translate the UID of the file's owner into a username The only place that information is stored is in the /etc/passwd file This is a problem Since everyone can read the /etc/passwd file they can also read the encrypted password The problem isn't that someone might be able to decrypt the password - the method used to encrypt the passwords is supposedly a one-way encryption algorithm You aren't supposed to be able to decrypt the passwords The problem is, however, that advances in computing power and parallel computing have shown it is possible to use the encrypted passwords to work out the actual passwords, as described below Password matching The quickest way to break into a UNIX system is to obtain a dictionary of words and encrypt the whole dictionary You then compare the encrypted words from the dictionary with the encrypted passwords If you find a match, you know what the password is Studies have shown that with a carefully chosen dictionary, between 10-20% of passwords can be cracked on any machine Later in this chapter you'll be shown a program that can be used by the Systems Administrator to test users' passwords An even greater problem is the increasing speed of computers One modern super computer is capable of performing 424,400 encryptions a second This means that all six-character passwords can be discovered in two days and all seven-character passwords within four months The solution The solution to this problem is simple: store the encrypted passwords in another file accessible only to the root user Remember the passwd program is setuid root This new file is called the shadow file and stores only passwords and password related information It can be stored in one of a number of different locations depending on the version of UNIX you are using A common location, and the one used by the Linux shadow password suite, is /etc/shadow By default, when shadow passwords are used, the more secure MD5 encryption algorithm is used to encrypt passwords During installation of your Linux distribution, you can opt not to use shadow passwords Utilities are available which can convert to and from normal passwords to shadow passwords after installation Where possible you should use shadow passwords Page 239 Shadow file format /etc/shadow Typically the shadow file consists of one line per user containing the encrypted password and some additional information, in the following format: · · · · · · · · username encrypted password If this field contains a * or ! the account is locked and the user cannot login If the account is new and no password has ever been set, the value is !! and the user cannot login the date the password was last changed minimum number of days before the password can be changed again maximum number of days before the password must be changed number of days until age warning is sent to user number of days of inactivity before account should be removed absolute date on which the password will expire The additional information is used to implement password aging which allows an administrator to force users to change passwords at specified intervals This will be discussed later in the security chapter Groups A group is a logical collection of users Users with similar needs or characteristics are usually placed into groups A group is a collection of user accounts that can be given special permissions Groups are often used to restrict the access to certain files and programs to a specified collection of users /etc/group The /etc/group file maintains a list of the current groups for the system and the users that belong to each group The fields in the /etc/group file include: · · · · the group name A unique name for the group an encrypted password (this is rarely used today) If the field contains an x, the shadow group passwords are in use the numeric group identifier or GID the list of usernames of the group members separated by commas Shadow Passwords for Groups /etc/gshadow Although group passwords are seldom used, shadow passwords are implemented for group passwords in the file /etc/gshadow In addition to storing the group password, the following information is maintained: · · The group name Encrypted password This allows users who know the group password to add themselves to the group with the newgrp command If the value is ! or !! no user can access the group via the newgrp command Page 240 At this point, by making the default umask 002, you can easily set up groups that users can take advantage of without any extra work, every time users write files to the group's common directory Just create the group, add the users, and the above chown and chmod on the group's directories Special accounts All UNIX systems come with a number of special accounts These accounts already exist and are there for a specific purpose Typically these accounts will all have UIDs of values less than 100, and are used to perform a variety of administrative duties Table 10.4 lists some of the special accounts that may exist on a machine To see the full list of standard groups, refer to the documentation for your Linux distribution Username UID Purpose The super user account Used by the Systems Administrator to perform a number of tasks Can anything Not subject to any restrictions root daemon Owner of many of the system daemons (programs that run in the background waiting for things to happen) bin The owner of many of the standard executable programs Table 10.4 Special accounts root The root user, also known as the super user, is probably the most important account on a UNIX system This account is not subject to the normal restrictions placed on standard accounts It is used by the Systems Administrator to perform administrative tasks that can't be performed by a normal account Restricted actions Some of the actions for which you'd use the root account include: · · · · · · creating and modifying user accounts shutting the system down configuring hardware devices like network interfaces and printers changing the ownership of files setting and changing quotas and priorities setting the name of a machine Be careful You should always be careful when logged in as root When logged in as root you must know what every command you type is going to Remember, the root account is not subject to the normal restrictions of other accounts If you execute a command as root it will be done, whether it deletes all the files on your system or not Page 242 The mechanics Adding a user is a fairly mechanical task that is usually automated either through shell scripts or, on many modern systems, with a GUI based program However it is still important that the Systems Administrator be aware of the steps involved in creating a new account If you know how it works, you can fix any problems which occur The steps to create a user include: · · · · · · · · · adding an entry for the new user to the /etc/passwd file adding an entry to the /etc/shadow file setting an initial password adding an entry to the /etc/group file creating the user's home directory creating the user's mail file or setting a mail alias creating any startup files required for the user testing that the addition has worked possibly sending an introductory message to the user Other considerations This chapter talks about account management which includes the mechanics of adding a new account User management is something entirely different When adding a new account, user management tasks that are required include: · · · · making the user aware of the site's policies regarding computer use getting the user to sign an "acceptable use" form letting the user know where and how they can find information about their system possibly showing the user how to work the system Pre-requisite Information Before creating a new user, there is a range of information that you must know including: · · · · · · · the username format being used at your site Are you using djones jonesdd david jones or perhaps you're using student or employee numbers for usernames? the user's name and other personal information Phone number, are they a computing person, someone from sales? where the user's home directory will be will this user need a mail file on this machine or should there be an alias set up startup shell startup files UID and GID Again there should be some site wide standard for this Page 243 Adding an /etc/passwd entry For every new user, an entry has to be added to the /etc/passwd file There are a variety of methods by which this is accomplished including: · · · a dedicated useradd program Many systems, Linux included, provide a program (the name will change from system to system) that accepts a number of command line parameters and then proceeds to perform many of the steps involved in creating a new account The Linux command is called useradd To initially create a locked user account, issue the useradd command To set an initial password and unlock the account, run the passwd command With shadow passwords in use by default this is the process most often used Part of the shadow passwords suite are shadow enabled utilities for administering users (useradd, usermod, userdel) and groups (groupadd, groupmod, groupdel, gpasswd for /etc/group management) using an editor Before shadow passwords, this was the method most often used However it can be unsafe and it is generally not a good idea to use it the command vipw Some systems (usually BSD based) provide this command vipw invokes an editor so the Systems Administrator can edit the passwd file safely The command performs some additional steps that ensure that the editing is performed consistently vipw is shadow enabled, and will detect the use of shadow passwords and allow safe editing of the /etc/shadow file The initial password NEVER LEAVE THE PASSWORD FIELD BLANK If you are not going to set a password for a user, put a * in the password field of /etc/passwd or !! in the /etc/shadow file On most systems, the * character is considered an invalid password and it prevents anyone from using that account If a password is to be set for the account, then the passwd command must be used The user should be forced to immediately change any password set by the Systems Administrator /etc/group entry While not strictly necessary, the /etc/group file should be modified to include the user's login name in their default group In the case of user private groups, this will be a new group with the same name as the user Also if the user is to be a member of any other group, they must have an entry in the /etc/group file The shadow utilities provide the commands groupadd, groupmod, and groupdel to administer the /etc/group and /etc/shadow files for users Alternatively, the program vigr (vipw’s group counterpart) allows safe editing of the /etc/group file, although editing it with an editor should be safe Page 244 The home directory Not only must the home directory be created, but the permissions also have to be set correctly so that the user can access the directory The permissions of a home directory should be set such that: · · · · the user should be the owner of the home directory the group owner of the directory should be the default group that the user belongs to at the very least, the owner of the directory should have rwx permissions the group and other permissions should be set as restrictively as possible The startup files Once the home directory is created, the startup files can be copied in or created Again you should remember that this will be done as the root user, and so root will own the files You must remember to change the ownership For example The following is an example set of commands that will perform these tasks: mkdir home_directory cp -pr /etc/skel/.[a-zA-Z]* home_directory chown -R login_name home_directory chgrp -R group_name home_directory chmod -R 700 home_directory One command to rule them all Having run through the more manual process of account creation, the following from Red Hat Linux 8.0: The Official Red Hat Linux System Administration Primer brings it all together with an example of the adduser command: The following steps illustrate what happens if the command /usr/sbin/useradd juan is issued on a system that has shadow passwords enabled: A new line for juan is created in /etc/passwd The line has the following characteristics: o It begins with the username, juan o There is an x for the password field indicating that the system is using shadow passwords o A UID at or above 500 is created (Under Red Hat Linux UIDs and GIDs below 500 are reserved for system use.) o A GID at or above 500 is created o The optional GECOS information is left blank o The home directory (/home/juan/) is specified o The default shell is set to /bin/bash A new line for a user named juan is created in /etc/shadow The line has the following characteristics: o It begins with the username, juan Page 245 o Two exclamation points (!!) appear in the password field of the /etc/shadow file, which locks the account o The password is set to never expire A new line for a group named juan is created in /etc/group A group bearing the same name as a user is called a user private group The line created in /etc/group has the following characteristics: o It begins with the group name, juan o An x appears in the password field indicating that the system is using shadow group passwords o The GID matches the one listed for user juan in /etc/passwd A new line for a group named juan is created in /etc/gshadow The line has the following characteristics: o It begins with the group name, juan o Two exclamation points (!!) appear in the password field of the /etc/gshadow file, which locks the group o All other fields are blank A directory for user juan is created in the /home/ directory This directory is owned by user juan and group juan However, it has read, write, and execute privileges only for the user juan All other permissions are denied The files within the /etc/skel/ directory (which contain default user settings) are copied into the new /home/juan/ directory At this point, a locked account called juan exists on the system To activate it, the Systems Administrator must next assign a password to the account using the passwd command and, optionally, set password aging guidelines Setting up mail A new user will want to one of the following: · · read their mail on this machine read their mail on another machine The user's choice controls how you configure the user's mail A mail file If the user is going to read their mail on this machine, then you must create them a mail file The mail file must go in a standard directory (usually /var/spool/mail under Linux) As with home directories, it is important that the ownership and the permissions of a mail file be set correctly The requirements are: · · the user must be able to read and write the file After all, the user must be able to read and delete mail messages the group owner of the mail file should be the group mail and the group should be able to read and write to the file Page 246 · The programs that deliver mail are owned by the group mail These programs must be able to write to the file to deliver the user's mail no-one else should have any access to the file No-one wants anyone else peeking at their private mail Mail aliases and forwards If the user's main mail account is on another machine, any mail that is sent to this machine should be forwarded to the appropriate machine There are two methods: · · a mail alias a file ~/.forward Both methods achieve the same result The main difference is that the user can change the forward file if they wish to They can't modify a central alias Testing an account Once the account is created, at least in some instances you will want to test the account creation to make sure that it has worked There are at least two methods you can use: · · login as the user use the su command The su command The su command is used to change from one user account to another To a certain extent, it acts like logging in as the other user The standard format is su username [david@beldin david]$ su Password: Time to become the root user su without any parameter lets you become the root user, as long as you know the password In the following, the id command is used to prove that I really have become the root user You'll also notice that the prompt displayed by the shell has changed as well In particular, notice the # character, commonly used to indicate a shell with root permission [root@beldin david]# id uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) [root@beldin david]# pwd /home/david Another point to notice is that when you don't use the "–" argument for su, all that has changed is user and group ids The current directory doesn't change [root@beldin david]# cd / [root@beldin /]# pwd / [root@beldin /]# su david [david@beldin /]$ pwd / [david@beldin /]$ exit However, when you use the "–" argument of the su command, it simulates a full login This means that any startup files are executed and that the current directory becomes the home directory of the user account you "are becoming" This is equivalent to logging in as the user Page 247 [root@beldin /]# su – david [david@beldin david]$ pwd /home/david If you run su as a normal user, you will have to enter the password of the user you are trying to become If you don't specify a username, you will become the root user (if you know the password) The "–" switch The su command is used to change from one user to another By default, su david will change your UID and GID to that of the user david (if you know the password) but won't change much else Using the “-” switch of su, it is possible to simulate a full login including execution of the new user's startup scripts and changing to their home directory su as root If you use the su command as the root user, you not have to enter the new user's password su will immediately change you to the new user su especially with the “-” switch, is useful for testing a new account Exercises 10.7 Login as yourself and perform the following steps: - show your current directory (use the pwd command), - show your current user id and group id (use the id command) - use su to become the root user - repeat the first two steps - use the command "su –" to simulate a full login as the root user - repeat the first two steps 10.8 What's the difference between using su and su -? Inform the user Lastly you should inform the user of their account details Included in this should be some indication of where they can get assistance, and some pointers on where to find more documentation Page 248 Removing an account Deleting an account involves reversing the steps carried out when the account was created It is a destructive process and whenever something destructive is performed, care must always be taken The steps that might be carried out include: · · · disabling the account backing up and removing the associated files setting up mail forwards Situations under which you may wish to remove an account include: · · as punishment for a user who has broken the rules In this situation, you may only want to disable the account rather than remove it completely an employee has left Disabling an account Disabling an account ensures that noone can login, but doesn't delete the contents of the account This is a minimal requirement for removing an account There are two methods for achieving this: · · change the login shell Setting the login shell to /bin/false will prevent logins However it may still be possible for the user to receive mail through the account using POP mail programs like Eudora, or to manipulate their files via ftp change the password The * character is considered by the password system to indicate an illegal password One method for disabling an account is to insert a * character into the password field in /etc/passwd If you want to re-enable the account (with the same password) simply remove the * Inserting an exclamation mark (!) in the password field in /etc/shadow will also lock the account The usermod command with –L or –U will lock or unlock and account in this way Another method is to simply remove the entry from the /etc/passwd and /etc/shadow files altogether The safest way to any manual editing of the passwd files is with vipw Backing up It is possible that this user may have some files that need to be used by other people So back everything up, just in case Remove the user's files All the files owned by the account should be removed from wherever they are in the file hierarchy It is unlikely for a user to own files that are located outside of their home directory (except for the mail file) However it is a good idea to search for them - another use for the find command Page 249 Mail for old users On some systems, even if you delete the user's mail file, mail for that user can still accumulate on the system If you delete an account entirely by removing it from the password field, any mail for that account will bounce In most cases, a user who has left will want their mail forwarded onto a new account One solution is to create a mail alias for the user that points to their new address The Goals of Account Creation As mentioned previously, there is little point in adding users manually It is a simple task which can be quite easily automated This section looks at some of the tools you can use to automate this task There are at least three goals a Systems Administrator will want to achieve with adding users: · · · make it as simple as possible automate the addition of large numbers of users delegate the task of adding users to someone else The following sections will show you the tools that will allow you to achieve these goals Making it simple You should by now be aware of what a straightforward, but time consuming, task creating a new user account is Creating an account manually might be okay for one or two accounts, but adding 100 this way would get quite annoying Luckily there are a number of tools that make this process quite simple useradd As demonstrated earlier, useradd is an executable program which significantly reduces the complexity of adding a new user A solution to the previous exercise using useradd looks like this: useradd –c "David Jones" david useradd will automatically create the home directory and mail file, copy files from skeleton directories and a number of other tasks Refer to the useradd man page for more information userdel and usermod is the companion command to useradd and as the name suggests, it deletes or removes a user account from the system usermod allows a Systems Administrator to modify the details of an existing user account userdel Graphical tools If you have X-Windows installed, several GUI tools are available which allow easy creation and management of users and groups Refer to your distribution’s documentation for the programs available Page 250 ... these tasks: mkdir home_directory cp -pr /etc/skel/.[a-zA-Z]* home_directory chown -R login_name home_directory chgrp -R group_name home_directory chmod -R 700 home_directory One command to rule... group, type: chown -R root.emacs /usr/lib/emacs/site-lisp Now, it is possible to add the proper users to the group with gpasswd: /usr/bin/gpasswd -a emacs Allow the users to actually... and group id (use the id command) - use su to become the root user - repeat the first two steps - use the command "su –" to simulate a full login as the root user - repeat the first two steps 10.8

Ngày đăng: 19/10/2013, 02:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan