net
The net
command is a versatile utility in Samba that provides a range of network and administrative operations. It allows you to manage various aspects of Samba, including domain operations, user and group management, and more. Below are the main uses and commands of net
.
General Usage
net [SUBCOMMAND] [OPTIONS]
Common Subcommands and Their Usage
Domain Management
Joining a Domain
net ads join -U administrator
This command joins a Samba server to an Active Directory domain.
Leaving a Domain
net ads leave -U administrator
This command removes a Samba server from an Active Directory domain.
Checking Domain Trust
net rpc trustdom list -U administrator
This command lists the trusted domains for the Samba server.
User and Group Management
Adding a User
net rpc user add username -U administrator
This command adds a new user to the Samba server.
Deleting a User
net rpc user delete username -U administrator
This command deletes a user from the Samba server.
Listing Users
net rpc user -U administrator
This command lists all users on the Samba server.
Adding a Group
net rpc group add groupname -U administrator
This command adds a new group to the Samba server.
Deleting a Group
net rpc group delete groupname -U administrator
This command deletes a group from the Samba server.
Listing Groups
net rpc group -U administrator
This command lists all groups on the Samba server.
Adding a User to a Group
net rpc group addmem groupname username -U administrator
This command adds a user to a specified group.
Removing a User from a Group
net rpc group delmem groupname username -U administrator
This command removes a user from a specified group.
Share Management
Creating a Share
net usershare add sharename path "Comment" everyone:F guest_ok=n
This command creates a new share on the Samba server.
Deleting a Share
net usershare delete sharename
This command deletes a share from the Samba server.
Listing Shares
net usershare list
This command lists all shares on the Samba server.
Print Management
Listing Printers
net rpc printer list -U administrator
This command lists all printers on the Samba server.
Adding a Printer
net rpc printer add printername -U administrator
This command adds a new printer to the Samba server.
Deleting a Printer
net rpc printer delete printername -U administrator
This command deletes a printer from the Samba server.
Password Management
Setting a User's Password
net rpc password username -U administrator
This command sets the password for a specified user.
Changing Own Password
net rpc password -U username
This command allows a user to change their own password.
Examples
Join a Samba Server to a Domain
net ads join -U administrator
Example output:
Enter administrator's password: Using short domain name -- EXAMPLE Joined 'SAMBA-SERVER' to dns domain 'example.com'
List All Users
net rpc user -U administrator
Example output:
Enter administrator's password: User accounts for \\SAMBA-SERVER --------------------------------- administrator guest john.doe
Create a New Share
net usershare add public /srv/samba/public "Public Share" everyone:F guest_ok=y
Example output:
Added share public.
List All Shares
net usershare list
Example output:
public
Set User Password
net rpc password john.doe -U administrator
Example interaction:
Enter administrator's password: Enter new password for user john.doe:
Summary
net ads join
Joins a Samba server to an AD domain
net ads join -U administrator
net ads join -U administrator
net rpc user add
Adds a new user
net rpc user add username -U administrator
net rpc user add john.doe -U administrator
net rpc group add
Adds a new group
net rpc group add groupname -U administrator
net rpc group add developers -U administrator
net usershare add
Creates a new share
net usershare add sharename path "Comment" everyone:F
net usershare add public /srv/samba/public "Public Share" everyone:F guest_ok=y
net rpc password
Sets a user's password
net rpc password username -U administrator
net rpc password john.doe -U administrator
Conclusion
The net
command in Samba provides extensive functionality for managing domains, users, groups, shares, printers, and passwords. It is a crucial tool for Samba administrators to perform a wide variety of administrative tasks efficiently. Understanding the different subcommands and their options allows administrators to effectively manage and maintain a Samba server in a network environment.
Last updated