Ask Your Question

How to enable `samba share` for a specific directory?

asked 2014-01-30 06:55:40 -0500

NickTux gravatar image

updated 2017-01-13 15:47:20 -0500

mattdm gravatar image

I want to share a specific directory with the machines on my local network. Samba is the preferred protocol, because of the global OS support. (Windows included).

What I have to do in order to enable sharing in Fedora 20? Do I have to install any additional software? Do I have to do any special configuration ?

edit retag flag offensive close merge delete



Thanks for a very throughout answer! My problem is that my server isn't connected to the Internet. How can I download the needed packages with a connected one and then transfer and install them to the server?

Ben Gt

Ben Gt gravatar imageBen Gt ( 2014-04-03 08:06:46 -0500 )edit

Hi and welcome to ask.fedoraproject. Please open a new question about your query, as this one has already an accepted answer. As a tip, you can use the yum --downloadonly --downloaddir=directory.

NickTux gravatar imageNickTux ( 2014-04-03 09:04:47 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-30 06:59:34 -0500

NickTux gravatar image

updated 2015-03-04 11:41:45 -0500

Fedora 20 includes special software that is enabled by default in order to protect the system from various security risks. That is, SELinux and the firewalld.service

Some tutorials on Internet (I have seen) suggest to disable SELinux in order to enable sharing through samba protocol, but this is completely wrong. Also it is dangerous too, for system security.

First you have to install the required packages for samba and samba configuration

sudo yum install samba samba-common samba-client cups-lib system-config-samba

Create the directory you want to share. We assume here that the directory doesn't exist.

mkdir /srv/shared

Now you have to configure SELinux in order to give read/write access to samba in this directory (and any files inside this directory).

sudo semanage fcontext -a -t samba_share_t "/srv/shared(/.*)?"
sudo restorecon -R -v /srv/shared/

Now run the following command to add the directory and configure the sharing permissions

sudo system-config-samba

Click on add (+) and select the folder we created before. Then configure the permissions on this folder and click OK.

image description

Now configure the firewall in order to open the ports for samba and samba-client

sudo firewall-config

Change the Default Zone to home. By default Fedora has the Public zone enabled. That is, very "restricted". Firewall behaves as if you are using your PC in a public place.

If you want the changes to be permanent change from Runtime to Permanent. If you don't then the changes will be lost in next reboot.

Click on Options and Change Default Zone. Select home.

image description

Then scroll down and check if samba and samba-client are selected. If not, the select them.

image description

You can always change the default Zone (to public) for the Runtime. For example if you go to a public place with your Laptop. Runtime options take place immediately, but Permanent changes need the service to be restarted, so...

...lets start(and restart) some services now

sudo systemctl start smb.service
sudo systemctl start nmb.service
sudo systemctl restart firewalld.service

Now you should be able to see the workgroup, "MYGROUP" is the default name, and the directory "shared" under your local network from any machine that is connected to it.

Don't forget to enable smb.service and nmb.service permanently

sudo systemctl enable smb.service 
sudo systemctl enable nmb.service

Tip: If you configured the directory to be accessed by you only, (not public I mean) then you have to create a new samba password for the user (your user).

sudo smbpasswd -a username

where username replace it with your actual username.

edit flag offensive delete link more



Very thorough answer, well done!

randomuser gravatar imagerandomuser ( 2014-01-30 10:32:30 -0500 )edit

Great answer.

Gaurav Dighe gravatar imageGaurav Dighe ( 2014-02-14 22:59:35 -0500 )edit

mkdir shared then chcon -R -t samba_share_t shared and sudo semanage fcontext -a -t samba_share_t "shared(/.*)?" .... i think

Xuan Lang gravatar imageXuan Lang ( 2014-04-16 08:01:11 -0500 )edit

What I'm writing in this answer, I've already tried on my F20 installation. It is working as it is, without problems. I streaming movies and songs (with XBMC on an android device) directly on my TV from my F20 Laptop.

NickTux gravatar imageNickTux ( 2014-04-17 18:40:01 -0500 )edit

Hi, I would like to share a folder from my mounted hard disk /run/media/Perseus/backup_data/backup. I can see the folder I created using Run on Windows(the IP is, I opened the shared folder using \ on the Run command at Windows) I can see two folders backup and Perseus. However, I cannot access both because according to the Windows prompt, I do not have permissions in accessing the shown Folders.

Pengasus gravatar imagePengasus ( 2014-07-24 01:09:22 -0500 )edit

Question Tools



Asked: 2014-01-30 06:55:40 -0500

Seen: 86,705 times

Last updated: Jan 13 '17