Let's give Flatcap credit for this elegant solution, instead of leaving it hidden as a comment. Tested on RHEL6 and it works. Nice and clean.
How to force a userid to log out of a Linux host, by killing all processes owned by the user, including login shells:
A shorter version of command #3014, using awk instead of sed. Useful when scraping websites with a script.
Converts the first letter of each word to upper case Show Sample Output
Not as cool as the python example, but it still works. Show Sample Output
Install using yum install yum-utils Options include: --oldkernels Remove old kernel and kernel-devel packages --count=KERNELCOUNT Number of kernel packages to keep on the system (default 2) use package-cleanup --help for a complete list
Nice simple example of something we can do in bash.
Start printing the contents of filename to stdout, until a matching line to regex is found, then stop.
Search in "filename" for the first line to match regex, and print to stdout from the matching line to the end of the file.
Figlet is easy to find for download on the internet, and works for any text. Quite cool. Show Sample Output
The Washington DC Metro area is not accustomed to getting large snow storms... http://snowpocalypsedc.com/
Print out the contents of $VARIABLE, six words per line, ignoring any single or double quotes in the text. Useful when $VARIABLE contains a sentence that changes periodically, and may or may not contain quoted text.
Change the number 50 to whatever number of characters you want. Change the character inside the double quotes to whatever you want printed.
Works in RHEL5 and derivatives.
This command line will display the output of , from the first line of output, until the first time it sees a pattern matching . You could specify the regex pattern /^$/ to look for the first blank line, or /^foobar/ to look for the first line that starts with the word foobar.
Tested on Fedora 12. This function will take a man page and convert it to pdf, saving the output to the current working directory. In Gnome, you can then view the output with "gnome-open file.pdf", or your favorite pdf viewer.
Force an fsck on reboot. Useful on a system where / has mounted read-only because of file system issues.
If you run this command on a VMWare Virtual Machine, it will return the string "VMware Virtual Platform". If you run it on a physical machine, it will return nothing. Useful for having a script determine if it's running on a VM or not. Of course, you must have dmidecode installed for this to work. Try it this way in a script: ISVM=$(dmidecode | awk '/VMware Virtual Platform/ {print $3,$4,$5}') Then test if $ISVM has text in it, or is blank.
THIS COMMAND IS DESTRUCTIVE. That said, lets assume you want to render your boot drive unbootable and reboot your machine. Maybe you want it to boot off the network and kickstart from a boot server for a fresh OS install. Replace /dev/fd0 with the device name of your boot drive and this DESTRUCTIVE command will render your drive unbootable. Your BIOS boot priority should be set to boot from HD first, then LAN.
'jot' does not come with most *nix distros, so we need to use seq to make it work. This version tested good on Fedora 11.
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.
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: