You are on page 1of 2

LINUX BASH SCRIPT EXAMPLE

ENABLE UFW

INSTALL SAMBA

CREATE SHARE PUBLICFOLDER

ENABLE UFW FIREWALL RULE for SAMBA

#!/bin/bash

# Update the package lists for upgrades and new package installations

sudo apt-get update

# Install ufw

sudo apt-get install ufw -y

# Enable ufw

sudo ufw enable

# Install samba

sudo apt-get install samba -y

# Create a public folder

sudo mkdir -p /home/$USER/publicfolder

# Change the ownership to 'nobody' and 'nogroup'

sudo chown nobody:nogroup /home/$USER/publicfolder

# Change the permissions to read/write

sudo chmod 777 /home/$USER/publicfolder


# Backup the original smb.conf file

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

# Add the new samba share to the smb.conf file

echo "[publicfolder]

path = /home/$USER/publicfolder

browsable =yes

read only = no

guest ok = yes" | sudo tee -a /etc/samba/smb.conf

# Restart the samba service

sudo service smbd restart

# Allow 'samba' through the ufw firewall

sudo ufw allow Samba

# Reload the ufw firewall

sudo ufw reload

You might also like