How to create a shared directory in Linux?

To create a shared directory in Linux, you can follow these steps:

  1. Firstly, login to the command line as the root user or a user with sudo privileges.
  2. Make sure you have installed the Samba software package. If not, you can install Samba using the following command:
  3. Update the system and install Samba using the following commands:
    sudo apt-get update
    sudo apt-get install samba
  4. Create a shared directory. You can choose to create a shared directory at any location. In this example, we will create a shared directory named “share” in the /srv directory.
  5. Create a new directory named ‘share’ in the /srv directory using superuser privileges.
  6. Set up Samba. Edit the Samba configuration file smb.conf, located in the /etc/samba directory.
  7. Please open the smb.conf file located at /etc/samba/ using the nano text editor with root privileges.
  8. Add the following content at the end of the document:
  9. [share]
    comment = Directory for shared files
    path = /srv/share
    browseable = yes
    read only = no
    guest ok = yes
  10. This will create a shared directory named “share” that allows all users to read and write, and also allows anonymous access.
  11. Save and close the file.
  12. Restart the Samba service to apply the configuration changes.
  13. Restart the smbd service using systemctl.

You have successfully created a shared directory. You can access this shared directory by navigating to smb:///share on Windows or other Linux machines. If you are using Windows, you can also map the shared directory as a network drive.

bannerAds