newbie: misc commands 2 - file, hostname, domainname
date: 9.10.99

As before, a few more commands found on unix systems. While not related, each 
will come in use at some time or another.

command: file Yes, it's a command. These days, there are hundres of different types of files. often when you run across one you don't know exactly what it is because of a short name, permission, or no man pages. If you try to view the file with cat or more and the file turns out to be binary, we get a screen flooded with garbage. To avoid that, we can use 'file'. examples below will show you everything: First, lets list a few files and a directory we will use file on: forced ~$ ls -ald xmas.schedule kalendar-0.4k.tar.gz bin .profile i idents.c -rw------- 1 jericho users 427 Nov 2 06:03 .profile drwx------ 2 jericho users 1024 Nov 24 18:02 bin/ -rw------- 1 jericho root 243462 Nov 27 22:27 kalendar-0.4k.tar.gz -rw------- 1 jericho hide 293 Dec 3 01:27 xmas.schedule -rwx------ 1 jericho hide 4666 Nov 24 18:02 i* -rw------- 1 jericho root 754 Nov 24 17:56 idents.c forced ~$ Now, using file we see what type of file each is: forced ~$ file .profile .profile: ASCII text forced ~$ file xmas.schedule xmas.schedule: ASCII text forced ~$ file bin bin: directory forced ~$ file kalendar-0.4k.tar.gz kalendar-0.4k.tar.gz: gzip compressed data - deflate method , last modified: Fri Nov 27 04:15:30 1998 , max compression os: Unix forced ~$ file i i: ELF 32-bit LSB executable i386 (386 and up) Version 1, dynamically linked, not stripped forced ~$ file idents.c idents.c: C program text forced ~$ As we can see, it will happily identify what each file is. Newer versions of 'file' will even tell you if something is PGP binary, PGP ascii, and more.
Two simple utils that may come in handy if you bounce around a lot of machines frequently. If a machine doesn't have BASH installed, and you haven't set your prompt in another shell.. you might forget which machine or domain you are on. hostname & domainname flatland ~$ hostname flatland flatland ~$ domainname flatland ~$ Using this information, you can put it together to form your entire domain. The above would indicate: Some systems will not use 'domainname', but may have alternatives: /bin/dnsdomainname /bin/nisdomainname /bin/ypdomainname (c) copyright 1998, 1999 Brian Martin