Guide to Unix/Commands/File Analysing

< Guide to Unix < Commands

file

file displays the file type. To get the mimetype, use the -i option.

Examples

$ file Unix.txt
Unix.txt: ASCII text
$ file -i Unix.txt
Unix.txt: text/plain; charset=us-ascii

Links:

wc

wc tells you the number of lines, words and characters in a file.

Examples:

$ wc hello.txt
2       6      29 hello.txt
$ wc -l hello.txt
2 hello.txt
$ wc -w hello.txt
6 hello.txt
$ wc -c hello.txt
29 hello.txt

Links:

cksum

cksum gives you the CRC checksum of some files.

Checksums can be used to protect against accidental modifications to files: if the checksum has not changed, then the file is probably undamaged. The default CRC checksum is not cryptographic.

Cryptographic checksums are those checksums which protect against both accidental modifications and malicious modifications. Use these to verify that there is no trojan inserted into your file. The "md5" algorithm is beginning to show weaknesses against attacks, so "sha1" is preferred.

Examples:

$ cksum /etc/passwd
3052342160 2119 /etc/passwd

Some "cksum" implementations provide other algorithms, such as "md5" and "sha1":

$ cksum -a sha1 /etc/passwd
SHA1 (/etc/passwd) = 816d937ca4cdb4dee92d5002610fae63b639d224

Some "cksum" implementations let you take checksums of strings specified as arguments:

$ cksum -s 'Guide to UNIX'
2195826759 13 Guide to UNIX
$ cksum -a sha1 -s 'Guide to UNIX'
SHA1 ("Guide to UNIX") = 0e9c1779e61c7fdb473d2e55eb878a82c37eecea

Links:

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.