Archive for December, 2010

Solaris /var full resolution

December 28th, 2010 Comments off

Using df -h to see the summary usage of partition:

df -h
/dev/md/dsk/d3 3.9G 3.6G 298M 93% /var

Then using du -sh ./* | sort,and you may find that directory /var/adm employs much of the space:

/var/adm 1.5GB

And go further to the directory,you may find the file /var/adm/wtmpx employs much of the directory size:

1.4G /var/adm/wtmpx

Here goes the resolution:

echo "" > /var/adm/wtmpx

If you want to delete any file(s),you must firstly see if any processes using them.You can do this check through command lsof:

lsof | grep wtmpx

If no process using the file,you can now using rm -i command to delete the file at ease and recreate the file,chmod it latter:

rm -i /var/adm/wtmpx
touch /var/adm/wtmpx && chmod 644 /var/adm/wtmpx

Categories: IT Architecture, Systems, Unix Tags:

How to Shut Down or Reboot a Solaris System

December 27th, 2010 Comments off

Solaris is usually used as a server operating system. Because of this, you want to make sure that you shut the system down as gracefully as possible to ensure there isn’t any data loss.

For every application that is installed on your server, you should make sure that you have the correct scripts in /etc/rc(x).d to gracefully shut down the service.

You have more than one command option that you can use. The best command is this, executed as root:
shutdown -y -i5 -g0
This will immediately shut the system down. You can also use the older command that still works:
sync;sync;init 5
You can even use:

If you are trying to reboot the system as opposed to turning it off, you could use:
shutdown -y -i6 -g0
sync;sync;init 6
Or even:
So many commands to do the same thing… almost seems silly.

Using shell read command to read first several lines from specified file

December 26th, 2010 Comments off

The following bash shell script will read first 2 lines from /etc/fstab and then bind each one to the corresponding variable $line1 & $line2. In the script, we will use Redirecting Input & Shell Builtin Commands of the bash shell.
# Reading lines in /etc/fstab.
{ read line1;read line2; } < $File
echo "First line in $File is:"
echo "$line1"
echo "Second line in $File is:"
echo "$line2"


You can also use awk to read specified line from a file, e.g.

awk '{if(NR=='1'){print}}' a.txt

This will print the first line of a.txt.