There are several ways to collaborate with files. The most common is to install a shared drive, which allows you to access files not only from your computer, but also from mobile devices. For example, using the NextCloud application allows you to quickly and conveniently deploy your own disk for file collaboration.
In this example, we will look at using the classic option, the previously widely used option using Samba. The application uses the smb protocol to share files and folders.
Using this guide, you can install it locally at home or on a VPS server to be able to connect via the Internet, as well as get a number of other advantages.
1. Install the package
apt update
apt upgrade
apt install samba
systemctl start smbd
systemctl enable smbd
2. Setting up the service
Please note that every time there is a change in the configuration file, you must restart the service and ensure that it is running using the commands:
service smbd restart
service smbd status
This way you apply the changes made, and the check confirms that there are no errors in the configuration.
nano /etc/samba/smb.conf
2.1 Setting up a folder with anonymous access
2.1.1 Create a directory
mkdir -p /var/fileshare/anonymous
chmod 777 /var/fileshare/anonymous
2.1.2 Add configuration to the /etc/samba/smb.conf file
[anon_share]
comment = Directory anonymous
path = /var/fileshare/anonymous
public = yes
writable = yes
read only = no
guest ok = yes
create mask = 0775
directory mask = 0775
force create mode = 0775
force directory mode = 0775
2.2 Setting up a folder with password access
2.2.1 Add a folder
mkdir -p /var/fileshare/pass-only
chmod 777 /var/fileshare/pass-only
2.2.2 Add configuration to the /etc/samba/smb.conf file
[access-by-pass]
comment = access-by-pass
path = /var/fileshare/pass-only
public = no
writable = yes
read only = no
guest ok = no
create mask = 0775
directory mask = 0775
force create mode = 0775
force directory mode = 0775
2.2.3 Add a user
adduser user2
smbpasswd -a user2
Now, when you try to access this directory, you will be asked to enter your login and password.
2.3 Setting access rights
Add lines to add write permissions to a specific user.
writable = no
guest ok = no
...
valid users = user2, user3, someone
write list = user2
...
create mask = 0775
3. Connecting to network folders
3.1 Connection in the Windows operating system
Open Explorer and enter ip followed by two backslashes as shown below:
\\xxx.111.xxx.234
3.2 Connection in the Linux operating system
3.2.1 Install the necessary utility
apt install cifs-utils
3.2.2 Example of mounting a network resource
mount.cifs //xxx.111.xxx.234/anon_share /mnt
Done, the samba file sharing server is installed and configured.
Note: Unlike the ftp protocol, in order to open a file you must always download it, samba network resources allow you to work with files as if they were connected using a USB drive, which provides significant convenience and is the main advantage for collaborating with files and folders over the network.