一.账户信息显示

1.groups命令

使用groups命令可以显示指定用户账户的组群成员身份。

[root@redhat2 ~]# groups --help

Usage: groups [OPTION]... [USERNAME]...

Print group memberships for each USERNAME or, if no USERNAME is specified, for

the current process (which may differ if the groups database has changed).

--help     display this help and exit

--version  output version information and exit

Report groups bugs to bug-coreutils@gnu.org

GNU coreutils home page: <http://www.gnu.org/software/coreutils/>

General help using GNU software: <http://www.gnu.org/gethelp/>

For complete documentation, run: info coreutils 'groups invocation

例:查看用户zhang是属于哪些组群的成员。

[root@redhat2 ~]# groups zhang

zhang : zhang zhangsan

[root@redhat2 ~]#

//可以看到用户zhang是属于zhang组群和zhangsan组群的用户。

2.id命令

使用id命令可以显示用户的ID以及该用户所属组群的GID。

[root@redhat2 ~]# 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

Without any OPTION, print some useful set of identified information.

Report id bugs to bug-coreutils@gnu.org

GNU coreutils home page: <http://www.gnu.org/software/coreutils/>

General help using GNU software: <http://www.gnu.org/gethelp/>

For complete documentation, run: info coreutils 'id invocation'

[root@redhat2 ~]#

例1:查询用户zhang的UID、GID以及归属组群的情况。

[root@redhat2 ~]# id zhang

uid=513(zhang) gid=513(zhang) groups=513(zhang),501(zhangsan)

[root@redhat2 ~]#

//用户zhang的UID是513,默认组群是zhang,默认用户组群的GID是513,归属于zhang和zhangsan组群。

例2:显示用户zhang所属主组群的GID。

[root@redhat2 ~]# id -g zhang

513

[root@redhat2 ~]#

例3:显示用户zhang所属组群的GID。

[root@redhat2 ~]# id -G zhang

513 501

[root@redhat2 ~]#

//可以看到用户zhang所属组群的GID是513和501。

例4:显示用户zhang的UID。

[root@redhat2 ~]# id -u zhang

513

[root@redhat2 ~]#

//可以看到用户zhang的UID是513。

3.W命令

使用W命令可以详细查询已登录当前计算机的用户。

例1:显示已登录当前计算机的用户详细信息。

4.who命令

使用who命令可以显示已登录当前计算机用户的简单信息。

[root@redhat2 ~]# who

root     pts/0        2015-01-14 04:35 (192.168.12.1)

[root@redhat2 ~]#

5.chage

在linux系统中可以使用chage命令管理用户口令的时效,防止用户口令由于长时间使用而导致泄露,或是被黑客破解口令而受到攻击。

[root@redhat2 ~]# chage

Usage: chage [options] [LOGIN]

Options:

-d, --lastday LAST_DAY        set date of last password change to LAST_DAY

-E, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE

-h, --help                    display this help message and exit

-I, --inactive INACTIVE       set password inactive after expiration to INACTIVE

-l, --list                    show account aging information

-m, --mindays MIN_DAYS        set minimum number of days before password change to MIN_DAYS

-M, --maxdays MAX_DAYS        set maximim number of days before password change to MAX_DAYS

-W, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS

[root@redhat2 ~]#

例:显示用户zhang当前口令失效的信息。

[root@redhat2 ~]#  chage -l zhang

Last password change                                    : Jan 13, 2015

Password expires                                        : never

Password inactive                                       : never

Account expires                                         : never

Minimum number of days between password change          : 0

Maximum number of days between password change          : 99999

Number of days of warning before password expires       : 7

[root@redhat2 ~]#

Linux 账户信息显示和实现账户安全的更多相关文章

  1. 服务器配置多版本CUDA、CUdnn(不同Linux账户使用不同CUDA、CUdnn版本)

    一.由于实验室大家使用的CUDA.CUdnn不同,所以需要在同一台服务器安装多个版本,而且要不引起冲突,方法如下: 1.一般来说CUDA安装在 /usr/local 目录下(当然你可以通过“echo ...

  2. 【shell脚本】通过位置变量创建Linux账户及密码===addUser.sh

    通过位置变量创建Linux账户及密码 脚本内容 [root@VM_0_10_centos shellScript]# vi addUser.sh #!/bin/bash # 通过位置变量创建系统账户及 ...

  3. linux 账户锁与解锁

    ,sudo passwd -l user 锁住user帐号,su 已经不能切换到user下. 2,sudo passwd -u user 解锁user帐号,su可以切换到user下. 3,如果不小心把 ...

  4. [Linux] 账户管理命令(二)

    组管理 1)groupadd 用于添加一个用户组. 格式:groupadd [-g -o GID] GROUP 其中:  GROUP:是要添加的组名   -g:用于指定 GID,默认为使用当前最大的 ...

  5. [Linux] 账户管理命令(一)

    用户和用户组 Linux用户组的所有信息都存放在/etc/group文件中.具有某种共同特征的用户集合起来就是用户组(Group).用户组(Group)配置文件主要有 /etc/group和/etc/ ...

  6. linux账户管理[转自vbird]

    useraddpasswdchageusermoduserdelfingerchfnchshidgroupaddgroupmodgroupdelgpasswd useradd 完全参考默认值创建一个用 ...

  7. linux账户管理(centos)

    1./etc/passwd 非常详细的/etc/passwd解释 http://luzl.iteye.com/blog/564404 vi /etc/passwd,可以看到如下信息,在最后一行可以看到 ...

  8. Linux - 账户切换授权

    sudo 切换账户 echo myPassword | sudo -S ls /tmp # 直接输入sudo的密码非交互,从标准输入读取密码而不是终端设备 visudo # sudo命令权限添加 /e ...

  9. linux 账户控制

    用户 用户是能够获取系统资源的权限的集合. linux用户组的分类: 管理员 root :具有使用系统所有权限的用户,其UID 为0. 普通用户 : 即一般用户,其使用系统的权限受限,其UID为500 ...

随机推荐

  1. Android Listview & Adapter

    Listview主要有两个职责: 将数据填充到布局 处理用户的选择点击等操作 列表的显示需要三个元素: ListVeiw 用来展示列表的View 适配器(Adapter) 用来把数据映射到ListVi ...

  2. web前端入门:一小时学会写页面

    一小时学会写页面 作为一个懒癌晚期患者,总是习惯找各种简单的解决问题的方法,也习惯性把问题简单化,所以今天想分享给大家简单的web前端入门方法.既然题目已经定了一个小时那么废话就不多说了,计时开始 1 ...

  3. Http协议(一)

    Http是一种无状态,面向连接的协议.是客户端与服务端进行超文本传输协议(HTTP)的一种通信协议.目前我们使用的是Http/1.1版本. Cookie是解决http无状态,相当于一个只有一天记忆的人 ...

  4. IP地址的分类——a,b,c 类是如何划分的

    现在的IP网络使用32位地址,以点分十进制表示,如172.16.0.0.地址格式为:IP地址=网络地址+主机地址 或 IP地址=主机地址+子网地址+主机地址. IP地址类型 最初设计互联网络时,为了便 ...

  5. 关于PCA的几何表示——MATLAB实现

    关于PCA的一道练习题.这个折腾了好久...终于做出来像样的图,开始的时候忘记对原始数据标准化,怎么也不对.经过标准化之后,做的图看着还可以,有错误请指出! MATLAB代码PCA.m: clear ...

  6. magento jQuery冲突N种方法

    在做修改模板的时候在page中加入jquery库发现原本自带的js冲突 商品无法加入购物车,很多js都没有效果 这是jQuery和magento自带prototype的冲突解决版本有很多种,说个简单点 ...

  7. [翻译]lpeg入门教程

    原文地址:http://lua-users.org/wiki/LpegTutorial 简单匹配 LPeg是一个用于文本匹配的有力表达方式,比Lua原生的字符串匹配和标准正则表达式更优异.但是,就像其 ...

  8. android之OptionMenu

    一.现在我给大家介绍两个不同版本的模拟器(2.3.3和4.0.3) 1.布局文件 (1)打开“res/layout/activity_main.xml”文件. 先看mian布局文件 <Relat ...

  9. Alpha版本——Postmortem会议

    No Bug 031402401鲍亮 031402402曹鑫杰 031402403常松 031402412林淋 031402418汪培侨 031402426许秋鑫 设想和目标 1.我们的软件要解决什么 ...

  10. 揭开Sass和Compass的神秘面纱

    揭开Sass和Compass的神秘面纱 可能之前你像我一样,对Sass和Compass毫无所知,好一点儿的可能知道它们是用来作为CSS预处理的.那么,今天请跟我一起学习下Sass和Compass的一些 ...