How to create a shared directory in Linux?

To set up a shared directory on Linux, you need to complete the following steps:

  1. Setting up and configuring a Samba server: Samba is an open-source software suite that allows for file and printer sharing between Linux and Windows operating systems. You can install Samba using the following commands:
  2. Update the system using the command “sudo apt-get update”, then install samba with the command “sudo apt-get install samba”.
  3. Create a shared directory: Use the following command to create a shared directory and set appropriate permissions:
  4. Create a shared directory at a specified path and change its permissions to allow all users full access.
  5. Configure Samba sharing: Edit the Samba configuration file and add the shared directory to the list of shares. Open the Samba configuration file using the following command:
  6. Please open the smb.conf file located in /etc/samba using the nano text editor with administrator privileges.
  7. Add the following content at the bottom of the document:
  8. – The shared directory path is set to /path/to/shared/directory with write permission enabled for guests and read-only mode disabled.
  9. This will create a shared directory named “shared” that allows all users to read and write to it.
  10. Save and exit the configuration file: press Ctrl + X, then press Y to save and exit.
  11. Set Samba password: Use the following command to set the password for a Samba user:
  12. Create a new password for the specified username with administrative privileges.
  13. The “username” is the username you want to set for the Samba user.
  14. Restart the Samba service: Use the following command to restart the Samba service to make the configuration file take effect:
  15. Restart the smbd service using systemctl command.

The shared directory has now been created and configured. You can access this directory from other computers by entering the IP address of the Linux machine in the file browser, and then entering the Samba username and password.

bannerAds