Archive for January, 2016

FTP server Setup

Posted: January 14, 2016 in Uncategorized

FTP server IP:

FTP client server IP:

Step 1: Install vsftp package

[root@ ~]# yum install vsftpd

Step 2: Start the service

[root@ ~]# /etc/init.d/vsftpd start

Step 3:  Need to edit the vsftpd configuration file.  

Before the edit, take the backup of existed file to any other location on the server

[root@ ~]# cp /etc/vsftpd/vsftpd.conf /tmp/vsftpd.conf

Now edit the file,

[root@ ~]# vi /etc/vsftpd/vsftpd.conf

Change the file as follows,

change the parameter YES to No for anonymous_enable  as below


Uncomment the below lines 


Add at the end of this file 

Save the file and exit.

Step 4:   Create FTP user

[root@ ~]# useradd ftpuser

Step 5: Create a password for ftp user

[root@ ~]# passwd ftpuser

Step 6: Restart the service

[root@ ~]# /etc/init.d/vsftpd restart

Step 7: Try to connect to FTP server from other Server. 

[root@ ~]# ftp 21
Connected to .
220 (vsFTPd 2.2.2)
Name ( ftpuser
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

Common Errors while connecting to FTP server we may encounter

ftp: connect: No route to host

ftp: connect: Connection refused

500 OOPS: failed to open xferlog log file:/var/log/xferlog
500 OOPS: cannot change directory:/foo
500 OOPS: Connection closed by remote host.
500 OOPS: failed to open xferlog log file:/var/log/xferlog
553 could not create file error

These errors are just because of selinux enabled on FTP server.

There 2 ways to resolve this.

  1. Allow selinux to proceed with FTP
  2. Disable selinux
  1. Allow selinux to proceed with FTP 

Allow the FTP Without disabling selinux 

[root@www ~]# setsebool -P /home/ftpuser on

2. Disable selinux

To disable the selinux temporary, follow below steps

Disabling of SELINUX

Step 1: Open the selinux configuration file on FTP server

[root@ ~]# vi /etc/selinux/config

Comment below line


and add below line


Save the file and exit

Step 2: Disable selinux

[root@ ~]# setenforce 0

Now try again to connect the server.

Note: To disable the selinux permanently we need to restart server



NFS: Network File system, which is about sharing of one server’s file system on other server.

Simply mounting of one server’s directory on other server as its local directory


NFS Server:

Client Server:

Serve side configuration:

Step 1:  Install the nfs and rpc (remote procedure call) packages

[root@ ~]# yum install nfs-utils nfs-utils-lib

Step 2: Start RPC bind services

[root@ ~]# /etc/init.d/rpcbind start

Step 3: Start NFS services

[root@ ~]#  /etc/init.d/nfs start

Note: If we start NFS before starting of RPC bind service, it wont start and it triggers below error.

[root@ ~]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
Starting NFS mountd: [FAILED]
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: unable to set any sockets for nfsd

Step 4: Add the rpcbind and nfs services at bootup

[root@ ~]# chkconfig rpcbind on

[root@ ~]# chkconfig nfs on

Step 5: Now create a directory which you want to share/mount on client server

[root@ ~]# mkdir -p /mnt/nfsshare

Step 6: Now add the shared directory on NFS main configuration file /etc/exports. 

[root@ ~]# vi /etc/exports


Here, is the client server.

Step 7: Now export as follows to effect the configuration

[root@ ~]# exportfs -a

Step 8: Restart the rpcbind and nfs services 

[root@ ~]# /etc/init.d/rpcbind restart

[root@ ~]# /etc/init.d/nfs restart

Client Side:

Make sure the NFS port 111 is allowed for client server, or else stop IPtables. But stopping of IPtables is not a good practice.

Step 9: Mount the shared directory which is exported on NFS server. 

[root@ ~]# mount -t nfs /mnt/nfsshare/


Step 10: Now check the mounted partition with below command

[root@ ~]# df -h


Step 9 is for only temporary mount. If you reboot the system it goes off. So, to mount it back automatically after the reboot also, then follow up below steps.

Step 11:  Open the fstab file and add below line 

[root@ ~]# vi /etc/fstab /mnt/nfsshare/         nfs     defaults        0 0

Save the file and exit

Now test the fstab configuration properly before reboot the server. Cause if there is any wrong entry, then the server will not start back

Try to unmount the share and mount it back as below

[root@ ~]#  umount

[root@ ~]# mount -a

If it mounts back properly then fstab works properly after the reboot.

Test with reboot now.





Samba Configuration in Linux

Posted: January 13, 2016 in Uncategorized

This document is all about samba installation and configuration in Ubuntu.

Hopefully it works on Redhat/CentOS flavored OS as well.

Step 1: Install the samba package

apt-get install samba

Step 2: Now add the user useradd sambauser, No need to create password as this is not to be ssh user. 

useradd sambauser

Step 3: Now create the password for the user created above

smbpasswd -a sambauser

Step 4: Create a shared directory

mkdir /home/sambauser/shared -p

Step 5: Change the ownership of the directory

chown -R sambauser:sambauser /home/sambauser/shared

Step 6: Give the permissions to the directory

chmod -R 775 /home/sambauser/shared

Step 7: Take the backup of samba configuration file before we start editing that.

cp /etc/samba/smb.conf /tmp/

Step 8: Open the smb.conf file and add the below lines

vi /etc/samba/smb.conf


path = /home/sambauser/shared

valid users = sambauser

writable = yes

read only = no

In this case, only sambauser can access this directory( /home/sambauser/shared) no other can’t access unless enter the correct credentials of this directory

The above is for single user and single directory.  We can add additional users also to access one directory by 2 or more users


path = /home/sambauser/shared

valid users = sambauser,user1,user2

writable = yes

read only = no

We can add one or more directories to provide the privileges to one or more user as below…


path = /home/rajesh

valid users = rajesh

writable = yes

read only = no

As this way, we can create multiple directories and setup their own credentials

But, username and smbpassword have to be created to work on…