LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-24-2011, 02:36 PM   #1
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Rep: Reputation: 16
'sudo rm' doesn't ask for confirmation


'sudo rm' on a file doesn't ask for confirmation, it just removes the file even though I aliased 'rm' to 'rm -i' in a script in /etc/profile.d/

Here's the strange part though. When I first do 'su root' and THEN as root do an 'rm', it will ask for confirmation. However, when I am logged in as a non-privileged user and do a 'sudo rm', it doesn't ask for confirmation (even though I thought sudo would do so because that's how it behaved for the root user when I did 'su root').

How can I ensure that 'sudo rm' will prompt me before removing anything?
 
Old 10-24-2011, 03:31 PM   #2
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
Check the output of alias as yourself, after su root, and then
Code:
sudo bash -c alias
I get different results for each, so I think sudo is getting a different environment from true root. I guess this is part of the "env_reset" function of sudo (which varies depending on how sudo was compiled for your distro, I think).
 
Old 10-24-2011, 04:19 PM   #3
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Original Poster
Rep: Reputation: 16
Turns out if you add the following as an alias (note the extra space at the end), aliases like 'll' and 'rm' get picked up when using sudo. And it IS documented behaviour apparently.

alias sudo='sudo '
 
1 members found this post helpful.
Old 10-25-2011, 06:22 AM   #4
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
That's freaky. Where did you find it documented?

Even with this, do you get any output from
Code:
sudo bash -c alias
? It's empty for me.
 
Old 10-25-2011, 06:44 AM   #5
spoodie
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Rep: Reputation: 0
If you use this you can see the aliases.
Code:
sudo su - root -c alias
I imagine it's all to do with sudo not reading the root user's environment files.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo doesn't work slack_prad Linux - General 2 02-21-2007 07:38 AM
su to root works sudo doesn't magnum81 Linux - Security 4 04-22-2006 08:29 PM
sudo doesn't work oomfoofoo Debian 3 08-13-2005 07:34 AM
sudo doesn't work mla Linux - Software 1 10-01-2003 08:24 PM
sudo doesn't work mla Linux - Software 4 10-01-2003 07:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration