468x60 Ads

Thursday, February 6, 2014

Setting Up NFS Services in Solaris10

Setting Up NFS Services for Sharing directories

Checking  nfs service status

# svcs -a |grep -i nfs
online         2012     svc:/network/nfs/status:default
online         2012     svc:/network/nfs/cbd:default
online         2012     svc:/network/nfs/mapid:default
online         2012     svc:/network/nfs/nlockmgr:default
online         2012     svc:/network/nfs/client:default
online         2012     svc:/network/nfs/rquota:default
online         12:17:33 svc:/network/nfs/server:default


Share any folder that you need share with nfs by editing /etc/dfs/dfstab file.

# 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 ""] [resource]
#       .e.g,
#       share  -F nfs  -o rw=engineering  -d "home dirs" /export/home2

/usr/sbin/share -F nfs -o rw -d "" /share

#


Disable the NFS service on the server.

# svcadm disable network/nfs/server


Enable the NFS service on the server.

# svcadm enable network/nfs/server



Select Different Versions of NFS on a Server

Edit the /etc/default/nfs file

NFS_SERVER_VERSMAX=value
NFS_SERVER_VERSMIN=value

Value :Provide the version number.


Mount NFS on the client.
# mount server-name:/share-point /local-dir


Check that the NFS services started on the NFS server 

# rpcinfo -s 172.16.0.4|egrep 'nfs|mountd'
    100005  3,2,1     ticots,ticotsord,tcp,ticlts,udp  mountd      superuser
    100003  4,3,2     tcp,udp                          nfs         1
    100227  3,2       tcp,udp                          nfs_acl     1

Check that the server's mountd is responding

# /usr/bin/rpcinfo -u 172.16.0.4 mountd
program 100005 version 1 ready and waiting
program 100005 version 2 ready and waiting
program 100005 version 3 ready and waiting

Verify that file system is shared as expected on the server

# showmount -e
export list for NTU-HQ-GLOBAL:
/share (everyone)


Some Troubleshoots:

#svcs -xv nfs/server
svc:/network/nfs/server:default (NFS server)
State: disabled since Tue Jan 12 12:19:22 2013
Reason: Disabled by an administrator.
   See: Sun Message ID: SMF-8000-06
   See: man -M /usr/share/man -s 1M nfsd
Impact: This service is not running.

It will say what is the problem of not starting the service, you can also go to that mention log file and observe error logs.

Nfs client mount RPC Error: Program not registered.

When trying to mount nfs partition from nfs client, its keep getting above message that saying
nfs client mount RPC Error: Program not registered.

# mount -t nfs 172.16.0.1:/usr/local/backup
mount: mount to NFS server 172.16.0.1' failed: RPC Error: Program not registered.
#

Solution

This is generally happens due to following reasons..
*not having any shared folders in server or
*not having necessary access rights to server or folder


NFS run in local Zones in solaris:

For this you have to enable nfs server in global Zone and for shearing you have to give local Zone path to mount point in nfstab

Eg: /usr/sbin/share -F nfs -o rw -d "" /Zones/EMS/root/share/backup

Wednesday, January 29, 2014

Display the number of files in a directory

Count the number of files in a directory

# ls -l | wc -l
   11484

#ls -1 targetdir | wc -l

Monday, January 27, 2014

Creating Persistent Routes in Solaris



Creating Persistent Routes in Solaris

Print the currently active routes:

# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              172.16.0.254         UG        1 1650937522
10.0.0.0             172.16.0.12          UG        1   10206514
172.16.0.0           172.16.0.3           U         1    9528249 igb0:1
224.0.0.0            172.16.0.3           U         1          0 igb0:1
127.0.0.1            127.0.0.1            UH       19      26626 lo0:1

Add a route persistently:

# route -p add default ip-address

Eg:
# route -p add 192.168.10.0/24 172.16.0.10

-p             Make changes to the network route tables per-
                    sistent across system restarts. The operation
                    is applied  to  the  network  routing  tables
                    first  and, if successful, is then applied to
                    the list  of  saved  routes  used  at  system
                    startup.  In determining whether an operation
                    was successful, a failure to add a route that
                    already  exists  or to delete a route that is
                    not in the routing table is ignored. Particu-
                    lar  care  should be taken when using host or
                    network  names  in  persistent   routes,   as
                    network-based  name  resolution  services are
                    not available at the time routes are added at
                    startup.
          (Reference :Solaris man page)

For routes that are created by using this method, use following command
to display all of the static routes

 #route -p show 

Following examples creates an IPv4 route to the destination 192.168.10.0 and subnet  with the subnet  mask of 255.255.255.0(/24):

# route add 192.168.10.0/24 somegateway
       
# route add 192.168.10.0 -netmask 255.255.255.0 somegateway

# route add 192.168.10.0 somegateway 255.255.255.0

For IPv6, only “/” format is accepting for subnet. The following example creates an IPv6 route to the destination 35dd:: with netmask of 16 one-bits followed by 112 zero-bits.


# route add -inet6 35dd::/16 somegateway




Monday, January 6, 2014

Useful commands for checking/find Directories/Files in Solaris

Useful commands for checking/find Directories/Files in Solaris  

Display the Size of Directories, Sub-directories, and Files

du -summarize disk usage

(By default, file sizes are written in 512-byte units, rounded up to the next 512-byte unit.)
OPTIONS:
-a
Displays the size of each file and subdirectory, and the total number of blocks that are contained in the specified directory.
-s
Displays the total number of blocks that are contained in the specified directory.
# du -s /var/adm/
1198    /var/adm

-h
All sizes are scaled to a  human  readable  format,for  example,  34K, 244M, 5.7G, or 2.0T.
Displays the size of each directory in 1024–byte blocks.
# du -h /var/adm/
   1K   /var/adm/acct/fiscal
   1K   /var/adm/acct/nite
   1K   /var/adm/acct/sum
   4K   /var/adm/acct
   1K   /var/adm/streams
   1K   /var/adm/sm.bin
   1K   /var/adm/exacct
   1K   /var/adm/log
   1K   /var/adm/sa
 599K   /var/adm

-H
Displays the size of each directory in 1000–byte blocks.
# du -H /var/adm/
2       /var/adm/acct/fiscal
2       /var/adm/acct/nite
2       /var/adm/acct/sum
8       /var/adm/acct
2       /var/adm/streams
2       /var/adm/sm.bin
2       /var/adm/exacct
2       /var/adm/log
2       /var/adm/sa
1198    /var/adm



Using ls and find commands:

Changes the directory in to the place of files are locating

# ls [-lh] [-s]

-l
Displays a list of files and directories in long format , sizes in bytes.
# ls -l
total 115540
-rw-r--r--   1 root     root         233 May 21  2013 Cms2Serv.bak
-rw-rw-rw-   1 root     root         213 May 21  2013 Cms2Serv.ini
-rw-r--r--   1 root     root     56479733 Jan  7 10:26 EMdatabase0.sa
-rw-r--r--   1 root     root      639742 Jan  7 10:28 EMdetect_00.bin

-h
Scales file sizes and directory sizes into human readable format like Kbytes, Mbytes, Gbytes, or Tbytes when the file or directory size is larger than 1024 bytes.
# ls -l -h
total 115540
-rw-r--r--   1 root     root         233 May 21  2013 Cms2Serv.bak
-rw-rw-rw-   1 root     root         213 May 21  2013 Cms2Serv.ini
-rw-r--r--   1 root     root         54M Jan  7 10:26 EMdatabase0.sav
-rw-r--r--   1 root     root        625K Jan  7 10:28 EMdetect_00.bin

-S
Displays a list of the files and directories, showing the sizes in blocks.
# ls -s
total 115800
   2 Cms2Serv.bak     1280 EMdetect_00.bin    92 EMhist.sav         28 elementMan.cms

How to Find Large Files

If the characters or columns for the files are different, use following command to sort a list of files by block size, from largest to smallest.

# ls -l| sort +4rn | more

# ls -l | sort +4rn | more
-rw-r--r--   1 root     root     56660746 Jan  7 10:34 EMdatabase0.sav
-rw-r--r--   1 root     root      961820 Jan  7 09:58 EMhist.bak
-rw-r--r--   1 root     root      640113 Jan  7 10:33 EMdetect_01.bin
-rw-r--r--   1 root     root      639742 Jan  7 10:28 EMdetect_00.bin
drwxr-xr-x   2 root     root      233984 Jan  7 10:33 ipcfg
-rw-r--r--   1 root     root       51608 Jan  7 10:36 EMhist.sav
drwxr-xr-x   2 root     root       41472 Jan  7 09:48 ipinv

Note that this command sorts files in a list by the character that is in the fourth field, starting from the left.

If the characters or columns for the files are the same, use the following command to sort a list of files by block size, from largest to smallest.

# ls -s | sort -nr |more
Note that this command sorts files in a list, starting with the left most character.

Find Files That Exceed a Specified Size Limit

find directory -size +nnn
directory
Identifies the directory that you want to search.

-size +nnn
Nnn in 512-byte blocks. Files that exceed this size will list.

# find . -size +400 -print
./ipcfg
./ipcfg/ipdevcfg.bin
./EMdetect_01.bin
./EMdetect_00.bin
./EMhist.bak

./EMdatabase0.sav

Wednesday, August 21, 2013

How to Add Access to CD/DVD Media in a Non-Global Zone in Solaris 10



Below is the procedure for Add Access to CD/DVD Media to Non-Global zone permanently.

1.     Login to global zone become super user.

2.     Determine whether the Volume Management file system is running in the global zone.

global # svcs volfs
STATE          STIME    FMRI
online         2012     svc:/system/filesystem/volfs:default

3.     (Optional) If the Volume Management file system is not running(offline) in the global zone,enable it.


4.     Insert the media.

5.     Check for media in the drive.

global# volcheck

6.     Test whether the DVD is auto mounted.

global# ls /cdrom

You will see a output similar to the following:

cdrom   cdrom1  

7.     Take backup of existing zone configuration similar to attached file with info command under zonecfg
Eg:


global


zonecfg:EMS> info

zonename: EMS

zonepath: /Zones/EMS

brand: native

autoboot: true

bootargs:

pool:

limitpriv:

scheduling-class:

ip-type: shared

hostid:

inherit-pkg-dir:

        dir: /lib

inherit-pkg-dir:

        dir: /platform

inherit-pkg-dir:

        dir: /sbin

inherit-pkg-dir:

        dir: /usr

fs:

        dir: /usr/local

        special: /Zones/storage/local/EMS

        raw not specified

        type: lofs

        options: []

net:

        address: 172.16.0.3

        physical: igb0

        defrouter not specified

zonecfg:EMS>exit

8.     Loopback mount the file system with the options nodevices, ro (no devices, read-only) in the Non-global zone.

zonecfg:EMS> add fs
zonecfg:EMS> set dir=/cdrom
zonecfg:EMS> set special=/cdrom
zonecfg:EMS> set type=lofs
zonecfg:EMS> add options [ro,nodevices]
zonecfg:EMS> end
zonecfg:EMS> commit
zonecfg:EMS> exit

9.     Reboot the non-global zone.


EMS—is Name of Non-Global Zone

10.  Use the zoneadm list command with the -v option to verify the status.


11.  You will see a display that is similar to the following:

ID  NAME     STATUS       PATH                           BRAND      IP
0  global   running      /                              native     shared
1  EMS      running      /Zones/storage/local/EMS       native     shared

12.  Log in to the non-global zone.

global# zlogin EMS

13.  Verify the DVD-ROM mount.

EMS# ls /cdrom

14.  You will see a display similar to this:

cdrom   cdrom1 

15.  Get the use of DVD/CD in Non-Global zone..:-)

16.  Exit the non-global zone.

EMS# exit

If you want to retain the /cdrom file system in your non-global zone. The mount will always reflect the current contents of the CD-ROM drive, or an empty directory if the drive is empty.

17.   (Optional) If you want to remove the /cdrom file system from the non-global zone, use the following procedure.

global# zonecfg -z EMS
zonecfg:EMS> remove fs dir=/cdrom
zonecfg:EMS> commit
zonecfg:EMS> exit

 

 

Wednesday, June 26, 2013

Create ftp access only user in Solaris 10 with user restrictions(access rights)


We are going to create user who can access toserver via ftp with following access rights:

Access to server via:

Telnet/ssh/other: No
FTP:Yes
                Read file: only user home directory.
                For that you can give whatever the location you need to give access to user
                Eg:/var/apache2/http/ftp/
                Then user can access only to that folder
            
            Chmod                 NotAllowe
Delete                  NotAllowe
Overwrite            NotAllowe
Rename               NotAllowe
Unmask               NotAllowe
Upload                NotAllowe


               
Verify ftp service is running in the server:

# svcs -a |grep -i ftp
online         12:17:58 svc:/network/ftp:default

Create new user for access server only for FTP

#useradd -g other -d /export/home/sltftp -m -s/bin/ftponly -c "ftp only user account for ftp backup" sltftp

other : This is the group that by default will own any files or processes created by this user. If this user attempts to access a file and the group of that file is the user's primary group then the group permissions for that file will apply (unless the user is the owner of the file).(not necessary)
/export/home/sltftp : A user's home directory typically contains all the files owned by that user. When a user logs in, he will be placed in his home directory and scripts like .cshrc or .profile will be run.
/bin/ftponly : When a user logs in via telnet or at the console, or opens an xterm window in X the users shell program will be run to interpret commands entered. If a user does not have a valid shell program or has one that does nothing (like /bin/false), then that user will not be able to login. This can be useful when creating users who can only read and send email.
"ftp only user account for ftp backup" : The real human-readable name of this user.
sltftp : The login name of this user. This must be unique.

Enter a password for newly created user :( otherwise its remaining blank)

# passwd sltftp
New Password:
Re-enter new Password:
passwd: password successfully changed for sltftp

Verify user creation:

# cat /etc/passwd
root:x:0:0:Super-User:/:/sbin/sh
daemon:x:1:1::/:
bin:x:2:2::/usr/bin:
sys:x:3:3::/:
adm:x:4:4:Admin:/var/adm:
.
.
sltftp:x:1000:10: ftp only user account for ftp backup: /export/home/sltftp:/bin/ftponly

1000: The user ID or UID is what the system really uses to enforce permissions on files and processes. If two users have the same UID, they will be able to access each other’s files - so every user should have a unique UID.

Create file /etc/shells ( by default this file not found in system)

# cat /etc/shells
/etc/shells: No such file or directory
Add this line : /bin/ftponly

# vi /etc/shells
/bin/bash
/bin/csh
/bin/gnome-autogen.sh
/bin/hash
/bin/jsh
/bin/ksh
/bin/pfcsh
/bin/pfksh
/bin/pfsh
/bin/remsh
/bin/rksh
/bin/rsh
/bin/sh
/bin/ssh
/bin/tcsh
/bin/zsh
/bin/ftponly

And save it Ece->:wq!

Try to telnet using this user and check the accessibility

login: sltftp
Password:
Last login: Wed Jun 26 12
No shell
Connection to host lost.

You can also create /bin/ftponly file and give some echo command with what you want to display when user try to login
      Eg:#touch /bin/ftponly>> echo “This account only allows FTP Access!”

After that when users try to login via telnet its shows like this:

login: sltftp
Password:
Last login: Wed Jun 26 12
This account only allows FTP Access!
Connection to host lost.

Limiting access rights for ftp user by editing ftpaccess file locate in /etc/ftpd/

#vi ftpaccess 

# ident "@(#)ftpaccess  1.2     03/05/14 SMI"
#
# FTP server configuration file, see ftpaccess(4).
#

class   realusers       real    *
class   guestusers      guest   *
class   anonusers       anonymous       *

loginfails      3
passwd-check    trivial         warn
private         no
shutdown        /etc/ftpd/shutdown.msg
# email         user@hostname
# guestuser     username
# rhostlookup   no

keepalive       yes
recvbuf         65536           real,guest,anonymous
sendbuf         65536           real,guest,anonymous
# flush-wait    no              anonymous
# passive       ports           0.0.0.0/0       32768   65535
# timeout       data            600
# timeout       idle            300

banner          /etc/ftpd/banner.msg
greeting        brief
message         /etc/ftpd/welcome.msg   login
message         .message                cwd=*
readme          README*                 login
readme          README*                 cwd=*
# quota-info    *

chmod   no      anonymous,guest
delete  no      anonymous,guest
overwrite       no      anonymous,guest
rename  no      anonymous,guest
umask   no      anonymous,guest

compress        yes             realusers guestusers anonusers
tar             yes             realusers guestusers anonusers

path-filter     anonymous,guest /etc/ftpd/filename.msg  ^[[:alnum:]._-]*$       ^[.-]

noretrieve      relative        class=anonusers         /
allow-retrieve  relative        class=anonusers         /pub

upload          class=guestusers    *    *         no  nodirs
upload          class=anonusers    *    *         no  nodirs
# upload        class=anonusers    *    /incoming yes ftpadm ftpadm 0440 nodirs

# log           commands        real,guest,anonymous
# log           security        real,guest,anonymous
# log           transfers       real,guest,anonymous    inbound,outbound
# xferlog       format  %T %Xt %R %Xn %XP %Xy %Xf %Xd %Xm %U ftp %Xa %u %Xc %Xs %Xr

# limit-time    anonymous       30
# limit         anonusers       10      Wk0730-1800       /etc/ftpd/toomany.msg
# limit         anonusers       50      SaSu|Any1800-0730 /etc/ftpd/toomany.msg
guestuser      sltftp ftptest
log     commands        anonymous,guest


Save the changers Ece->:wq!

We create this user under guest list:

Define sltftp user as guest:

guestuser       sltftp ftptest

create a class for guest user:

The WU FTP server allows you to classify users based on the address they login from and their user type. The three user types are :
Unix - Normal users on your system.
Guest - Unix users who have been classified as guests.
Anonymous - Logins by the anonymous or ftp user, if allowed on your system.
The top section of this page allows you to define named classes, based on user types and source addresses. Every login is classified into the first matching class, so classes should be ordered from the most to least specific. The matching addresses for each class can be full or partial IP addresses, IP networks/netmasks, hostnames, host wildcards (like *.foo.com) or the absolute paths to files containing additional addresses. Any type of address can be preceded with a ! to negate it.

class   guestusers      guest   *

Limiting access rights for guest user:(this will effect to all guest users)

chmod   no      anonymous,guest
delete  no      anonymous,guest
overwrite       no      anonymous,guest
rename  no      anonymous,guest
umask   no      anonymous,guest

Put some logging banner to display when logging:

message        /etc/ftpd/welcome.msg   login
#vi /etc/ftpd/welcome.msg  
***************************
Welcome to ftp Sever
Authorized access only!
***************************
Save it:Ece->:wq!

No need to restart the ftp server for effect the changes
To restart ftp process :
#svcadm restart  svc:/network/ftp:default

Done! J

Now check ftp user

C:\Windows\system32\ftp 172.16.0.3
Connected to 172.16.0.3.
220 NTU-DR-EMS FTP server ready.
User (172.16.0.3:(none)): sltftp
331 Password required for sltftp.
Password:
230 User sltftp logged in.  Access restrictions apply.


Try to upload some files:
ftp> mput
Local files C:\Users\Daraka\Desktop\test.txt
mput C:\Users\Daraka\Desktop\test.txt?
200 PORT command successful.
553 test.txt: Permission denied on server. (Upload)


You can only able to download from the server