LSA 5: Describe Net Commands (Net.exe)¶
The Net commands are a set of command-line tools used in Windows to manage and configure network resources and services. They allow administrators to perform a wide range of networking tasks, such as managing user accounts, shared resources, network connections, and more. These commands are particularly useful for system administrators and cybersecurity professionals to manage networks, troubleshoot issues, and automate tasks via scripts.
Key Uses of Net.exe:¶
- User and Group Management
-
Net.exe
allows administrators to create, modify, or delete user accounts and manage group memberships. It simplifies tasks such as adding new users, setting passwords, or assigning users to specific groups. -
Service Management
-
The tool helps in managing network-related services by starting or stopping them, as well as configuring service settings. This is particularly useful for controlling background processes like file sharing or authentication services.
-
Network Connections
- Administrators can use
Net.exe
to establish or disconnect network connections to shared resources such as files, printers, and servers. It also provides detailed information on current network connections, helping to monitor and manage resource access.
Common Net.exe Commands¶
Here’s a breakdown of some essential commands available through Net.exe
and their functions:
1. net /?
¶
- Usage: Displays the help page for the
Net.exe
command, listing all available commands and their syntax. - Example:
net /?
This command will provide an overview of thenet
command options, including descriptions of available commands and their functions.
2. net user
¶
- Usage: Manages user accounts on the local machine or a domain. Administrators can add, delete, modify, or display user account information.
- Examples:
- Add a new user:
net user username password /add
Example:
net user JohnDoe P@ssw0rd /add
(Creates a new user "JohnDoe" with password "P@ssw0rd") - Delete a user:
net user username /delete
Example:
net user JohnDoe /delete
(Removes the user "JohnDoe") - Display all users:
net user
Example:
net user
(Lists all user accounts on the machine)
- Add a new user:
3. net group
¶
- Usage: Manages local groups and their members. Allows adding or removing users from groups and viewing group membership.
- Example:
- Add a user to a group:
net localgroup groupname username /add
Example:
net localgroup administrators JohnDoe /add
(Adds "JohnDoe" to the "Administrators" group) - Remove a user from a group:
net localgroup groupname username /delete
Example:
net localgroup administrators JohnDoe /delete
(Removes "JohnDoe" from the "Administrators" group)
- Add a user to a group:
4. net share
¶
- Usage: Manages shared network resources such as folders, printers, and devices. Displays shared resources or configures new shares.
- Examples:
- Create a shared folder:
net share sharename=path
Example:
net share Documents=C:\Users\JohnDoe\Documents
(Shares the "Documents" folder) - List all shared resources:
net share
Example:
net share
(Displays all shared resources on the local machine) - Remove a shared folder:
net share sharename /delete
Example:
net share Documents /delete
(Removes the shared "Documents" folder)
- Create a shared folder:
5. net start
/ net stop
¶
- Usage: Starts or stops services on the local machine. This is useful for managing background services like networking, file sharing, or system processes.
- Examples:
- Start a service:
net start servicename
Example:
net start spooler
(Starts the Print Spooler service) - Stop a service:
net stop servicename
Example:
net stop spooler
(Stops the Print Spooler service)
- Start a service:
6. net use
¶
- Usage: Connects to or disconnects from a shared resource on the network. It can also display information about currently mapped network drives and connections.
- Examples:
- Map a network drive:
net use Z: \\servername\sharename
Example:
net use Z: \\Server01\Documents
(Maps the shared folder "Documents" on "Server01" to the Z: drive) - Disconnect a network drive:
net use Z: /delete
Example:
net use Z: /delete
(Disconnects the Z: network drive) - Display all mapped network drives:
net use
Example:
net use
(Lists all currently mapped network drives and connections)
- Map a network drive:
7. net session
¶
- Usage: Displays information about the sessions that are currently open on the machine. This can be useful for monitoring active connections and troubleshooting network issues.
- Examples:
- View active sessions:
net session
Example:
net session
(Lists all active network sessions on the local machine)
- View active sessions:
8. net time
¶
- Usage: Synchronizes the system time with a network time server, ensuring that the machine's clock is accurate and synchronized with a trusted source.
- Examples:
- Synchronize time with a time server:
net time \\time.server /set
Example:
net time \\time.windows.com /set
(Synchronizes the local computer's time with "time.windows.com")
- Synchronize time with a time server:
9. net file
¶
- Usage: Manages open files on the network, including displaying a list of files currently being accessed and the ability to close them.
- Examples:
- View open files:
net file
Example:
net file
(Lists all open files on the local machine or server) - Close an open file:
net file fileID /close
Example:
net file 123 /close
(Closes the file with ID 123)
- View open files:
10. net share
¶
- Usage: Manages shared resources (like folders or printers) on a Windows system. You can use it to create, display, or manage shares, such as shared folders or drives, on the computer.
Syntax:¶
net share
— Displays all shared resources on the computer.net share [share_name]
— Displays information about a specific shared resource.net share [share_name]=[folder_path]
— Shares a folder on the network.net share [share_name] /delete
— Deletes a network share.
11. netstat
¶
- Usage: used for network diagnostics and troubleshooting. It provides information about active network connections, open ports, and listening services on the system. It's a useful tool for analyzing network traffic and detecting any unusual activity.
- Analyze network traffic for potential issues.
Syntax:¶
netstat
— Displays active connections, ports, and other network statistics.netstat -a
— Shows all active connections and listening ports.netstat -n
— Displays network addresses in numeric form (IP address and port number).netstat -o
— Displays active connections and the process ID (PID) using the connection.netstat -b
— Displays the executable involved in creating each connection or listening port.
Summary¶
Net commands (accessed via the net.exe utility) are a powerful set of command-line tools in Windows that enable administrators and users to manage and troubleshoot various network-related tasks. These commands are essential for network configuration, system management, and diagnostics in both local and networked environments. Net commands offer comprehensive tools for network administration, troubleshooting, and resource management, making them a vital part of the Windows operating system for both daily use and in specialized network security roles. Their ability to interact with both local systems and remote resources makes them invaluable for IT professionals in various scenarios.