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

Find the process you are looking for minus the grepped one
preferred way to query ps for a specific process name (not supported with all flavors of ps, but will work on just about any linux afaik)

Pretty-print user/group info for a given user

get a rough estimate about how much disk space is used by all the currently installed debian packages
The vaule is expressed in megabytes

Get all mac address
I prefer the ip command to ifconfig as ifconfig is supposedly going to be deprecated. Certain IP address aliases can only be seen with the ip command (such as the ones applied by RHCS).

Show Apt/Dpkg configuration
Shows all configurations to apt and dpkg, rarely changed, you probably still have the default configuration. Go ahead and explore your configuration if you dare, perhaps change your apt-cache directory, Dir::Cache "var/cache/apt/"; or the names of the log files.

Remove everything except that file
Remove everything except that file with shell tricks inside a subshell to avoid changes in the environment. $ help shopt

Compute running average for a column of numbers
This is an on-line algorithm for calculating the mean value for numbers in a column. Also known as "running average" or "moving average".

Execute a sudo command remotely, without displaying the password
The ssh command alone will execute the sudo command remotely, but the password will be visible in the terminal as you type it. The two stty commands disable the terminal from echoing the password back to you, which makes the remote sudo act as it does locally.

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"

Search for an active process without catching the search-process
This does the same thing as many of the 'grep' based alternatives but allows a more finite control over the output. For example if you only wanted the process ID you could change the command: $ ps -ef | awk '/mingetty/ && !/awk/ {print $2}' If you wanted to kill the returned PID's: $ ps -ef | awk '/mingetty/ && !/awk/ {print $2}' | xargs -i kill {}


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: