1. 程式人生 > 其它 >Linux系統:不使用 useradd 建立使用者

Linux系統:不使用 useradd 建立使用者

不使用 useradd 建立使用者

# 建立使用者家目錄
[root@localhost opt]# mkdir -p /home/test  

# 檢視使用者資訊配置檔案
[root@localhost opt]# cat  /etc/passwd

# 建立test使用者並寫入使用者資訊配置檔案
[root@localhost ~]# echo 'test:x:1001:1001::/home/test/:/bin/bash' >> /etc/passwd

# 再次檢視使用者資訊配置檔案
[root@localhost ~]# cat /etc/passwd
test:x:1001:1001::/home/test/:/bin/bash  #可以發現新增的使用者

# 給使用者新增屬組
[root@localhost ~]# echo 'test:x:1001' >> /etc/group

# 給使用者家目錄配置環境變數
[root@localhost ~]# cp /etc/skel/.bashrc  /home/test
[root@localhost ~]# cp /etc/skel/.bash_profile   /home/test

# 修改使用者家目錄許可權
[root@localhost home]# chown test.test test/

# 切換使用者
[root@localhost ~]# su - test

上一次登入:二 12月 14 19:05:50 CST 2021pts/0 上


# 成功切換使用者
[test@localhost ~]$   
從來就沒有正確的選擇,我們只不過是要努力奮鬥,使當初的選擇變得正確。