CentOS | home目录丢失后的修复

2021-12-28  本文已影响0人  布莱特杨

最近服务器拿出去修,然后修回来登录后就变成了这样:


图1 home登录信息诡异

再看一下home目录,


图2 home目录不见了
这个问题貌似能解决!

先查看一下/etc/passwd文件,部分内容如下:

...
zhang3:x:999:1002::/home/zhyyT:/bin/bash
...
wangxy:x:1005:1002::/home/wangxy:/bin/bash
...

记录要修复的账号zhang3和组ID1002。
以下全程需要使用root权限。

cd home
mkdir zhang3
cd zhang3
touch .bashrc
touch .bash_profile

编辑.bashrc,输入以下内容:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

编辑.bash_profile,输入以下内容:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

最后,改变下zhang3及其内容的属主和组别。

chown 999:1002 -R zhang3

如此,便可修复home目录,然而home目录中的其他内容则付之东流了。

上一篇下一篇

猜你喜欢

热点阅读