【Linux】解决切换用户出现bash-4.2$问题

切换用户出现 bash 4.2 问题

出现 bash 4.2 错误 发现是用户指定家目录下 缺少2个隐藏文件

这题前提条件 我指定的家目录是 /opt/{孙悟空,猪八戒,唐僧,沙悟净}

/etc/skel/.bashrc /etc/skel/.bash_profile 传过去后显示登录成功

问题展示:

root@localhost \~# su sunwukong

bash-4.2$ ll

bash: ll: 未找到命令

bash-4.2$

更新隐藏文件 root用户下

source ~/.bashrc

source ~/.bash_profile

使用root用户登录,在用户指定的家目录中传入2个隐藏文件

cp /etc/skel/.bashrc /opt/孙悟空

cp /etc/skel/.bash_profile /opt/孙悟空

cp /etc/skel/.bashrc /opt/沙悟净

cp /etc/skel/.bash_profile /opt/沙悟净

cp /etc/skel/.bashrc /opt/唐僧

cp /etc/skel/.bash_profile /opt/唐僧

cp /etc/skel/.bashrc /opt/猪八戒

cp /etc/skel/.bash_profile /opt/猪八戒

登录效果:

root@localhost sunwukong# su sunwukong

sunwukong@localhost \~$ ll

总用量 0

sunwukong@localhost \~$

相关推荐
楚枫默寒7 小时前
Linux 编辑文件后自动添加修改日期
linux·运维·bash
苦青藤8 小时前
从零搭建 WSUS 隔离网络:完整实战指南(内网离线补丁分发)
运维·windows·microsoft
2601_961194029 小时前
27考研刘晓艳单词pdf
linux·sql·ubuntu·华为·pdf·.net
2023自学中11 小时前
imx6ull 开发板 推流ov5640数据,虚拟机用 ffplay 拉流播放
linux·音视频·嵌入式·开发板
shandianchengzi11 小时前
【记录】Ghidra|Ubuntu 26.04 下 Ghidra 界面缩放完整指南
linux·ubuntu·逆向·ghidra
天天进步201511 小时前
Python全栈项目--Python自动化运维工具开发
运维·python·自动化
Soari11 小时前
Ubuntu 根分区文件系统损坏,系统启动时自动检查失败
linux·运维·ubuntu
杨云龙UP12 小时前
Oracle Health Check巡检脚本使用SOP V2.0:从HTML原始报告→生成Word专业巡检报告→交付客户_2026-06-03
linux·运维·数据库·sql·oracle·报告·巡检
广州灵眸科技有限公司12 小时前
瑞芯微RV1126B开发板(EASY-EAI-PI2) Linux虚拟机准备
linux·运维·服务器
Lana学习中13 小时前
【运维杂记】连接不上远程服务器的问题处理
运维·服务器