### What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

### Check These Out

List bash functions defined in .bash_profile or .bashrc

escape any command aliases
e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash: rm [file] # WILL prompt for confirmation per the alias \rm [file] # will NOT prompt for confirmation per the default behavior of the command

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Convert CSV to JSON

Convert encoding from cp1252 (MS Windows) to UTF-8 on source code files

Change gnome-shell wallpaper

cycle through everything sox knows how to read, playing only the first three seconds
I wasted two hours reading the sox documentation and searching on the web for the format of some obscure fscking sound sample, and then finally came up with this. This plays only the first three seconds of your unknown formatted sound file using every one of sox's built-in filetypes. If you don't get an exact match, you may get close. . I could not fit every single type in and keep it under 127 characters, so you will have to replace "..." with the full list obtainable by $sox --help (or try Show sample output) . note: /usr/bin/play should be linked to sox on most systems. Running scripts after a reboot for non-root users . Sometimes we may want to run a script when a system reboots . We can simply do this by just scheduling the script using vixie cron with the @reboot option . e.g @reboot I use it to send me an alert message on our prod hosts to send an alert message when the system reboots . @reboot zaman uptime | echo uptime | mail -s "uname -n got rebooted" me@myhost.com Commit only newly added files to subversion repository Get AWS temporary credentials ready to export based on a MFA virtual appliance You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: awk '{ print "export AWS_ACCESS_KEY_ID=\""$1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\""$3 "\"" }' You must adapt the command line to include: * \$MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials