How to Install Samba & Plex Media Server on Ubuntu 16.04

Introduction

In this tutorial I will be showing you how you can install and configure Samba and Plex Media Server in your Ubuntu 16.04 server (or desktop). This tutorial is a continuation of the video tutorials previously produced by myself where I showed you how to install Ubuntu Server on an older computer (Videos: Part 1, Part 2, Part 3). However, You do not need to have followed those tutorials in order to perform all the steps in this one.

Now that I have gotten that out of the way, we need to know what Samba and Plex are, as well as what they can do. Samba is a suite of programs that allow us to share files through computers, as well as to send print jobs through a network to a specific machines. In our case, we will be using Samba to create a network folder in which we can place our files and be able to access them through our network from different devices. Plex Media Server, on the other hand, is a service and application that allow us to view media content which is stored in a specific machine in many other devices which can be located within our network or outside of our network. Their server application connects remotely to their service to allow us to use an account to manage all our Plex servers and also to do many other interesting things.

These two programs/services come in very handy when you would like to make a file server which can can also serve media to devices within your network or outside of it such as TVs, mobile devices and other devices. Basically giving you the functionality that most NAS boxes have these days.

Preparing Our Machine

-Finding the IP of the Machine

This tutorial requires you to know what is the current IP of your machine. In order to find the IP of your machine you need to run the following command:

$ ip address

*The command “ip address” Gives you the IP of your machine, useful to be able to connect through SSH to it.

The IP address of your machine should be the number after ‘inet’. It will also depend on the network card which you are using where you will be able to see your IP. In my case, I am using an Ethernet card with the name enp0s3, so my ip should be “10.100.153.244”. Save this number be cause we will be using it later on in the tutorial.

-Testing Outbound Internet Connection

We will also need a working Internet connection in order to be able to complete all the steps in this tutorial successfully. In order to test that our network connection is working we will need to run the following command:

$ ping www.google.com

* The command “ping” allows you to ping a specific website and see whether the website responds to it, allowing us to test that your connection to that website is working.

If you get an output in your terminal similar to the one in the picture above, then your connection is working. If you see that you get an error when you run this command, that means that your network settings are not properly configured in your machine. To stop the output of this command you can press “CTRL + C” and it will stop the command.

-Connecting To The Machine

This tutorial assumes that you are able to connect to your machine through the network using a remote session protocol such as SSH. In order to connect to our machine we will be using SSH. You could also do the whole process while connected to your machine without the need of a remote connection, but if you have a server, it makes it easier work on it.

In order to use the SSH from our client machine (The one we are configuring from) we have three choices:

For Linux, we can connect directly by using the SSH Client, if it’s not included in your distribution, you can easily install it from the repositories. For Ubuntu for Ex: “sudo apt install ssh”. After installing it, we can connect to our server by using the command “ssh username@ipofserver“. Where “username” is the username of the account you have access to in your server and “ipofserver” is the ip of your server machine (Which we found before).

From Windows you can use an SSH client application like Putty [http://www.putty.org/] and follow their instructions in order to connect to your server.

For Android (I am not sure why you will do this from Android but I’m not here to judge) you can use a SSH application known as JuiceSSH [https://play.google.com/store/apps/details?id=com.sonelli.juicessh&hl=en] in order to connect to the machine. You will have to configure a user to use with your server and then connect with it.

Installing Samba

After you have gained access to your server machine, you will now need to install Samba. Since we are using Ubuntu Server, and we have already chosen to install the package when we were installing the package, we don’t need to do much else.

If you did not follow the previous tutorial and you have a server going but without Samba installed, you can install it in Ubuntu Server (or any other Ubuntu derivatives by running) by running:

$ sudo apt install samba

*The command “apt install” allows you to install applications in your system. It must be run with the “sudo” prefix in front in order to run it as a super user or administrator.

After the process of installation is done, it will be time for us to start configuring Samba. Our Samba configuration file is located in “/etc/samba/smb.conf”. To be safe, before modifying this file, we will make a copy or backup of it. In order to make a backup of it, run the command:

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

*the command “cp” allows you to copy files from one directory to another.

Which will make a copy of the file and put in the same directory, calling it “smb.conf.bak“. To confirm that your “smb.conf” file was backed up properly, you can use the command:

$ ls /etc/samba/

*the command “ls” allows you to view the files that are within a specified directory, if not specified, it will show you the files in the current working directory.

If at any point, you make a bad mistake while configuring the “smb.conf” file, you can revert back to the defaults by deleting the broken “smb.conf” file.

$ sudo rm /etc/samba/smb.conf

and then replacing it with the backup:

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

*the command “rm” allows you to delete files. If you would like to delete a directory, you can use the command “rmdir“.

Before configuring our “smb.conf” file, it would be a good idea for us to choose the folder that we will be placing the files that we will be sharing. In my case I will be placing the files in “~/share” or “/home/currentuser/share” where “currentuser” is the user that you are currently using, which should be the same as the one you used to log in. In order to create our new folder, we need to run the command:

$ mkdir ~/share

*the command “mkdir” allows us to create new directories. If a path is not specified, the directory will be created in the current working directory

To make sure that your folder was properly created in the proper path, you can use the command:

$ ls ~/

Both of these commands should show you a list of files or folders in your home directory, make sure that the folder that you just created is there.

Now, let’s start configuring our Samba configuration file, in order to start configuring this file, we need to run this command:

$ sudo nano /etc/samba/smb.conf

*the command “nano” allows us to edit and create text files.

Now we will navigate towards the bottom of the file and we will add the following to the file:

[File Server]
comment =A private file server
path =/home/currentuser/share
security = user
browsable = yes
guest ok = no
read only = no
create mask = 0755

Now press “CTRL + X” and then press “Y” to save the file. Here is what every single one of the arguments we placed in the file do:

[File Server] – is the name which our share will have, it will be displayed when we search our network for shares.

path – has the path where the files that will be accessed by our share are located in our system. In my case, they are located in “/home/angel/share”.

security – states the security type which is gonna be set for our share. In this case, Samba users will be able to access our share. We will set these up later.

browsable – will allow our share to be seen by the Windows clients.

guest ok – tells the system whether systems without an account can access our share. In our case, these users will not be able to access our share.

read only – tells our share whether users can make modifications to the files in our share.

create mask – this argument will determine the permission settings used when we create a new file in our share.

Now that we are done configuring our configuration file, we need to configure our Samba user. This user has to be an existing user in our system. To add a new user we need to run the command:

$ sudo smbpasswd -a user

Where “user” is the existing user who we want to give permission to use our share. Next the system will ask you to add a password to it and then retype the same password. This password is the one that we will be using to connect to our share.

Now we need to make sure that the directory that our share will be using to store our files will have the permissions required for us to be able to access them. In order to do that, we run the following command:

$ sudo chmod 0777 ~/share

*the command “chmod” changes the permission settings of a file or folder.

Next, we are going to test the parameters of our smb.conf file in order to make sure that there were no ground breaking errors in it. To do so, we must execute the following command:

$ testparm

And you will see some information in your terminal that looks like this:

Now press “Enter” and it will dump all your configurations. If you do not get any errors here, you configuration should be fine. All we have to do now is restart our Samba processes by running the command:

$ sudo systemctl restart smbd.service nmbd.service

*The command “systemctl” controls actions and other things related to systemd. Systemd can start, restart and kill processes. It can also monitor processes do many other things which we will not be discussing here.

You should not see any output for this command, it will mean that the restart was successful. Now you can navigate to your file manager, go to your “Networks” section and then try to find the Samba share with the name that we specified before.

If your share’s security is working, then the share will ask you to input your user name and password, both which we created in previous steps.

And this concludes the setup of Samba. Now you can use your computer as file server that many computers from within your network can use. Now we need to go ahead and set up Plex.

Setting Up Plex Media Server

Plex Media Server is an extremely good way for us to be able to access our media and serve it to a big range of devices, in our network our outside of our network. But, we will let Plex itself show you what it can do.

First, we need to navigate to Plex’s download page and download their .deb package for Ubuntu 64-bit, In order to get there you can click this link. Click on “Download Plex Media Server” and then we need to click the drop down menu and select “Linux”. After that, click “Choose Distribution” and right click “Ubuntu 64-bit” and select “Copy Link Location”. What we want to do is copy the link for this file to be able to download it from our server.

Now we need to go to our server and execute the following command in order to download the file:

$ wget [Pasted Link]

*The command wget is the command used to download files or other documents from http/https websites to our machine.

Please be sure to change [Pasted Link] for the link which you copied from the Plex website. The reason why I do not just explicitly paste the link here is because it will be outdated really soon since the Plex team is constantly updating their software. Now we need to install the .deb package which we just downloaded. This can be done by running the command:

$ sudo dpkg -i [Name of Package]

*the command ‘dpkg -i’ will install any .deb package which we give it the name of.

Be sure to replace [Name of Package] by the actual name of your package, which you can see by typing the command “ls” as before. Again, I will not be giving you the name explicitly because it changes with the version of Plex.

After the package is done installing, we will need to go to our favorite browser and configure our Plex Media Server. Now will be a good time also to start copying the media that you would like to access with Plex, just so we have something to test Plex with. In order to connect to our Plex server, we will use the IP address of our machine (Which we found before) and the Plex port to be able to access our server. For instance, for my server it is:

http://192.168.0.102:32400/web

So yours should be something like:

http://ip:32400/web

Where “ip” is the ip address of your server. Now is where the fun starts, if your Plex Media Server was installed properly, you should get a web page that looks like this:

Now we need to either create a Plex account or login with an existing account. Since I have an existing account I can log in with it and add my new server to that account. If you don’t have an account, now would be a good time to create one. After skipping some of the promotional stuff and introductions to how to use Plex, we are greeted with a screen asking us to add a name for our server. In this case I called mines Ratsnest, but you can call yours whatever you want. If you would like to access your media outside of your network, tap the check-box with the same name.

Now it is time for us to select the folders with the media that we would like Plex to have access to. Click “Add Library” and then select the type of media in your library and then give it a name.

Press “Next” and then select the location of the media. In our case, as an example we can set it to be “/home/user/share/” (Where user is the user’s home directory in which the file are stored in) which was the share that we made previously. You can set it to be wherever you would like to really. Remember that in order to get to your home folder you will first need to click on “/” then on “home”, the name of your user and then you will be at the files in your home directory. In my case, my files are located in “/home/angel/share”.

After selecting our folder, we can click “Add” and then “Next”. Then we can just skip everything else in this window by clicking “Next”, defaults are fine in our case. You can add as many more libraries as you would like to, and after you are done, you can move on by clicking “Next”.

After clicking “Next”, Plex will tell us about the applications that they have available for different platforms. Click “Done” to finish the setup process.

After clicking “Done”, you will be greeted with the default UI of Plex. To make sure that your media can be properly accessed, click your libraries on your left side of the screen and try playing some of the media in them. If it plays, then HOORAY! You now have a fully functional media server!

Be sure that, after testing, you visit the settings page which can be accessed by click on the wrench on the top right corner. After you have reached that screen, you can click on “Show Advanced” to see all the settings which you can change. Tweak these settings so you can get the optimal playback experience and fulfill other needs that you might have.

And that concludes this very detailed tutorial on how to install Samba and Plex Media Server. If you have any questions, please leave them in the comments below or contact us directly.

Note: This tutorial assumes that you have some understanding on how to maintain and secure a Linux server. If you think that you might not be able to fully protect your server, do not forward any ports to it or keep it behind a firewall.

Posts created 26

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top