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:
'watch' repeatedly (default every 2 seconds, -n 1 => every second) runs a command (here ':', a shorthand for 'true'), displays the output (here nothing) and the date and time of the last run.
I thought it to be obvious but it seemingly is not: to exit use Ctrl-C.
grep -- displays process ids
-v -- negates the matching, displays all but what is specified in the other options
-u -- specifies the user to display, or in this case negate
The process loops through all PIDs that are found by pgrep, then orders a forced kill to the processes in numerical order, effectively killing the parent processes first including the shells in use which will force the users to logout.
Tested on Slackware Linux 12.2 and Slackware-current
Replace "url" with the correct address of what your're downloading. Replace 01:00 with what time you want. (24-hour clock).
By 'pst' you can print out process tree with all details about all processes (including a command line, PID, and the current process you are running in).
By 'pst username' you can get an information about processes belonging to the particular user 'username'.
Ever had a file with a list of numbers you wanted to add, use:
cat file | sed ':a;N;$!ba;s/\n/+/g' | bc
* size must be 640?480 pixels
* only has 14 colors
* save it in XPM format
Edit /boot/grub/menu.lst and add
make sure for your path name and hard disk
NOT MINE! Taken from hackzine.com blog.
It creates a tree-style output of all the (sub)folders and (sub)files from the current folder and down(deeper)
Quoting some of hackzine's words
"Murphy Mac sent us a link to a handy find/sed command that simulates the DOS tree command that you might be missing on your Mac or Linux box. [..split...] Like most things I've seen sed do, it does quite a bit in a single line of code and is completely impossible to read. Sure it's just a couple of substitutions, but like a jack in the box, it remains a surprise every time I run it."
cd into the directory that contains the file.
this is just the usual move command but shortcut'd.
say you wanted to move a photo img1.png from ~/photos/holidayphotos into the parent directory which is ~/photos
command would be:
~/photos/holidayphotos$ mv img1.png ..
I use Ubuntu so this'll work in debian but not sure what else.
Suppose you made a backup of your hard disk with dd:
dd if=/dev/sda of=/mnt/disk/backup.img
This command enables you to mount a partition from inside this image, so you can access your files directly.
Substitute PARTITION=1 with the number of the partition you want to mount (returned from sfdisk -d yourfile.img).
The large context number (-C 1000) is a bit of a hack, but in most of my use cases, it makes sure I'll see the whole log output.
This is useful if you have a program which doesn't work well with multicore CPUs. With taskset you can set its CPU affinity to run on only one core.
I use this command on my machines running VMware Server to print out the state of all registered Virtual machines.