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:
Just added -sn1
-s = silent
-n1 = only one symbol needed to continue after the insert
#sorry if my English isn't perfect ;P
Waiting for a key stroke. You can use this with a ";" behind to build a command chain.
extension to tali713's random fact generator. It takes the output & sends it to notify-osd. Display time is proportional to the lengh of the fact.
hold period (or whatever character) and hit enter after a second. You need to make the next line of periods the same length as the previous line... score starts at 0 and increase each time length of line is same.
Really bored during class so I made this...
Basically, you hold period (or whatever) and hit enter after a second and you need to make the next line of periods the same length as the previous line...
My record was 5 lines of the same length.
It's best if you do it one handed with your pointer on period and ring on enter.
Compresses each file individually, creating a $fileneame.tar.gz and removes the uncompressed version, usefull if you have lots of files and don't want 1 huge archive containing them all. you could replace ls with ls *.pdf to just perform the action on pdfs for example.
If you want to relocate a package on your own, or you just want to know what those PREIN/UN and POSTIN/UN scripts will do, this will dump out all that detail simply.
You may want to expand the egrep out other verbose flags like CHANGELOGTEXT etc, as your needs require.
It isn't clear, but the formatting around $tag is important: %{$tag} just prints out the first line, while [%{$tag }] iterates thru multi-line output, joining the lines with a space (yes, there's a space between the g and } characters. To break it out for all newlines, use [%{$tag\n}] but the output will be long.
This is aside from rpm2cpio | cpio -ivd to extract the package files.
When your wtmp files are being logrotated, here's an easy way to unpack them all on the fly to see more than a week in the past. The rm is the primitive way to prevent symlink prediction attack.
This is not recommended... lossy -> lossy = lossier.
Still, you can do it! ;)
Read all contents from current directory and display to stdout.
Read all contents from current directory and display it on stdout.
This one uses hex conversion to do the converting and is in shell/sed only (should probably still use the python/perl version).
Prompts the user for username and password, that are then exported to http_proxy for use by wget, yum etc
Default user, webproxy and port are used.
Using this script prevent the cleartext user and pass being in your bash_history and on-screen
If you need to randomize the lines in a file, but have an old sort commands that doesn't support the -R option, this could be helpful. It's easy enough to remember so that you can create it as a script and use that.
It ain't real fast. It ain't safe. It ain't super random. Do not use it on untrusted data. It requires bash for the $RANDOM variable to work.
This command will play back each keystroke in a session log recorded using the script command. You'll need to replace the ^[ ^G and ^M characters with CTRL-[, CTRL-G and CTRL-M. To do this you need to press CTRL-V CTRL-[ or CTRL-V CTRL-G or CTRL-V CTRL-M.
You can adjust the playback typing speed by modifying the sleep.
If you're not bothered about seeing each keypress then you could just use:
cat session.log
CHANGELOG
Version 1.1
removedir () { echo "You are about to delete the current directory $PWD Are you sure?"; read human; if [[ "$human" = "yes" ]]; then blah=$(echo "$PWD" | sed 's/ /\\ /g'); foo=$(basename "$blah"); rm -Rf ../$foo/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
BUG FIX:
Folders with spaces
Version 1.0
removedir () { echo "You are about to delete the current directory $PWD Are you sure?"; read human; if [[ "$human" = "yes" ]]; then blah=`basename $PWD`; rm -Rf ../$blah/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
BUG FIX:
Hidden directories (.dotdirectory)
Version 0.9
rmdir () { echo "You are about to delete the current directory $PWD. Are you sure?"; read human; if [[ "$human" = "yes" ]]; then blah=`basename $PWD`; rm -Rf ../$blah/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
Removes current directory with recursive and force flags plus basic human check. When prompted type yes
1. [user@host ~]$ ls
foo bar
2. [user@host ~]$ cd foo
3. [user@host foo]$ removedir
4. yes
5. rm -Rf foo/
6. [user@host ~]$
7. [user@host ~]$ ls
bar
My old Solaris server does not have lsof, so I have to use pfiles.
Route output to notify-send to show nice messages on the desktop, e.g. title and interpreter of the current radio stream
man 5 shadow
I think it's more reliable, because
passwd -S
dont show "locked" but "L" as second field on my Archlinux for a particular user.
( unixhome alternative ).