使用bash脚本删除“.bash_aliases”

问题描述 投票:-1回答:1

在我的.bashrc中,我使用.sh脚本轻松配置新安装的Debian。但是在尝试的同时

rm -f ~/.bash_aliases
wget https://raw.githubusercontent.com/.../.bash_aliases

rm -f ~/.bashrc
wget https://raw.githubusercontent.com/.../.bashrc

它只是省略了那些线?文件是由chmod +x ./script.sh许可并由sudo ./script.sh运行可能有什么问题?

(在最终代码中有完整链接,文件正在下载为.bashrc.1.bash_aliases.1

linux bash debian wget rm
1个回答
0
投票

除非你有充分的理由,否则不要使用sudo

当你运行sudo ./script.sh时它以root身份运行,所以~指的是root的主目录/root而不是你用户的主目录。

只需运行./script.sh,以便它像你一样运行并修改你自己的主目录。

© www.soinside.com 2019 - 2024. All rights reserved.