# Configure and access shared folders on Linux

In this article, you will learn how to set up a shared folder on Linux and access another device's shared folder from a Linux device.

{% hint style="info" %}
**Note**

For this procedure, Ubuntu 24.04 LTS is used as an example.
{% endhint %}

## Prerequisites

Before you begin, download and prepare the [Samba](https://www.samba.org/) app on your Linux device. Samba uses the [SMB](https://nordvpn.com/blog/what-is-smb/) protocol to share resources over the network. If you want to configure a shared folder using the GUI, you should also install the [nautilus-share](https://packages.ubuntu.com/noble/nautilus-share) package.

<details>

<summary>Install Samba</summary>

To install Samba, on your system:

1. Open **Terminal**.
2. Run the following command, which will fetch updates from your repositories and install Samba:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo apt update &#x26;&#x26; sudo apt install samba -y
   </code></pre>

</details>

<details>

<summary>Enable Samba authentication</summary>

To secure access to your shared folders, you need to create a Samba password.

1. Open **Terminal**.
2. Run the command below, which will prompt you to create a new Samba password for your current user:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo smbpasswd -a $USER
   </code></pre>

   &#x20;
3. Enter and confirm your new password.

   <div align="left"><figure><img src="/files/eE8XQAk7fWWGRFnfUNTv" alt="Terminal output asking for the SMB password."><figcaption></figcaption></figure></div>

   &#x20;
4. Add your current user to the `sambashare` group with this command:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo usermod -aG sambashare $USER
   </code></pre>

   &#x20;
5. Restart your PC.

</details>

<details>

<summary>GUI only: Install nautilus-share</summary>

The `nautilus-share` extension adds folder-sharing options to the system's context menu allowing convenient setup.

1. Open **Terminal**.
2. Install `nautilus-share` by running the command below:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo apt install nautilus-share -y
   </code></pre>

   &#x20;
3. To activate the extension you need to restart the Nautilus processes. Use this command to quit Nautilus:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">nautilus -q
   </code></pre>

   &#x20;\
   Next time you open the **Files** app, Nautilus will start automatically.

</details>

## Configure a shared folder

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.

{% tabs %}
{% tab title="GUI" %}
To create a network share using a file manager's network-sharing options:

1. Right-click the folder you want to share and choose **Sharing options**.

   <div align="left"><figure><picture><source srcset="/files/AvCdBz1xo0L6LYOcH5lC" media="(prefers-color-scheme: dark)"><img src="/files/3ZTh2Vq4bvvDXr19uziD" alt="Selecting &#x22;Sharing options&#x22; from the context menu." width="375"></picture><figcaption></figcaption></figure></div>

   &#x20;
2. Select **Share this folder**, and, if needed, enter a custom name for your network share.
3. Click **Create share**.

   <div align="left"><figure><picture><source srcset="/files/aM8jWVBsRjRJq8BPONbD" media="(prefers-color-scheme: dark)"><img src="/files/9hXVNULrKTKNeYClThWL" alt="&#x22;Create share&#x22; buttong highlighted." width="375"></picture><figcaption></figcaption></figure></div>

{% endtab %}

{% tab title="Terminal" %}
Take the following steps to share a folder via the command line:

1. Open **Terminal**.
2. Navigate to the folder that you want to share and print out its absolute path by using the `pwd` command.\
   &#x20;

   **Example**

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">/home/meshnet/Desktop/MeshnetFolder
   </code></pre>

   &#x20;

   <div align="left"><figure><img src="/files/6217NvzPjJMFhIFMcpIM" alt="Output of &#x27;pwd&#x27; command"><figcaption></figcaption></figure></div>

   &#x20;
3. Run the following command to open the Samba configuration file using the Nano text editor:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo nano /etc/samba/smb.conf
   </code></pre>

   &#x20;
4. At the end of the file, append the following lines where `<ShareName>` is the name for your network share and `</path/to/folder>` is the absolute path of the folder from step 2:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">[&#x3C;ShareName>]
   path = &#x3C;/path/to/folder>
   read only = no
   browsable = yes 
   </code></pre>

   &#x20;

   **Example**

   <div align="left"><figure><img src="/files/aw5cAcW6TK5CGfBVLx7O" alt="Samba configuration file with the changes for the shared folder."><figcaption></figcaption></figure></div>

   &#x20;
5. Press **Ctrl** + **X**, **Y**, and **Enter** to save changes and exit.
6. Run the following command to restart the Samba process:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo systemctl restart smbd
   </code></pre>

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note**

To access the shared folder, the peer device will need to use your Linux username and the previously created Samba password for authentication.
{% endhint %}

## Access shared folders

{% hint style="info" %}
**Note**

You can find platform-specific instructions for accessing the shared folder in the appropriate guides:

* [Access shared folders from Windows](/how-to/remote-files-media-access/set-up-folder-sharing/configure-and-access-shared-folders-on-windows.md#access-shared-folders)
* [Access shared folders from macOS](/how-to/remote-files-media-access/set-up-folder-sharing/configure-and-access-shared-folders-on-macos.md#access-shared-folders)
* [Access shared folders from Android](/how-to/remote-files-media-access/set-up-folder-sharing/access-shared-folders-on-android.md)
* [Access shared folders from iPhone/iPad](/how-to/remote-files-media-access/set-up-folder-sharing/access-shared-folders-on-ios.md)
* [Access shared folders from Android TV](/how-to/remote-files-media-access/set-up-folder-sharing/access-shared-folders-from-android-tv.md)
  {% endhint %}

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 list` command and copy the Nord name of the sharer's device.

   <div align="left"><figure><img src="/files/PoV5fD9oT5ybmblwioc6" alt="Terminal output of the &#x27;nordvpn meshnet peer list&#x27; command with a peer device&#x27;s Nord name underlined."><figcaption></figcaption></figure></div>

   &#x20;
2. Open GNOME **Files** and select **Other locations** in the sidebar.

   <div align="left"><figure><picture><source srcset="/files/Cw1KOzszdpKMMZTJhPiH" media="(prefers-color-scheme: dark)"><img src="/files/1k8Tn87mJyaNWalfOqfP" alt="&#x22;Other locations&#x22; option highlighted." width="278"></picture><figcaption></figcaption></figure></div>

   &#x20;
3. In the **Enter server address** field at the bottom, type in`smb://`, paste the copied Nord name, add a slash (/) followed by the network share name, and click **Connect**.\
   &#x20;\
   **Example**

   `smb://secret.meerkat-himalayas.nord/MeshnetFolder`\
   &#x20;

   <div align="left"><figure><picture><source srcset="/files/54WZGRjdDZDGIDEHbA53" media="(prefers-color-scheme: dark)"><img src="/files/llgY9ca9y0GAUcNgaGPU" alt="Shared folder&#x27;s network path entered in the file manager."></picture><figcaption></figcaption></figure></div>

   &#x20;
4. Select **Registered user** and enter the username and password for accessing the shared folder.

   <div align="left"><figure><picture><source srcset="/files/veKbOmyfr0mb3hnnHqRz" media="(prefers-color-scheme: dark)"><img src="/files/tkwRlo5nFCg8yO27lRXz" alt="" width="563"></picture><figcaption></figcaption></figure></div>

   &#x20;
5. Click **Connect**.

The shared folder should now open in the file manager.

## Mount a shared folder

The shared folder you connect to becomes unavailable after a system restart, which means that you would need to reconnect to the folder each time you wish to access the files stored in it. However, by utilizing [CIFS](https://wiki.samba.org/index.php/LinuxCIFS_utils), you can mount the shared folder directly on your system and use it as a persistent storage location.

### Prepare a mounting point

1. Open **Terminal**.
2. Fetch repository updates and install CIFS by entering the following:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo apt update &#x26;&#x26; sudo apt install cifs-utils -y
   </code></pre>

   &#x20;
3. Create a new directory using the `mkdir` command, where you want to mount the shared folder.\
   &#x20;\
   **Example**

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">mkdir SharedFolder
   </code></pre>

   &#x20;
4. Navigate to the newly created folder using the `cd` command and print out its full path using the `pwd` command.

   <div align="left"><figure><img src="/files/H4ZP4Uzt0jZEpm0cFOwE" alt="Ouput of &#x27;pwd&#x27; command"><figcaption></figcaption></figure></div>

   &#x20;
5. Check your user ID number by executing this command:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">echo $UID
   </code></pre>

### Edit the file system table

1. Open the `fstab` file with root privileges using the Nano text editor by running this command:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo nano /etc/fstab
   </code></pre>

   &#x20;
2. At the end of the file, append the following line for the shared folder:

   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">//&#x3C;NordName>/&#x3C;ShareName> &#x3C;/path/to/folder> cifs username=&#x3C;USERNAME>,password=&#x3C;PASSWORD>,uid=&#x3C;UID>,iocharset=utf8 0 0
   </code></pre>

   &#x20;

   Where:

   * &#x20;`<NordName>` is the Nord name or the Meshnet IP of the host device.
   * &#x20;`<ShareName>` is the name of the network share you are trying to access
   * `</path/to/folder>` is the path to the mounting point from Step 4 of the [Prepare a mounting point](#prepare-a-mounting-point) section.
   * `<USERNAME>` and `<PASSWORD>` are the authentication details for accessing the shared folder.
   * `<UID>` is the user ID from Step 5 of the [Prepare a mounting point](#prepare-a-mounting-point) section.

     &#x20;\
     **Example**

     <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">//secret.meerkat-pyrenees.nord/MeshnetFolder /home/meshnet/SharedFolder cifs username=meshnet,password=securepwd123,uid=1000,iocharset=utf8 0 0
     </code></pre>

     &#x20;
3. Press **Ctrl** + **X**, **Y**, and **Enter** to save changes and exit.
4. Run the following command to mount the network share:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo mount -a
   </code></pre>

   &#x20;
5. Apply the changes to your file system table by reloading SystemD with the following command:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo systemctl daemon-reload
   </code></pre>

You can now access the shared folder from the sidebar in the **Files** app.

<div align="left"><figure><picture><source srcset="/files/PLM3u2x4NTV8e4ypoutI" media="(prefers-color-scheme: dark)"><img src="/files/qr1SqYOefW00djimfS50" alt="The mounted shared folder highlighted in the &#x22;Files&#x22; app." width="417"></picture><figcaption></figcaption></figure></div>

## See also

* [Configure and access shared folders on Windows](/how-to/remote-files-media-access/set-up-folder-sharing/configure-and-access-shared-folders-on-windows.md)
* [Configure and access shared folders on macOS](/how-to/remote-files-media-access/set-up-folder-sharing/configure-and-access-shared-folders-on-macos.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://meshnet.nordvpn.com/how-to/remote-files-media-access/set-up-folder-sharing/configure-and-access-shared-folders-on-linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
