Linux Training : Section 8 (Part-3)

Samba

  • Samba is a Linux tool or utility that allows sharing for Linux resources such as files and printers to with other OS.

  • It works exactly like NFS but the difference is NFS shared within Linux or Unix like system whereas Samba shares with other OS (e.g., Windows, MAC etc)

  • For Example, Computer “A“ shared its filesystem with computer “B“ using Samba then computer “B“ will see that shared filesystem as if it is mounted as the local filesystem.

  • Samba shares its filesystem through a protocol called SMB (Server Message Block) which was invented by IBM

  • Another protocol used to share Samba is through CIFS (Common Internet File System) invented by Microsoft and also NMB (NetBios Name server)

  • CIFS became the extension of SMB and now Microsoft has introduced newer version of SMB v2 and v3 that are mostly used in the industry

  • Most people, when they use either SMB or CIFS, are talking about the same exact thing. The two are interchangeable not only in discussion, but also in application – i.e., a client speaking CIFS can talk to a server speaking SMB and vice versa. Why? Because CIFS is a form of SMB

Step by steps installation instructions

First please make sure to take a snapshot of your VM

  1. Install samba packages

    # Become root user

    # yum install samba samba-client samba-common

  2. Enable samba to be allowed through firewall (Only if you have firewall running)

    # firewall-cmd --permanent --zone=public --add-service=samba

    # firewall-cmd –reload

  3. To stop and disable firewall or iptables

    # systemctl stop firewalld

    # systemctl stop iptables

    # systemctl disable firewalld

    # systemctl disable iptables

  4. Create Samba share directory and assign permissions

    # mkdir -p /samba/morepretzels

    # chmod a+rwx /samba/morepretzels

    # chown -R nobody:nobody /samba

  5. Also, you need to change the SELinux security context for the samba shared directory as follows: (Only if you have SELinux enabled)

    # chcon -t samba_share_t /samba/morepretzels

  6. If you want to disable SELinux, follow these instructions

    # sestatus To check the SELinux status)

    # vi /etc/selinux/config

    Change SELINUX=enforcing To SELINUX=disabled

    # reboot

  7. Modify /etc/samba/smb.conf file to add new shared filesystem (Make sure to create a copy of smb.conf file) Delete everything from smb.conf file and add the following parameters

    [global]

    workgroup = WORKGROUP

    netbios name = centos

    security = user

    map to guest = bad user

    dns proxy = no

    [Anonymous]

    path = /samba/morepretzels

    browsable = yes

    writable = yes

    guest ok = yes

    guest only = yes

    read only = no

  8. Verify the setting

    # testparm

  9. Once the packages are installed, enable and start Samba services

    # systemctl enable smb

    # systemctl enable nmb

    # systemctl start smb

    # systemctl start nmb

  10. Mount on Windows client

    Go to start

    Go to search bar

    Type \\192.168.1.95 (This is my server IP, you can check your Linux CentOS IP by running the command ifconfig)

  11. Mount on Linux client

    Become root

    # yum -y install cifs-utils samba-client

    Create a mount point directory

    # mkdir /mnt/sambashare

    Mount the samba share

    # mount -t cifs //192.168.1.95/Anonymous /mnt/sambashare/

    # Entry without password

    Secure Samba Server

  12. Create a group smbgrp & user larry to access the samba server with proper authentication

    # useradd larry

    # groupadd smbgrp

    # usermod -a -G smbgrp larry

    # smbpasswd -a larry

    New SMB password: YOUR SAMBA PASS

    Retype new SMB password: REPEAT YOUR SAMBA PASS

    Added user larry

  13. Create a new share, set the permission on the share:

    # mkdir /samba/securepretzels

    # chown -R larry:smbgrp /samba/securepretzels

    # chmod -R 0770 /samba/securepretzels

    # chcon -t samba_share_t /samba/securepretzels

  14. Edit the configuration file /etc/samba/smb.conf (Create a backup copy first)

    # vi /etc/samba/smb.conf

    Add the following lines

    [Secure]

    path = /samba/securepretzels

    valid users = @smbgrp

    guest ok = no

    writable = yes

    browsable = yes

  15. Restart the services

    # systemctl restart smb

    # systemctl restart nmb

NAS Device for NFS or Samba

  • Network-attached storage (NAS) is a file-dedicated storage device that makes data continuously available for employees to collaborate effectively over a network.

SATA and SAS

  • SATA stands for Serial Advanced Technology Attachment and SAS stands for Serial Attached SCSI (Small Computer System Interface, typically pronounced as “scuzzy“)

  • Both SATA and SAS utilize serial communication. Serial communication means that the highway has both lanes.

  • The main difference between them is that SAS drives are faster and more reliable then SATA drives.

  • SAS is generally more expensive, it’s better suited for use in servers or in processing-heavy computer workstations. SATA is less expensive, and it’s better suited for desktop file storage

  • In a SATA cable, all 4 wires are placed within the same cable. In a SAS cable, the 4 wires are separated into 2 different cables.

Why divide the wires between 2 cables??

  • So you can connect more devices to one another. With a SATA cable, you can only link the motherboard and the storage drive. You could hook up an expansion device, but that takes up valuable room inside your computer.

  • With a SAS cable, you can hook up the motherboard to both a storage drive and another piece of hardware that has SAS connectors.

Here’s what the highways look like, metaphorically:

  • SATA Cable: Bhopal to Indore

  • SAS Cable: Bhopal to Indore or Bhopal to Ujjain

MYSQL and MariaDB

A database is a structured collection of data that can be stored electronically. It can include text, numbers, images, videos, and files.

  • As a relational database system, MySQL stores data in rows and columns defined by schemas. MySQL derives part of its name from the SQL language, which is used for managing and querying data in databases. MySQL offers full ACID transactions and can handle a high volume of concurrent connections.

  • MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system (RDBMS), intended to remain free and open-source software under the GNU General Public License.

Install and Configure MariaDB & MySQL

  1. Step 1: Install and Start MariaDB

    dnf install mariadb-server mariadb -y

    systemctl start mariadb

    systemctl enable mariadb

    systemctl status mariadb

  2. Step 2: Secure MariaDB Installation

    mysql_secure_installation

  3. Step 3: Create Database and User in MariaDB

    mysql -u root -p

    CREATE DATABASE first_MariaDB;

    CREATE USER 'aditya'@'localhost' IDENTIFIED BY '123';

    GRANT ALL PRIVILEGES ON first_MariaDB.* TO 'aditya'@'localhost';

    FLUSH PRIVILEGES;

    SHOW DATABASES;

    EXIT;

  4. Step 4: Create Table and CURD operation

    Now, Press CNTL + L

    vi /etc/nginx/nginx.conf

    USE first_MariaDB;

    CREATE TABLE people (

    id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100), profession VARCHAR(100) );

    INSERT INTO people (name, profession) VALUES ('Alice', 'Engineer'), ('Bob', 'Doctor'), ('Charlie', 'Teacher');

    SELECT * FROM people;

    UPDATE people SET profession = 'Principal' WHERE name = 'Charlie';

    DELETE FROM people WHERE name = 'Bob';

    EXIT;

  5. Step 5: Uninstall MariaDB

    systemctl stop mariadb

    dnf remove mariadb mariadb-server

    rm -rf /var/lib/mysql

    rm -rf /etc/my.cnf

  6. Step 6: Install and Setup MySQL

    dnf install mysql-server -y

    systemctl start mysqld

    systemctl enable mysqld

    systemctl status mysqld

    mysql_secure_installation

    After this, all the steps are same as MariaDB.

LAMP Stack

L » Linux

A » Apache

M » MySQL

P » PHP


Thanks for going through this blog, Happy Learning !! 😁

0
Subscribe to my newsletter

Read articles from Aditya Dev Shrivastava directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aditya Dev Shrivastava
Aditya Dev Shrivastava