Software & AppsOperating SystemLinux

How To Mount a CIFS Share via FSTAB and Give Full RW Access to Guest on Ubuntu

Ubuntu 21

In this guide, we’ll walk you through the process of mounting a CIFS share via FSTAB and granting full Read-Write (RW) access to guests on Ubuntu. This can be useful in a variety of scenarios, such as setting up a shared drive on your network.

Quick Answer

To mount a CIFS share via FSTAB and give full RW access to guests on Ubuntu, you need to add an entry for the share in the FSTAB file with the appropriate options. This allows the share to be automatically mounted at boot and grants guest users read and write permissions.

What is a CIFS Share?

CIFS (Common Internet File System) is a network protocol that allows sharing of resources (like files and printers) among different devices in a network. It’s a version of SMB (Server Message Block) and is primarily used by Windows, but it’s compatible with other systems like Ubuntu.

Prerequisites

Before we start, you’ll need:

  • An Ubuntu system
  • A CIFS share you want to mount
  • Access to the terminal/command line

Step 1: Opening the FSTAB File

First, we need to open the FSTAB file. FSTAB is a system configuration file in Ubuntu and other Linux distributions. It contains information about filesystems and partitions, and the system reads it at boot to mount the specified filesystems.

Open your terminal and type:

sudo nano /etc/fstab

This command opens the FSTAB file in the nano text editor. sudo is used to run the command with root privileges.

Step 2: Adding the CIFS Share to FSTAB

Next, we’ll add an entry for the CIFS share. At the end of the FSTAB file, add the following line:

//192.168.0.5/storage /media/myname/TK-Public/ cifs guest,uid=nobody,gid=nogroup,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0

Here’s what each part of this line means:

  • //192.168.0.5/storage is the location of the CIFS share on the network.
  • /media/myname/TK-Public/ is the mount point on your Ubuntu system. This is where you’ll access the files on the share.
  • cifs specifies the filesystem type.
  • guest allows guest access to the share.
  • uid=nobody,gid=nogroup sets the user and group IDs for the share. In this case, we’re setting them to ‘nobody’ and ‘nogroup’ respectively.
  • iocharset=utf8 sets the character set to use for file names.
  • file_mode=0777,dir_mode=0777 sets the permissions for files and directories on the share. 0777 gives full read, write, and execute permissions to all users.
  • noperm tells the client to not do permission checks. This can be helpful for shares with different permission schemes than the client.
  • 0 0 at the end are dump and pass values. They’re not relevant for network shares, so we set them to 0.

Step 3: Saving Changes and Mounting the Share

Once you’ve added the line, save the changes and exit the editor. In nano, you can do this by pressing Ctrl+X, then Y, then Enter.

Now, you can mount the share by running:

sudo mount -a

This command mounts all filesystems specified in FSTAB.

Step 4: Verifying the Mount

To verify that the share is mounted correctly, you can use the df command:

df -h

This command lists all mounted filesystems in a human-readable format. You should see your CIFS share listed.

Conclusion

You’ve now successfully mounted a CIFS share via FSTAB and given full RW access to guests on Ubuntu. Remember that this configuration allows anyone on your network to read, write, and execute files on the share, so use it carefully.

For more information on FSTAB and its syntax, you can check out the Ubuntu FSTAB community documentation. For more details on CIFS and its options, refer to the CIFS/SMB Linux kernel documentation.

If you encounter any issues, make sure that the server’s configuration allows guest access and that the share’s ownership and permissions are correctly set. You can use the chown command to change the ownership of the share if needed.

What is the purpose of mounting a CIFS share via FSTAB?

Mounting a CIFS share via FSTAB allows you to automatically mount the share at system startup, ensuring that it is always accessible without manual intervention.

Can I mount multiple CIFS shares via FSTAB?

Yes, you can add multiple entries for different CIFS shares in the FSTAB file. Simply follow the same format as described in the guide, and add each share on a new line.

How can I change the permissions for the mounted CIFS share?

You can modify the permissions for the mounted CIFS share by adjusting the file_mode and dir_mode options in the FSTAB entry. These options determine the permissions for files and directories on the share. Make sure to use the appropriate numeric values to set the desired permissions.

What if the CIFS share requires authentication?

If the CIFS share requires authentication, you can include the username and password options in the FSTAB entry. Replace guest with username=your_username,password=your_password in the entry, where your_username is your username for accessing the share and your_password is your corresponding password.

How can I unmount the CIFS share?

To unmount the CIFS share, you can use the umount command followed by the mount point. For example, if your mount point is /media/myname/TK-Public/, you can run sudo umount /media/myname/TK-Public/ to unmount the share.

Can I specify a different mount point for the CIFS share?

Yes, you can choose a different mount point for the CIFS share by modifying the /media/myname/TK-Public/ part in the FSTAB entry. Replace it with the desired path where you want to mount the share.

How can I automatically mount the CIFS share when the system reboots?

By adding the entry to the FSTAB file as described in the guide, the CIFS share will be automatically mounted at system startup. The sudo mount -a command can also be used to mount all filesystems specified in FSTAB manually.

Is it possible to mount a CIFS share from a different operating system?

Yes, CIFS shares can be mounted from different operating systems, including Windows, macOS, and other Linux distributions. However, the specific steps and commands might vary slightly depending on the operating system you are using.

Can I mount a CIFS share with read-only access instead of read-write?

Yes, if you want to mount the CIFS share with read-only access, you can modify the file_mode and dir_mode options in the FSTAB entry. Replace 0777 with 0555, which gives read-only permissions to all users.

What should I do if I encounter permission issues when accessing the mounted CIFS share?

If you encounter permission issues when accessing the mounted CIFS share, ensure that the server’s configuration allows the specified user or guest access. Additionally, check the ownership and permissions of the share on the server side. You can use the chown command to change the ownership of the share if needed.

Leave a Comment

Your email address will not be published. Required fields are marked *