Linux有这个用户,但是不能切换

Posted by JustDoDT on March 19, 2018

切换用户报错

[root@hadoop001 java]# 
[root@hadoop001 java]# su - uucp
su: warning: cannot change directory to /var/spool/uucp: No such file or directory
This account is currently not available.

查看是否存在该用户

[root@hadoop001 java]# cat /etc/passwd | grep uucp
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

因为uucp是nologin;即禁止登陆的,所以需要修改

把sbin/nologin修改为bin/bash

uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
[root@hadoop001 java]# vi /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
#uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/bin/bash

然后切换用户

[root@hadoop001 java]# 
[root@hadoop001 java]# su - uucp
su: warning: cannot change directory to /var/spool/uucp: No such file or directory
-bash-4.1$ ll
total 181172
drwxr-xr-x. 8 root root      4096 Jul 22  2017 jdk1.8.0_144
-rw-r--r--. 1 root root 185515842 Jul 16  2018 jdk-8u144-linux-x64.tar.gz
-bash-4.1$ 
-bash-4.1$ 

出现上面这种情况,需要修改把/etc/skel/* 拷贝到uucp用户的目录下

[root@hadoop001 spool]# pwd
/var/spool
[root@hadoop001 spool]#
[root@hadoop001 spool]# mkdir uucp
[root@hadoop001 spool]# cd uucp/
[root@hadoop001 uucp]# ll
total 0
[root@hadoop001 uucp]# ll -al
total 8
drwxr-xr-x.  2 root root 4096 Mar 15 19:56 .
drwxr-xr-x. 14 root root 4096 Mar 15 19:56 ..
[root@hadoop001 uucp]# 
[root@hadoop001 uucp]# ll
total 0
[root@hadoop001 uucp]# cp /etc/skel/.* /var/spool/uucp
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
cp: omitting directory `/etc/skel/.gnome2'
cp: omitting directory `/etc/skel/.mozilla'
[root@hadoop001 uucp]# su - uucp
[uucp@hadoop001 ~]$