Uncategorized

linux command to chmod directories to 755, chmod files to 644

Here are two simple unix commands to chmod directories to 755 (drwxr-xr-x), while chmod’ing files to 644 (-rw-r–r–).

find . -type d -print0 | xargs -0 chmod 0755 # for directories
find . -type f -print0 | xargs -0 chmod 0644 # for files
Tuesday, July 1st, 2014 Uncategorized No Comments

Rationale behind the naming of the Unix file system hierarchy

Have you ever wondered the origins of unix directory names, like /etc, /usr, /var, … ?

Today I came across a PDF explaining the rationale behind the naming of Unix file system hierarchy.

Here is a link to the PDF: http://www.pathname.com/fhs/pub/fhs-2.3.pdf

Wednesday, June 12th, 2013 Uncategorized No Comments

Recursive md5sum of Files in Directory

Calculating the md5 sum of a file is useful for verifying transfers, checking for changes, etc.

This command can be used to recursively scan through a directory calculating md5sum’s for each file:

find . –type f –print0 | xargs –0 md5sum

Example output:

dan@dk01:/usr/local/lib$ find . -type f -print0 | xargs -0 md5sum
3f4b60def4965a65a8ba74d6bfb705af ./libopencv_nonfree.so.2.4.2
cbddb8854f5038283fc8a50be44531e9 ./libv4l2.so.0
cb6d070e09dd5e95c78402901d5208ad ./libswresample.so.0.15.100
d019c220c7214bf709b5073eb7730f9d ./libavdevice.so.54.2.100
0da4b285acd5d6dff73dd1143ca5864d ./libswresample.a
f302fb887de867e903e70de4ba56d4de ./libopencv_core.so.2.4.2
4ad325f7d0c0828aa7ba72f62135e935 ./libavdevice.so.54.0.100
268f814fcce9913773814fce8de216c7 ./libpostproc.so.52.0.100
790eade5ba41a9afdc28d434587a94ec ./libv4l1.so.0
128d7d2286e5d59fafc8e56728bdbf2e ./libopencv_features2d.so.2.4.2
cd2dc23377d519ea29d57c95983ead2c ./libavfilter.so.2.77.100
8034f30e406473844620b50177a9fdc7 ./libavfilter.a
740361c12d3d2206c45ad59504eecd03 ./libopencv_legacy.so.2.4.2
bee0be81c7b3b1518ff03a3ad7ba5a05 ./libswscale.so.2.1.100
7d08940cb3ba9ce18a3ceb0c4bfacf19 ./libv4l/ov511-decomp
e02ff7015998829cb7734ec44b7047ea ./libv4l/ov518-decomp
2b8044e5cf4c0e7de6e7a3fadda8a598 ./libv4l/v4l1compat.so
Friday, September 28th, 2012 Uncategorized No Comments

Create list of installed packages (Linux)

To create a list of installed packages in linux:

dpkg –get-selections > installed-software

If you wanted to use the list to re-install this software on a fresh linux setup:

dpkg –set-selections < installed-software dsel

Friday, September 28th, 2012 Uncategorized No Comments

Possibly Worthwhile Reads

Getting People to Use Statistics Properly

This may be a worthwhile read. It was written in 1978, revised in 1979, so it may be a bit dated. View Article…

 

The Flesch Reading Ease Score

Reader’s Digest magazine has a readability index of about 65, Time magazine scores about 52, an average 6th grade student’s (an 11-year-old) written assignment has a readability test of 60–70 (and a reading grade level of 6–7), and the Harvard Law Review has a general readability score in the low 30s. The highest (easiest) readability score possible is around 120 (e.g. every sentence consisting of only two one-syllable words). Read On…

 

more to come..

Monday, September 17th, 2012 Uncategorized No Comments

Java Socket Server – Clients Disconnecting (Ungracefully)

If you’re writing a java socket server you’ll need to detect when a client disconnects — even if they don’t have the courtesy to disconnect gracefully. This is especially annoying if you’re sending the client socket a lot of streaming data and the client just stops listening without saying a word.

If you’re using an PrintStream to write data to the socket, the way to check this is to check the result from PrintStream.checkError(). If its false, the client disconnected. I’m assuming other output streams will have similar functionality.

If the client doesn’t disconnect gracefully, these things may still occur:

  • Socket.isConnected() may return true
  • Socket.isClosed() may return return false
  • Socket.isInputShutdown() may return false
  • Socket.isOutputShutdown() may return false

I just wasted an hour figuring this out.. Hopefully it will help someone.

Monday, June 11th, 2012 Uncategorized No Comments
Psst.. There is no more.