root的家目录根下的root
root的家目录是/root
其他普通用户的家目录在/home/下
如何知道root的家目录:
方法1:
su - root #su切换目录使用 - 时,切换用户后会进入当前用户的家目录
su root #su切换目录不使用 - 时,切换用户后,的当前目录不变
[root@localhost mnt]# cat 04.sh
#!/bin/bash
testing=student
if grep $testing /etc/passwd
then
echo The bash files for user $testing are:
ls -a /home/$testing/.b*
fi
[root@localhost mnt]# sh 04.sh
student:x:1001:1001::/home/student:/bin/bash
The bash files for user student are:
/home/student/.bash_logout
/home/student/.bash_profile
/home/student/.bashrc
[root@localhost mnt]# cat 04.sh
#!/bin/bash
testing=studentggggggg
if grep $testing /etc/passwd
then
echo The bash files for user $testing are:
ls -a /home/$testing/.b*
fi
[root@localhost mnt]# sh 04.sh
后面可以跟你随便想跟的用户