Monday, January 8, 2007

When did this windows box boot last?

Windoze:


Ever wonder when a windows box was last booted. In linux we can use “who –b” (in most flavours) but what about windows?

Try from the command prompt:

"net statistics workstation ¦ more "

(the for those unfamiliar "¦" is the "pipe" symbol. It is usualy depicted on the keyboard as two vertical lines one above the other)

The output of this command will show the date and time of last startup of windows. (The rest is mostly irrelevant info unless troubleshooting connections to servers)


Linux:

Did you ever have a file with a weird name including control characters which you could not delete? (ab^Hrd[ or something like that) (It could happen when naming a file you do a backspace which is sometimes input as ^H) You can’t do rm ab^Hrd[ because the shell will read part of the name as a control character.

One way to do it is to use the files inode number.

ls –il will show you the inode number of the files in the directory so you find what the inode number of that file is.

then you just type
find . -inum <inode-number>-exec rm -i {} \;
(Of course, replace <inode-number> with the actual inode number)
You will be asked to confirm the deletion and voila. File deleted.