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:
useful for loops like for i in $(cat list_of_servers); do ssh -q $i hostname; done
if there is an unreachable server, you can just press ctrl + \ to skip that server and continue on with the loop
This will show all physically connected SATA (and SCSI) drives on your system. This is particularly useful when troubleshooting hard disks.... or when a mount point seems to be missing.
Create an ISO Image from a folder and burn it to CD (Os X)
I save this to bin/iptrace and run "iptrace ipaddress" to get the Country, City and State of an ip address using the http://ipadress.com service.
I add the following to my script to get a tinyurl of the map as well:
URL=`lynx -dump http://www.ip-adress.com/ip_tracer/?QRY=$1|grep details|awk '{print $2}'`
lynx -dump http://tinyurl.com/create.php?url=$URL|grep tinyurl|grep "19. http"|awk '{print $2}'
This will append the output of "command" to whatever file you're currently editing in vim. Who else has good vim tricks? :)
Split File in 19 MB big parts, putting parts together again via
cat Nameforpartaa Nameforpartab Nameforpartac >> File
The hyphen tells vim to open from STDOUT - saves having to create temporary files.
I've had this as mute.sh in my ~/bin/ for some time.
Adjust the
head -c
part for password length.
I use filenames like "hans@commandlinefu.com.gpg" and a vim which automatically decrypts files with .gpg suffixes.
This is my first attempt at converting all HTML files to UTF-8 file encoding, including all subfolders.
Theres probably a much more compact way to do it, but I'm quite proud of it with my windows background ;)
Add the functions to the .bashrc to make it work
Example: First go to the iso file directory and type:
----------------------------------------------------------------------------------------------------
user@box:~$ miso file.iso
----------------------------------------------------------------------------------------------------
It will put you into a temporary mounting point directory (ISO_CD) and will show the files
You can umount the iso file whatever the directory you are
----------------------------------------------------------------------------------------------------
user@box:~/ISO_CD$ uiso
----------------------------------------------------------------------------------------------------
It wil umount the iso file and remove the temporary directory in your home
Takes input from the connected terminal and dumps it to the specified file. Stop writing and close file with control + D or the end of line character. Useful for copying+pasting large blobs of text over SSH to a new machine.
I often forget to type sudo before a command that needs it. This is the quickest way to rerun the command prefixed by sudo.
Sometimes commands are long, but useful, so it's helpful to be able to make them permanent without having to retype them. An alternative could use the history command, and a cut/sed line that works on your platform.
history -1 | cut -c 7- > foo.sh
finding all files with the metadata tag "data" using the metadata find command mdfind , writing the list to a temporary file, reading the input for the .zip file from this temporary file.
Converts a .pdf to .jpg . should work with jpeg | tiff | png | gif | jp2 | pict | bmp | qtif | psd | sgi | tga
I use this on debian testing, works like the other sorted du variants, but i like small numbers and suffixes :)