netstat、net user、net use、net view、net share、net start、net account


Formatting legend

Format

Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

 

Netstat

Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Used without parameters, netstat displays active TCP connections.

Syntax

netstat [-a] [-e] [-n] [-o] [-p Protocol] [-r] [-s] [Interval]

Parameters

-a   Displays all active TCP connections and the TCP and UDP ports on which the computer is listening.

-e   Displays Ethernet statistics, such as the number of bytes and packets sent and received. This parameter can be combined with -s.

-n   Displays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names.

-o   Displays active TCP connections and includes the process ID (PID) for each connection. You can find the application based on the PID on the Processes tab in Windows Task Manager. This parameter can be combined with -a-n, and -p.

-p   Protocol   Shows connections for the protocol specified by Protocol. In this case, the Protocol can be tcpudptcpv6, or udpv6. If this parameter is used with -s to display statistics by protocol, Protocol can be tcpudpicmpiptcpv6udpv6icmpv6, or ipv6.

-s   Displays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. If the IPv6 protocol for Windows XP is installed, statistics are shown for the TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols. The -p parameter can be used to specify a set of protocols.

-r   Displays the contents of the IP routing table. This is equivalent to the route print command.

Interval   Redisplays the selected information every Interval seconds. Press CTRL+C to stop the redisplay. If this parameter is omitted, netstat prints the selected information only once.

/?   Displays help at the command prompt.

Remarks

  • Parameters used with this command must be prefixed with a hyphen (-) rather than a slash (/).

  • Netstat provides statistics for the following:

    • Proto

      The name of the protocol (TCP or UDP).

    • Local Address

      The IP address of the local computer and the port number being used. The name of the local computer that corresponds to the IP address and the name of the port is shown unless the -n parameter is specified. If the port is not yet established, the port number is shown as an asterisk (*).

    • Foreign Address

      The IP address and port number of the remote computer to which the socket is connected. The names that corresponds to the IP address and the port are shown unless the -n parameter is specified. If the port is not yet established, the port number is shown as an asterisk (*).

    • (state)

      Indicates the state of a TCP connection. The possible states are as follows:

      CLOSE_WAIT

      CLOSED

      ESTABLISHED

      FIN_WAIT_1

      FIN_WAIT_2

      LAST_ACK

      LISTEN

      SYN_RECEIVED

      SYN_SEND

      TIMED_WAIT

      For more information about the states of a TCP connection, see RFC 793.

  • This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections

Examples

To display both the Ethernet statistics and the statistics for all protocols, type the following command:

netstat -e -s

To display the statistics for only the TCP and UDP protocols, type the following command:

netstat -s -p tcp udp

To display active TCP connections and the process IDs every 5 seconds, type the following command:

nbtstat -o 5

To display active TCP connections and the process IDs using numerical form, type the following command:

nbtstat -n -o

 

 

Net user

Adds or modifies user accounts or displays user account information.

Syntax

net user [UserName [Password | *] [options]] [/domain]

net user [UserName {Password | */add [options] [/domain]]

net user [UserName [/delete] [/domain]]

Parameters

UserName   Specifies the name of the user account to add, delete, modify, or view. The name of the user account can have as many as 20 characters.

Password   Assigns or changes a password for the user's account. Type an asterisk (*) to produce a prompt for the password. The password is not displayed when you type it at the password prompt.

/domain   Performs the operation on the domain controller in the computer's primary domain.

options   Specifies a command-line option. The following table lists valid command-line options that you can use.

Command-line option syntax

Description

/active:{no | yes}

Enables or disables the user account. If the user account is not active, the user cannot access resources on the computer. The default is yes (that is, active).

/comment:" text "

Provides a descriptive comment about the user's account. This comment can have as many as 48 characters. Enclose the text in quotation marks.

/countrycode: nnn

Uses the operating system Country/Region codes to implement the specified language files for a user's Help and error messages. A value of 0 signifies the default Country/Region code.

/expires:{{mm/dd/yyyy |dd/mm/yyyy | mmm,dd ,yyyy} |never}

Causes the user account to expire if you specify date. Expiration dates can be in [mm/dd/yyyy], [dd/mm/yyyy], or [mmm,dd ,yyyy] format, depending on the Country/Region code. Note that the account expires at the beginning of the specified date. For the month value, you can use numbers, spell it out, or use a three-letter abbreviation (that is, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec). You can use two or four numbers for the year value. Use commas or slashes to separate parts of the date. Do not use spaces. If you omit yyyy, the next occurrence of the date (that is, according to your computer's date and time) is assumed. For example, the following entries are equivalent if entered between Jan. 10, 1994, and Jan. 8, 1995:

jan,9 
1/9/95 
january,9,1995 
1/9

/fullname:" name "

Specifies a user's full name rather than a user name. Enclose the name in quotation marks.

/homedir: Path

Sets the path for the user's home directory. The path must exist.

/passwordchg:{yes | no}

Specifies whether users can change their own password. The default is yes.

/passwordreq:{yes no}

Specifies whether a user account must have a password. The default is yes.

/profilepath:[Path]

Sets a path for the user's logon profile. This path points to a registry profile.

/scriptpath: Path

Sets a path for the user's logon script. Path cannot be an absolute path. Path is relative to %systemroot%\System32\Repl\Import\Scripts.

/times:{day[-day][,day[-day]],time[-time][,time[-time]] [;] | all}

Specifies the times that users are allowed to use the computer. Time is limited to 1-hour increments. For the day values, you can spell out or use abbreviations (that is, M,T,W,Th,F,Sa,Su). You can use 12-hour or 24-hour notation for hours. If you use 12-hour notation, use AM and PM, or A.M. and P.M. The value all means a user can always log on. A null value (blank) means a user can never log on. Separate day and time with commas, and units of day and time with semicolons (for example, M,4AM-5PM;T,1PM-3PM). Do not use spaces when designating times.

/usercomment:" text "

Specifies that an administrator can add or change the "User comment" for the account. Enclose the text in quotation marks.

/workstations:{ComputerName[,...] | *}

Lists as many as eight workstations from which a user can log on to the network. Separate multiple entries in the list with commas. If /workstationshas no list or if the list is an asterisk (*), users can log on from any computer.

net help   command   Displays help for the specified net command.

Remarks

  • Used without parameters, net user displays a list of the user accounts on the computer. You can also type net users.

  • A password must satisfy the minimum length set with net accounts /minpwlen. It can have as many as 127 characters. However, if you are using Windows 2000 or Windows XP on a network that also has computers using Windows 95 or Windows 98, consider using passwords not longer than 14 characters. Windows 95 and Windows 98 support passwords of up to 14 characters. If your password is longer, you might not be able to log on to your network from those computers.

Examples

To display a list of all user accounts for the local computer, type:

net user 

To view information about the user account jimmyh, type:

net user jimmyh 

To add a user account for Jay Jamison, with logon rights from 8 A.M. to 5 P.M., Monday through Friday (no spaces in time designations), a mandatory password (jayj), and the user's full name, type:

net user jayj /add /passwordreq:yes /times:monday-friday,8am-5pm/fullname:"Jay Jamison"

To set johnsw's logon time (8 A.M. to 5 P.M.) using 24-hour notation, type:

net user johnsw /time:M-F,08:00-17:00 

To set johnsw's logon time (8 A.M. to 5 P.M.) using 12-hour notation, type:

net user johnsw /time:M-F,8am-5pm 

To specify logon hours of 4 A.M. until 5 P.M. on Monday, 1 P.M. until 3 P.M. on Tuesday, and 8 A.M. until 5 P.M. Wednesday through Friday for marysl, type:

net user marysl /time:M,4am-5pm;T,1pm-3pm;W-F,8:00-17:00 

 
 
 
 

Net share

Manages shared resources. Used without parameters, net share displays information about all of the resources that are shared on the local computer.

Syntax

net share [ShareNamenet share [ShareName=Drive:Path [{/users:number|/unlimited}] [/remark:"text"] [/cache: {manual|automatic|no}]] net share [ShareName[{/users:number|unlimited}] [/remark:"text"] [/cache: {manual|automatic|no}]] net share [{ShareName|Drive:Path/delete]

Parameters

ShareName   Specifies the network name of the shared resource. Type net share with a ShareName to display information about that share only.

Drive : Path   Specifies the absolute path of the directory to be shared.

/users: number   Sets the maximum number of users who can simultaneously access the shared resource.

/unlimited   Specifies an unlimited number of users who can simultaneously access the shared resource.

/remark: " text "   Adds a descriptive comment about the resource. Enclose the text in quotation marks.

/cache:automatic   Enables offline client caching with automatic reintegration.

/cache:manual   Enables offline client caching with manual reintegration.

/cache:no   Advises the client that offline caching is inappropriate.

/delete   Stops sharing the shared resource.

net help   command   Displays Help for the specified net command.

Remarks

  • To share a directory with a path that contains a white space, enclose the drive and the path of the directory in quotation marks (for example, "C:\Path Name").

  • When you display all of the shared resources on a computer, the share name of the resource, the device names or path associated with the resource, and a descriptive comment about the resource is displayed. The output is similar to the following:

    Sharename  Resource                     Remark
    ------------------------------------------------------
    ADMIN$     C:\WINNT                     Remote Admin
    C$         C:\                          Default Share for Internal Use
    print$     C:\WINNT\SYSTEM\SPOOL        
    IPC$                                    Remote IPC
    LASER      LPT1               Spooled   Laser printer
  • As you create shares on a server, they are saved. When you stop the Server service, all shares are disconnected, but they are reconnected automatically the next time the Server service is started or the computer is restarted. For more information about services, see Services  

  • Shared resource names that end in a $ character are not displayed when you are browsing the local computer from a remote computer.

Examples

To display information about shared resources on the computer, type:

net share

   

 

 

加$的是隱藏共享,以windows平台系統去查看列表時候,默認是不顯示的(其他平台或軟件是可以顯示的),但可以直接輸入地址來訪問。
另外,Windows為遠程管理設置的管理共享也是這樣設置的,一般形如Admin$,c$,d$這樣,你在c盤共享屬性那或共享管理(fsmgmt.msc)那可以看得到的。

To share a computer's C:\Data directory with the share name DataShare and include a remark, type:

net share DataShare=c:\Data /remark:"For department 123."

To stop sharing the DataShare folder you created in the previous example, type:

net share DataShare /delete

To share a computer's C:\Art Lst directory with the share name List, type:

net share list="c:\art lst"

 

 

 

Net use

Connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections. The command also controls persistent net connections. Used without parameters, net use retrieves a list of network connections.

Syntax

net use [{DeviceName | *}] [\\ComputerName\ShareName[\volume]] [{Password | *}]] [/user:[DomainName\]UserName] [/user:[DottedDomainName\]UserName] [/user:[UserName@DottedDomainName] [/savecred] [/smartcard] [{/delete | /persistent:{yes | no}}]

net use [DeviceName [/home[{Password | *}] [/delete:{yes | no}]]

net use [/persistent:{yes | no}]

Parameters

DeviceName   Assigns a name to connect to the resource or specifies the device to be disconnected. There are two kinds of device names: disk drives (that is, D: through Z:) and printers (that is, LPT1: through LPT3:). Type an asterisk (*) instead of a specific device name to assign the next available device name.

\\ ComputerName \ ShareName   Specifies the name of the server and the shared resource. If ComputerName contains spaces, use quotation marks around the entire computer name from the double backslash (\\) to the end of the computer name (for example, "\\Computer Name\Share Name"). The computer name can be from 1 to 15 characters long.

\ volume   Specifies a NetWare volume on the server. You must have Client Service for NetWare installed and running to connect to NetWare servers.

Password   Specifies the password needed to access the shared resource. Type an asterisk (*) to produce a prompt for the password. The password is not displayed when you type it at the password prompt.

/user   Specifies a different user name with which the connection is made.

DomainName   Specifies another domain. If you omit DomainNamenet use uses the current logged on domain.

UserName   Specifies the user name with which to log on.

DottedDomainName   Specifies the fully-qualified domain name for the domain where the user account exists.

/savecred   Stores the provided credentials for reuse.

/smartcard   Specifies the network connection is to use the credentials on a smart card. If multiple smart cards are available, you are asked to specify the credential.

/delete   Cancels the specified network connection. If you specify the connection with an asterisk (*), all network connections are canceled.

/persistent: { yes no Controls the use of persistent network connections. The default is the setting used last. Deviceless connections are not persistent. Yes saves all connections as they are made, and restores them at next logon. No does not save the connection being made or subsequent connections. Existing connections are restored at the next logon. Use /deleteto remove persistent connections.

/home   Connects a user to the home directory.

net help   command   Displays help for the specified net command.

Remarks

  • Connecting and disconnecting from a network resource

    Use net use to connect to and disconnect from a network resource, and to view your current connections to network resources. You cannot disconnect from a shared directory if you use it as your current drive or an active process is using it.

  • Viewing connection information

    To view information about a connection, you can do either of the following:

    • Type net use DeviceName to get information about a specific connection.

    • Type net use to get a list of all the computer's connections.

  • Using deviceless connections

    Deviceless connections are not persistent.

  • Connecting to NetWare servers

    After you install and run Client Service for NetWare, you can connect to a NetWare server on a Novell network. Use the same syntax that you use to connect to a Windows Networking server, except you must include the volume you to which you want to connect.

  • Using quotation marks

    If the ServerName that you supply contains spaces, use quotation marks around the text (that is, "Server Name"). If you omit quotation marks, an error message appears.

Examples

To assign the disk-drive device name E: to the Letters shared directory on the \\Financial server, type:

net use e: \\financial\letters 

To assign (map) the disk-drive device name M: to the directory Mike within the Letters volume on the \\Financial NetWare server, type:

net use m: \\financial\letters\mike 

To connect the user identifier Dan as if the connection were made from the Accounts domain, type:

net use d:\\server\share /user:Accounts\Dan 

To disconnect from the \\Financial\Public directory, type:

net use f: \\financial\public /delete 

To connect to the resource memos shared on the \\Financial 2 server, type:

net use k: "\\financial 2" \memos 

To restore the current connections at each logon, regardless of future changes, type:

net use /persistent:yes 

 

 

 

  

 

另一個示例:

 

 

 

 

Net start

Starts a service. Used without parameters, net start displays a list of services that are currently operating.

Syntax

net start [service]

Parameters

service   Starts the specified service. The following table lists values for service.

Value

Description

Remarks

alerter

Starts the Alerter service.

  • Start the Alerter service to send alert messages to specified users that are connected to the server. Alert messages warn users about security, access, and user session problems.

  • Use Server Manager (that is, systemroot\System32\Srvmgr.exe) to specify the administrators who you want to receive administrative alerts. Server Manager is available on Windows Server 2000 computers only.

  • Alert messages are sent as messages from the server to a user's computer. The Messenger service must be running on the user's computer for the user to receive alert messages.

browser

Starts the Computer Browser service.

  • The Computer Browser service maintains an up-to-date list of computers on your network and supplies the list to programs that request it.

"client service for netware"

Starts the Client Service for NetWare service.

  • This command is available only if you have installed Client Service for NetWare.

clipbook

Starts the ClipBook service.

  • ClipBook permits you to cut and paste text and graphics over the network.

  • The ClipBook service supports ClipBook Viewer, which allows pages to be seen by remote ClipBooks.

dhcp client

Starts the DHCP Client service.

  • This command is available only if you have installed the TCP/IP protocol.

  • The DHCP Client service manages network configuration by registering and updating IP addresses and DNS names. The DHCP Client service supports obtaining an IP address from the DHCP service.

  • You cannot stop or pause the DHCP Client service.

eventlog

Starts the Event Log service.

  • The Event Log service logs event messages issued by programs and Windows XP. Event Log reports contain information that can be useful in diagnosing problems. Reports are viewed in Event Viewer. The Event Log service must be started prior to using Event Viewer to view the logged events.

  • You cannot stop or pause the Event Log service.

file replication

Starts the File Replication service.

 

messenger

Starts the Messenger service.

  • The Messenger service enables a computer to receive messages.

  • A message is sent to a computer using the names assigned to the computer as identification.

netlogon

Starts the Net Logon service.

  • The Net Logon service verifies logon requests and controls domain-wide replication of the user accounts database.

  • Start the Net Logon service on all the servers in a domain that use a copy of the domain's user accounts database.

"nt lm security support provider"

Starts the NT LM Security Support Provider service.

  • This command is available only if you have installed the NT LM Security Support Provider.

"plug and play"

Starts the Plug and Play service.

 

"remote access connection manager"

Starts the Remote Access Connection Manager service.

  • This command is available only if you have installed the Remote Access Service.

"routing and remote access"

Starts the Routing and Remote Access service.

 

rpclocator

Starts the Remote Procedure Call (RPC) Locator service.

  • Allows distributed applications to use the Microsoft RPC name service.

  • The Remote Procedure Call (RPC) Locator service is the RPC name service for Microsoft Windows XP. The RPC Locator manages the RPC name service database.

  • The server side of the distributed application registers its availability with the RPC Locator service. The client side of the distributed application queries the RPC Locator service to find available compatible server applications.

rpcss

Starts the Remote Procedure Call (RPC) service.

  • The Remote Procedure Call (RPC) service is the RPC subsystem for Windows XP. The RPC subsystem includes the endpoint mapper and other miscellaneous RPC services. Net start rpcss starts the Remote Procedure Call (RPC) service to allow distributed applications to use dynamic endpoints. The Remote Procedure Call (RPC) service manages the endpoint map database.

    The server side of the distributed application registers its endpoints with the Remote Procedure Call (RPC) service. The client run-time library, on behalf of the client side of the distributed application, queries the Remote Procedure Call (RPC) service to obtain the endpoint information. To determine whether a distributed application uses the endpoint mapper service, see the documentation for that distributed application.

schedule

Starts the Task Scheduler service.

  • With Task Scheduler, you can start programs at a specified time with the at command. You might need to have other services running before you can run scheduled commands.

  • Task Scheduler is initially configured to run in the System account on the local computer. When Task Scheduler runs using this account, there are no restrictions on the jobs that you can run with Task Scheduler. However, these jobs have limited network access because the System account on a local computer is not recognized by other computers.

  • To overcome network access limitations, you can configure Task Scheduler to run in a user's account. If you do this, jobs executed by Task Schedule are governed by the user account's network access. However, because Task Scheduler is not using the local System account in this case, you can only run jobs that do not require the presence of a window.

server

Starts the Server service.

  • You can use the Server service to share server resources with users on the network.

spooler

Starts the Print Spooler service.

  • The Print Spooler service loads files to memory for printing.

"tcp/ip netbios helper"

Starts the NetBIOS helper over TCP service, which enables NetBIOS over TCP/IP (NetBT) services.

  • NetBT services provide NetBIOS data grams, NetBIOS sessions, and NetBIOS name management (such as name registration and resolution) for NetBIOS applications that are using the TCP/IP protocol.

  • This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections

ups

Starts the Uninterruptible Power Supply service.

  • The Uninterruptible Power Supply service manages an uninterruptible power supply (UPS) connected to the computer.

  • You can configure the Uninterruptible Power Supply service by using Power Options in Control Panel. If you configure the Uninterruptible Power Supply service to execute a command file upon shutdown the command file must finish running in 30 seconds. A run time that is greater than 30 seconds threatens the capability of Windows XP to complete a graceful system shutdown.

workstation

Starts the Workstation service.

  • The Workstation service enables a computer to connect to and use network resources.

net help   command   Displays help for the specified net command.

 

 

 

Net accounts

Updates the user accounts database and modifies password and logon requirements for all accounts.

Syntax

net accounts [/forcelogoff:{minutes | no}] [/minpwlen:length] [/maxpwage:{days unlimited}] [/minpwage:days] [/uniquepw:number] [/domain]

Parameters

/forcelogoff: { minutes no Sets the number of minutes to wait before ending a user's session with a server when the user account or valid logon time expires. The default value, no, prevents users from being forced to log off.

/minpwlen: length   Sets the minimum number of characters for a user account password. The range is from 0 through 127 characters and the default is six characters.

/maxpwage: { days unlimited Sets the maximum number of days that a user account's password is valid. The unlimited value sets no maximum time. The /maxpwage command-line option must be greater than /minpwage. The range is from 1 through 49,710 days (that is, unlimited equals 49,710 days), and the default value is 90 days.

/minpwage: days   Sets the minimum number of days before a user can change a new password. The default value is zero days, which sets no minimum time. The range is from 0 through 49,710 days.

/uniquepw: number   Requires a user to not repeat the same password for the specified number of password changes. The range is from 0 through 24 password changes, and the default is five password changes.

/domain   Performs the operation on the primary domain controller of the current domain. Otherwise, the operation is performed on the local computer.

net help   command   Displays help for the specified net command.

Remarks

  • The Net Logon service must be running on the computer where you want to change account parameters. Used without parameters, net accounts displays the current settings for password, logon limitations, and domain information.

  • You must do the following before you can use net accounts:

    • Create user accounts. Use User Manager or net user to set up user accounts.

    • Run the Net Logon service on all servers that verify logon in the domain. Net Logon starts automatically at startup.

  • When you use /forcelogoff:minutes, a warning is sent minutes before users are forced to log off from the network. Users are also notified if any files are open. If minutes is less than two, users are warned to log off from the network immediately.

Examples

To display the current settings, the password requirements, and the server role for a server, type:

net accounts

To set a minimum of seven characters for user account passwords, type:

net accounts /minpwlen:7

To specify that users can reuse a password only after the fifth time they change passwords, type:

net accounts /uniquepw:5

To prevent users from changing passwords more often than every seven days, force users to change passwords every 30 days, and force users to log off after the logon time expires with a five-minute warning, type:

net accounts /minpwage:7 /maxpwage:30 /forcelogoff:5

To ensure that the preceding settings take effect for the domain that the computer is logged on to, type:

net accounts /minpwage:7 /maxpwage:30 /domain

 

 

 

 

Net view

Displays a list of domains, computers, or resources that are being shared by the specified computer. Used without parameters, net view displays a list of computers in your current domain.

Syntax

net view [\\ComputerName] [/domain[:DomainName]]

net view /network:nw [\\ComputerName]

Parameters

\\ ComputerName   Specifies the computer that contains the shared resources that you want to view.

/domain [ : DomainName Specifies the domain for which you want to view the available computers. If you omit DomainName/domain displays all of the domains in the network.

/network:nw   Displays all available servers on a NetWare network. If you specify a computer name, /network:nw displays the resources available on that computer in the NetWare network. You can also specify other networks that are added to the system.

net help   command   Displays help for the specified net command.

Remarks

  • Use the net view command to display a list of computers. The output is similar to the following:

    Server Name           Remark
    -------------------------------------------------
    \\Production          Production file server
    \\Print1              Printer room, first floor
    \\Print2              Printer room, second floor

Examples

To see a list of the resources shared by the \\Production computer, type:

net view \\production

To see the resources available on the NetWare server \\Marketing, type:

net view /network:nw \\marketing

To see a list of the computers in the sales domain or workgroup, type:

net view /domain:sales

To see all the servers in a NetWare network, type:

net view /network:nw

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM