Linux的使用者和組之管理命令詳解

來源:互聯網
上載者:User

Linux的使用者和組之管理命令詳解 Linux系統以組Group方式系統管理使用者 使用者和組的配置和管理命令主要有: 使用者管理主要命令useradd     建立使用者usermod     修改使用者userdel     刪除使用者newusers    建立使用者(批量)passwd      修改使用者密碼chsh        設定使用者的shellchage       設定使用者密碼有效期間newgrp      將使用者添加至某個組id          列印使用者id和所屬組idwho         列印當前登入使用者whoami      列印目前使用者名稱和id 命令詳情如下(從命令手冊截取): useraddNAME 名稱       useradd - create a new user or update default new user informationSYNOPSIS 用法       useradd [options] LOGIN       useradd -D       useradd -D [options]DESCRIPTION 概述       When invoked without the -D option, the useradd command creates a new       user account using the values specified on the command line plus the       default values from the system. Depending on command line options, the       useradd command will update system files and may also create the new       user′s home directory and copy initial files.       By default, a group will also be created for the new user (see -g, -N,       -U, and USERGROUPS_ENAB).  usermodNAME       usermod - modify a user accountSYNOPSIS       usermod [options] LOGINDESCRIPTION       The usermod command modifies the system account files to reflect the       changes that are specified on the command line.  userdelNAME       userdel - delete a user account and related filesSYNOPSIS       userdel [options] LOGINDESCRIPTION       The userdel command modifies the system account files, deleting all entries       that refer to the user name LOGIN. The named user must exist.             newusersNAME       newusers - update and create new users in batchSYNOPSIS       newusers [options new_users]DESCRIPTION       The newusers command reads a file of user name and clear-text password pairs       and uses this information to update a group of existing users or to create new       users. Each line is in the same format as the standard password file (see       passwd(5)) with the exceptions explained below:       pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shell       pw_name           This is the name of the user.           It can be the name of a new user or the name of an existing user (or an           user created before by newusers). In case of an existing user, the user′s           information will be changed, otherwise a new user will be created.                                passwdNAME       passwd - update user’s authentication tokensSYNOPSIS       passwd  [-k]  [-l]  [-u  [-f]] [-d] [-n mindays] [-x maxdays] [-w warndays] [-i       inactivedays] [-S] [--stdin] [username]DESCRIPTION       The passwd utility is used to update user’s authentication token(s).       This task is achieved through calls to the Linux-PAM and Libuser  API.   Essen-       tially, it initializes itself as a "passwd" service with Linux-PAM and utilizes       configured password modules to authenticate and then update a user’s  password.              chshNAME       chsh - change your login shellSYNOPSIS       chsh [-s shell] [-l] [-u] [-v] [username]DESCRIPTION       chsh is used to change your login shell.  If a shell is not given on the command line, chsh prompts for one.   VALID SHELLS       chsh will accept the full pathname of any executable file on the system.  However, it will issue a warning if the       shell is not listed in the /etc/shells file.  On the other hand, it can also be configured such that it will only       accept shells listed in this file, unless you are root.  chageNAME       chage - change user password expiry informationSYNOPSIS       chage [options] [LOGIN]DESCRIPTION       The chage command changes the number of days between password changes       and the date of the last password change. This information is used by       the system to determine when a user must change his/her password.  newgrpNAME       newgrp - log in to a new groupSYNOPSIS       newgrp [-] [group]DESCRIPTION       The newgrp command is used to change the current group ID during a       login session. If the optional - flag is given, the user′s environment       will be reinitialized as though the user had logged in, otherwise the       current environment, including current working directory, remains       unchanged.       newgrp changes the current real group ID to the named group, or to the       default group listed in /etc/passwd if no group name is given.  newgrp       also tries to add the group to the user groupset. If not root, the user       will be prompted for a password if she does not have a password (in       /etc/shadow if this user has an entry in the shadowed password file, or       in /etc/passwd otherwise) and the group does, or if the user is not       listed as a member and the group has a password. The user will be       denied access if the group password is empty and the user is not listed       as a member.       If there is an entry for this group in /etc/gshadow, then the list of       members and the password of this group will be taken from this file,       otherwise, the entry in /etc/group is considered.       idNAME       id - print real and effective user and group IDsSYNOPSIS       id [OPTION]... [USERNAME]DESCRIPTION       Print  user  and  group  information for the specified USERNAME, or       (when USERNAME omitted) for the current user.       Without any OPTION, print some useful set  of  identified  information.AUTHOR       Written by Arnold Robbins and David MacKenzie.  whoNAME       who - show who is logged onSYNOPSIS       who [OPTION]... [ FILE | ARG1 ARG2 ]DESCRIPTION       Print information about users who are currently logged in.  whoamiDESCRIPTION       Print  the user name associated with the current effective user ID.       Same as id -un.  群組管理groupadd    新群組groupmod    修改組groupdel    刪除群組groups      列印目前使用者所屬的組gpasswd     設定組密碼  groupaddNAME       groupadd - create a new groupSYNOPSIS       groupadd [options] groupDESCRIPTION       The groupadd command creates a new group account using the values       specified on the command line plus the default values from the       system. The new group will be entered into the system files as       needed.  groupmodNAME       groupmod - modify a group definition on the systemSYNOPSIS       groupmod [options] GROUPDESCRIPTION       The groupmod command modifies the definition of the specified GROUP       by modifying the appropriate entry in the group database.  groupdelNAME       groupdel - delete a groupSYNOPSIS       groupdel groupDESCRIPTION       The groupdel command modifies the system account files, deleting       all entries that refer to group. The named group must exist.  groupsNAME       groups - print the groups a user is inSYNOPSIS       groups [OPTION]... [USERNAME]...DESCRIPTION       Print  group memberships for each USERNAME or, if no USERNAME is specified, for       the current process (which may differ if the groups database has changed).  gpasswdNAME       gpasswd - administer /etc/group and /etc/gshadowSYNOPSIS       gpasswd [option] groupDESCRIPTION       The gpasswd command is used to administer /etc/group, and /etc/gshadow. Every       group can have administrators, members and a password.       System administrators can use the -A option to define group administrator(s)       and the -M option to define members. They have all rights of group       administrators and members.       gpasswd called by a group administrator with a group name only prompts for the       new password of the group.       If a password is set the members can still use newgrp(1) without a password,       and non-members must supply the password.    Notes about group passwords       Group passwords are an inherent security problem since more than one person is       permitted to know the password. However, groups are a useful tool for       permitting co-operation between different users.  相關命令chmod    設定檔案許可權chown    設定檔案的ownerchgrp     設定檔案的group owner  chmodNAME       chmod - change file mode bitsSYNOPSIS       chmod [OPTION]... MODE[,MODE]... FILE...       chmod [OPTION]... OCTAL-MODE FILE...       chmod [OPTION]... --reference=RFILE FILE...DESCRIPTION       This  manual  page  documents the GNU version of chmod.  chmod changes the file       mode bits of each given file according to mode, which can be either a  symbolic       representation of changes to make, or an octal number representing the bit pat-       tern for the new mode bits.  chownNAME       chown - change file owner and groupSYNOPSIS       chown [OPTION]... [OWNER][:[GROUP]] FILE...       chown [OPTION]... --reference=RFILE FILE...DESCRIPTION       This manual page documents the GNU version of chown.  chown changes the user and/or group ownership of each given       file.  If only an owner (a user name or numeric user ID) is given, that user is made  the  owner  of  each  given       file,  and  the  files’  group  is not changed.  If the owner is followed by a colon and a group name (or numeric       group ID), with no spaces between them, the group ownership of the files is changed as well.  If a colon  but  no       group  name follows the user name, that user is made the owner of the files and the group of the files is changed       to that user’s login group.  If the colon and group are given, but the owner is omitted, only the  group  of  the       files  is  changed; in this case, chown performs the same function as chgrp.  If only a colon is given, or if the       entire operand is empty, neither the owner nor the group is changed.  chgrpNAME       chgrp - change group ownershipSYNOPSIS       chgrp [OPTION]... GROUP FILE...       chgrp [OPTION]... --reference=RFILE FILE...DESCRIPTION       Change  the group of each FILE to GROUP.  With --reference, change the group of       each FILE to that of RFILE. 以上為使用者和群組管理的常用命令,可以通過man命令查看這些命令的參數、用法和詳細資料。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.