给Linux添加新用户,新建用户,新建帐号
生活随笔
收集整理的這篇文章主要介紹了
给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添加新用户,新建用户,新建帐号的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: grep / egrep
- 下一篇: DNS正向解析过程