- 浏览: 135367 次
- 性别:
- 来自: 成都
文章分类
最新评论
【基本介绍】
Linux系统的一大块就是用户管理,管理用户的信息,这里介绍用户。
常用的命令有useradd , userdel , usermod , users
【基本操作】
添加用户
简单实例
删除用户
简单实例
修改用户
简单实例
查看用户信息:finger , id
finger 用户名 ----可以查看用户的相关信息,包括用户的主目录,启动shell,用户名等
finger -l 用户名----以长格式显示用户信息
finger -s 用户名 ----以短格式显示用户信息
【参考】
http://www.g-loaded.eu/2005/11/06/manage-users-from-the-command-line/
http://www.cnblogs.com/end/archive/2011/05/25/2057129.html
Linux系统的一大块就是用户管理,管理用户的信息,这里介绍用户。
常用的命令有useradd , userdel , usermod , users
【基本操作】
添加用户
[root@bogon ~]# useradd --help Usage: useradd [options] LOGIN Options: -b, --base-dir BASE_DIR base directory for the home directory of the new 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 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 -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
简单实例
useradd -c "This user cannot login to a shell" -s /sbin/nologin username #添加用户,但是不能登入shell useradd -c "This user login by bash" -s /bin/bash username #添加用户登入用后环境是bash useradd -d /usr/username username #添加用户并指定加目录,默认是/home下面 useradd -s /bin/sh -g group -G adm,root gem #添加用户指定shell,主组是group,从组是adm,root,gem
删除用户
[root@bogon ~]# userdel --help Usage: userdel [options] LOGIN Options: -f, --force force removal of files, even if not owned by user -h, --help display this help message and exit -r, --remove remove home directory and mail spool -Z, --selinux-user remove SELinux user from SELinux user mapping
简单实例
userdel username #删除用户(passwd ,shadow),但是不会删除该用户的家目录 userdel -r username #删除用户,包括家目录
修改用户
[root@bogon ~]# usermod --help Usage: usermod [options] LOGIN Options: -c, --comment COMMENT new value of the GECOS field -d, --home HOME_DIR new home directory for the user account -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE -f, --inactive INACTIVE set password inactive after expiration to INACTIVE -g, --gid GROUP force use GROUP as new primary group -G, --groups GROUPS new list of supplementary GROUPS -a, --append append the user to the supplemental GROUPS mentioned by the -G option without removing him/her from other groups -h, --help display this help message and exit -l, --login NEW_LOGIN new value of the login name -L, --lock lock the user account -m, --move-home move contents of the home directory to the new location (use only with -d) -o, --non-unique allow using duplicate (non-unique) UID -p, --password PASSWORD use encrypted password for the new password -s, --shell SHELL new login shell for the user account -u, --uid UID new UID for the user account -U, --unlock unlock the user account -Z, --selinux-user new SELinux user mapping for the user account
简单实例
usermod -d /usr/tttt -m tttt #移动家目录到/usr/tttt usermod -d /usr/tttt tttt #修改家目录到/user/tttt,原来的/home/tttt还保留 usermod -s /bin/ksh -d /home/z -g developer sam #用户sam的登录Shell修改为ksh,主目录改为/home/z,用户组改为developer
查看用户信息:finger , id
NAME finger - user information lookup program SYNOPSIS finger [-lmsp] [user ...] [user@host ...] DESCRIPTION The finger displays information about the system users.
finger 用户名 ----可以查看用户的相关信息,包括用户的主目录,启动shell,用户名等
finger -l 用户名----以长格式显示用户信息
finger -s 用户名 ----以短格式显示用户信息
[root@bogon srv]# finger spark Login: spark Name: Spark Directory: /home/spark Shell: /bin/bash On since Tue Jul 15 16:56 (CST) on tty1 from :0 23 days 18 hours idle No mail. No Plan.
[root@bogon srv]# id --help Usage: id [OPTION]... [USERNAME] Print user and group information for the specified USERNAME, or (when USERNAME omitted) for the current user. -a ignore, for compatibility with other versions -Z, --context print only the security context of the current user -g, --group print only the effective group ID -G, --groups print all group IDs -n, --name print a name instead of a number, for -ugG -r, --real print the real ID instead of the effective ID, with -ugG -u, --user print only the effective user ID --help display this help and exit --version output version information and exit
【参考】
http://www.g-loaded.eu/2005/11/06/manage-users-from-the-command-line/
http://www.cnblogs.com/end/archive/2011/05/25/2057129.html
发表评论
-
linux shell - 远端修改非root密码
2015-01-09 20:40 958【基本介绍】 通过远端修改普通用户密码,而passwd --s ... -
linux shell - broken pip error
2015-01-07 15:36 2671【基本介绍】 这里我们介绍发生broken pipe错误的原因 ... -
linux locate - find files by name
2014-12-17 17:46 566【基本介绍】 这里我们介绍locate命令,用来查找文件。 ... -
linux ssh - GSSAPIAuthentication
2014-12-10 14:58 2012【基本介绍】 最近公司搬家,发现合作伙伴的服务器的用ftp工具 ... -
linux tar - 压缩解压
2014-12-01 16:04 975【基本介绍】 今天遇到要添加文件到tar文件里面,所以在这里介 ... -
linux parameter substitution - 字符串/变量处理
2014-11-17 15:56 781【基本介绍】 这里我们介绍bash里面对字符串,变量等的替换等 ... -
linux netstat - status状态描述
2014-11-14 17:59 1118【基本介绍】 这里介绍netstat命令返回的结果status ... -
linux set - set variables and set positional parameters
2014-11-10 18:26 409【基本介绍】 set是shell的内置命令。可以用来设置修改变 ... -
linux nc - arbitrary TCP and UDP connections and listens
2014-10-31 17:46 761【基本介绍】 nc是可以打开任意端口的TCP/UDP连接和监听 ... -
linux 报错集 - Cannot retrieve metalink for repository: epel. Please verify its pat
2014-10-29 15:12 927【基本介绍】 运行yum报错Error: Cannot ret ... -
linux awk - awk tutorial
2014-10-21 10:47 461【基本介绍】 awk是一款强大的对文件内容进行处理的软件,可以 ... -
linux ps - processes
2014-10-20 14:17 1226【基本介绍】 ps - report a snapshot o ... -
linux lsof - list open files
2014-10-17 17:31 715【基本介绍】 lsof - list open files I ... -
linux - 网络连接状态
2014-10-13 11:00 1355【基本情况】 这里介绍 ... -
linux netstat - Print network connections, routing tables, interface statistics,
2014-10-13 10:37 982【基本介绍】 netstat - Print network ... -
linux vmstat - Report virtual memory statistics
2014-10-10 17:39 697【基本介绍】 vmstat - Report virtual ... -
linux yum - yum warning: rpmts_HdrFromFdno
2014-10-09 15:08 566【基本介绍】 在yum安装软件的时候有时候会报warning: ... -
Linux ip subnet mask - 网段分析
2014-09-24 19:22 1298【基本介绍】 网段的分析可以帮助我们查看两个局域地址是否可以互 ... -
linux curl - curl 上传下载
2014-09-19 11:45 2084【基本介绍】 curl is a tool to tra ... -
linux mkpasswd - 密码生成器
2014-09-18 17:18 1382【基本介绍】 作为linux admin要经常创建用户,并初始 ...
相关推荐
07.1.1 用户和用户组管理-用户配置文件-用户信息文件.mp4 07.1.2 用户和用户组管理-用户配置文件-影子文件.mp4 07.1.3 用户和用户组管理-用户配置文件-组信息文件.mp4 07.2 用户和用户组管理-用户管理相关文件....
Linux笔记-Linux文件和用户管理(作者:千锋教育-磊哥)
openldap 管理linux用户/组、密码策略
MySQL 企业版审计功能使用“mysql”系统数据库存储过滤条件和用户的账户数据,为了增加灵活性,此版本增添了一个“audit_log_database”服务器系统变量,在服务器启动时可以指定到其他的数据库。 MySQL 企业版数据...
Linux笔记-Linux用户管理及权限
Linux系统进程管理(作者:千锋教育-磊哥)
《Linux-标准学习教程》课件第4-管理用户和用户组.docx
08.1.1 权限管理-ACL权限-简介与开启.mp4 08.1.2 权限管理-ACL权限-查看与设定.mp4 08.1.3 权限管理-ACL权限-最大有效权限与删除.mp4 08.1.4 权限管理-ACL权限-默认与递归ACL权限.mp4 08.2.1 权限管理-文件特殊...
Linux系统管理-用户管理.pdf
Linux运维-运维课程运维基本功d5-文件管理&用户管理-16-用户的添加操作.mp4
Linux 基础 77-用户管理-08-su切换用户.flv
4.5 Linux常用命令-文件搜索命令-用户管理命令 4.6 Linux常用命令-文件搜索命令-压缩解压命令 4.7 Linux常用命令-网络命令 4.8 Linux常用命令-关机重启命令 5 文本编辑器Vim 5.1 文本编辑器Vim-Vim常用操作 5.2 ...
在分布式系统中,如何管理节点间的状态一直是一个难题,etcd像是专门为集群环境的服务发现和注册而设计,它提供了数据TTL失效、数据改变监视、多值、目录监听、分布式锁原子操作等功能,可以方便的跟踪并管理集群...
Linux 基础 70-用户管理-01-新建用户useradd和passwd.flv
2、Linux LVM逻辑卷管理 3、Linux 软RAID创建和维护 4、Quota磁盘限额 5、RedHat 5.4 RHCE YUM学习笔记 6、RHCE-253 Apache服务常规配置 7、RHCE-253 Apache服务高级配置 8、RHCE-253 DHCP服务配置 9、RHCE-253 DNS...
用户权限管理。使用linux查看文件的权限。
Linux 基础 75-用户管理-06-usermod指定用户登录shell.flv
Compose允许用户通过一个单独的docker-compose.yml模板文件(YAML 格式)来定义一组相关联的应用容器为一个项目(project)。 Docker-Compose项目由Python编写,调用Docker服务提供的API来对容器进行管理。因此,...
Java 11是一个长期支持(LTS)版本。这意味着那些对平台采用持保守态度并需要长期支持的用户可以通过Java SE...它还包括对 My Oracle Support (MOS)24x7的访问、对27种语言的支持、Java SE 8桌面管理、监控和部署特性等。
bitnami-suitecrm-7.11.13-0-linux-x64-installer.run自动安装软件。 SuiteCRM是受欢迎的客户关系管理(CRM)系统 SugarCRM的软件分支, 由SalesAgility开发和维护。它是一个免费的开源替代应用程序。它于2013年10月...