Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

Friday, February 10, 2017

How to Create Local YUM Repository on CentOS 7 / RHEL 7

In this post, I describes how to setup a local Yum repository on CentOS 7 & RHEL 7 server operating system.

The local YUM repository is the most significant way to perform any type of package installation without any internet connection. If you have to install software, security updates and fixes often in multiple systems in your local network, then having a local repository is an efficient way. 

All required packages are downloaded over the fast LAN connection from your local server, so that it will save your Internet bandwidth and reduces your annual cost of Internet.

Now, please find the step by step method to create a YUM repository on RHEL 7 & CentOS 7.

Mount the Local Media:

In this step we mount our CentOS 7 / RHEL 7 installation DVD. For example, let us mount the installation media on /mnt directory.

#mount -o loop /dev/cdrom /mnt

In my Linux machine i will insert the ISO on cdrom and mount it on /mnt directory.

Copy or Extract the Media:

In this step, we will extract or copy iso files to local machine. For this work we will create a one mount point directory and copy all the packages files from /mnt.

#mkdir /centos
#cp -rvf /mnt/* /centos

So all the packages are copied on the "/centos" directory.

Install repository packages:

In this step, we will create repository but before this we need to install the "createrepo" rpm on the YUM server.

For createrepo, you need to install some dependency rpm which are listed in "Packages" folder.

#rpm -ivh libxml2-python-2.9.1-5.el7_0.1.x86_64.rpm
#rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
#rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
#rpm -ivh createrepo-0.9.9-23.el7.noarch.rpm

Once these required packages is installed we create the repo using createrepo command.

#createrepo -v /centos/Packages

Remove the Online Repository:

Please remove the old repository from /etc/yum.repos.d directory. In this directory all the default local centOS / RHEL repository are exist.

#rm -rf /etc/yum.repos.d/*

Create Local Repository:

In this step we will create the local repostiory which is always kept as a local. Using this local repo we can install all the packages and their dependency.

#vi /etc/yum.repos.d/local.repo

[Packages]
baseurl=file:///centos/Packages
gpgcheck=0
enable=1

After save the file your local.repo repository has been created. In next step we will enable it.

Enable Local Repository:

After successfully creation of YUM repository we will enable it.

#yum clean all
#yum repolist all

Using this repolist command you can check the newly created and existing repository on the server. After that you can easily install the pacakges using YUM in RHEL 7 & CentOS 7.

How to setup NFS Server on CentOS 7 / RHEL 7

In this post, I would explain you , how to setup NFS server on CentOS 7 & RHEL 7. This step by step installation and configuration method of NFS server is work in Fedora 22 version also.

Network File System is used for to share files and folders between Linux / Unix systems. NFS enables you to mount a remote share locally as well as it allows to have updated files across the share.

Before starting the setup method , we need to understand which service and files are used for NFS setup.

Please find the below services which are used for NFS setup. its must be always runs on operating system.

rpcbind service: The rpcbind server is used to converts RPC program numbers into universal addresses.

nfs-server service:  Its enables the NFS clients to access NFS shares.

nfs-lock / rpc-statd service: these are the recovery services when an NFS server crashes and reboots.

nfs-idmap service: It translates user and group ids into names, and to translate user and group names
into ids.

The mail configuration file for NFS server and client is "/etc/exports". It controls which file systems are exported to remote hosts and specifies options.

Now, we will start the step by step process for setup of NFS server on CentOS 7 / RHEL 7.

NFS Server Setup:

1. First we need to install the NFS packages on the server where we want to setup of NFS server. We can install the required NFS packages using YUM.

#yum install nfs-utils libnfsidmap

It's installed all the required packages on NFS server.

2. Once the packages are installed we will enable and start all the above services which we explain in my post.

#systemctl enable rpcbind
#systemctl enable nfs-server
#systemctl start rpcbind
#systemctl start nfs-server
#systemctl start rpc-statd
#systemctl start nfs-idmapd

You can check the status of all these service by using this command "systemctl status service_name" to ensure all are working fine.

3. Now we will created the shared directory which we want to share for client.

#mkdir /backup
#chmod -R 777 /backup

We can change the permission of NFS folder as per your requirement. In my case I'll provide the read write permession to all NFS client on this shared folder, so they can easily copy and remove the files. Ideally for security purpose we never provide 777 permission.

4. In this step we will make an entry of shared folder and client information , what permission we give to client to access the folder and which client can access the NFS shared folder.

# vi /etc/exports

/backup 10.135.0.27(rw,sync,no_root_squash)

In above command output, you can see the "/backup" is shared NFS server folder and "10.135.0.27" user client have rights to access this shared folder.

Also in brackets if you see the permission parameter which is very important when we setup the NFS setup. Please find the small idea about these permission parameteres.

rw: Writable permission to shared folder

sync:  all changes to the according filesystem are immediately flushed to disk.

no_root_squash: By default, any file request made by user root on the client machine is treated as by user nobody on the server. If no_root_squash is selected, then root on the client machine will have the same level of access to the files on the system as root on the server

5. Now, we will export the shared directories using following command.

# exportfs -r

We can use other syntax as well for this, which is listed below.

exportfs -v : Displays a list of shares files and export options on a server
exportfs -a : Exports all directories listed in /etc/exports
exportfs -u : Unexport one or more directories
exportfs -r : Reexport all directories after modifying /etc/exports

6. Now in above step 5, we configured and installed the NFS server but if firewall is running on your machine then we need to add NFS services in firewall as well.

#firewall-cmd --permanent --zone public --add-service mountd
#firewall-cmd --permanent --zone public --add-service rpc-bind
#firewall-cmd --permanent --zone public --add-service nfs
#firewall-cmd --reload

NFS Client Steup:

1. Once we installed the NFS server, now we will mount the remote file system on NFS client machine. So for this , on client machine we will install the same NFS packages which we installed during NFS server setup.

#yum install nfs-utils libnfsidmap

It's installed all the required packages on NFS client. Once the packages is installed on NFS client machine we will start the "rpcbind" services on client machine.

#systemctl enable rpcbind
#systemctl start rpcbind

2. Now we will mount the NFS shared folder on client machine but before doing that we will check on client machine which NFS server is available.


client# showmount -e 10.135.0.27    (10.135.0.2 is myserver machine IP)

Export list for 10.135.0.27:
/backup      10.135.0.2

So you can able to see on client machine our NFS shared folder is available on 10.135.0.27 NFS server. 

3. In this step , now we will mount this NFS shared folder on NFS client machine, for this we will create a mount point on client machine where we mount the server shared folder.

client# mkdir /mnt/backup
client#mount 10.135.0.27:/backup /mnt/backup

So you can check the mount folder using "df -h" command.

4. To make a permanent entry on client machine so that once you take a reboot of client machine , the shared folder is not umount.

client# vi /etc/fstab
10.135.0.27:/backup/ /mnt/backup nfs rw,sync,hard,intr 0 0

Please make an entry permanent on client machine and save it and take a restart of machine , after reboot once you login you will see the shared folder still available on the client machine.

5. For testing of shared folder, you can create a one file on client machine then check on the server this newly created file is shown on the server folder also.

So, using all these steps you can easily setup the NFS server and client on your machine.

Monday, February 6, 2017

How to create local zone in Solaris 10

Hello Friends,

In this post, I will explain you how to create a new local zone on Sun Solaris operating system. Before describe the step by step installation and configuration method we need to understand what is zone and where it is used.

Basically Zone is a virtual operating system environment created within a single instance of the Solaris operating system. The mail goal of this technology is efficient resource utilization. We can create multiple zone on one Solaris operating system.
Solaris 10's zone partitioning technology can be used to create local zones that behave like virtual servers. All local zones are controlled from the system's global zone. Processes running in a zone are completely isolated from the rest of the system.


Note- That processes running in a local zone can be monitored from global zone but the processes running in a global zone or even in another local zone cannot be monitored from a local zone.

Global Zone: When we install the Solaris 10 operating system, a global zone gets installed automatically, and the core operating system runs under global zone as well as all the local zone are also runs on same global zone. Using "zoneadm" command we can check list of all configured zones which are running on Solaris operating system.


# zoneadm list -v

  ID NAME             STATUS         PATH
   0 global           running        /

Step by step method to create a Local Zone:

When we create a local Solaris zone on global zone , we have to complete some prerequisite before installing the zone.

Prerequisites:  A lot of disk space is required to installed the newly zone. It needs at least 3 GB space to copy the essentials files to the local zone. In my case I normally use 10 GB free disk space to installed the local zone. Also for configuration we required a dedicated IP for network connectivity.

1. First we will check the disk space and network configuration by using running below command.

[sun]# df -h /
 Filesystem             size   used  avail capacity  Mounted on
 /dev/dsk/c1t1d0s0       50G    22G   28G    46%    /

[sun] # ifconfig -a
 lo0: flags=2001000849 mtu 8232 index 1   
 inet 127.0.0.1 netmask ff000000  
 em0: flags=1000843 mtu 1500 index 2   
 inet 10.135.0.23 netmask fffffe00 broadcast 10.135.0.255

Here, if you see the "df -h" command output we can found that the disk "c1t1d0s0" is mounted on the root file system. Currently the total disk space size of root partition is approx 50 GB, as we required 10 GB free space for installation and configuration of local zone, so free space on root partition is sufficient for zone installation.

In "ifconfig" command output we can able to see the the ip address of global zone.

2. As we have sufficient space on the server so we can go ahead for local zone installation. First we need to create a directory where we want to install the zone. All the files is keep in this folder only.

[sun]# mkdir /zones

3. Next step is to define/create the zone root. This is the path to zone's root directory that is relative to the global zone's root directory. Zone root must be owned by root user with the mode 700. This will be used in setting the zonepath property, during the zone creation process.

[sun]# cd /zones[sun]# mkdir sun01[sun]# chmod -R 775 sun01[sun]# ls -l
 total 2
 drwx------   2 root     root         512 Feb 06 12:46 sun01

In a Sparse Root Zone, the directories /usr, /sbin, /lib and /platform will be mounted as loopback file systems. That is, although all those directories appear as normal directories under the sparse root zone, they will be mounted as read-only file systems. Any change to those directories in the global zone can be seen from the sparse root zone.


However if you need the ability to write into any of those directories listed above, you may need to configure a Whole Root Zone. For example, softwares like ClearCase need write permissions to /usr directory. In that case configuring a Whole Root Zone is the way to go. The steps for creating and configuring a new 'Whole Root' local zone are as follows:

4. In this step we will create & configure a new 'Sparse Root' local zone, with root privileges. For configuration of installed zone we will used "zonecfg" command. It is most widely used command for zone configuration.

[sun]# zonecfg -z sun01sun01: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:
sun01> create
zonecfg:
sun01> set zonepath=/zones/sun01
zonecfg:
sun01> set autoboot=true
zonecfg:
sun01> add net
zonecfg:
sun01:net> set physical=em0
zonecfg:
sun01:net> set address=10.135.0.24
zonecfg:
sun01:net> end
zonecfg:
sun01> add fs
zonecfg:
sun01:fs> set dir=/repo2
zonecfg:
sun01:fs> set special=/dev/dsk/c1t20d0s1
zonecfg:
sun01:fs> set raw=/dev/rdsk/c1t20d0s1
zonecfg:
sun01:fs> set type=ufs
zonecfg:
sun01:fs> set options noforcedirectio
zonecfg:
sun01:fs> end
zonecfg:
sun01> add inherit-pkg-dir
zonecfg:
sun01:inherit-pkg-dir> set dir=/opt/csw
zonecfg:
sun01:inherit-pkg-dir> end
zonecfg:
sun01> info
zonepath: /zones/
sun01
autoboot: true
pool:
inherit-pkg-dir:   dir: /lib
inherit-pkg-dir:   dir: /platform
inherit-pkg-dir:   dir: /sbin
inherit-pkg-dir:   dir: /usr
inherit-pkg-dir:   dir: /opt/csw
net: address: 
10.135.0.24
physical: 
em0
zonecfg:appserv> verify
zonecfg:appserv> commit
zonecfg:appserv> exit

4. Secondly we will create & configure a new 'Whole Root' local zone, with root privileges. In this again we will used the same zone name "sun01".

[sun]zonecfg -z sun01
sun01: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:
sun01> create
zonecfg:
sun01> set zonepath=/zones/sun01
zonecfg:
sun01> set autoboot=true
zonecfg:
sun01> add net
zonecfg:
sun01:net> set physical=em0
zonecfg:
sun01:net> set address=10.135.0.24
zonecfg:
sun01:net> end
zonecfg:
sun01> add inherit-pkg-dir
zonecfg:sun01:inherit-pkg-dir> set dir=/opt/csw
zonecfg:
sun01:inherit-pkg-dir> end
zonecfg:
sun01> remove inherit-pkg-dir dir=/usr
zonecfg:
sun01> remove inherit-pkg-dir dir=/sbin
zonecfg:
sun01> remove inherit-pkg-dir dir=/lib
zonecfg:
sun01> remove inherit-pkg-dir dir=/platform
zonecfg:
sun01> info
zonepath: /zones/
sun01
autoboot: true
pool:
inherit-pkg-dir:  dir: /opt/csw
net:  address: 
10.135.0.24
physical: 
em0
zonecfg:appserv> verify
zonecfg:appserv> commit
zonecfg:appserv> exit

Brief explanation of the properties that we added:

\* zonepath=/zones/sun01
Local zone's root directory, relative to global zone's root directory. ie., local zone will have all the bin, lib, usr, dev, net, etc, var, opt etc., directories physically under /zones/appserver directory

\* autoboot=true

boot this zone automatically when the global zone is booted

\* physical=em0

em0 card is used for the physical interface

\* address=10.135.0.24
10.135.0.24 is the IP address. It must have all necessary DNS entries

The whole add fs section adds the file system to the zone. In this example, the file system that is being exported to the zone is an existing UFS file system.

\* set dir=/repo2

/repo2 is the mount point in the local zone

\* set special=/dev/dsk/
c1t20d0s1 set raw=/dev/rdsk/c1t20d0s1

Grant access to the block (/dev/dsk/c1t20d0s1) and raw (/dev/rdsk/c1t20d0s1) devices so the file system can be mounted in the non-global zone. Make sure the block device is not mounted anywhere right before installing the non-global zone. Otherwise, the zone installation may fail with ERROR: file system check </usr/lib/fs/ufs/fsck> of </dev/rdsk/c2t40d1s6> failed: exit status <33>: run fsck manually. In that case, unmount the file system that is being exported, uninstall the partially installed zone (zoneadm -z <zone> uninstall) then install the zone from the scratch (no need to re-configure the zone, just do a re-install).

\* set type=ufs

The file system is of type UFS

\* set options noforcedirectio

Mount the file system with the option redirection.

\* dir=/opt/csw

Read-only path, will be lofs'd (loop back mounted) from global zone.

Note: it works for sparse root zone only -- whole root zone cannot have any shared file systems

Zonecfg commands verify and commit, verifies and commits the zone configuration for the zone, respectively. Note that it is not necessary to commit the zone configuration; it will be done automatically when we exit from zonecfg tool. info displays information about the current configuration

5. Now we will check the current state of the newly created/configured zone, for this we will use zoneadm command

[sun]# zoneadm list -cv
   ID NAME             STATUS         PATH
    0 global           running        /
    - sun01          configured     /zones/sun01

6. Next step is to install the configured zone "sun01". It takes a while to install the necessary packages
  
[sun]# zoneadm -z sun01 install 

The file contains a log of the zone installation. Once the zone installation is completed you can able to see the message on the installation window, all the required packages get installed during this installation.

7. Now verify the state of the sun01 zone

[sun]# zoneadm list -cv
   ID NAME             STATUS         PATH
    0 global           running        /
    - sun01          installed      /zones/sun01

8. In final step we will boot up the sun01 zone.

[sun]# zoneadm -z sun01 boot
zoneadm: zone 'sun01': WARNING: em0:1: no matching subnet found in netmasks(4) for 
10.135.0.24,using default of  255.0.0.0.

[sun]# zoneadm list -cv
   ID NAME             STATUS         PATH
    0 global           running        /
    1 sun01          running        /zones/sun01


9. Login to the Zone {console} and performing the internal zone configuration. zlogin utility can be used to login to a zone with -C option of zlogin can be used to log in to the Zone console.

[sun]# zlogin -C sun01

9.1. It is asking for some option when we run the above command. for language option you need to select the "English" option. Most probably it is "0" option in the menu.

9.2  After language option it is asking for locale. You need to set "English (c-7-bit ASCII) locale for Solaris 10 zone.

9.3  Enter the host name which identifies this system on the network.  The name must be unique within your domain; creating a duplicate host name will cause problems on the network after you install Solaris. A host name must have at least one character; it can contain letters, digits, and minus signs (-).

10. Now simply login to the newly created zone, just like connecting to any other system in the network.

Note: You can create another local zone using this same method. In this blog we get the idea how we will create the new zone on Solaris 10. The installation method on other Solaris operating system is different. This post is used for only zone creation on Solaris 10 only.

Friday, February 3, 2017

How to Shrink or reduce size of LVM partitons in RHEL/CentOS

LVM (Logical Volume Manager) is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes.

LVM allows users to create partitions from more than one disk and allows them to extend the filesystem size online within few seconds.

In this post, we will see how we can shrink the size of an LVM partition without losing data.

On my linux virtual machine, the VG name is “rootvg” and LV name is “Vibhor” which has 60 GB size. I want to reduce the LV size to 4GB. Please note down the following points before proceeding with the shrinking of filesystem.

  • Make sure the current disk usage of the filesystem is less than the size to which you are going to reduce the logical volume.
  • Always take a backup of filesystem data before doing any size change in LVM as a simple mistake in command can cause filesystem corruption and hence loss of data.

Now, please find the below steps which we need to follow for reduce or shrink the partition size.

Umount the filesystem:

We will check the file system through fsck command but before running fsck on the filesystem, it should be unmounted.You can unmount the filesystem “/vibhor” as follows.

#umount /Vibhor

Performing filesystem check:
Before proceeding with reducing filesystem, “fsck” should be done in order to avoid inconsistency of filesystem data.
#e2fsck –f /dev/mapper/rootvg/rootvg_vibhor

Resizing filesystem:

Now, we will reducing the size of the Logical Volume, but before we need to reduce the filesystem in it. The command “resize2fs” can be used for this as follows.

#resize2fs –p /dev/mapper/rootvg/rootvg_vibhor 4G

This will decrease or shrink the filesystem size to 4GB.

Reducing the LV size:

After reduce or shrink the filesystem, we can reducing the LV as given below.

#lvreduce –L 4G /dev/mapper/rootvg/rootvg_vibhor

This will reduce the logical volume size to 4 GB. Now I will mount the filesystem again and check it using the command “df –h”. the file system has reduced to 4 GB without losing any data.

#mount /Vibhor
#df –h

This output will show you the reduce filesystem size.

Thursday, February 2, 2017

How to stop USB Mass Storage device in RHEL/CentOS

Hello Friends,

I’d like to disable all USB devices connected to our Red Hat Linux based workstations. I’d like to disable USB flash or hard drives, which users can use with physical access to a system to quickly copy sensitive data from it.

How do I disable USB device support under RHEL/CentOS workstation operating systems. The USB storage drive automatically detects USB flash or hard drives. You can easily force and disable USB storage devices under any Linux distribution.

The modprobe program used for automatic kernel module loading and can be configured to not load the USB storage driver upon demand. This will prevent the modprobe program from loading the usb-storage module, but will not prevent root (or another program) from using the insmod program to load the module manually.


In linux it’s even more easily done, by unloading the usb_storage module:

for disable the usb storage run the below command :-

# modprobe -r usb_storage

for enable the usb storage run the below command :-

# modprobe -i usb_storage

##############################################################################

The easiest way to disable usb storage device in linux is create following file And add following line inside the file

# touch /etc/modprobe.d/no-usb


install usb-storage /bin/true

##############################################################################

Monday, January 9, 2017

Solaris local zone not booting "zoneadm: zone 'zone_name': call to zoneadmd failed"

Hello Friends,

In this post, I will explain you the one important issue which we generally facing while we boot the local Solaris zone on the Sun Solaris operating system.

When you are trying to boot the local zone from your Global zone, you encounter the below error message as mentioned below.

Error: zoneadm: zone 'sunz1': "/usr/lib/fs/zfs/mount das/sunz1/export /zones/sunz1/root/export" failed with exit code 1
zoneadm: zone 'sunz1': call to zoneadmd failed.



Solution: For such type of issue is normally related to NFS. When you boot the server, it will start NFS service before start zones. so, as NFS is started, FS /zones/sunz1/root/export  is already in use so global zone doesn't want to start a zone with a FS already in use by a process. You can check which file system is mounted on your global zone as describe below.

sun:/> cat /etc/dfs/dfstab

#       Place share(1M) commands here for automatic execution
#       on entering init state 3.
#
#       Issue the command 'svcadm enable network/nfs/server' to
#       run the NFS daemon processes and the share commands, after adding
#       the very first entry to this file.
#
#       share [-F fstype] [ -o options] [-d "<text>"] <pathname> [resource]
#       .e.g,
#       share  -F nfs  -o rw=engineering  -d "home dirs"  /export/home
share -F nfs -o rw=sun.vibhor.com:sunz1.vibhor.com /zones/sunz2/root/export

In above output you can see one folder is NFS mounted on the two local zone.

2. Now for resolving the issue , please stop the NFS service, boot the zone and restart the service.

sun:/> svcs status nfs/server
STATE          STIME    FMRI
online          5:13:30 svc:/network/nfs/status:default
online          5:13:36 svc:/network/nfs/server:default

Currently NFS server service is online on the Global zone, so using below command we will disable the service.

sun:/> svcadm disable nfs/server

sun:/> svcs status nfs/server
STATE          STIME    FMRI
disabled        5:21:57 svc:/network/nfs/server:default
online          5:13:30 svc:/network/nfs/status:default

3. Now we will boot the local zone again and see the existing error occur or not.

sun:/> zoneadm -z sunz1 boot

Note: Now your local zone is boot without any error. So normally this problem occur when NFS is mounted on the server.

4. Once the issue has been resolved you may enable the NFS server services.

sun:/> svcadm enable nfs/server

sun:/> svcadm restart nfs/server











If you see the my screen output images the whole method is describe step by step. If you facing still issue please comment on this post.

Thursday, January 5, 2017

How to Set a Solaris 11 Machine's NIS Domain Name

Hello Friends,

Hope you are doing well at your end. In this post, I will explain to you, how to set a Solaris machine NIS domain name on Solaris 11 operatings system. 

If domainname command not showing any output then you need to check either defaultdomain or NIS domain is configured or not.

Steps which we need to follow to set the NIS domain name as describe below.

1. Please run  "cat /etc/defaultdomain" command and check the output that domain is set or not.

    #domainname

The above command shows you the current domain name on the server, if no output is display you need to set the domain by below command.

   #domainname UNIX

Run the below command to check the output again.

   #domainname
   UNIX

You can see the output. All the above command is used for checking and setting the domain name on the Solaris operating server.

2. If you want to set the domain using NIS, then first please check the NIS/DOMAIN service is running or not

root@sun:~# svcs status nis/domain
STATE          STIME    FMRI
disabled       18:20:04 svc:/network/nis/domain:default

In my Solaris machine, currently NIS domain services is stop, we will start it later once we will configured the NIS domain name on the Solaris server.

3. Now you need to configure the NIS domain for your machine ( in my case - UNIX is my domain name)

root@sun:~# svccfg -s svc:/network/nis/domain setprop config/domainname = UNIX

If you see the above command, "svccfg" command is used to configure the domain and set the proper properties.

4. In the final step once the configuration has been completed you need to refresh & enable the NIS domain service again.

root@sun:~# svccfg -s nis/domain:default refresh
root@sun:~# svcadm enable nis/domain

You can check the NIS domain service status as describe in step 2. 

5. Now you can verify the domain name using below command so we can ensure that the NIS domain name has been set successfully. 

root@sun:~# domainname
UNIX
The above command output show "UNIX" domain name which we set during the configuration, so using these above method we can easily set the NIS domain name on the Solaris operating server.

I would request to you please comment on the post if you are facing any issue during setting the NIS domain name on Solaris platform. 

Monday, January 2, 2017

Step by step installation method of FTP server in linux

In this post, I will guide to you how to install or create the ftp server in Linux operating system.

Generally FTP server is used to upload or download the files from server machine to client machine. FTP works on TCP 20/21 protocol, TCP port 20 is used for uploading and TCP 21 port is used for downloading purpose.

In this article, I will explain step by step method of ftp server creation and configuration.

Step by step method of FTP server installation and configuration:

1. In the initial step , we will install the all required rpm or packages on the Linux server using "YUM" utility.

#yum  install  vsftpd*

If you have source rpm packages then you can install it. In our case we will install the rpm with yum. Using above command all the ftp packages and their dependency are installed.

2. Once the required packages has been installed successfully on the Linux server, we will start the ftp services on the server.

#service  vsftpd  start

Once the service start successfully we will make permanent it so after reboot of server it would be enable always.

#chkconfig vsftpd on

3. Now, to check the location of ftp server file which we upload or create after ftp server installation.

#cd /var/ftp/pub
#ls

And check the file which you have created after ftp server installation. If you find your created file here then you can ensure your ftp server has been installed successfully on Linux server.

4. Now for checking the ftp server using login in it.

# ftp  Server IP address  ( In my case server ip is 192.168.1.240)
Name(192.168.1.240:root):anonymous
Passwd   (press enter)   --- by defult anonymous password is blank

ftp>   (It will show you have successfully enter in ftp server)
ftp> ls
pub ( will see this directory in ftp location)
ftp>cd  pub
pub> mkdir  vibhor
pub> permission denied  (error getting)

5. To give the permission to make a directory in pub ,changes in this file

#vi  /etc/vsftpd/vsftpd.conf

Uncomment all these below lines
anonymous_enable=yes
anon_upload_enable=yes
anon_mkdir_write_enable=yes
save the file

6. Now we will take a restart of the ftp services again. You can follow the step 2 to take a restart of ftp services.

7. In this step we will provide the permission to pub folder so that client user can read/write the file and folder in the default direcoty.

#chmod 777  /var/ftp/pub

In my case I will give the full permission to pub folder. You can set the permission according to your project requirement.

8. If you want to ensure that you are able to created and access the folder or not on ftp server then in this case you need to login again in ftp server.

#ftp  192.168.1.240
Name: anonymous
Passwd (enter)
ftp> Cd  pub
pub>mkdir vibhor
vibhor           (directory created)
pub>ls
vibhor

If you want to check the directory which we created in above text please go to the below location and find it

#cd  /var/ftp/pub
Pub]#ls
Vibhor

So now you will get the file on the ftp pub folder which you created that means the permission which you provide to the user are working properly.

9. You want only one user is able to login by ftp server and access only one particular folder, also not able to delete the file and folder on ftp server, having a ability of uploading and downloading through ftp server. For this thing we have to change in configuration file and chroot_list, ftpuser file.

First create a user which you want to access for ftp user
# useradd  -s /sbin/nologin  ttftpuser       (His shell is nologin so other user not login)
#passwd  ttftpuser

Now create a folder in ttftpuser which you want to give access

#cd  /home/ttftpuser
ttftpuser~]#mkdir  noidaftp
ttftpuser~]#chmod  777  noidaftp

Now go to the file chroot_list, add the user  only which you want to give access.

#vi  /etc/vsftpd/chroot_list
ttftpuser    (make a entry of user which you want to give access)

Now if you want no other user login in ftp server then entry all those user except chroot_list user in ftpuser file.

#vi /etc/vsftpd/ftpuser

Promartuser    (these are users on which ftp server is make )
Vibhor

Now go to configuration file and make changes in  file and change all the parameter which is required on the configuration files.

#vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
syslog_enable=NO
dual_log_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
ftpd_banner=*************************Welcome to blah FTP service******************
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
listen_port=54321
cmds_allowed=ABOR,ACCT,ALLO,APPE,CDUP,CWD,EPRT,EPSV,FEAT,HELP,LIST,MDTM,MKD,MODE,NLST,NOOP,OPTS,PASS,PASV,PORT,PWD,QUIT,REIN,REST,RETR,RMD,RNFR,RNTO,SITE,SIZE,SMNT,STAT,STOR,STOU,STRU,SYST,TYPE,USER,XCUP,XCWD,XMKD

Save the file for above changes which is in bold text in file and restart the ftp services which is describe in step 2.

#service vsftpd restart

Now check login on console mode

#ftp  192.168.1.243 54321

Enter username:ttftpuser
Passwd..enter the passwd
ftp> you have successfully enter
ftp>ls
noidaftp      (folder you have seen)
ftp>put  vsftpd.conf        (it will upload file )
ftp>get  vsftpd.org          (it will download file)

If you want to change the user shell please run the below command method as describe below.

#usermod  -s  /sbin/nologin  username
#usermod  -s /bin/bash  username

So using above method we can easily installed and configured the ftp server on Linux operating system.

Wednesday, December 28, 2016

Step by step method to configure static IP address in Solaris10


Please find the step by step method to provide the static ip address on Solaris 10 operating system.

Step 1: Please run the below command to delete the old ip address. In my machine the "net1" Ethernet card is configured already.

sun> ipadm delete-ip net1

Step 2: To check the current status of all Ethernet card attached with machine as per below command.

sun> ipadm show-if -o all
IFNAME     CLASS    STATE    ACTIVE CURRENT       PERSISTENT OVER
lo0        loopback ok       yes    -m46-v------  46--       --
net0       ip       ok       yes    bm46--------  46--       --
sppp0      ip       ok       yes    -m4-p-------  ----       --

Step 3: Please create your new Ethernet card as per below command.

sun> ipadm create-ip net1

sun> ipadm show-if -o all
IFNAME     CLASS    STATE    ACTIVE CURRENT       PERSISTENT OVER
lo0        loopback ok       yes    -m46-v------  46--       --
net0       ip       ok       yes    bm46--------  46--       --
net1       ip       down     no     bm46--------  46--       --
sppp0      ip       ok       yes    -m4-p-------  ----       --

Step 4: To provide the static IP address please run the below command. Please change your IP address with highlighted address.

sun> ipadm create-addr -T static -a 172.26.7.29/16 net1/v4

In case of any issue please comment on the blog.