commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
Forces the -i flag on the rm command when using a wildcard delete.
There is 1 alternative - vote for the best!
-R Recursively change attributes of directories and their contents.
+i to set the immutable bit to prevent even root from erasing or changing the contents of a file.
If you can do better, submit your command here.
You must be signed in to comment.
Clever.
Great.
But why should you change directory? Just do the:
touch /path/-iI'm constantly tripping over the 'alias rm="rm -i"' that gets forced on me with Fedora/Debian Linux distros. I like this idea for a per-directory molly-guard.
Unfortunately it doesn't save from
rm -fr ./*or when deleting parent dirs:
touch ./path/-irm -fr *Very interesting but doesn't seem to work here on a Mac nor a CentOS 5.3 machine using bash 3.2
david@host /tmp $
cd a
david@host /tmp/a $
mkdir ta tb tc
david@host /tmp/a $
touch ta/-i
david@host /tmp/a $
rm -rf *
david@host /tmp/a $
ls
david@host /tmp/a $
DaveQB ... did you read aikikode's comment?
Works fine for me on Mac OSX.
My vote is up, but still it will not protect against rm -rf -- *
Nice thinking though.
safe-rm (http://www.safe-rm.org.nz) is another way of preventing accidental deletions through a blacklist of paths you don't want to delete (e.g. /bin, /usr/lib or ~/important_file.gpg)
fmarier, that looks interesting I'll take a look. oh and thanks for the up votes guys, its not perfect but handy when training the junior sys admins.
If you really want to protect files from being deleted or change, even by root,
use the chattr command:
chattr +ihttp://en.wikipedia.org/wiki/Chattr
Only works on ext2 systems.
@unixmonkey21519 aikikode Must have posted seconds before me as I did not see it just before or I posted (or even after actually)