parsed.org

Popular tags

aliases analysis apache apt-get array ascii authentication autocomplete awk background backup bash boot broken browser bsd buffer c capture characters cisco cmd commands compilation configuration connections control conversion convert copy data database debian debugging diagnostic diff directory dns document dos dot-emacs download editors elisp emacs encryption enumeration escape ethereal ethernet extension extras filesystem filter find firefox firewall freebsd functions gnu gotcha grep gvim headers highlighting html http image imagemagick import indentation internals javascript key keystrokes languages latex line-endings loop lsof mail mailbox messages metadata microsoft modules monitoring mta mua mutt mysql neat network newline obscure oracle os output packages packet parsing password path performance perl permissions php pipe postgresql process programming psql python queries recovery redirect regex restore root router ruby schema scp screen screenrc security sed server session shell solaris sort split sql ssh startup subversion svn symlinks syntax system tagging tail tcpdump template terminal tex tips tunnel typesetting ui unix url utilities vi vim vimrc virtualhost windows wireshark x11 xargs xml zsh

» Show all tags...

Most recent tips:

Word finder by https://me.yahoo.com/dogbnny2#64692 on Dec 01, 2008 05:52 PM

Have a bunch of gibberish? Curious as to what words might be found inside? Try selecting that text, copying it, and typing this code into a terminal (but without the $):

$ (for i in `xclip -o -selection clipboard | grep -o -F -f /usr/share/dict/words | sed -e "/^.$/d"`; do echo -n "$i, "; done) | tee >(xclip -selection clip)

Breakdown:

The xclip -o -selection clipboard bit captures what you've copied. Make sure you have the xclip utility installed!

The grep -o -F -f /usr/share/dict/words takes whatever xclip told it and finds all the words. -F means "I'm going to tell you a list of patterns to match against, not just one." -f means "Not just a normal pattern, but everything inside this file." /usr/share/dict/words is the system dictionary. -o means "Just tell me what you found, not the entire thing."

sed -e "/^.$/d" means "Get rid of every word that's a single letter long.

for i in `...`; do echo -n "$i, "; done means "Instead of having each word on its own line, put it in a nice comma formatted list."

Finally, (...) | tee >(xclip -selection clip) means "Take everything and put it back into the clipboard as well as put it on the screen."

When I run my script against this text:

aoeuthasonetbusnthelurbtaoesunthaoenutdntqhxebunthdaonthedu

my script produces this output:

has, one, bus, nth, es, nth, nut, bunt, on, the,

Great fun. Here is a simplified version that does not use the clipboard and has each word on its own line. Maybe you can understand it better:

System Message: ERROR/3 (<string>, line 32)

Unexpected indentation.
$ echo "Gibberish Here" | grep -o -F -f /usr/share/dict/words | sed -e "/^.$/d"
dictionarygibberishgrepuselessxclip

If you try to unmount a partition and get a message like this:

# umount /media/usbdisk/
umount: /media/usbdisk: device is busy

Use the lsof command to find out what programs are using what files:

# lsof /media/usbdisk/
COMMAND  PID USER  FD TYPE DEVICE SIZE NODE NAME
bash    6925 root cwd  DIR   8,17 4096    1 /media/usbdisk/
xmms    6979 root cwd  DIR   8,17 4096    1 /media/usbdisk/

This shows that the programs bash and xmms are using the device. For an even clearer picture, use the device name rather than the mountpoint:

Using device name:

# lsof /dev/sdb1
COMMAND  PID USER  FD TYPE DEVICE    SIZE NODE NAME
bash    6925 root cwd  DIR   8,17    4096    1 /media/usbdisk
xmms    6979 root cwd  DIR   8,17    4096    1 /media/usbdisk
xmms    6979 root  8r  REG   8,17 2713101  377 /media/usbdisk/a.mp3

Other tips for using lsof

# all tcp connections
lsof -i tcp

# connections to mail server on 10.2.3.4
lsof -i 10.2.3.4:25

# What's connected to my PostgreSQL server via TCP/IP?
lsof -i :5432

# What is my browser connected to?
lsof -i :80

Copied from the linuxjournal website here

connectionslsofnetworking

NOTE: wildcards are acceptable when specifying a packages name

searching for a rpm

$ yum search nagios*

listing rpms

$ yum list all
$ yum list available
$ yum list installed
$ yum list updates
$ yum list recent

download/install updated rpm packages

$ yum update

exclude a package

$ yum update --exclude=nagios-plugins*

exclude multiple packages

$ yum update --exclude=nagios-plugins* --exclude=faad2* --exclude=vlc*
fedorapackagesrpmyum

bzip2 -c largefile.txt | ssh user@hostname "bzip2 -dc > /home/user/myDir/largefile.txt"

Bascially it bzips the file on the fly whilst sending over ssh and decompressing at the other end on the target machine. Very useful for send large files over a vpn or slow connection.

It also saves time by combining all the processes into one.

I know you can use scp -C, but this is faster as it uses bzip.

You can also increase the compression on bzip to make the transfer size smaller, though this will increase processing time however if it's a very slow connection this should not matter.

bzip -c1 will compress at the highest compression ratio

bzipscpshellssh
$ echo file.ext1.ext2 | cut -d"." -f1-2
cutextensionfileshshell
RSS