why are my ~/.bashrc aliases not honoured by sudo
I have already read:
https:/
https:/
but they don't seem to address my exact problem, and I don't grok this login shell / interactive shell business completely so I'll go ahead and ask. In both my /home/samjnaa/
[samjnaa:~] cd /tmp
[samjnaa:/tmp] touch foo
[samjnaa:/tmp] rm foo
rm: remove regular empty file `foo'? n
[samjnaa:/tmp] sudo -i
[sudo] password for samjnaa:
[root:~] rm /tmp/foo
rm: remove regular empty file `/tmp/foo'? n
[root:~] exit
logout
[samjnaa:/tmp] sudo rm /tmp/foo
[samjnaa:/tmp]
Also with a sub-shell:
[samjnaa:/tmp] touch foo
[samjnaa:/tmp] sudo bash -c 'rm foo'
[samjnaa:/tmp]
I don't get it. IIRC sudo runs the command with the process's uid/gid=0. To execute the command, bash is needed anyhow. So whether bash reads the user's .bashrc or root's .bashrc, it must see and obey this alias. Why does this not happen? Does bash not see the rm command at all?
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Ubuntu sudo Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Shriramana Sharma for more information if necessary.