简体   繁体   English

为什么在sudo命令后未调用.bashrc文件?

[英]Why the .bashrc file is not invoked after a sudo command?

I switch to another user using the command: 我使用以下命令切换到另一个用户:

sudo -u dsc -i

After the command executions moves to the home directory /home/dsc . 命令执行后,移至主目录/ home / dsc。

However, the .bashrc file in this directory is not executed. 但是,不会执行此目录中的.bashrc文件。 Why this happens? 为什么会这样?

sudo -i starts a login shell; sudo -i启动一个登录 shell; .bashrc is only executed for non-login interactive shells. .bashrc仅对非登录交互式shell执行。 One of .bash_profile , .bash_login , or .profile should have been executed, though. 不过, .bash_profile.bash_login.profile应已执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在.bashrc“ sudo vi / etc / hosts”中为该命令添加别名 - How to add this command an alias in .bashrc “sudo vi /etc/hosts” 使用echo命令将别名写入bashrc文件 - writing alias to bashrc file using echo command 为什么找不到 sudo: bundle 命令? - Why is sudo: bundle command not found? 我为用户〜/ .bashrc添加了别名,但是“sudo -u user -i'alias_name'”仍然报告“找不到命令”? - I added aliases to user ~/.bashrc but “sudo -u user -i 'alias_name'” still reports “command not found”? 在ubuntu中编辑bashrc文件后命令不起作用 - Commands not working after editing bashrc file in ubuntu 以 sudo 身份执行时找不到命令,但在“sudo su”后有效 - Command not found when executed as sudo, but works after "sudo su" .bashrc采购后,如何在使用ssh登录时在远程上执行命令? - How to execute a command on the remote at login with ssh, after .bashrc sourcing? 为什么 docker exec 命令 ingore bashrc 在 docker 容器内? - Why docker exec command ingore bashrc inside docker container? sudo 用户是否可以读取启用了 sudo 访问权限的命令文件? - Can a sudo user read the command file for which sudo access is enabled? sudo命令后如何执行多个命令 - how to execute multiple commands after sudo command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM