Archive for Newbie

How many files in a directory.. with find and wc

I’ve had to figure out how many files are in a directory about a billion times now… and the easiest way I’ve done it is

cd /directory-in-question
find . | wc -l

This introducting WC, wordcount… Wordcount works in many ways, however it can be used to count lines in a file or directory listing or a find or whatever you need…

output is something like:

$ find . | wc -l [ENTER}
325
$

Saying I have 325 files in the directory (and any subdirectories)

Comments

Grep… and some of it’s useful commands

I love grep… it’s a great way to search for lines in error logs, find out where references to a URL are in your websites, and all in all, a good program.

context is : grep searchterm filename

however it’s much more powerful.

For example, you can do a

grep username /etc/passwd

to find out if a user has an account. Or you can pipe system processes thru grep to find only the ones in question

ps -awux | grep processname

You can exclude things using grep as well, for example lets say you know you have 20 sendmail processes going but you just need the one thats “accepting connections”

ps -awux | grep sendmail | grep -v accepting

will show it to you (yes, it’s an abuse of grep there.. you can complain if you want :)

Comments

Knoppix — The Linux Lifesaver

Knoppix is a great bootable live operating system for x86 machines (ya know, intel boxes, windows boxes) that gives you a full XWindows implementation with utiltiies, network connectivity, and more..

I’ve used this to save my butt so many times when an OS won’t boot and I need to get to the data on the drives, or edit a config file, or even just to troubleshoot a friends PC.. I suggest getting it up on your USB keychain device and BURNING A FEW SPARE CD’S WITH IT.

I keep one in the car, in a ziplock bag just in case :)

Go Grab Knoppix now.

Comments

Putty.exe - The windows SSH Client

Everyone has used a windows machine at one point or another.. and one of the annoying thigns is that you can’t SSH using a built in program… thats why one of the first things I put onto my USB Flashdrive is Putty.exe.

This is a very straightforward SSH program for windows thats only like 200k and self contained, no installers, no nothing. I just copy the file over to C:\WINNT or whatever their windows directory is and Start->Run->Putty[ENTER] it’s perfect.

You can grab a copy here, or directly link to the exe file here.

Comments

· Next entries »