日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

给Linux添加新用户,新建用户,新建帐号

發布時間:2025/3/20 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 给Linux添加新用户,新建用户,新建帐号 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

給Linux添加新用戶,新建用戶,新建帳號

添加用戶組

sudo groupadd groupname

添加用戶

sudo useradd username -m -s /sbin/nologin -d /home/username -g groupname -s /sbin/nologin 設置不能登陸 -s /bin/false(老方法) 也行 -d 設置用戶主目錄 -g 用戶組 -m 創建用戶目錄

useradd的具體參數為

[root@317304 ~]# useradd --help Usage: useradd [options] LOGINOptions:-b, --base-dir BASE_DIR base directory for the home directory of thenew account-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 newaccount-G, --groups GROUPS list of supplementary groups of the newaccount-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 andfaillog 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 asthe 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-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 the SELinux user mapping

更改用戶登錄權限

在增加了-s /sbin/nologin 參數后,那么這個帳號就不能登陸了,如果想要恢復登陸使用

sudo usermod -s /bin/bash username

禁用用戶登錄權限

sudo usermod -s /sbin/nologin username

設置密碼

給用戶設置密碼,這樣帳號就能使用了。

sudo passwd username

刪除用戶

刪除用戶

sudo userdel username

原文??https://www.chenyudong.com/archives/linux-add-new-userer.html


linux下查看所有用戶及所有用戶組
? ? 原文?https://blog.csdn.net/zdwzzu2006/article/details/7944434groups 查看當前登錄用戶的組內成員
groups gliethttp 查看gliethttp用戶所在的組,以及組內成員
whoami 查看當前登錄用戶名

/etc/group文件包含所有組
/etc/shadow和/etc/passwd系統存在的所有用戶名


#修改passwd文件禁止mysql登陸


vi /etc/passwd


將/bin/bash改為/sbin/nologin

轉載于:https://www.cnblogs.com/yisuo/p/9246864.html

總結

以上是生活随笔為你收集整理的给Linux添加新用户,新建用户,新建帐号的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。