Thursday, September 13, 2007

UNIX - determine file type

`file` - determine file type

USAGE:
file [ -h ] [ -m mfile ] [ -f ffile ] file ...

file [ -h ] [ -m mfile ] -f ffile

file -c [ -m mfile ]

DESCRIPTION:
The file utility performs a series of tests on each file supplied by file and, optionally, on each file listed in ffile in an attempt to classify it. If the file is not a regular file, its file type is identified. The file types directory, FIFO, block special, and character special are
identified as such. If the file is a regular file and the file is zero-length, it is identified as an empty file.

If file appears to be a text file, file examines the first 512 bytes and tries to determine its programming language. If file is an executable a.out, file prints the version stamp, provided it is greater than 0. If file is a symbolic link, by default the link is followed and file tests the file to which the symbolic link refers.

By default, file will try to use the localized magic file /usr/lib/locale/locale/LC_MESSAGES/magic, if it exists, to identify files that have a magic number. For example, in the Japanese locale, file will try to use /usr/lib/locale/ja/LC_MESSAGES/magic. If a localized magic file does not exist, file will utilize /etc/magic. A magic number is a numeric or string constant that indicates the
file type. See magic(4) for an explanation of the format of /etc/magic.

If file does not exist, cannot be read, or its file status could not be determined, it is not considered an error that affects the exit status. The output will indicate that the
file was processed, but that its type could not be deter mined.

OPTIONS:
The following options are supported:

-c Check the magic file for format errors. For reasons of
efficiency, this validation is normally not carried
out.
-h Do not follow symbolic links.
-f ffile

EXAMPLES:
[root@server root]# file *
3c2000.tar.gz: gzip compressed data, from Unix
DriverInstall: directory
fw_script.sh: Bourne shell script text executable
install.log: ASCII text
[root@serverroot]#

UNIX - change login password

`passwd` - change login password and password attributes.

Usage:
passwd [OPTION...]

OPTION:
-k, --keep-tokens keep non-expired authentication tokens
-d, --delete delete the password for the named account (root only)
-l, --lock lock the named account (root only)
-u, --unlock unlock the named account (root only)
-f, --force force operation

-x, --maximum=DAYS maximum password lifetime (root only)
-n, --minimum=DAYS minimum password lifetime (root only)
-w, --warning=DAYS number of days warning users receives before
password expiration (root only)
-i, --inactive=DAYS number of days after password expiration when an
account becomes disabled (root only)
-S, --status report password status on the named account (root
only)
--stdin read new tokens from stdin (root only)


EXAMPLE:

[root@server root]# passwd smith
Changing password for user smith.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

***