English
Ask Your Question
5

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

asked 2014-01-30 12:55:40 +0000

NikTh gravatar image

updated 2017-01-13 21:47:20 +0000

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

Comments

Hi,

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 ( 2014-04-03 13:06:46 +0000 )edit
2

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.

NikTh ( 2014-04-03 14:04:47 +0000 )edit

1 answer

Sort by ยป oldest newest most voted
19

answered 2014-01-30 12:59:34 +0000

NikTh gravatar image

updated 2015-03-04 17:41:45 +0000

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

Comments

2

Very thorough answer, well done!

randomuser ( 2014-01-30 16:32:30 +0000 )edit

Great answer.

Gaurav Dighe ( 2014-02-15 04:59:35 +0000 )edit
1

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

Xuan Lang ( 2014-04-16 13:01:11 +0000 )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.

NikTh ( 2014-04-17 23:40:01 +0000 )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 192.168.7.8, I opened the shared folder using \192.168.7.8 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 ( 2014-07-24 06:09:22 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

Follow
3 followers

Stats

Asked: 2014-01-30 12:55:40 +0000

Seen: 68,556 times

Last updated: Jan 13