Sub topic 2
Checking your Samba setup
This chapter assumes you can use sudo, edit files in a terminal, understand Linux users, groups, and permissions, and restart services with systemctl. It also assumes a Samba server with a share named projects already exists in /etc/samba/smb.conf.
Checking the Samba configuration
Run testparm to check the syntax of smb.conf. The -s flag skips the interactive prompt and prints the effective configuration.
sudo testparm -sFix any errors it reports before you restart the service. Then confirm that the server offers the share and that a Samba user can log in:
smbclient -L //fileserver -U aliceTwo errors are common. NT_STATUS_LOGON_FAILURE means the Samba password is missing or wrong, so reset it with sudo smbpasswd -a alice. NT_STATUS_BAD_NETWORK_NAME means the share name in the command does not match the share name in smb.conf.
Mounting a Samba share from Linux
Install the cifs-utils package, which provides mount.cifs. Then create a mount point and mount the share:
sudo mkdir -p /mnt/projects
sudo mount -t cifs //fileserver/projects /mnt/projects -o username=alice,vers=3.0,uid=1000,gid=1000The uid and gid options set the local owner of the files. Without them, the files belong to root. If you omit the password, mount.cifs prompts for it.
NFS versions and how they work
NFS (Network File System) is the native file sharing protocol for Unix-like systems. NFSv3 relies on several helper services, such as mountd and rpcbind, which use extra ports. NFSv4 uses a single TCP port, 2049, and includes locking and security in the protocol. Use NFSv4 unless a client needs NFSv3.
Exporting directories over NFS
The server lists its exports in /etc/exports. Each line gives a directory, a client, and options:
/srv/nfs/projects 192.168.1.0/24(rw,sync,no_subtree_check)Apply the file and list the active exports:
sudo exportfs -ra
sudo exportfs -vThe default root_squash option maps requests from client root to an unprivileged user on the server. Keep it enabled.
> Keep this tip in mind: exports that are not listed by exportfs -v are not served, even if they appear in /etc/exports.
Mounting an NFS export
List the exports that a server offers, then mount one over NFSv4:
showmount -e fileserver
sudo mkdir -p /mnt/projects
sudo mount -t nfs4 fileserver:/srv/nfs/projects /mnt/projectsExercise
A Samba client gets NTSTATUSBADNETWORKNAME when it connects to //fileserver/projects. Where do you look first, and what command confirms the name the server actually offers?
Show answer
Check the share name in the [projects] section header of smb.conf. Run smbclient -L //fileserver -U alice, which lists the share names the server offers. Correct the name in the mount or client command so it matches.