有两种方法:
方法1:在.bashrc文件中使用cd命令,加上指定目录即可!
如:
# cd ~
[root@test10vm1 ~]# vim .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
cd /xxxx/xxxx/xxxx --------指定默认目录
# User specific aliases and functions
方法二:修改/etc/passwd文件,修改此文件时要注意,修改好后不要关闭xshell窗口,验证是否生效最好复制ssh渠道验证,防止此文件修改错误,导致无法连接!
如将root1登陆后进入的路径由/home/root1改为/usr/tmp:
# cd /etc
# vim passwd
root1:x:0:0::/home/root1:/bin/bash----改为root1:x:0:0::/usr/tmp:/bin/bash