How to create a shared directory in Linux?
To create a shared directory in Linux, you can follow these steps:
- Firstly, login to the command line as the root user or a user with sudo privileges.
- Make sure you have installed the Samba software package. If not, you can install Samba using the following command:
- Update the system and install Samba using the following commands:
sudo apt-get update
sudo apt-get install samba - 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.
- Create a new directory named ‘share’ in the /srv directory using superuser privileges.
- Set up Samba. Edit the Samba configuration file smb.conf, located in the /etc/samba directory.
- Please open the smb.conf file located at /etc/samba/ using the nano text editor with root privileges.
- Add the following content at the end of the document:
- [share]
comment = Directory for shared files
path = /srv/share
browseable = yes
read only = no
guest ok = yes - This will create a shared directory named “share” that allows all users to read and write, and also allows anonymous access.
- Save and close the file.
- Restart the Samba service to apply the configuration changes.
- Restart the smbd service using systemctl.
You have successfully created a shared directory. You can access this shared directory by navigating to smb://