DevOps / Sys Admin Q & A: Linux - Samba
Samba file server allows files to be shared across Windows, MacOS, and Linux systems.
The Samba is a collection of programs that implements the Server Message Block (SMB) protocol and provides Active Directory (AD) services.
In this post, we're going to install Samba. For testing, we'll use smbclient
as a client instead of testing it with Windows.
Samba can be easily installed with the following command:
$ sudo yum install samba
Let's configure it. Add the following lines to /etc/samba/smb.conf:
[data] comment = data path = /data read only = No
Then run 'testparm' to verify the config is correct:
$ testparm Load smb config files from /etc/samba/smb.conf Loaded services file OK. Server role: ROLE_STANDALONE ...
Start and check the status:
$ sudo systemctl start smb $ sudo systemctl status smb ● smb.service - Samba SMB Daemon Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2020-08-10 17:22:54 UTC; 9s ago Docs: man:smbd(8) man:samba(7) man:smb.conf(5) Main PID: 1344 (smbd) Status: "smbd: ready to serve connections..." CGroup: /system.slice/smb.service ├─1344 /usr/sbin/smbd --foreground --no-process-group ├─1346 /usr/sbin/smbd --foreground --no-process-group ├─1347 /usr/sbin/smbd --foreground --no-process-group └─1348 /usr/sbin/smbd --foreground --no-process-group Aug 10 17:22:54 ip-172-31-0-52.ec2.internal systemd[1]: Starting Samba SMB Daemon... Aug 10 17:22:54 ip-172-31-0-52.ec2.internal smbd[1344]: [2020/08/10 17:22:54.404005, 0] ../../lib/util/become_daemon.c:136(daemon_ready) Aug 10 17:22:54 ip-172-31-0-52.ec2.internal systemd[1]: Started Samba SMB Daemon. Aug 10 17:22:54 ip-172-31-0-52.ec2.internal smbd[1344]: daemon_ready: daemon 'smbd' finished starting up and ready to serve connections $ sudo systemctl enable smb Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
Let's add the samba service to firewallD and relax SElinux:
$ sudo firewall-cmd --add-service samba --permanent success $ sudo setenforce permissive
Now we need to add a samba user and the user should match the linux user:
$ sudo smbpasswd -a khong New SMB password: Retype new SMB password: Added user khong.
The best testing is to accessing the shared disk from Windows. But in this post, we'll just use Samba client.
Checking the Samba client from yum and install:
$ yum provides */smbclient Loaded plugins: fastestmirror Determining fastest mirrors * base: d36uatko69830t.cloudfront.net * extras: d36uatko69830t.cloudfront.net * updates: d36uatko69830t.cloudfront.net base/7/x86_64/filelists_db | 7.1 MB 00:00:00 extras/7/x86_64/filelists_db | 217 kB 00:00:00 updates/7/x86_64/filelists_db | 2.1 MB 00:00:00 samba-client-4.10.4-10.el7.x86_64 : Samba client programs Repo : base Matched from: Filename : /usr/bin/smbclient samba-client-4.10.4-11.el7_8.x86_64 : Samba client programs Repo : updates Matched from: Filename : /usr/bin/smbclient $ sudo yum install samba-client
Now that the client has been installed, let's check if it can access the /data share. We don't need to type in password here:
$ smbclient -L //localhost Enter SAMBA\centos's password: Anonymous login successful Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers data Disk data IPC$ IPC IPC Service (Samba 4.10.4) Reconnecting with SMB1 for workgroup listing. Anonymous login successful Server Comment --------- ------- Workgroup Master --------- -------
We successfully set up Samba linux!
DevOps
DevOps / Sys Admin Q & A
Linux - system, cmds & shell
- Linux Tips - links, vmstats, rsync
- Linux Tips 2 - ctrl a, curl r, tail -f, umask
- Linux - bash I
- Linux - bash II
- Linux - Uncompressing 7z file
- Linux - sed I (substitution: sed 's///', sed -i)
- Linux - sed II (file spacing, numbering, text conversion and substitution)
- Linux - sed III (selective printing of certain lines, selective definition of certain lines)
- Linux - 7 File types : Regular, Directory, Block file, Character device file, Pipe file, Symbolic link file, and Socket file
- Linux shell programming - introduction
- Linux shell programming - variables and functions (readonly, unset, and functions)
- Linux shell programming - special shell variables
- Linux shell programming : arrays - three different ways of declaring arrays & looping with $*/$@
- Linux shell programming : operations on array
- Linux shell programming : variables & commands substitution
- Linux shell programming : metacharacters & quotes
- Linux shell programming : input/output redirection & here document
- Linux shell programming : loop control - for, while, break, and break n
- Linux shell programming : string
- Linux shell programming : for-loop
- Linux shell programming : if/elif/else/fi
- Linux shell programming : Test
- Managing User Account - useradd, usermod, and userdel
- Linux Secure Shell (SSH) I : key generation, private key and public key
- Linux Secure Shell (SSH) II : ssh-agent & scp
- Linux Secure Shell (SSH) III : SSH Tunnel as Proxy - Dynamic Port Forwarding (SOCKS Proxy)
- Linux Secure Shell (SSH) IV : Local port forwarding (outgoing ssh tunnel)
- Linux Secure Shell (SSH) V : Reverse SSH Tunnel (remote port forwarding / incoming ssh tunnel) /)
- Linux Processes and Signals
- Linux Drivers 1
- tcpdump
- Linux Debugging using gdb
- Embedded Systems Programming I - Introduction
- Embedded Systems Programming II - gcc ARM Toolchain and Simple Code on Ubuntu/Fedora
- LXC (Linux Container) Install and Run
- Linux IPTables
- Hadoop - 1. Setting up on Ubuntu for Single-Node Cluster
- Hadoop - 2. Runing on Ubuntu for Single-Node Cluster
- ownCloud 7 install
- Ubuntu 14.04 guest on Mac OSX host using VirtualBox I
- Ubuntu 14.04 guest on Mac OSX host using VirtualBox II
- Windows 8 guest on Mac OSX host using VirtualBox I
- Ubuntu Package Management System (apt-get vs dpkg)
- RPM Packaging
- How to Make a Self-Signed SSL Certificate
- Linux Q & A
- DevOps / Sys Admin questions
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization