- What hardware to choose for a headless Linux Server?
- What Linux OS to choose for a headless Linux Server?
- Step by Step guide to set up Ubuntu Server LTS
This guide was written with Ubuntu Server16.04 LTS as reference.
1) Usually while installing the server editions of linux you have the option to install samba service or the samba file server. You can check whether samba(smb for short) is installed on your server with these commands.
samba --version
You should see the proper version number as shown above.
You can also check if samba is installed by checking if samba config folder exists,you can do that by running the below command.
cd /etc/samba
2) If you already have samba installed, you can skip to step 3. You can install samba by running this command.
sudo apt-get install samba
3) Next create a directory/folder to be shared on the network using the mkdir command.
You can skip this step if you want to share an existing folder.
I created a folder called 'share' in my home folder.
If you want to share a different partition or a different storage device, you'll have to mount it inside the share folder, you can manually mount it every time the OS boots up but creating an fstab entry will automatically mount it for you.
You can check out this article to know more about adding entries to fstab.
4)(Optional but recommended) Create a new user using the following command
This will be the dedicated user to access your file share, having different users will allow you to set access control over your file share. You can create a user with read-only permissions and control what parts of the share they can view,access and modify.
You can create sub-folders within the main share directory and assign different folders to different users and varying access controls and allow only the admin to manage the whole share(more on this later)
sudo useradd -M shareUser
-M attribute creates the user without the home directory.
Since, this user is only needed for access control and authentication it does not need a home folder.
5) Create a new SMB password for your user, this password will be necessary to access the share.
sudo smbpasswd -a shareUser
Make sure that the smb password is not same as the linux account password.
It is a good idea to block ssh login's for the shareUsers if you use the same password.
6)Open the smb.conf file by running the following command.
sudo nano /etc/samba/smb.conf
smb.conf is where you configure all your shares and manage your shares.
Add the following lines to the end of the file.
The name in [] has to be the name of your shared folder, path points to your shared folder(existing or newly created). Remaining parameters are quite self explanatory.
Make sure you have proper spacing between the attribute and its value as shown(one space before and after the '=').
Save the file and exit.
There are many more parameters you can configure based on your specific needs, but these are the basic set of parameters which are usually defined.
7) Restart the smb service by using one of the following commands.
sudo service smbd restart
or
sudo systemctl restart smbd
This will restart the samba service and your configurations should be set up.
Now you should be able to access your share from a different machine, windows or unix based systems.
Most of the linux distros come with samba client pre-installed and you can set up the share in the network section of your file explorer.
I use VLC on smart TV's to access my shares and playback media content and Solid Explorer on my phone for backing up phone data.




Comments
Post a Comment