You are on page 1of 18

Solaris kb

Solaris UNIX Configure Disk Quota For UFS File System


by Vivek Gite on August 29, 2009 2 comments

How do I configure file system quotas to control how much available storage space can be used on a given UFS file system (such as /export/home) under Solaris UNIX operating systems? A disk quota is nothing but a limit set by a sys admin that restricts certain aspects of file system usage on UNIX operating systems. Both UFS and ZFS support the disks quota for user. Under UFS you can set the number of blocks and inodes that can be used by a user on a file system such as /export/home: Contents 1. 2. 3. 4. 5. 6. 7. 8. 9. Quota Limits Configure Filesystem Remount File System Create Empty Quotas File Set User Quota Turn on User Quota User's Quota and Usage Reporting Testing Further Resources

Block quota, limits the amount of disk space that can be used. Inode quota, limits the number of files and directories that can be created.

Quota Limits
The number of blocks and inodes is often specified with both soft and hard values:
y

Soft value or soft limits - It may be temporarily exceeded and the user will be warned about the violation. In addition, administrators usually define a warning level, or soft quota, at which users are informed they are nearing their limit, that is less than the effective limit, or hard quota. There may also be a small grace interval, which allows users to temporarily violate their quotas by certain amounts if necessary.

Hard limits - are those that cannot be exceeded and attempts to use more blocks or inodes beyond a user's hard limit will be denied.

The quota system on ufs, zfs and vxfs filesystems to put limits on resources of a filesystem. Most of the actions listed in this FAQ are written with the assumption that they will be executed by the root user running the ksh or bash shell. Also, only super-user root can set disk quota.

Step # 1: Configure /export/home


Edit /etc/vfstab, enter:
# vi /etc/vfstab

Update /export/home as follows:


/dev/dsk/c0d0s7 /dev/rdsk/c0d0s7 /export/home ufs 2 yes rq

rq mount options enables disk quota for /export/home. This make sure that disk quota enabled after each reboot.

Step # 2: Remount File System


Type the following command to mount /export/home with quota:
# mount -o remount,quota /export/home

Step # 3: Create Empty Quotas File


You need to create empty quotas file in in root of file system i.e. create /export/home/quotas
# touch /export/home/quotas # chown root:root /export/home/quotas # chmod 0600 /export/home/quotas

Step # 4: Set User Quota


You edit and set user quotas for user vivek using edquota command.
# edquota username # edquota vivek

edquota is a quota editor. One or more users may be specified on the command line. For each user a temporary file is created with an ASCII representation of the current disk quotas for that user for each mounted ufs file system that has a quotas file, and an editor is then invoked on the file. The quotas may then be modified, new quotas added, etc. Upon leaving the editor, edquota reads the temporary file and modifies the binary quota files to reflect the changes made. To make any changed to user quota use the same command again.

Step # 5: Turn on User Quota


The quotaon command turns on disk quotas for /export/home ufs file systems. Type the command:
# quotaon -v /export/home

Sample Outputs:
/export/home: quotas turned on

How Do I Display a User's Quota and Usage?


The quota command display a user's ufs file system disk quota and usage. Run it as follows:
# quota -v username # quota -v vivek

The repquota command displays a summary of the disk usage and quotas for the specified ufs file systems such as /export/home, enter:
# repquota /export/home

To display quota information of all users, type:


# repquota -va

Testing
The user vivek will get an error message if the quota has been exceeded. You can test this with the following simple command (try creating 500M file in a home directory):
# su - vivek $ dd if=/dev/zero of=bigfile bs=1024 count=512000

Alternatively, you can use mkfile to create a file called bigfile


$ mkfile 500m bigfile

Solaris UNIX: Display LUNs


by Vivek Gite on June 29, 2009 0 comments

How do I display LUNs under Solaris UNIX version 10 or earlier? To see LUNs use the cfgadm command as follows (open the terminal or login using ssh as root):
cfgadm -al -o show_SCSI_LUN

Solaris 8 user can use the command as follows:


cfgadm -al -o show_FCP_dev c2 cfgadm -al -o show_FCP_dev c3

This is useful when you want to configure LUNs on a Solaris UNIX box

Solaris UNIX LUN Rescan With cfgadm Command by Vivek Gite on February 17, 2008 0 comments

I know how to do LUN rescan under Linux using echo command. A reboot option (downtime) is not available for me. How do I rescan LUN under Solaris UNIX operating systems? The cfgadm command provides configuration administration operations on dynamically reconfigurable hardware resources. Pass the -l option to Lists the state and condition of attachment points specified. Login as root and type the following command: cfgadm -al For further information read cfgadm and format command man page

Solaris UNIX: Show Network Routing Table Information

How do I show networking routing table information under Solaris UNIX operating systems using a shell prompt?

You need to use the netstat command to display the IP routing table under Solaris UNIX operating systems. netstat command example Type the following commands: netstat -r OR /usr/bin/netstat OR netstat -rn

Commonly used UNIX / Linux commands by new user by nixcraft on March 3, 2006 0 comments

Q. . I'm a new Linux user. Can you tell me commonly used Linux / UNIX command? A. If you are new to Linux/FreeBSD or Solaris then you will find that there are some very powerful commands that you use repeatedly. Here is a list of commonly used commands: Shutdown the operating system halt init 0 shutdown -h now Reboot the operating system reboot init 6

Display the manual (man) page for the given command. The must command for mastering Linux/UNIX. If you do not know how to use some command, use man to display its manual page. Remember you can exit a man page by pressing q.

man ls man man man date

Switch the current user. If you logged in as vivek and need to change to user account jadmin, then you need to type following command: su jadmin

However, this command is mostly used to switch super user account. Just type command su - and you will switch to root user account with its entire environment exported su

Display the environment variable: env

Display a message on the screen or display value of environment variable. For example, display value of HOME variable: echo $HOME

Setup and export environment variable, for example setup JAVA path with following command: export PATH=$PATH:/usr/java/bin

Display list of currently running process. To exit top press q top

Display full path of shell command. For example display full path of gcc command: which gcc

Display list of logged in users who

Display what users are doing w

Display status of network netstat -r netstat -nat Display or setup routing table route

Manage network interface ifconfig

Sun Solaris UNIX display list for loaded kenel device driver / modules by Vivek Gite on August 20, 2007 0 comments

Q. How do I display information about loaded kernel modules under Sun Solaris UNIX operating system?

A. You need to use modinfo command which is a trivial program to display information about the loaded modules. The format of the information is as follows: Id Loadaddr Size Info Rev Module Name where Id is the module ID, Loadaddr is the starting text address in hexadecimal, Size is the size of text, data, and bss in hexadecimal bytes, Info is module specific information, Rev is the revision of the loadable modules system, and Module Name is the filename and description of the module. Task: Displaying the status of kernel modules Just enter modinfo command: modinfo You can pass -c option to modinfo command to display the number of instances of the module loaded and the module's current state: modinfo -c Display information about particular module / driver only You can also display information about particular module only by specifying its ID #: modinfo -i 5 The above example displays the status of module # 5. Read modinfo man page for other information and options.

Solaris UNIX Add Static Routes by Vivek Gite on February 21, 2008 8 comments

Q. How do I add Static Routes under Solaris UNIX? My default gateway configured in /etc/defaultrouter, but what is the proper place to configure static routes for a Solaris UNIX server? Can you tell me exact configuration file name for a static routing? A.. There are many ways to configure static routing under Solaris UNIX. Task: Display current routing table Use netstat command, enter: # netstat -nr Task: Delete a route

To delete a route, enter: # route delete dest gateway # route delete myhost myrouter Method # 1: Set static routes using route command Use route command to add static route on fly (dynamic modification of routing table), enter: # route add dest gateway # route add net 10.0.0.0 netmask 255.0.0.0 10.20.110.1 # route add net 192.168.1.0 192.168.1.254 # route add host myhostname myrotername The only drawback is static routes are not persistence i.e. routing will be deleted when Solaris box get rebooted. Method # 2: Set static routing using /etc/gateways configuration for in.routed The file /etc/gateways is act as configuration file for /usr/sbin/in.routed IPv4 network routing daemon. All you have to do is put static route per line using following format: net Nname[/mask] gateway Gname metric value <passive | active | extern> Open config file: # vi /etc/gateways Append following entries: net 192.168.1.0 gateway 192.168.1.254 metric 1 passive net 10.0.0.0 gateway 10.20.110.1 metric 1 active You must one of these keywords must be present to indicate whether the gateway should be treated as passive or active, or whether the gateway is external to the scope of the RIP protocol. A passive gateway is not expected to exchange routing information, while gateways marked active should be willing to exchange RIP packets. The keywoard passive should be used if you want the entry to be permanent.The keyword active should be used if you want in.routed to occasionally query the gateway host, and delte the route if it becomes inactive. See in.routed man page for further details. Save and close the file. You can set default router in /etc/defaultrouter file. Method #3 : Managing routing using routeadm command Solaris has routeadm command which is used to administer system-wide configuration for IP forwarding and routing. IP forwarding is the passing of IP packets from one network to another; IP routing is the use of a routing protocol to determine routes. You need to use /etc/defaultrouter to setup the default route and /etc/gateways to set static routing. To start the in.routed, enter: # routeadm -u -e ipv4-routing To view current routing configuration, enter: # routeadm

To stop the in.routed daemon, enter: # routeadm -u -d ipv4-routing Method # 4: Old way - Create a init script Login as root and type the command: # cd /etc/rc2.d/ # touch S99static-routes # chmod +x S99static-routes # vi S99static-routes Write a shell script and append static route using route command itself: #/bin/sh route add net 192.168.1.0 netmask 255.255.255.0 192.168.1.254 1 route add net 10.0.0.0 netmask 255.0.0.0 10.20.110.1 Save and close the file. I recommend using method # 2 to create static routing under Solaris UNIX. See following man pages for further details: $ man in.routed $ man route $ man gateways

Linux / UNIX: mplayer Play mp3s From a Playlist File by Vivek Gite on December 19, 2010 2 comments

I'm an extreme newbie to the Linux world, but any time I try to get play files according to a playlist file using mplayer command line it turns up this error: $ mplayer playlist.m3u MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team mplayer: could not connect to socket mplayer: No such file or directory Failed to open LIRC support. You will not be able to use your remote control.

Playing playlist.m3u. Cache fill: 0.00% (44 bytes) Exiting... (End of file) How do I fix this and play music without using GUI tools?

mplayer is a movie player for Linux and UNIX like operating systems (it may also runs on many other platforms). It plays most MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ files, supported by many native and binary codecs. You can watch VCD, SVCD, DVD, 3ivx, DivX 3/4/5, WMV and even H.264 movies, too. mplayer: Playing Music Using a Playlist File First, make sure your playlist in ASX, Winamp, SMIL, or one-file-per-line format. Next, you need to use the following syntax to play any media file from playlist. Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command: mplayer -playlist {yourlist.input.file} mplayer -playlist playlist.m3u A Sample One-file-per-line Playlist Format $ cat playlist.m3u Sample output (tracks): track1.mp3 track2.mp3 track3.mp3 track4.mp3 You can create a playlist called mylist.txt as follows by searching all .mp3s in /home/vivek/music directory: find /home/vivek/music/ -type f -iname "*.mp3" > mylist.txt

To play mp3 from a playlist, enter: mplayer -playlist mylist.txt USING the "newfs" COMMAND- SOLARIS 10 To usethe disk to store unix files and dir a file system must be created on every disk partions. #newfs /dev/rdsk/c#t#d#s# by default the newfs command reserves between 1 - 10% of file system space,depending on the size of the file system for maintenance, this free space is refer to as minfree. TO SHOW THE VALUE OF MINFREE ON A FILESYSTEM: #fstyp -v /dev/dsk/c#t#d#s# |head you can use the newfs -m % free command tp preset the % of free space when you create new file system #newfs -m 2 /dev/rdsk/c#t#d#s# TO CHANGE THE MIN FREE VALUE OF FREE SPACE ON AN EXITING FILESYSTEM,YOU CAN USE #tunefs -m 4 /dev/dsk/c#t#d#s#.

Configuring NFS Posted by Vivaan | 2:29 AM | 0 comments Configuring NFS NFS Server Files /etc/dfs/dfstab Lists the local resources to share at boot time /etc/dfs/sharetab Lists the local resources currently being shared. /etc/dfs/fstypes Lists the default FS types for remote FS /etc/rmtab Lists FS remotely mounted by NFS clients /etc/nfs/nfslog.conf Lists info of the location of config logs used for NFS server logging /etc/default/nfslogd Lists config info describing the behavior of the nfslogd daemon

# cat /etc/dfs/dfstab

share F nfs o ro /export.sys44_data # cat /etc/dfs/sharetab /export/sys44_data - nfs ro # cat /etc/dfs/fstypes nfs NFS Utilities autofs AUTOFS Utilities cachefs CACHEFS Utilities # cat /etc/rmtab sys42:/export/sys44-data #sys41:/usr/share/man #sys43:/export/sys44_data -- The # entries are removed by the mountd daemon during a system startup NFS Server Daemons To start the NFS server daemons or to specify the number of concurrent NFS requests that can be handled by the nfsd daemon, use the /etc/rc3.d/S15nfs.server script mountd Handles FS mount requests from remote systems, and provides access control nfsd Handles client FS requests statd Works with the lockd daemon to provide crash recovery functions for the lock manager lockd Supports record locking operations on NFS files nfslogd Provides operational logging # /etc/init.d/nfs.server start -- To start NFS server daemon # /etc/init.d/nfs.server stop -- To stop NFS server daemon NFS Server Commands # share -- To share directory and also displays the contents of the /etc/dfs/sharetab file # unshare /test -- Unshare the share # shareall -- Shares all resources listed in the /etc/dfs/dfstab file # unshareall /export/sys44_data -- Unshare currently shared file resources listed in the /etc/dfs/sharetab file # dfshares -- Displays currently shared resources by using the NFS dameon mountd # dfshares 140.40.40.160 -- Lists available shared resources in remote system # dfmounts -- Displays a list of NFS resources that are currently mounted and client list

# dfmounts sys42 -- Displays NFS resources of sys42 that are currently mounted & clients share [-F nfs] [-o options] [-d description] [pathname] # share o ro /export/sys44_data -- By default resources available with RW. Access decision is based on a comparison of the UID of the client and the owner. The Share Command Options ro Informs clients that the server accepts only read requests rw Allows the server to accept read and write requests from the client root=client Informs client that the root user on the specified client system or systems can perform superuser-privileged requests on the share resource. ro=access-list Allows read requests from the specified access list rw=access-list Allows RW requests from the specified access list Access List Options access-list=client:client Allows access based on a colon-separated list of clients access-list=@network Allows access based on a network number (eg @192.168.100 or a network name eg. @mynet.com). The network name must be defined in the /etc/networks file access-list=.domain Allows access based on a DNS domain access-list=netgroup_name Allows access based on a config net group (NIS) or (NIS+) anon=n Sets n to be the effective user ID (EUID) of anonymous users. By default, anonumous users are given the EUID 6001-nobody user. If n is set to 1, access is denied. # share F nfs o r0 direcctory -- Restricts access to read-only access. # share F nfs o r0,rw=client1 directory -- Restricts access to read-only, however, the NFS server accepts both read & write requests from the client client1 # share F nfs o root=client2 directory -- Allows the root user on the client named client2 to have superuser access to the NFS mounted resources # share F nfs o ro,anon=0 directory -- By setting the option anon=0, the EUID for access to shared resources by an anonymous user is set to 0. The access is also set to read only. # share - /export/sys44_data ro

Managing the NFS Client NFS Client Files /etc/vfstab Defines FS to be mounted locally /etc/mnttab Lists currently mounted FS including automounted directories. /etc/dfs/fstypes Lists the default FS types for remote FS NFS Client Daemons The NFS client daemons are started using the /etc/rc2.d/S73nfs.client script statd Works with the lockd daemon to provide crash recovery functions lockd Supports record-locking operations on NFS files /etc/init.d/nfs.client start (or) stop NFS Client Commands dfshares Lists available shared resources from a remote or local NFS server mount Attach a file resource to a specified local mount point umount Unmounts a currently mounted file resources mountall Mounts all file resources or a specified group of file resources listed in the /etc/vfstab file with a mount at boot value of yes umountall Unmounts all non-critical local and remote file resources dfmounts Displays a list of currently mounted NFS server directories mount [-F nfs] [-o options] server:pathname mount-point # mount sys44:/export/sys44_data /export/remote-data # mount o ro sys45,sys43,sys41:/multi_home_data /remote_shared_data -- When mounting a read-only remote resources, you can specify a comma separated list of sources for the remote resources. Which are then used as a list of failover resources # umount /export/remote-data -- Unmounting remote FS from the client # mountall r -- To limit the action of this command to remote file resources. # umountall r -- To unmount all remote file systems Mounting Remote Resources at Boot Time

Enter appropriate entries in the client s /etc/vfstab file to mount the remote file resources at boot time. # vi /etc/vfstab sys44:/export/sys44_data - /export/remote-data nfs - yes soft,bg Mount Command Options rw | ro Read/Write or read-only. The default is read/write bg | fg Retry to mount in background or foreground. The default is to retry in the foreground soft | hard Soft option reports an error on the request, and stop trying when retrans=n reach. Whereas hard option prints a warning message and continue to try. Default is hard mount intr | nointr Enables or disabled the use of KB interrupts to kill aprocess that hangs on a hard-mounted FS. The default is intr. suid | nosuid Indicates whether to enable setuid execution. Default is setuid execution timeo=n Sets the timeout to n tenth of a second. The default timemout is 11, measures in one-tenth of a second for UDP and 600 tenths of a second for TCP. retry=n Sets the no of times to retry the mount operation. Default is 10,000 times retrans=n Sets the number of NFS retransmission to n. The default is 5 for UDP.

Enabling the NFS Server Logging nfslogd daemon responsible for NFS logging The /etc/nfs/nfslog.conf file defines the path, file names, and type of logging that the nfslogd daemon must use. There is a taq corresponding to each definition. Eg. Of nfslog.conf file # NFS server log configuration file global defaultdir=/var/nfs \ log=nfslog fhtable=fhtable buffer=nfslog_workbuffer defaultdir=dir_path -- Specifies the default parent directory log=logfile_pat -- Specifies relative or absolute path and the filename for the ASCII log file fhtable=table_path -- Specifies path and the filename for the file-handle-to-path DB file buffer=buffer_path -- Specifies path and the filename for the raw buffer file log format=basic | extended -- Specifies the format when creating user-redable log files

To easily identify the log files for different shared resources, place them in separate dir. For eg.

# cat /etc/nfs/nfslog.conf global defaultdir=/var/nfs \ log=nfslog fhtable=fhtable buffer=nfslog-workbuffer public defaultdir=/var/nfs/public \ log=nfslog fhtable=fhtable buffer=nfslog-workbuffer Create the /var/nfs/public directory before starting NFS server logging Specify a tag by entering the tag to use with the log=taq option in the /etc/dfs/dfstab file. Use the log option without specifying a taq, which mean use the default global tag share F nfs o ro,log /export/sys44_date /etc/default/nfslogd -- The config info file controls the logging behavior of the nfslogd daemon.

Solaris OE Directory Hirerarchy Posted by Vivaan | 2:33 AM | 0 comments Introducing the Solaris OE Directory Hirerarchy

/bin Symbolic link to /usr/bin contains binary files of standard system commands /kernel Platform independent lodable kernel modules /platform Platform dependable lodable kernel modules /sbin Single user bin directory contains essential executables /usr Contains programs, scripts and libraries that are used by all system users UNIX System Resources /var Directory of varying files, includes temporary, logging, or status files /dev/cua Dial out device files for UUCP & PPP /dev/dsk Block disk devices /dev/rdsk Raw disk devices /dev/pts Psuedo terminal devices /dev/md Metadisk devices

/dev/term Serial devices /dev/sound Audio device files /dev/rmt Raw magnetic tape devices /etc/cron.d Config info for cron utility /etc/default Default info for various prog. /etc/inet Config files - network services /etc/init.d Scripts to stop & start services /etc/lp Config info for printer /etc/nfs Config info for NFS server logging /etc/rc#.d Scripts for various run levels /etc/skel Default shell initialization files /usr/bin Standard system command /usr/sbin System administration commands /usr/kernel Platform independent lodable kernel module devfsadm Solaris 8 & 9 drvconfig Solaris 2.x through 2.7

Uname commands Posted by Vivaan | 4:08 AM | 0 comments http://solarisinterview.blogspot.com solaris interview questions and answers # uname # uname # uname # uname # uname a Gives all details about the system m Displays H/W platform (sun4u) p Machine processor architecture (sparc or i386) i Machine model architecture (SUNW, Ultra 5_10) X Detailed description

Grep Command Options Posted by Vivaan | 4:17 AM | 0 comments http://solarisinterivew.blogspot.com/ solaris interview questions and answers

Grep Command Options

-i - Searches for both upper & lower case characters -l - Lists the names of files with matching lines -n - Proceeds each line with the relative line number in the file -v - Inverts the search to display lines that do not match the pattern -w - Searches for the expression as a complete word

You might also like