Difference between revisions of "Mounting CIFS Shares from the command line"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Install cifs-utils =
'''<span style="color: rgb(186, 55, 42); font-size: 24pt;" >This page is definitely a WIP...</span>'''


*<code>sudo apt install cifs-utils -y</code>
= Install cifs-utils and samba-client =
 
*<code>sudo apt install cifs-utils samba-client -y</code>


= Create a mount point =
= Create a mount point =
Line 8: Line 10:


= Mount the share =
= Mount the share =
== At Need Mounting ==
*<code>sudo mount -t cifs -o username='''USER''',password='''PASSWORD''' //'''SERVERNAME'''/'''SHARENAME''' /'''MOUNTPOINT'''</code>
=== Permissions ===
Changing that mount command to


*<code>sudo mount -t cifs -o username='''USER''',password='''PASSWORD''' //'''SERVERNAME'''/'''SHARENAME''' ~/'''MOUNTPOINT'''</code>
*<code>sudo mount -t cifs -o username='''USER''',password='''PASSWORD''',dir_mode=0777,file_mode=0666 //'''SERVERNAME'''/'''SHARENAME''' /'''MOUNTPOINT'''</code>
allows actual access for ANYONE...


== Permissions ==


Changing that command to
*<code>sudo mount -t cifs -o username='''USER''',password='''PASSWORD''',uid='''1000''',gid='''1000''' //'''SERVERNAME'''/'''SHARENAME''' /'''MOUNTPOINT'''</code>
Allows full access by the user with UID 1000 & GID 1000...


*<code>sudo mount -t cifs -o username='''USER''',password='''PASSWORD''',dir_mode=0777,file_mode=0666 //'''SERVERNAME'''/'''SHARENAME''' ~/'''MOUNTPOINT'''</code>
<span style="color: rgb(132, 63, 161);">(Gotta be a better way...)</span>


allows actual access...
== Persistent mounting ==


(Gotta be a better way...)
*<code>sudo vi /etc/fstab</code>
Add a line:
//'''SERVERNAME'''/'''SHARENAME'''    /'''MOUNTPOINT'''    cifs user,username='''USER''',password='''PASSWORD''',_netdev 0 0
'''Notes:'''
: The user option allows you to mount the shares without sudo
: The _netdev option is important since we are mounting a network device. Clients may hang during the boot process if the system encounters any difficulties with the network.
Or
 
Create a credentials file:
*<code>sudo vi /etc/MountCreds</code>
username='''USER'''
password='''PASSWORD'''
*<code>sudo vi /etc/fstab</code>
Add a line:
//'''SERVERNAME'''/'''SHARENAME'''    /'''MOUNTPOINT'''    cifs user,credentials=/etc/MountCreds,_netdev 0 0
Manually mount the filesystems:
*<code>mount -a</code>


= Check it out =
= Check it out =


*<code>ls /'''MOUNTPOINT'''</code>
*<code>ls /'''MOUNTPOINT'''</code>
= Usage Notes =
== List shares available ==
*<code>sudo smbclient -L '''HOSTNAME'''</code>
[[Category:Linux]]
[[Category:WIP]]

Latest revision as of 16:13, 26 January 2022

This page is definitely a WIP...

Install cifs-utils and samba-client

  • sudo apt install cifs-utils samba-client -y

Create a mount point

  • sudo mkdir /MOUNTPOINT

Mount the share

At Need Mounting

  • sudo mount -t cifs -o username=USER,password=PASSWORD //SERVERNAME/SHARENAME /MOUNTPOINT

Permissions

Changing that mount command to

  • sudo mount -t cifs -o username=USER,password=PASSWORD,dir_mode=0777,file_mode=0666 //SERVERNAME/SHARENAME /MOUNTPOINT

allows actual access for ANYONE...


  • sudo mount -t cifs -o username=USER,password=PASSWORD,uid=1000,gid=1000 //SERVERNAME/SHARENAME /MOUNTPOINT

Allows full access by the user with UID 1000 & GID 1000...

(Gotta be a better way...)

Persistent mounting

  • sudo vi /etc/fstab

Add a line:

//SERVERNAME/SHARENAME     /MOUNTPOINT     cifs user,username=USER,password=PASSWORD,_netdev	0	0

Notes:

The user option allows you to mount the shares without sudo
The _netdev option is important since we are mounting a network device. Clients may hang during the boot process if the system encounters any difficulties with the network.

Or

Create a credentials file:

  • sudo vi /etc/MountCreds
username=USER
password=PASSWORD
  • sudo vi /etc/fstab

Add a line:

//SERVERNAME/SHARENAME     /MOUNTPOINT     cifs user,credentials=/etc/MountCreds,_netdev	0	0

Manually mount the filesystems:

  • mount -a

Check it out

  • ls /MOUNTPOINT

Usage Notes

List shares available

  • sudo smbclient -L HOSTNAME