1、chfn 修改用户信息工具;

chfn 这个工具主要是用来改用户的全名,办公室地址,电话之类的;用法如下:

chfn [ -f full-name ] [ -o office ] [ -p office-phone ] [ -h home-phone ] [ -u ] [ -v ] [ username ]

最简单的方法是

chfn 用户名

[root@localhost ~]# chfn beinanlinux 注:更改用户beinanlinux的信息;

Changing finger information for beinanlinux.

Name []: BeiNan.Linux 注:用户全名BeiNan.Linux ,随便写一个就行;

Office []: ChinaDL

Office Phone []: 66666666

Home Phone []: 99999999

Finger information changed. 注:更改完成;

我们怎么能知道更改好了呢??可以通过finger 或直接查看/etc/passwd文件;

[root@localhost ~]# finger beinanlinux

Login: beinanlinux Name: BeiNan.Linux

Directory: /home/beinanlinux Shell: /bin/bash

Office: ChinaDL Home Phone: 99999999

Last login Sat Nov 5 11:27 (CST) on tty2

No mail.

No Plan.

chfn 究竟改了/etc/passwd 文件中beinanlinux用户的哪部份呢??

[root@localhost ~]# more /etc/passwd |grep beinanlinux

beinanlinux:x:509:509:BeiNan.Linux,ChinaDL,66666666,99999999:/home/beinanlinux:/bin/bash

通过more /etc/passwd ,然后来抽取 beinanlinux记录,看一下红字标出的,就是我们通过chfn 修改过的地方,所以我们可以直接通过修改/etc/passwd文件来达到目的;

2、chsh 改变用户的SHELL类型;

[root@localhost ~]# chsh --help

Usage: chsh [ -s shell ] [ --list-shells ] [ --help ] [ --version ] [ username ]

如果chsh 不加任何参数及用户名的情况下,默认为更改当前操作用户的SHELL类型;

举例说明:

[root@localhost ~]# chsh --list-shells 注:列出当前系统中所有的SHELL;

/bin/sh

/bin/bash

/sbin/nologin 注:这个是不允许用户登录系统所用,是极为有用的;您可以通过查看/etc/passwd 中看哪些用户是nologin;

/bin/ksh

/bin/tcsh

/bin/csh

/bin/zsh

[root@localhost ~]# finger beinanlinux |grep Shell 注:查看用户beinanlinux 所用的SHELL类型;

Directory: /home/beinanlinux Shell: /bin/bash 注:beinanlinux用的是bash ;

[root@localhost ~]# chsh -s /bin/ksh beinanlinux 注:更改beinanlinux所用的shell 为ksh ;

Changing shell for beinanlinux.

Shell changed. 注:更改完成;

[root@localhost ~]# finger beinanlinux |grep Shell 注:再次查询beinanlinux所用的SHELL;

Directory: /home/beinanlinux Shell: /bin/ksh 注:看来已经改过来了;

chsh 还是有用的,特加是不允许用户登录时,我们可以把用户的SHELL改到 /sbin/nologin;系统中一些虚拟用户大多是不能登录系统的,这对于系统安全来说是极为重要;通过下面的命令查看一下系统中哪些用户是没有登录权限的?

[root@localhost ~]# more /etc/passwd |grep nologin

当前1/2页 12下一页阅读全文