37.7 smbclient and mount.cifs: Accessing Windows Shares from Linux

Right, so you’ve got a Linux machine and you need to get at files on a Windows share. Welcome to one of the most common, yet perpetually fiddly, tasks in cross-platform sysadmin life. We’re going to bypass the GUI file manager stuff—because you’re not here to click buttons, you’re here to understand—and talk about the two heavy hitters: the nimble smbclient and the steadfast mount.cifs. The Quick and Dirty: smbclient Think of smbclient as the SMB version of an old-school FTP client. It’s your go-to for a quick one-off file transfer, a directory listing, or when you just can’t be bothered to set up a full mount. It’s a Swiss Army knife that’s probably already installed on your system.

37.6 smb.conf: Shares, Workgroup, and Authentication

Right, let’s get our hands dirty with smb.conf. This file is the beating heart of your Samba server, and it’s where you’ll either achieve glorious cross-platform file-sharing nirvana or descend into a frustrating hellscape of authentication errors. I’m here to make sure it’s the former. Think of smb.conf not as a monolithic config, but as a set of Russian nesting dolls. The outermost doll is [global], which sets the rules for the entire server. Inside that, you define your individual share dolls, like [Documents] or [PrinterShare]. A setting in a share can override the global setting, but if you don’t set it there, it inherits from [global]. This structure is your best friend and will keep you from repeating yourself.

37.5 Samba Overview: SMB/CIFS for Windows Interoperability

Alright, let’s talk about Samba. You know that feeling when you’re at a party and two groups of people just can’t seem to talk to each other? That’s your network. Over in the corner, you have the Unix-like systems (Linux, macOS) speaking the native tongue of POSIX permissions and NFS. And then there’s the Windows crowd, holding court in the center of the room, chatting away in a proprietary dialect called SMB. They don’t mean to be difficult; it’s just how they were raised.

37.4 NFS Security: Host-Based Access and Kerberos

Right, let’s talk about securing NFS. The default setup, which relies on hostnames and UID matching, is what I like to call “optimistically insecure.” It trusts the client to tell it who a user is. This is like a nightclub where the bouncer just asks, “You’re on the list, right?” and takes your word for it. It’s fine for a homogenous, trusted network (like a 1995 lab), but in the modern world, it’s a gaping hole. We’re going to fix that by moving from this “host-based” trust to actual user authentication with Kerberos.

37.3 Mounting NFS Shares: mount and /etc/fstab

Alright, let’s get you connected to that NFS share. The mount command is your Swiss Army knife here, but like any good tool, you can use it for quick jobs or set it up for permanent, reliable work. We’re going to cover both: the quick-and-dirty on-the-fly mount and the proper, “I don’t want to do this every reboot” method using /etc/fstab. The On-the-Fly mount Command Think of the mount command as a temporary hookup. It’s great for testing a share or for a one-off data transfer, but it won’t survive a reboot. The basic syntax is deceptively simple, which is where most of the pitfalls hide.

37.2 Setting Up an NFS Server: /etc/exports and exportfs

Alright, let’s get our hands dirty. Setting up an NFS server isn’t rocket science, but it’s one of those tasks where the devil is absolutely in the details. Get one tiny syntax error in the config file and you’ll be staring at Permission denied errors until you question your life choices. I’ve been there. We’re going to avoid that. The heart and soul of your NFS server is the /etc/exports file. This is where you declare which directories on your server you want to share (to “export”) and exactly which clients are allowed to mount them, and with what permissions. The syntax is deceptively simple, which is why it bites so many people.

37.1 NFS Overview: Network File System Versions (v3 vs v4)

Alright, let’s talk about NFS versions. This isn’t just a matter of bigger numbers being better; it’s a fundamental shift in philosophy. The jump from v3 to v4 is like trading in a trusty, greasy socket set for a brand new, all-in-one, computerized tool kit. The old one is simple and you know exactly how it breaks, but the new one can do things the old one could only dream of, provided you read the manual and don’t mind the occasional proprietary bolt.

— joke —

...