Skip to main content

How to Configure Samba to Share a Folder with Two Users on Ubuntu (with Read/Write and Read-Only Permissions)

Samba is a file sharing software that allows you to share files between Linux and Windows computers. It is a popular choice for home users and businesses alike.

In this article, we will show you how to configure Samba to share a folder with two users, one with read/write permissions and one with only read permissions, on Ubuntu.


Before you begin, you will need the following:

  • A Linux computer running Ubuntu
  • Two user accounts
  • A shared folder


  1. Install Samba.
sudo apt install samba
  1. Create the shared folder.
sudo mkdir /shared
  1. Configure Samba's global options.

Open the Samba configuration file /etc/samba/smb.conf in a text editor.

Add the following lines to the [global] section:

security = user
passdb backend = tdbsam

This will set the security mode to user, which means that users will be authenticated using their local Linux accounts. The passdb backend option specifies the database that Samba will use to store user passwords. In this case, we are using the tdbsam database, which is a simple flat file database.

  1. Set up a user account for each user.

Create two user accounts, one for each user who will be accessing the shared folder. For example:

sudo adduser user1
sudo adduser user2
  1. Configure Samba share directory settings.

Add the following lines to the [share] section of the smb.conf file:

path = /shared
available = yes
valid users = user1,user2
write list = user1

This will create a share named share that is accessible to the users user1 and user2. The read only option is set to no, which means that both users will have read/write permissions to the shared folder. The write list option specifies the users who are allowed to write to the shared folder.

  1. Update the firewall rules.

If you are using a firewall, you will need to open the port that Samba uses. The default port is 139.

sudo ufw allow 139/tcp
  1. Restart Samba.
sudo systemctl restart smbd

Once you have completed these steps, the shared folder will be available to the two users. The user user1 will have read/write permissions to the folder, while the user user2 will only have read permissions.



Popular posts from this blog

Take Action: Add Your Voice to Keep the Internet #Freeandopen - by Google

Tell the world's governments you support a free and open web at takeaction . Starting December 3rd, the world's governments are meeting behind closed doors at the ITU to discuss the future of the Internet. Some governments want to use this meeting in Dubai to increase censorship and regulate the Internet.   Tell the world's governments you support a free and open web at takeaction . Then spread the word with #freeandopen. It is ours and it is free. A free and open world   depends on a free and open web. And a free and open web depends on me.

Create Great looking diagrams -

I was looking for an online diagram creating tool. Came across where I could create actually great looking diagrams without much of learning curve. The tool is 1. Very easy to use 2. Has drag and drop of elements to your diagram 3. Collaboration (which I have not tested). 4. Works from anywhere on a browser with Internet connection (I used it in Google Chrome on Linux Mint 10) When you click on the "Try it now" a new screen will open as below. You can either create a blank page to create a diagram from scratch or select from a bunch of samples and work on them to create one for your requirement. There are options to export the diagrams you created to SVG, JPEG, PNG and XML format once you register for free on the website. Once you register you can save the diagrams that you created in the site itself and retrieve it at a later time by logging into the website. I made three diagrams and it was real easy and simple. The site has two kind of pa

Nodejs and NPM setup on Linux Mint

To install current version of Node js on Linux Mint or any Ubuntu derivatives 1. Install Node      $ curl -sL | sudo -E bash - 2. Check Node version     $ node -v         vxx.xx.x    $ npm -v         x.x.x 3. Verify the Node installation      var http = require('http');      http.createServer(function (req, res) {      res.writeHead(300, {'Content-Type': 'text/plain'});      res.end('Hello World...!!!');      }).listen(3001, "");      console.log('Server running at');     open your browser and type the URL    You can see the me ssage “Hello World…!!!” Source:  1. 2.