linux 建立使用者

2022-07-07 20:42:10 字數 2474 閱讀 3514

一、新增使用者

linux下新增使用者有兩條命令:adduser和useradd

adduser:此命令可以一鍵幫助建立使用者目錄、系統的shell,預設情況下建立同名使用者組,對應的刪除使用者命令是deluser,通過此命令建立使用者比較簡單

useradd:此命令需要配合一些命令引數才能配置上述設定,預設無任何設定,既沒有使用者目錄也沒有shell,功能幾乎一片空白,對應的刪除使用者命令是userdel,通過此命令建立使用者比較靈活

useradd 命令引數說明:

-d 指定使用者目錄,一般和-m(建立使用者目錄)一起使用

-s 指定shell命令工具,一般為/bin/bash即可

例如建立乙個aa使用者,useradd aa -d /home/aa -m -s /bin/bash

usage: useradd [options] login

useradd -d

useradd -d [options]

options:

-b, --base-dir base_dir base directory for

the home directory of the

newaccount

-c, --comment comment gecos field of the new

account

-d, --home-dir home_dir home directory of the new

account

-d, --defaults print or change default

useradd configuration

-e, --expiredate expire_date expiration date of the new

account

-f, --inactive inactive password inactivity period of the new

account

-g, --gid group name or id of the primary group of the new

account

-g, --groups groups list of supplementary groups of the new

account

-h, --help display this

help message and exit

-k, --skel skel_dir use this

alternative skeleton directory

-k, --key key=value override /etc/login.defs defaults

-l, --no-log-init do

not add the user to the lastlog and

faillog databases

-m, --create-home create the user'

s home directory

-m, --no-create-home do not create the user'

s home directory

-n, --no-user-group do not create a group with the same name as

the user

-o, --non-unique allow to create users with duplicate

(non-unique) uid

-p, --password password encrypted password of the new

account

-r, --system create a system account

-r, --root chroot_dir directory to chroot into

-s, --shell shell login shell of the new

account

-u, --uid uid user id of the new

account

-u, --user-group create a group with the same name as

the user

-z, --selinux-user seuser use a specific seuser for

--extrausers use the extra users database

linux建立使用者

新增使用者 root localhost useradd test root localhost passwd test changing password for user test.new unix password retype new unix password passwd all aut...

linux建立使用者

1.su root 非root許可權使用者 2.useradd g 組 使用者名稱 3.passwd 密碼 ps 準備在redhat下增加乙個新使用者,操作如下 利用su先進入root,然後在root下敲入useradd dauglas命令,但是敲入以後特別奇怪,出現以下錯誤 bash userad...

linux 建立使用者

實習期間,由於公司的需要,建立使用者並指定該使用者的主目錄,也就是賬戶一登入,就直接到該目錄下來,當時很傻的以為是useradd g g p d什麼的,一頓試啊,結果還是試出來了,因為之前在培訓的時候就死記了useradd g g 那些固定好了的命令,到現實中的時候,發現並不是這樣的,一定要學會靈活...