All commands (14,187)

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

strip config files of comments
some configuration files, particularly those installed by default as part of a package, have tons of comment lines, to help you know what's possible to configure, and what it means. That's nice, but sometimes you just want to see what specifically what _has_ been configured. That's when I use the above snippet, which I save as a bash alias 'nocom' (for 'no comments'). Apache default config files are perfect examples of when/why this script is handy.

See your current RAM frequency
man dmidecode [look for type]

Prettify an XML file
Like `tidy`, `xmllint` can be used to prettify XML files. The --nsclean option is also useful to remove redundant namespaces.

Dump a configuration file without comments or whitespace...
A short, *easy-er* to remember command for stripping whitespace and comments from a config file, (or any file for that matter). Remember regex as: slash, space, star. pound, slash, bar. pointy-hat, dollar. (or "caret, dollar" if you must) :-P

Kill process by pid
To kill a process in windows by using the PID. Change 10728 to the PID of the process you want to kill.

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"

Introduction to user commands
Tested on debian and ubuntu. Translations could be useless, so "LANG=C man intro" is a better alternative.

Stripping ^M at end of each line for files

Find all the files more than 10MB, sort in descending order of size and record the output of filenames and size in a text file.
This command specifies the size in Kilobytes using 'k' in the -size +(N)k option. The plus sign says greater than. -exec [cmd] {} \; invokes ls -l command on each file and awk strips off the values of the 5th (size) and the 9th (filename) column from the ls -l output to display. Sort is done in reversed order (descending) numerically using sort -rn options. A cron job could be run to execute a script like this and alert the users if a dir has files exceeding certain size, and provide file details as well.

Polkit: Force KDE apps to always recognize your display
KDE apps expect certain variables to be set, and unfortunately pkexec doesn’t set them by default. So, by setting this alias, it becomes possible to run, e.g. “pkexec kate” or “pkexec dolphin” and it’ll actually run.


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: