UNIX Users Caught In The NeT

If you're a HP-UX or other UNIX user, it's fun to complain about Microsoft Windows.One of my pet peeves is how everything is done with a mouse. I hate mice.

But if you're willing, many tasks and data requests can be performed from the Windowscommand line -- just like you would do in UNIX. Take the Windows NT net command, forexample, which just happens to be the subject of this month's column.

As is typical with many commands, net is not the most accurate name. In this case, it'sbecause the command does so much more than just network-related issues. The syntax for thenet command is:

net command-word options

The power of this command becomes apparent when you realize that there are over 20command-words. The options allowed vary depending on the command word being used. There isnot much consistency in how the options are formatted. Most use a preceding backslash,some do not. A few take a preceding hyphen. You'll see some examples later.

MESSAGE-WHERE?

In UNIX, you can issue the write, writeall or talk commands to send a quick message toanother user. In NT you can use the send command-word of the net command. It takes atarget option and the message is a quoted string on the same command line. The targetoption could be a user name, a Domain name (where a message is sent to all logged-inmembers), or /users (messages sent to everyone connected to a server). If you specify * asthe target, the message is sent to all members of your own group. Here are examples:

net send lwall "When is version 6 shipping?"
net send [DEMO]eting in 10 minutes."
net send /users "Shutting down in 1 minute."

The message service must be running on the targeted computer for the dialog box toappear. The GUI equivalent of this is in the Server Manager menus.

On UNIX boxes, very few users are given the rights to shutdown a machine, even the oneon their own desk. In NT networks, that varies, because it's up to the administrators todecide if you can shutdown your machine. Before shutting down any computer, you shouldcheck to see if anyone is using resources from over the network. Checking for shared fileaccess on NT boxes can be done with the session command-word of net:

net session
net session \\fredspc
net session \\fredspc /delete

In the first line above, the command returns a list of computers that are using localresources, including the user name, and most important, how many files are open. That issimilar to the UNIX command showmount. If there are open files and this host is shutdown,you can cause data loss.

The second line shown will give you more specific information about sessions accessingthis computer from the computer name supplied (fredspc in these examples). The thirdexample is what might be used to forcibly disconnect a session. Remember that there areother ways that a system might be in use over the network.

TRACKING FILES

If you want to know what files are being used remotely, use the net file command --similar to the UNIX fuser command. With no options, net file provides a list of openfiles; an item number precedes each. You can then issue the command again with an itemnumber as an option to get more detailed information:

net file 3.

Occasionally the system loses track of which files are open. This typically happenswhen a client crashes while it has files shared from another computer. Once you'vedetermined that the file is not really in use, you can "fix" this with the netfile command's /close option:

net file 3 /close.

In the discussion above, we mentioned sending a message to all members of your group.On a UNIX box, sophisticated users know they can look at group information by issuing somegrep commands against passwd file data. On NT it's easier to find out who is a member of aparticular group. The net command-words of user, account, group, and localgroup give youaccess to a great deal of data. They also allow you to modify account, group and userinformation, but this all assumes you have sufficient permissions.

To display all groups in a domain, issue net group by itself. If you want to see whatusers are members of a group, for example, before sending a message to the entire group,supply the group name as an option. The command: net group design would list all membersof this domain's group named design. If you're using local accounts instead of domain-wideaccounts supplied by a Domain Controller, you can use the localgroup command-word tosimilar purposes.

If there is a name you expected but which did not appear in a list of group members,you'll find the netuser command helpful. It lists all usernames that exist on a system orin a domain. If you also specify a username as the final argument, you'll get accountinformation for that user.

WHO'S IN A NAME?

Considering that we began talking about sending messages, I'd better mention the namecommand-word of the net command. It provides a list of names that are valid for sendingmessages to. If you are a UNIX geek, think of it as a type of who command. This might bemore useful than the list of all usernames, because it provides currently available names.

This command can also be used to add names that are available for messaging. Addednames are aliases and are rather helpful if you must be logged in using a generic account.For example, if I was logged in as "dbmanager," I could issue net name frederm/add. Now people can send messages to me using my normal login name --"frederm"-- which is the one they might expect to find.

Most of us at some time or another have gotten cryptic error messages from commands.The net command is no different. If you ever issue a net command, and get a four digiterror code, use net helpmsg; and supply the error number as the last argument. For examplenet helpmsg 6118. What it returns is a much longer cryptic description of the error.

--Fred is currently creating a 12-step program for helping people dealwith learning NT.

Must Read Articles