Searches backwards through your command-history for the typed text. Repeatedly hitting Ctrl-R will search progressively further. Return invokes the command. Show Sample Output
This just reads in a local file and sends it via email. Works with text or binary. *Requires* local mail server.
After executing this, click on a window you want to track X Window events in. Explaination: "xev will track events in the window with the following -id, which we get by greping window information obtained by xwininfo" Show Sample Output
for one line per process:
ss -p | cat
for established sockets only:
ss -p | grep STA
for just process names:
ss -p | cut -f2 -sd\"
or
ss -p | grep STA | cut -f2 -d\"
This will log your internet download speed.
You can run
gnuplot -persist <(echo "plot 'bps' with lines")
to get a graph of it.
show only the name of the apps that are using internet Show Sample Output
I often need to know of my directory in the PATH, which one DOES NOT exist. This command answers that question * This command uses only bash's built-in commands * The parentheses spawn a new sub shell to prevent the modification of the IFS (input field separator) variable in the current shell
Get sopcast links for live sports from http://myp2p.eu (for example) Get sp-sc or sp-auth binary by googling (sopcast + linux) eg http://www.jbg.f2s.com/sp-sc.gz Requires the 32bit libstdc++5 package. After exiting mplayer, type 'killall sp-sc'
Show apps that use internet connection at the moment. Can be used to discover what programms create internet traffic. Skip the part after awk to get more details, though it will not work showing only unique processes. This version will work with other languages such as Spanish and Portuguese, if the word for "ESTABLISHED" still contain the fragment "STAB"(e.g. "ESTABELECIDO") Show Sample Output
This corrects duplicate output from the previous command. Show Sample Output
Can be used to discover what programms create internet traffic. Skip the part after awk to get more details. Has anyone an idea why the uniq doesn't work propperly here (see sample output)? Show Sample Output
I usually have 5 or more ssh connections to various servers, and putting this command in my .bash_profile file makes my putty window or x terminal window title change to this easily recognizable and descriptive text. Includes the username, group, server hostname, where I am connecting from (for SSH tunneling), which device pts, current server load, and how many processes are running.
You can also use this for your PROMPT_COMMAND variable, which updates the window title to the current values each time you exec a command.
I prefix running this in my .bash_profile with
[[ ! -z "$SSH_TTY" ]] &&
which makes sure it only does this when connecting via SSH with a TTY.
Here's some rougher examples from http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
# If set, the value is executed as a command prior to issuing each primary prompt.
#H=$((hostname || uname -n) 2>/dev/null | sed 1q);W=$(whoami)
#export PROMPT_COMMAND='echo -ne "\033]0;${W}@${H}:${PWD/#$HOME/~} ${SSH_TTY/\/dev\//} [`uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g"`]\007"'
#PROMPT_COMMAND='echo -ne "\033]0;`id -un`:`id -gn`@`hostname||uname -n 2>/dev/null|sed 1q` `command who -m|sed -e "s%^.* \(pts/[0-9]*\).*(\(.*\))%[\1] (\2)%g"` [`uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g"` / `command ps aux|wc -l`]\007"'
#[[ -z "$SSH_TTY" ]] || export PROMPT_COMMAND
#[[ -z "$SSH_TTY" ]] && [[ -f /dev/stdout ]] && SSH_TTY=/dev/stdout
And here's a simple function example for setting the title:
function set_window_title(){ echo -e "\033]0; ${1:-$USER@$HOST - $SHLVL} \007"; }
Show Sample Output
Finds executable and existing directories in your path that can be useful if migrating a profile script to another system. This is faster and smaller than any other method due to using only bash builtin commands. See also: + http://www.commandlinefu.com/commands/view/743/list-all-execs-in-path-usefull-for-grepping-the-resulting-list + http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html Show Sample Output
in place of warptv use shagadelictv, edgetv, agingtv, dicetv, vertigotv, revtv or quarktv (see 'gst-inspect-0.10 effectv'. Requires gstreamer-plugins-good (or gstreamer0.10-plugins-good ).
For slow webcams use something like
gst-launch-0.10 v4l2src ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! warptv ! ffmpegcolorspace ! autovideosink
.
For basic webcam view via gstreamer use
gst-launch-0.10 v4l2src ! autovideosink
emulates bash4's "echo {03..20}" Uses bash3 builtin function printf Show Sample Output
Uses 'seq' with formatting parameter to generate the necessary padded sequence. Change '%02.0f' to how many digits you need (for 3, use %03.0f, etc) and replace 5 & 15 with your desired min and max. Show Sample Output
You need bonnie++ package for this. More detail than a simple hdparm -t /dev/sda would give you. the -d is the directory where it performs writes/reads for example I use /tmp/scratch with 777 permissions Bonnie++ benchmarks three things: data read and write speed, number of seeks that can be performed per second, and number of file metadata operations that can be performed per second.
This is just for fun. Show Sample Output
Bash 4 will let you do {00..19} to get leading zeros, but Bash 3 doesn't have that feature. This technique gets you partway there (the sequences need be such that the last digit ranges from zero to nine - you can't use this for something like Bash 4's {03..27}, for example). When this limitation is not a problem, you can avoid some complicated string manipulation for concatenating leading zeros.
You can add more digits like this: {0..1}{0..9}{0..9} (ranges from 0 to 99 with up to two leading zeros). To pad with additional zeros:
for i in 000{0..1}{0..9}; do echo $i; done
or
for i in {0..1}{0..9}; do echo "000$i"; done
This is useful for creating values to sort or for creating filenames with a fixed format. Note that this will also work:
touch {0..1}{0..9}
Show Sample Output
I sometimes (due to mismanagement!) end up with files in a git repo which have had their modes changed, but not their content. This one-liner lets me revert the mode changes, while leaving changed-content files be, so I can commit just the actual changes made.
Handles everything except octets with 255. Ran through ip generator with variable octet lengths.
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: