Linux使用者管理

2022-03-29 07:37:50 字數 3231 閱讀 4102

使用者的新增

useradd demo (預設是普通使用者 uid從500開始)

[root@localhost usr]# tail -n 1 /etc/passwd

demo01:x:

501:501::/home/demo01:/bin/bash #以:分割

#第乙個字段  使用者名稱

#第二個字段  密碼的佔位符

#第三個字段  uid 

#第四個字段  gid

#第五個字段  使用者全名

#第六個字段  使用者的宿主目錄

#第七個字段  登陸shell的程式路徑

[root@localhost usr]# useradd -d /opt/stu01 stu01 #-d 修改宿主目錄

[root@localhost usr]#

tail -n 1 /etc/passwd

stu01:x:

502:502::/opt/stu01:/bin/bash

[root@localhost usr]#

ls /home

demo01 yimiao

檢視系統下面的shell,sh是為了相容unix的方式建立的link

[root@localhost usr]# cat /etc/shells

/bin/sh

/bin/bash

/sbin/nologin

/bin/tcsh

/bin/csh

/bin/ksh

[root@localhost usr]# ls -l /bin/*sh

-rwxr-xr-x 1 root root 801528 2011-05-13 /bin/bash

lrwxrwxrwx 1 root root      4 2014-06-22 /bin/csh -> tcsh

lrwxrwxrwx 1 root root     21 2014-06-22 /bin/ksh -> /etc/alternatives/ksh

lrwxrwxrwx 1 root root      4 2014-06-22 /bin/sh -> bash

-rwxr-xr-x 1 root root 352904 2010-10-05 /bin/tcsh

[root@localhost usr]# useradd -s /bin/ksh stu02 #建立使用者並指定不同的bash,切換到新建使用者能看到提示符不一樣,exit退出。

[root@localhost usr]#

passwd

stu02

changing password

foruser stu02.

new unix password:

retype new unix password:

passwd

: all authentication tokens updated successfully.

[root@localhost usr]#

su -stu02

$

[root@localhost usr]# passwd -l sys02 #passwd -l【鎖定使用者】 -s【檢視使用者狀態】 -u【解鎖使用者】 --stdin【修改密碼不必重複】

locking password

foruser sys02.

passwd

: success

[root@localhost usr]#

passwd -s sys02

sys02 lk

2014-06-22

099999

7 -1 (password locked.)

[root@localhost usr]# passwd -u sys02

unlocking password for user sys02.

passwd: success.

[root@localhost usr]# passwd -s sys02

sys02 ps 2014-06-22 0 99999 7 -1 (password set, md5 crypt.)

[root@localhost usr]# passwd --stdin sys02

changing password for user sys02.

123456

passwd: all authentication tokens updated successfully.

[root@localhost usr]# echo 1232444 | passwd --stdin sys02

changing password for user sys02.

passwd: all authentication tokens updated successfully.

useradd預設的配置檔案:vi /etc/default/useradd 開啟即可看到預設的使用者組預設的bash

管理工具 chage -l【列出密碼的有效期】 -e【修改密碼的過期時間】-1置為空 ,id 檢視使用者id和組別id userdel -r username 刪除使用者

對於新增使用者的配置資訊:

/etc/default/useradd

# useradd defaults file

group=100

home=/home #預設家園的路徑

inactive=-1

expire=shell=/bin/bash #預設使用的bash

skel=/etc/skel #預設home下的模板目錄

create_mail_spool=yes

/etc/skel  

./bashrc  當使用者進入新的環境時候載入。大多時候可設定別名

./bash_profile   當使用者登入的時候載入,大多時候可設定環境變數

./bash_logout  當使用者退出的時候載入

usermod 修改使用者賬號

usermod -g root demo

全域性的使用者配置:

etc/bashrc /etc/profile  

使用者組

LInux 使用者管理

最近在使用nagios的時候,需要新增一些使用者和組的資訊。需要整理一下,有些記不清楚了。原文連線 http www.g loaded.eu 2005 11 06 manage users from the command line userinfo 使用者資訊 命令id 顯示使用者基本資訊 命令u...

Linux使用者管理

0 產看使用者uid gid 等資訊 id 使用者名稱 1 linux使用者型別 1 超級使用者 root uid 0 2 偽使用者 uid 1 499之間 3 普通使用者 uid 500 60000之間 2 配置檔案 1 使用者資訊檔案 etc passwd 2 密碼檔案 etc shadow 3...

Linux 使用者管理

1 linux裡檢視所有使用者 linux裡,並沒有像windows的net user,net localgroup這些方便的命令來管理使用者.xwindows介面的就不說了.1 在終端裡.其實只需要檢視 etc passwd檔案就行了.2 看第三個引數 500以上的,就是後面建的使用者了.其它則為...