How To Add, Remove and Manage Windows Shares Network Drives From Command Line

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-add-remove-and-manage-windows-shares-network-drives-from-command-line/
PINTEREST
PINTEREST
INSTAGRAM

Windows operating systems provides some mechanism to share the resources between different systems. One of the most known and popular tool to manage these resources is net command whit related sub command. In this tutorial we will look how to create, mount, remove and manage network shares with net use  and net share command.

Syntax

Help

Help about net use command can be get with the following command.

Create Share

We will create a share which maps to the C:\cygwin64 folder.  We will also set the network share name as myshare with the following command. We will provide the share name and the path like below.

We have successfully created the share named myshare . If we have do not have permission for given mapped shared directory we will get error and the share will not created.

List Shares

Existing shares can be listed with net share command without providing any parameter. This will list current host network shares.

As we see from screenshot there are a lot of shares. Shares like C$, ADMIN$ are created by default. If we do not need them we should remove them. Listing shares provides following information

  • Share name is the name used to mount this share in the client side
  • Resource is the path the share will be mapped
  •  Remark is comments  and notes about this share which is set while share creation.
LEARN MORE  How To Install, Configure and Run Linux Tftp Client

Mount Share

We have created and listed shares in previous mount shares are easy as creating them. We will use net use command to mount a windows share from command line. We will mount share named myshare located at 192.168.122.167 to our drive z: .

We have succesfully mounted the share. While mounting user credentials should be provided. but in this example the share was created with the same user who mounts the share. So we have all ready have permission access to the share.

List Mounted Shares

We have mounted the remote file share in the previous example. We can list all ready mounted shares simly using net use command like below.

Listing shares will provide information like below.

  • Status shows current situation like connected or not connected
  • Local shown the local mount point
  • Remote shows remote file share full path including the hostname/IP address and the path
  • Network shows network used to access share.

Unmount Share

We can unmount a share similar like mounting it. We will provide /delete option to the mount command like below. In the example we will unmount the remote share name  \\192.168.122.167\myshare from our local system.

Delete or Remove Share With Share Name

We can stop sharing previously shared resource with the /delete parameter and the share name. In this example we will stop sharing myshare .

Delete or Remove Share

Delete or Remove Share

Delete or Remove Share With Physical Location

Alternative way to remove a share is providing the physical location of the shares. This will delete related share and share name. In this example we will provide physical location as c:\cygwin64 to remove related share.

LEARN MORE  How To Make Samba Server Secure?

Delete or Remove Share From Remote Computer

In previous example we have removed existing share from local computer. We can also remove remote systems share by specifying remote system IP address or host name. In this example we will remove share from 192.168.122.66 with the following command.

Set Permission For Share Access

While creating network shares the access permission is important factor for security reasons. We must set which users accounts can access to the share with which access rights. This can be set with /GRANT option and specifying user and rights. Syntax of grant options is like below.

In this  example we will give user account john full access which means READ , WRITE and EXECUTE permissions for the given share.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-add-remove-and-manage-windows-shares-network-drives-from-command-line/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)