Commands by UnixNeko (4)

  • PING parameters c 1 limits to 1 pinging attempt q makes the command quiet (or silent mode) /dev/null 2>&1 is to remove the display && echo ONLINE is executed if previous command is successful (return value 0) || echo OFFLINE is executed otherwise (return value of 1 if unreachable or 2 if you're offline yourself). I personally use this command as an alias with a predefined machine name but there are at least 2 improvements that may be done. Asking for the machine name or IP Escaping the output so that it displays ONLINE in green and OFFLINE in red (for instance).


    9
    ping -c 1 -q MACHINE_IP_OR_NAME >/dev/null 2>&1 && echo ONLINE || echo OFFLINE
    UnixNeko · 2012-02-09 06:30:55 26
  • Extracting .gz files and placing the output in another directory in one command line is convenient thing. I just followed some how-to to install Nagios on Ubuntu Lucid Lynx but they give the method to install from archives. I wished to install from the repository. If you do so some files are missing. I've not tested yet but this is an example command line I did to extract sudo sh -c 'gunzip -c /usr/share/doc/nagios3-common/examples/template-object/templates.cfg.gz > /etc/nagios3/objects/templates.cfg' We need privilege to write the destination file. Show Sample Output


    0
    sudo sh -c 'gunzip -c source.gz > destination'
    UnixNeko · 2011-07-05 23:51:01 4
  • Can be useful to rip a CD. Show Sample Output


    -1
    ripit -c 0 --outputdir $1 --nosubmission
    UnixNeko · 2011-06-12 12:29:26 3
  • I have some problems with gnome panel which does not load completely leaving me without the actual GUI. This commands helps to kill the gnome-panel process then it should be relaunch automatically.


    -2
    pgrep -lf gnome-panel | awk '{if ($2=="gnome-panel") print $1}' | xargs kill -9
    UnixNeko · 2011-06-12 12:23:27 13

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.

Share Your Commands


Check These Out

Twitpic upload and Tweet

Find the package that installed a command

open path with your default GNOME program
Another step to bring cli and gui closer together: gnome-open It opens a path with the default (gui) application for its mime type. I would recommend a shorter alias like alias o=gnome-open More examples: $ gnome-open . [opens the current folder in nautilus / your default file browser] $ gnome-open some.pdf [opens some.pdf in evince / your default pdf viewer] $ gnome-open trash:// [opens the trash with nautilus] $ gnome-open http://www.commandlinefu.com [opens commandlinefu in your default webbrowser]

Advanced python tracing
Trace python statement execution and syscalls invoked during that simultaneously

list block devices
Shows all block devices in a tree with descruptions of what they are.

get delicious bookmarks on your shell (text version :-))
a variation of avi4now's command - thanks by the way!

Check if you work on a virtual/physical machine in Linux
Command used to know if we are working on a virtual or physical machine. This command will use the dmidecode utility to retrieve hardware information of your computer via the BIOS. Run this command as root or with sudo.

diff two sorted files
Sees if two records differ in their entries, irrespective of order.

Put public IP address in a variable

tar+pbzip2 a dir


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: