Configure and access shared folders on Linux
Learn how to configure shared folders and access them on Linux over Meshnet.
In this article, you will learn how to configure a new network share and access a folder shared from another device using Debian-based Linux distributions.
For this procedure, Ubuntu 22.04.1 LTS is used as an example.
Before you start the sharing process, be sure to complete the following steps to prepare your system:
- 1.Update all of your repositories and install Samba by running the following command in the terminal:sudo apt update && sudo apt install samba -y
- 2.Change permissions for the
/home/$USERdirectory to allow access by running this command:sudo chmod 755 /home/$USER
Depending on your system, you may opt to configure a shared folder using the operating system's file manager or by using the command line.
To create a network share using a file manager's network-sharing options:
- 1.Open Files and navigate to the folder you wish to share.
- 2.Right-click the folder, select Properties, and click Local network share.
- 3.Select Share this folder, and enter the name for your network share.
- 4.Select Guest access to allow passwordless access to the shared folder.
- 5.Click Create share.
Take the following steps to complete the shared folder configuration using the command line:
- 1.Open the terminal.
- 2.Navigate to the folder that you want to share and print out its full path by using the
- 3.Run the following command to open the Samba configuration file using the Nano text editor:sudo nano /etc/samba/smb.conf
- 4.At the end of the file, add the following information where
<name>is a specific name for your network share and
</path/to/folder>is the full path from Step 2:[<name>]path = </path/to/folder>browsable = yeswritable = yesguest ok = yesguest only = yesThe complete configuration in the
- 5.Press Ctrl + X, Y, and Enter to save changes and exit.
- 6.Run the following command to restart the Samba daemon process:sudo systemctl restart smbd
Most Linux file managers let you directly access files shared on other devices. In this example, you will learn how to access a network share using GNOME Files.
- 1.Run the
nordvpn meshnet peer listcommand, and copy the Nord name of the peer you wish to reach.
- 2.Open GNOME Files and select Other locations in the sidebar.
- 3.In the Connect to server field, enter
smb://, paste the Nord name followed by a slash (/) and the name of the network share, and click Connect. Example
- 4.Select Anonymous or Registered user, depending on the folder’s configuration. Click Connect.
Once you restart your machine, the network share that you connected to will become unavailable. To access it again, follow the steps outlined in the Access shared folders section. However, you can mount the shared folder directly onto your operating system for convenient access whenever you need it. On Linux, you can achieve this by using CIFS.
- 1.Open the terminal.
- 2.Update all of your repositories and install the CIFS tool by entering the following:sudo apt update && sudo apt install cifs-utils -y
- 3.Create a new directory using the
mkdircommand, where the network share will be mounted. Examplemkdir MeshnetFolder
- 4.Navigate to the newly created folder using the
cdcommand and print out its full path using the
- 5.Check your user ID by executing this command:echo $UID
- 1.Open the
fstabfile with root privileges using the Nano text editor by running this command:sudo nano /etc/fstab
- 2.At the end of the file, add a line for the network share.For guest access://<NordName>/<ShareName> </path/to/folder> cifs guest,uid=<UID>,iocharset=utf8 0 0For access with username and password authentication://<NordName>/<ShareName> </path/to/folder> cifs username=<USERNAME>,password=<PASSWORD>,uid=<UID>,iocharset=utf8 0 0Where:
<NordName>is the Nord name or the Meshnet IP of the host device.
<ShareName>is the name of the network share you are trying to access
<PASSWORD>are the authentication details for accessing the network share.
- 3.Press Ctrl + X, Y, and Enter to save changes and exit.
- 4.Run the following command to mount the network share:sudo mount -a