What is file server in linux

Samba as a file server

One of the most common ways to network Ubuntu and Windows computers is to configure Samba as a file server. It can be set up to share files with Windows clients, as we’ll see in this section.

The server will be configured to share files with any client on the network without prompting for a password. If your environment requires stricter Access Controls see Share Access Control.

Install Samba

The first step is to install the samba package. From a terminal prompt enter:

That’s all there is to it; you are now ready to configure Samba to share files.

Configure Samba as a file server

The main Samba configuration file is located in /etc/samba/smb.conf . The default configuration file contains a significant number of comments, which document various configuration directives.

Note:
Not all available options are included in the default configuration file. See the smb.conf man page or the Samba HOWTO Collection for more details.

First, edit the workgroup parameter in the [global] section of /etc/samba/smb.conf and change it to better match your environment:

Create a new section at the bottom of the file, or uncomment one of the examples, for the directory you want to share:

[share] comment = Ubuntu File Server Share path = /srv/samba/share browsable = yes guest ok = yes read only = no create mask = 0755 
  • comment
    A short description of the share. Adjust to fit your needs.
  • path
    The path to the directory you want to share.

Note:
This example uses /srv/samba/sharename because, according to the Filesystem Hierarchy Standard (FHS), /srv is where site-specific data should be served. Technically, Samba shares can be placed anywhere on the filesystem as long as the permissions are correct, but adhering to standards is recommended.

Create the directory

Now that Samba is configured, the directory needs to be created and the permissions changed. From a terminal, run the following commands:

sudo mkdir -p /srv/samba/share sudo chown nobody:nogroup /srv/samba/share/ 

The -p switch tells mkdir to create the entire directory tree if it doesn’t already exist.

Enable the new configuration

Finally, restart the Samba services to enable the new configuration by running the following command:

sudo systemctl restart smbd.service nmbd.service 

Warning:
Once again, the above configuration gives full access to any client on the local network. For a more secure configuration see Share Access Control.

From a Windows client you should now be able to browse to the Ubuntu file server and see the shared directory. If your client doesn’t show your share automatically, try to access your server by its IP address, e.g. \\192.168.1.1 , in a Windows Explorer window. To check that everything is working try creating a directory from Windows.

Читайте также:  Scp linux указать порт

To create additional shares simply create new [sharename] sections in /etc/samba/smb.conf , and restart Samba. Just make sure that the directory you want to share actually exists and the permissions are correct.

The file share named [share] and the path /srv/samba/share used in this example can be adjusted to fit your environment. It is a good idea to name a share after a directory on the file system. Another example would be a share name of [qa] with a path of /srv/samba/qa .

Further reading

  • For in-depth Samba configurations see the Samba HOWTO Collection
  • The guide is also available in printed format.
  • O’Reilly’s Using Samba is another good reference.
  • The Ubuntu Wiki Samba page.

Источник

HOW TO SETUP NFS SERVER (NETWORK FILE SYSTEM) ON REDHAT/CENTOS/FEDORA

Setup NFS Server in Linux

In this artical we are going to learn how to configure NFS Server (Network File System) as well as on Client in Linux. NFS Stands for ( Network File System ) also known as Linux File Server is a Network service in Linux used to share the File System/Directory of the Server to Users/clients on the network like Map Drive in Windows Systems and user can access and store data on Central Location but This can be Possible only between Linux to Linux Systems or between Linux to Unix (Such as Vmware, Solaris Operating Systems) Systems. We also can access the share drive in Windows System but through Samba. The Port Number of NFS is 2049.

This NFS Protocol was first introduced by Sun Microsystem in 1984. The versions of NFS has been released over the time i.e. NFS, NFSv2, NFSv3, NFSv4.

Let’s take a Scenario like In a Organisation we have some data which suppose to be access by all users, in that case instead of go and copy the data in all users system manually, we can setup NFS Server and put the data on the exported Directory then Share the Directory to all users to access the data Centrally. Thin Client users also can use NFS to store their data centrally and their login Profiles can be stored in NFS shared drive as thin client doesn’t have Hardisk.

NFS DAEMONS

NFS Server uses several daemons to make available the exported directory from server to client computers over TCP/IP network and performs so many other tasks such as mount and unmount exported file system, disk quota management, map client requests to NFS daemons and So on. The daemons are listed below :

• rpc.nfsd
• rpc.mountd
• rpc.portmapper
• rpc.rquotad
• rpc.statd
• rpc.lockd

MY SCENARIO

NFS Server :-

Hostname – Computer1
IP Address :- 192.168.0.106
Operating System – Linux

NFS Client :-

Hostname – Computer2
IP Address – 192.168.0.105
Operating System – Linux

As per above scenario we have two Computers i.e. Computer1 & Computer2 out of which Computer1 is going to be configured as a NFS Server and Computer2 as a NFS Client and Both computers are in same network where “Computer1 has IP Address 192.168.0.106” and “Computer2 has IP Address 192.168.0.105”

Читайте также:  Linux dhcp option 138

So let’s have look at steps of NFS Server Configuration and Client Side configuration in Linux.

NFS Server Side Configuration :

Step: 1 Install Required Packages

We need to install below mentioned Packages to Configure NFS.

nfs-utils.xxx.xxx.rpm
nfs-utils-lib.xxx.xxx.rpm
portmap.xxx.xxx.rpm
system-config-nfs.xxx.xxx.rpm (For Graphical configuration of NFS)

Install the above Packages by below command.

As we can see above we have installed all required packages for NFS, Now let’s go ahead and configure the NFS from Server Side.

Step:2 Configure NFS in “/etc/exports”

Here we are going to Create three Directories named “applications” , “common” and “backup“in “/” and create some files in all created directories, Follow the below steps.

# mkdir /applications # touch /applications/doc.txt # ls /applications/ doc1.txt doc2.txt doc3.txt doc4.txt doc5.txt # mkdir /common # touch /common/data.txt # ls /common/ data1.txt data2.txt data3.txt data4.txt data5.txt # mkdir /backup # touch /backup/test.txt # ls /backup/ test1.txt test2.txt test3.txt test4.txt test5.txt

I have created three directories to export all them in /etc/exports file so that I can explain at least three different examples.Now give Full access to all created directories by using chmod command as shown below.

# chmod 777 /applications/ /common/ /backup/ # Output: drwxrwxrwx 2 root root 4096 Dec 25 00:05 applications drwxrwxrwx 2 root root 4096 Dec 25 00:08 backup drwxrwxrwx 2 root root 4096 Dec 25 00:07 common

Now let’s configure the main configuration file i.e. “/etc/exports”.

By Default the “/etc/exports” file would be empty, Now here we will export our “/applications“, “/common” and “/backup” directories by edit the “/etc/exports” Configuration file, Follow the below Steps.

Format of an entry in the “/etc/exports” file shown below.

directory-pathname host-designation(options)

Example: 1

Here I am going to export the Directory /common with Everyone (all Users/Networks) with Read/Write (i.e. rw) and Synchronize access (i.e. sync), Follow the below steps.

# nano /etc/common /applications *(rw,sync)

Note: Here “*” means we have allowed the “/common” directory with Everyone So that any can access the directory and can store their data in this.

Example: 2

To share the directory with a Particular user you have just mention the IP Address of that System, Here we have shared the /applications Directory with a single system with IP Address 192.168.0.10 with Read Only (i.e. ro), and Synchronize Permissions (i.e. sync).

# nano /etc/applications /applications 192.168.0.10(ro,sync)

Example: 3

Below scenarios configured to share the directory with all Hosts that is comes under network 192.168.0.0 with Netmask 255.255.255.0. with Read Only and Synchronize Permissions.

# nano /etc/backup /applications 192.168.0.0/24(ro,sync)

NFS Basic Permission Options

ro – Allows only Read-Only Access
rw – Allows Read/Write Access
sync – Performs all writes when Requested.
async – Performs all writes when server is busy.

Now save the Configuration File then run the below command to activate the Export List.

# exportfs -rav exporting *:/applications
  • r – Re-Export all Directories
  • a Export or unexport all Directories
  • v – When Exporting and Unexporting shows whats going on.
Читайте также:  Линукс как откатить систему

exportfs” command used to maintain list of NFS exported file systems.

Now Start the nfs and portmap service by using below command.

# /etc/init.d/nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS daemon: [ OK ] Starting NFS mountd: [ OK ] # /etc/init.d/portmap start Starting portmap: [ OK ]

Start all the services on startup by using below command.

# chkconfig --level 35 nfs on # chkconfig --level 35 portmap on

Now we have Done all required configurations from Server end, Now It’s time to check from NFS Client Side i.e. on Computer2.

Step:3 Configure NFS from Client Side

So Let’s have a look at the steps to configure NFS Client.

Before mount the NFS Server share directories from client side let’s check which directories been shared from Server Side by using below command.

# showmount -e 192.168.0.106 Export list for 192.168.0.106: /applications *


Note: Mention the IP Address of the Server.

1. Mount NFS shares manually :-

NFS manually mounting command format shown below.


mount -t :

So to mount the Exported NFS directory from client side just created a directory and run the below command, Here I have created a directory /nfs to mount the shraed directory “applications“.

# mount -t nfs 192.168.0.106:/applications/ /nfs/

: Version of nfs you are using For Example NFS, NFS2, NFS3, NFS4.
: IP Address of the NFS Server.
: Exported Directory Path from Server.
: Directory Path where you are going to mount the NFS exported directory.

After mounting the file system use the below command to refresh the mount table by using command mount -a and then run the command df -h to check the mounted file systems.

# mount -a # To Refresh the Mount Table # df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 18G 3.1G 14G 19% / tmpfs 252M 0 252M 0% /dev/shm 192.168.0.106:/applications/ 18G 3.1G 14G 19% /nfs

Replace the with the remote host(IP Address of the NFS Server), with the remote directory being mounted, replace with the local directory where the remote file system is to be mounted.

Follow the below Steps to mount the NFS share Permanently in /etc/fstab.

2. Mount NFS shares in “/etc/fstab”

To mount the NFS exported directory permanently we need to enter it in /etc/fstab file, So follow the below step to do the same.
Entry for /etc/fstab Pattern shown below.

: nfs 0 0

192.168.0.106:/applications /nfs nfs defaults 0 0

HOW TO CONFIGURE NFS (NETWORK FILE SYSTEM) SERVER ON REDHAT/CENTOS



Replace the with the IP Address of the Server.

Replace the with the directory path exported by NFS Server.

Replace with the local directory where the remote file system is to be mounted.

Now for just create a File or Directory on exported directory from Server end and go and check from client side you will find the File/Directory.

If you found this Article useful then Like it, Share it, Subscribe our Site for more Linux Tutorials OR If you have any thing to say then feel free to Comment on Comment Box below.

Источник

Оцените статью
Adblock
detector