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:
- file, opengroup.org
- file man page, man.cat-v.org
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:
- wc, opengroup.org
- wc man page, man.cat-v.org
- 6.1 wc in GNU Coreutils manual, gnu.org
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:
- cksum, opengroup.org
- sum man page, man.cat-v.org
- cksum, freebsd.org
- 6.3 cksum in GNU Coreutils manual, gnu.org
grep
Outputs lines matching a regular expression, not matching it, and similar, depending on options and the regular expression used. See Grep Wikibook.
Links:
- grep, opengroup.org
- grep man page, man.cat-v.org
- grep, freebsd.org
- GNU Grep 3.0, gnu.org
diff
Compares file content of two files line by line and outputs differences. See also diff3.
Links:
- diff, opengroup.org
- diff man page, man.cat-v.org
- diff, freebsd.org
- Comparing and Merging Files, gnu.org
diff3
Compares file content of three files line by line and outputs differences. See also diff.
Links:
- diff3 man page, man.cat-v.org
- diff3, freebsd.org
- Comparing and Merging Files, gnu.org
cmp
Compares files byte by byte, outputting the byte number and the line number where a first difference is found, if any. Outputs nothing if the files are binary identical. No indication is made of the further differences beyond the first one unless option -l is used.
Links:
- cmp, opengroup.org
- cmp man page, man.cat-v.org
- cmp, freebsd.org
- Invoking cmp in Comparing and Merging Files, gnu.org
strings
Outputs printable strings found in files, useful when these files are binary.
Links:
- strings, opengroup.org
- strings, freebsd.org
- strings in GNU Binary Utilities, sourceware.org
- W:strings (Unix)