Howto mount Samba share on the CLI

Appearantly it can be handy for various reasons to have samba shares mount via the command line. I’m not going to explain the case why I figured this out. But it can be a little hassle. If you follow this guide it should be really easy.

There are 2 methods which i will explain. First one is just mounting it on the command line. The other one is permanent mounting via /etc/fstab

This works in Centos 6.5

Pre-requisites:
– Samba server with samba shares + proper firewall rules
– second linux machine to mount on

First method: Mount on CLI

Second method: Automatically mount via fstab
Creating a credentials file. The reason is that every user is able to check /etc/fstab. So they would be able to see your username and password. This is never a good idea.

After we have created the file we’re going to give it the appropriate rights

To see if our entry in fstab works perform the following command:

To list all the mounts:

There you have it, your samba mount will be mount automatically on boot.

Please refer to man mount.cifs and man mount for more information on this subject.

Leave a Reply

Your email address will not be published. Required fields are marked *