I often misuse "rm" for "mv"! I hope to make "rm" a command requiring root privilege, like "apt-get". How to do that, please? My system is Ubuntu 10.10.
migrated from stackoverflow.com Feb 16 '12 at 9:03
|
change to your root user. Then run:
It should already be owned by root:root. |
|||||||||||||||||
|
|
Definitely aliasing the interactive version of I think it is better that aliasing |
|||
|
|
|
How about alias rm to 'sudo rm'? Every time you need to enter the password. |
|||||||
|
|
You could This will prevent you from using rm. Then, if you really want to remove something you will need to type |
||||
|
|
|
This is off the top of my head. I'm sure folks will correct edit if I have my syntax off or something. Insert this script in your ~/bin and call it rm.
Make sure that ~/bin is first in your $PATH so your rm is found before /bin/rm. Set that script to ownership root:your_group and permissions 760 so that you must sudo in order to execute rm and you will not need to be root to write or read the file. You can then also get around this script by simply using /bin/rm instead of rm, but you'll do that knowingly. Maybe you'll even get in the habit of specifying rm by absolute path and eventually will do without the little extra script. If you aren't familiar with setting your own path variable, edit your .bash_profile with these lines (or edit if they already exist).
You'll need to restart bash or use the command 'source .bash_profile' to bring your changes in to the current shell. (Of course, |
||||
|
|
rm:'rm -i'– Brett Hale Feb 16 '12 at 8:17rm– CJBrew Feb 16 '12 at 9:34rmwhen you meanmv, and don't have backups or a versioning system (git-scm.com) or at least a recycle bin or something (pages.stern.nyu.edu/~marriaga/software/libtrash), you kind of deserve to lose files. – Christoffer Hammarström Feb 16 '12 at 16:15