Gestionarea utilizatorilor si grupelor in Linux

6
Gestiunea utilizatorilor și grupelor Comenzi Linux 1) Id - prints information for a certain user SYNTAX id [-a] [-G] [-g] [-u] [user] -a Reports user name, use ID and all the groups to which the user belongs. -G Output all different group IDs (effective, real and supplementary) only, using the format "%u\n". If there is more than one distinct group affiliation, output each such affiliation, using the format " %u", before the new line character is output. -g Output only the effective group ID, using the format "%u\n". -n Output the name in the format "%s" instead of the numeric ID using the format "%u". -r Output the real ID instead of the effective ID. -u Output only the effective user ID, using the format "%u\n". user The user (login) name for which information is to be written. 2) Useradd - Enables a super user or root to create a new user or updates default new user information. SYNTAX useradd [-c comment] [-d home_dir] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-p passwd] [-s shell] [-u uid [ -o]] login useradd -D [-g default_group] [-b default_home] [-f default_inactive] [-e default_expire_date] [-s default_shell] -c comment The new user's password file comment field. -d home_dir The new user will be created using home_dir as the value for the user's login directory. The default is to append the login name to default_home and use that as the login directory name. -e The date on which the user account will be disabled.

Transcript of Gestionarea utilizatorilor si grupelor in Linux

Page 1: Gestionarea utilizatorilor si grupelor in Linux

Gestiunea utilizatorilor și grupelor

Comenzi Linux1) Id - prints information for a certain user

SYNTAXid [-a] [-G] [-g] [-u] [user]

-a Reports user name, use ID and all the groups to which the user belongs.

-G Output all different group IDs (effective, real and supplementary) only, using the format "%u\n". If there is more than one distinct group affiliation, output each such affiliation, using the format " %u", before the new line character is output.

-g Output only the effective group ID, using the format "%u\n".

-n Output the name in the format "%s" instead of the numeric ID using the format "%u".

-r Output the real ID instead of the effective ID.

-u Output only the effective user ID, using the format "%u\n".

user The user (login) name for which information is to be written.

2) Useradd - Enables a super user or root to create a new user or updates default new user information.SYNTAXuseradd [-c comment] [-d home_dir] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-p passwd] [-s shell] [-u uid [ -o]] loginuseradd -D [-g default_group] [-b default_home] [-f default_inactive] [-e default_expire_date] [-s default_shell]

-c comment The new user's password file comment field.

-d home_dir The new user will be created using home_dir as the value for the user's login directory. The default is to append the login name to default_home and use that as the login directory name.

-e expire_date The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD.

-f inactive_time The number of days after a password expires until the account is permanently disabled. A value of 0 disables the account as soon as the password has expired, and a value of -1 disables the feature. The default value is -1.

-g initial_group The group name or number of the user's initial login group. The group name must exist. A group number must refer to an already existing group. The default group number is 1.

-G group,[,...] A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option. The default is for the user to belong only to the initial group.

-m The user's home directory will be created if it does not exist. The files

Page 2: Gestionarea utilizatorilor si grupelor in Linux

contained in skeleton_dir will be copied to the home directory if the -k option is used, otherwise the files contained in /etc/skel will be used instead. Any directories contained in skeleton_dir or /etc/skel will be created in the user's home directory as well. The -k option is only valid in conjunction with the -m option. The default is to not create the directory and to not copy any files.

-p passwd The encrypted password, as returned by crypt. The default is to disable the account.

-s shell The name of the user's login shell. The default is to leave this field blank, which causes the system to select the default login shell.

-u uid The numerical value of the user's ID. This value must be unique, unless the -o option is used. The value must be non-negative. The default is to use the smallest ID value greater than 99 and greater than every other user. Values between 0 and 99 are typically reserved for system accounts.

-b default_home The initial path prefix for a new user's home directory. The user's name will be affixed to the end of default_home to create the new directory name if the -d option is not used when creating a new account.

-e default_expire_date

The date on which the user account is disabled.

-f default_inactive The number of days after a password has expired before the account will be disabled.

-g default_group The group name or ID for a new user's initial group. The named group must exist, and a numerical group ID must have an existing entry.

-s default_shell The name of the new user's login shell. The named program will be used for all future new user accounts.

3) Groupadd - Creates a new group account.SYNTAXgroupadd [-g gid [-o]] group

-g gid The numerical value of the group's ID. This value must be unique, unless the -o option is used. The value must be non-negative. The default is to use the smallest ID value greater than 99 and greater than every other group. Values between 0 and 99 are typically reserved for system accounts.

4) Passwd - Allows you to change your password.SYNTAXpasswd [-r | files | -r nis | -r nisplus ] [-a] [-d | -l] [-e] [-f] [-g] [-h] [-n min] [-s] [-w warn] [-x max] [-D domainname][ name ]

-r Specifies the repository to which an operation is applied. The supported repositories are files, nis or nisplus.

-a Show password attributes for all entries. Use only with the -s option; name must not be provided. For the nisplus repository, this will show only the entries in the NIS+ password table in the local domain that the invoker is authorized to "read".

-d Deletes password for name. The login name will not be prompted for password. It is only

Page 3: Gestionarea utilizatorilor si grupelor in Linux

applicable to the files repository.

-l Locks password entry for name.

-e Change the login shell. For the files repository, this only works for the super-user. Normal users may change the nis or nisplus repositories.

-f Force the user to change password at the next login by expiring the password for name.

-g Change the gecos (finger) information. For the files repository, this only works for the superuser. Normal users may change the nis or nisplus repositories.

-h Change the home directory.

-n min Set minimum field for name. The min field contains the minimum number of days between password changes for name. If min is greater than max, the user may not change the password.

-s Displays information including your username and if you do/don't have a password (This command will not actually show the password.)

-w warn Set warn field for name. The warn field contains the number of days before the password expires and the user is warned. This option is not valid if password aging is disabled.

-x max Set maximum field for name. The max field contains the number of days that the password is valid for name. The aging for name will be turned off immediately if max is set to -1. If it is set to 0, then the user is forced to change the password at the next login session and aging is turned off.

-D domainname Consult the passwd.org_dir table in domainname. If this option is not specified, the default domainname returned by nis_local_directory(3N) will be used. This domain name is the same as that returned by domainname(1M).

name Login ID of user

5) Userdel - Enables a super user to remove a users account.SYNTAXuserdel [-r] login

-r Files in the user's home directory will be removed along with the home directory itself and the user's mail spool. Files located in other file systems will have to be searched for and deleted manually.

Comenzi Windows1) Net user - add a new user account to the domain or groups

Page 4: Gestionarea utilizatorilor si grupelor in Linux

SYNTAXnet user username {password | *} /ADD [options] [/DOMAIN]Example: net user John fadf24as /ADD /DOMAIN

2) NET GROUP - Add, delete, view, and otherwise manage network workgroups.SYNTAX[groupname [/COMMENT:"text"]] [/DOMAIN]groupname {/ADD [/COMMENT:"text"] | /DELETE} [/DOMAIN]groupname username [...] {/ADD | /DELETE} [/DOMAIN]

3) NET LOCALGROUP - Add, delete, view, and otherwise manage network groups.SYNTAX[groupname [/COMMENT:"text"]] [/DOMAIN]groupname {/ADD [/COMMENT:"text"] | /DELETE} [/DOMAIN]groupname name [...] {/ADD | /DELETE} [/DOMAIN]

4) NET ACCOUNTS - Adjust account settings.SYNTAX[/FORCELOGOFF:{minutes | NO}] [/MINPWLEN:length][/MAXPWAGE:{days | UNLIMITED}] [/MINPWAGE:days][/UNIQUEPW:number] [/DOMAIN]

5) NET PASSWORD - Changes your logon password.SYNTAXNET PASSWORD [oldpassword [newpassword]]NET PASSWORD \\computer | /DOMAIN:name [user [oldpassword [newpassword]]]

oldpassword Specifies your current password.newpassword Specifies your new password. It can have as many as 14 characters.computer Specifies the Windows NT or LAN Manager server on which you want to change your

password./DOMAIN Specifies that you want to change your

password on a Windows NT or LAN Manager domain.Name Specifies the Windows NT or LAN Manager domain on whichyou want to change your password.

user Specifies your Windows NT or LAN Manager user name.

The first syntax line above is for changing the password for your password-list file. The second syntax line above is for changing your password on a Windows NT or LAN Manager server or domain.