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.
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:
Generate a random MAC address with capital letters
In the field, I needed to script a process to scan a specific vendor devices in the network. With the help of nmap, I got all the devices of that particular vendor, and started a scripted netcat session to download configuration files from a tftp server.
This is the nmap loop (part of the script). You can however, add another pipe with grep to filter the vendor/manufacturer devices only. If want to check the whole script, check in http://pastebin.com/ju7h4Xf4
Enable root user to run VLC
List all fonts used by an SVG file. Useful to find out which fonts you need to have installed in order to open/edit an SVG file appropriately.
With sed you can replace strings on the fly.
Google Cloud SDK comes with a package manager `gcloud components` but it needs a bit of `sed` to work. Modify the "^| Not" bit to change the package selection. (The gcloud --format option is currently broken)
The command will read the apache log file and fetch the virtual host requested and the number of requests.
This sed command will search for 18.104.22.168 in all lines of test.txt and replace comment symbol ";" . You can use it for other purpose also.
polls the pirate bay mirrors list and chooses a random site and opens it for you in firefox
This modifies the output of ls so that the file size has commas every three digits. It makes room for the commas by destructively eating any characters to the left of the size, which is probably okay since that's just the "group".
Note that I did not write this, I merely cleaned it up and shortened it with extended regular expressions. The original shell script, entitled "sl", came with this description:
: For tired eyes (sigh), do an ls -lF plus whatever other flags you give
: but expand the file size with commas every 3 digits. Really helps me
: distinguish megabytes from hundreds of kbytes...
: Corey Satten, email@example.com, 11/8/89
Of course, some may suggest that fancy new "human friendly" options, like "ls -Shrl", have made Corey's script obsolete. They are probably right. Yet, at times, still I find it handy. The new-fangled "human-readable" numbers can be annoying when I have to glance at the letter at the end to figure out what order of magnitude is even being talked about. (There's a big difference between 386M and 386P!). But with this nifty script, the number itself acts like a histogram, a quick visual indicator of "bigness" for tired eyes. :-)
When booting a VM through OpenStack and managed through cloudinit, the hosts file gets to write a line simiar to
127.0.1.1 ns0.novalocal ns0
This command proven useful while installing a configuration manager such as Salt Stack (or Puppet, or Ansible) and getting node name
credit shall fall to this for non-gzipped version:
Works great on Mac OSX.
Thx Mass1 for the sharing
Print the IP address and the Mac address in the same line
Similar to the following:
curl -I <URL>
but curl -I performs a HEAD request, which can yield different results.
Calculate the date of Sysadmin day (last Friday of July) of any given year
change the path where you are, when is executed, is usefule when you've got folders to classify something like a tags, you've got devel/dist, android/ios, etc. like:
You can change between devel/project folder to dist/project without leave project.
If somebody has a better idea to do that without replace command.
It requires https://jqplay.org/, that comes with brew: brew install jq
Replace "APIKEY" with your public apikey
Before: :key => 'value'
After: key: 'value'
I have only tested this a little, so please don't run this on anything important unless you have version control or other backups!
Change lang from ru to something else.
Curl version - Mac OS etc, any system w/o wget.