Cover V06, I07
Article

jul97.tar


UNIXisms in NT

Marian Myerson

The first step in administering a new and unfamiliar system is to find elements of the new system that are similar to the system you know well. Thinking of common administrative tasks in terms of a higher level of abstraction will then allow you to work effectively on the new system while you learn its intricacies. The following is a partial list of commands common to both UNIX and NT, showing the general syntax of usage along with a bit of explanation. NT commands are shown in blue, while similar UNIX commands are in green.

cd pathname
md pathname
rd pathname
cd pathname
md pathname
rd pathname
pwd

In Windows NT and UNIX, the cd, md, and rd commands allow you to change working (current) directory, make a new directory, and remove the directory. These are abbreviations for chdir, mkdir, and rmdir. The pwd command prints (on the screen by default) working directory. On NT, cd without an argument does the same task.

copy [/A | /B] source [/A | /B] [+ source [/A | /B]{+ ...] [destination [/A | /B] [/V] [/Y | /-Y]
cp -i {BSD}

You can copy an old file to a new one. This is also true of cp. With copy, you have the option of indicating an ACSII file with /A and a binary file with /B. The /V option allows you to verify that new files are written correctly. Unlike copy, which uses /Y and /-Y to cause and suppress prompting of the user to write over an existing destination file, cp uses one option, -i, to ask the user whether to overwrite the existing target file.

rename [directoryname1 | filename1] [directlyname2 | filename2]
mv -i {BSD} [filename1 filename2| filename(s) directory name]

You can use rename and mv to rename a file. Unlike rename, which renames a directory, you use mv to move file(s) from one directory to another. Like cp, mv may have an -i option. If mv has an -f option, it functions like cp.

finger [-l][user]@host[...]
finger [-b ] [ -f ] [ -h ] [ -I ] [ -m ] [ -p ] [ -q ] [ -s ] [ -w ][user]@host[...]

You can finger point to information on one or more users in networked environments. Available in both UNIX and NT systems, the -l parameter stands for long list format. The -I, -q, and -s options are UNIX shorthands for idle, quick, and short formats. The -h and -p options omit the display of .plan and .project files on user information.

The -s parameter can be used with the -w parameter to hide the user's full name, and the -b parameter can be used to shield the user's home directory and shell from display. The nice feature about the -m option is that users must match usernames exactly instead of searching for a "guess" match of first or last names. In NT, a typo error may return an unwanted list of usernames.

date
time
date[-u][+format]
date [-a  | -u][string]
In NT, the date and time commands behave like their MSDOS counterparts. They have no optional display formats. Typing date and time without options displays the current date and time and prompts for new ones. In contrast, a UNIX user can use the first date form with the -u option to print the current time and date among 30 date formats. In the second form, a privileged user can set the current date by using either the -a or -u option and supplying a numeric string of time, day, and year. To set the date to March 5 (0305), 9 p.m. (2100), 1997 (97), type in:

date 0301210097

To format a date with greetings, use the command:

date +"Good Morning%t Date is %D %n%t Time is %T"

You will get:

Good Morning             Date is 011/12/97
Time is 15:43:39

who [-a ] [ -b ] [ -d ] [ -H ] [ - l ] [ -nx ] [ - p ] \
[ -q ] [ -r ] [ -s ] [ -t ] [ -T ] [ -u ] [ am I ] [file]

This command is unique to UNIX. It has no NT counterpart. who is usually invoked without options. The -a option uses all options. am I and -u, the most useful options, print the name of the invoking user and report how long terminal usage has been idled. Seven other options have reporting functions:

-b information on the last reboot

-d processes that have expired

-l inactive terminal lines

-p processes that were previously spawned

-r run level

-t last change of the system clock

-T whether terminals are writeable

Of possible interest to users are the two other options, -H and -s. They print headings and list the name, line, and name fields, respectively.

mail [-e ] [ -f file ] [ -F names ] [ -h ] [ -p ] [ -P ] \
  [ -q ] [ -r] [ -m type ] [ -t] [ -w ][ users]

The -h option is more practical in displaying a window of messages than the latest message. You can read your mail without the users option in your mailbox file. If you want to read mail from a different mailbox file, use the -f file option. Be careful not to type in the -F option. You may accidentally forward your mail to recipient names that are identical to names of the files. The mail command gives you three options of printing: You can use the -p option to print all messages without pausing. Do not confuse this with the -P option, which may print messages with header lines you do not want. If you want to print the oldest messages first, use the -r option.

In sending mail, you can use the -t option to print a "To:" line to show the names of the recipients. You really do not know how long a remote transfer program would take when you send mail to remote users. If you are in a hurry, you do not have to wait for the transfer program to complete. You can use the -w option to force mail to be sent to remote users.

sort [/R] [+n] < [drive1:][path1]filename1 \
  [> [drive2:][path2] filename2]
[command | ] sort [/R] [/+n] [> [drive2:] [path2] filename2}
sort [-b ] [ -c ] [ -d ] [ -f ] [ -i ] [ -m ] [ -M ] \
  [ -n ] [ -o file ] [ -r ] [ -tc ] [ -u ]
    [ -y kmem ] [ -z recz ][ +n [-m] ] [files]

Both NT and UNIX allow the reverse of sort order on a specified field. In NT, the < filter directs the sorting of an input file. The > filter directs the sorted input to a file. In UNIX, files to be sorted are specified after the options. The -o file option directs the input to an output file. Obviously, the UNIX sort command does more. You can sort in dictionary order [/d] or in arithmetic order [/n].

For a large list, you can use the -b option to ignore leading spaces and tabs, the -i option to ignore nonprinting characters, and the -f option to forget about uppercase/lowercase differences. If you are unsure whether you have previously sorted a file, you can check with the -c option. Numerous duplicate lines in the list can be a headache. You can get some relief with the -u option to make the lines to appear as unique. Input files are easily sorted with the -m option. The -y kmem option lets you makes changes in the amount of memory the sort command needs. If you encounter abnormal termination, try the -z recsz option. This option will provide you with the maximum number of bytes for any one line in the file.

rcp [ -a | -b ] [ -h ] [ -r ] [host][.user:] \
  source [host] [.user:] path\destination
rcp [-p | -r] sources target

In both NT and UNIX, files are copied between machines. In UNIX, the -p option preserves copies of the modification times, access times, and modes of the source files. With the -r option, the command copies each subtree rooted at source. This option works when both target and sources are directories. Similarly, in NT, the -r option copies the contents of all subdirectories into a destination directory. The NT command provides two transfer mode options: ASCII [ -a] and binary [ -b] You need the -h option to transfer hidden files.

ping [-t ][ -a ][ -n count ][ -l size ][ -f ][ -i TTL ] \
  [ -v TOS ][ -r count ][ -s count ] [-j host-list] | \
  [ -k host-list ] ] [ -w timeout ] destination-list
ping [-c count] [ -d] [ -f] [ -i wait ] [ l preload ] \
  [ - n] [ -p pattern] [ -q ] [-R ] [ -r ] \
  [ -s packetsize ] [ -v ] host

This is a TCP/IP command to indicate whether a remote host can be reached. It is intended for use in network testing, measurement, and management. You should test the network during off hours. The use of ping may impose heavy load on the network. The NT ping command focuses more on testing the route among the intermediate hosts before it reaches the final destination host. In UNIX, ping has more options on the sending of packets and bypassing of normal routing tables for testing purposes. Here are some of the differences and similarities between the two ping commands.

In NT, the -n count option specifies the number of echo requests to send. In UNIX, the -c count option does more than that; it counts how many times the requests should be sent and received. The -d option turns on a debug option. A similar option is unavailable for the NT command. In NT, the -w timeout option sets timeout to wait for each reply. In UNIX, the -i count option performs the same function. Unique to the UNIX command is the -l preload option, which sends preload number of packets as fast as possible before falling into a normal mode of operation. The usefulness of the -n option to produce numeric output is questionable. Numbers are harder to understand than symbolic names for host addresses. The -p pattern and -s packetsize options are similar. The difference is that the first option specifies up to 16 pad bytes to fill out the packet to be sent. The second option specifies the number of data bytes to be sent.

In NT, the -i size merely sets the buffer size. If you do not like the clutter of information after invoking the UNIX command, you can use the -q option to "quiet" the output. You will only see the summary at startup time and when finished. If you wish information on routes the UNIX command has taken, use the -R option. It will store the route of the packet inside the IP header. Otherwise, use the -r option to bypass the normal routing tables. In NT, the -j and -k options, respectively, require a list of hosts to trace "loose" and "strict" source routes. Unique to the NT command are the -i TTL (Time to Live) and -v TOS (Type of Service) options.

About the Author

Marian Myerson holds an MSE degree in Computer and Information Sciences from an ivy league university. She has been working with computers and systems for many years and spent time working with Windows NT and UNIX. She can be reached at 71054.546@compuserve.com.