-bash-4.2$
时间: 2023-10-04 21:06:08 浏览: 166
当在Linux服务器上创建一个用户并使用su命令切换用户后,终端提示符显示为"-bash-4.2$"而不是预期的"user@主机名 路径"的显示方式。这可能是由于创建用户时丢失了用户家目录下的环境变量文件所导致的。解决这个问题的方法是使用以下命令从主默认文件夹/etc/skel/重新拷贝一份配置信息到用户的家目录下:
```
cp /etc/skel/.bashrc /home/user/
cp /etc/skel/.bash_profile /home/user/
```
这样做可以恢复终端提示符的显示方式并使以往的脚本能够正常执行。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [【Linux】解决切换用户出现bash-4.2$问题](https://blog.csdn.net/whowhowhoisimportant/article/details/127223884)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [登录用户出现‘’-bash-4.2$‘’的问题解决](https://blog.csdn.net/weixin_43279032/article/details/84531082)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [bash-4.2源码](https://download.csdn.net/download/wjcapple/9684136)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文