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 administratorThis command joins a Samba server to an Active Directory domain.
Leaving a Domain
net ads leave -U administratorThis command removes a Samba server from an Active Directory domain.
Checking Domain Trust
net rpc trustdom list -U administratorThis command lists the trusted domains for the Samba server.
User and Group Management
Adding a User
net rpc user add username -U administratorThis command adds a new user to the Samba server.
Deleting a User
net rpc user delete username -U administratorThis command deletes a user from the Samba server.
Listing Users
net rpc user -U administratorThis command lists all users on the Samba server.
Adding a Group
net rpc group add groupname -U administratorThis command adds a new group to the Samba server.
Deleting a Group
net rpc group delete groupname -U administratorThis command deletes a group from the Samba server.
Listing Groups
net rpc group -U administratorThis command lists all groups on the Samba server.
Adding a User to a Group
net rpc group addmem groupname username -U administratorThis command adds a user to a specified group.
Removing a User from a Group
net rpc group delmem groupname username -U administratorThis command removes a user from a specified group.
Share Management
Creating a Share
net usershare add sharename path "Comment" everyone:F guest_ok=nThis command creates a new share on the Samba server.
Deleting a Share
net usershare delete sharenameThis command deletes a share from the Samba server.
Listing Shares
net usershare listThis command lists all shares on the Samba server.
Print Management
Listing Printers
net rpc printer list -U administratorThis command lists all printers on the Samba server.
Adding a Printer
net rpc printer add printername -U administratorThis command adds a new printer to the Samba server.
Deleting a Printer
net rpc printer delete printername -U administratorThis command deletes a printer from the Samba server.
Password Management
Setting a User's Password
net rpc password username -U administratorThis command sets the password for a specified user.
Changing Own Password
net rpc password -U usernameThis command allows a user to change their own password.
Examples
Join a Samba Server to a Domain
net ads join -U administratorExample 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 administratorExample output:
Enter administrator's password: User accounts for \\SAMBA-SERVER --------------------------------- administrator guest john.doeCreate a New Share
net usershare add public /srv/samba/public "Public Share" everyone:F guest_ok=yExample output:
Added share public.List All Shares
net usershare listExample output:
publicSet User Password
net rpc password john.doe -U administratorExample 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