# How to Install and Configure Samba Server on Fedora

> URL: https://www.atlantic.net/dedicated-server-hosting/how-to-install-and-configure-samba-server-on-fedora/ | Published: 2023-07-14 | Updated: 2023-11-15 | Author: Hitesh Jethva

Samba is an open-source implementation of SMB networking protocol used for sharing files and printers across different operating systems. It helps system administrators to share files between multiple operating systems. Samba can also be used to join a Linux machine to Windows active directory domain controller. If you are looking for an open-source file-sharing solution, then Samba is the best choice for you.

In this post, we will show you how to install the Samba server on Fedora.

## Step 1 – Install Samba Server

By default, the Samba package is included in the Fedora default repository. You can install it with other packages using the following command.

```
dnf install samba samba-common samba-client
```

Once all the packages are installed, you can proceed to the next step.

## Step 2 -Create a Samba User

Next, you will need to create a user and group to control access on Samba Share.

Let’s create a new user using the following command.

```
useradd smbuser
```

Next, set a password for the Samba user.

```
smbpasswd -a smbuser
```

Set the password as shown below.

```
New SMB password:
Retype new SMB password:
Added user smbuser.
```

Next, create a Samba group with the following command.

```
groupadd smbgroup
```

Next, add smbuser to smbgroup.

```
usermod -g smbgroup smbuser
```

## Step 3 -Create a Public Share with Samba

With Samba, you can create a public share for all users in a network. It can be accessed without providing a user or password.

First, create a directory for Public share using the following command.

```
mkdir -p /data/share/public
```

Next, set the permission and ownership to the Public share.

```
chmod -R 755 /data/share/public
chown -R  nobody:nobody /data/share/public
```

Next, create some files inside the Public directory.

```
cd /data/share/public
touch public1 public2
```

Next, back up the Samba main configuration file and create a new one.

```
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
nano /etc/samba/smb.conf
```

Add the following lines to define your public share.

```
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = sambaserver
security = user
map to guest = bad user
dns proxy = no
ntlm auth = true


[Public]
path =  /data/share/public
browsable =yes
writable = yes
guest ok = yes
read only = no
```

Save and close the file, then test the configuration with the following command.

```
testparm
```

Next, start and enable both smb and nmb services.

```
systemctl start smb nmb
systemctl enable smb nmb
```

## Step 4 -Verify Public Share

Now, you can verify your Public share using the following command.

```
smbclient -L samba-server-ip
```

Just press the enter key without providing any password to list your share.

```
Enter WORKGROUP\root's password: 

	Sharename       Type      Comment
	---------       ----      -------
	Public          Disk      
	IPC$            IPC       IPC Service (Samba Server 4.14.12)
SMB1 disabled -- no workgroup available
```

Next, access the Public share with the following command.

```
smbclient //samba-ip-address/public
```

You will get into the Samba share.

```
Enter WORKGROUP\root's password: 
Try "help" to get a list of possible commands.
```

Run the following command to list all files inside the public share directory.

```
smb: \> ls
```

You will see both files in the following output.

```
  .                                   D        0  Fri Jun 23 22:45:10 2023
  ..                                  D        0  Fri Jun 23 22:49:40 2023
  public1                             N        0  Fri Jun 23 22:45:10 2023
  public2                             N        0  Fri Jun 23 22:45:10 2023

		52416512 blocks of size 1024. 50410328 blocks available
```

## Step 5 – Create a Private Share with Samba

Private share is very useful when you want to control access to the share.

Let’s create a private share with the following command.

```
mkdir -p /data/share/private
```

Next, create two files inside the private share.

```
cd /data/share/private
touch private1 private2
```

Now, set permissions and ownership on the private share.

```
chmod -R 770 /data/share/private
chown -R root:smbgroup /data/share/private
```

Now, edit the Samba configuration file.

```
nano /etc/samba/smb.conf
```

Add the following configurations to define your private share.

```
[Private]
path = /data/share/private
valid users = @smbgroup
guest ok = no
writable = no
browsable = yes
```

Save and close the file, then restart both services to apply the changes.

```
systemctl restart smb nmb
```

## Step 6 – Verify Private Share

Now, you can access your private share using the following command.

```
smbclient //samba-ip-address/private -U smbuser
```

Provide your smbuser password to access the share as shown below.

```
Enter WORKGROUP\smbuser's password: 
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Fri Jun 23 22:50:26 2023
  ..                                  D        0  Fri Jun 23 22:49:40 2023
  private1                            N        0  Fri Jun 23 22:50:26 2023
  private2                            N        0  Fri Jun 23 22:50:26 2023

		52416512 blocks of size 1024. 50410392 blocks available
smb: \>
```

To exit from the Samba shell, run the following command.

```
smb: \> exit
```

## Conclusion

In this post, we explained how to install the Samba server on Fedora. We also showed you how to create a public and private share with Samba. You can now use this solution in your local network to share files between multiple systems. You can now share files and folders with Samba on [dedicated server hosting](https://www.atlantic.net/dedicated-server-hosting/) from Atlantic.Net!
