This blog covers Unix system administration HOWTO tips for using inline for loops, find command, Unix scripting, configuration, SQL, various Unix-based tools, and command line interface syntax. The Unix OS supports tasks such as running hardware, device drivers, peripherals and third party applications. Share tips/comments. Read the comments. But most importantly: Read Disclaimer - Read Disclaimer.
Monday, April 30, 2007
Define Two IPs on a Network Interface Card (NIC)
#vi /etc/hostname.hme0
esofthub
For the virtual
#vi /etc/hostname.hme0:1
esofthub-virt
To activate virtual connection without rebooting
#ifconfig hme0:1 plumb
#ifconfig hme0:1 inet 192.xxx.xx.xx netmask 255.255.255.0 broadcast 192.xxx.xx.xx
#ifconfig hme0:1 up
#ifconfig -a
Ensure that you populate the name service (files, nis, nis+, etc) with the virtual's IP address.
Friday, April 27, 2007
Create Virtual Screen Covering Two Monitors
#vi /etc/dt/config/Xservers
:0 Local local_uid@concole root /usr/openwin/bin/Xsun :0 +xinerama -dev /dev/fbs/jfb0a -dev /dev/fbs/jfb0b -nobanner
Thursday, April 26, 2007
Copy Contents of One Tape to Another
#dd if=/dev/rmt/0 of=/dev/rmt/1
Create a Clone Disk Drive
Disk to Disk (Ensure the disks are the same size)
#dd if=/dev/rdsk/c0t10d0s2 of=/dev/rdsk/c0t11d0s2 (default blocksize 512)
Blocksize is configurable (For RAIDs, we use larger blocksizes, e.g. 4k)
#dd if=/dev/rdsk/c0t10d0s2 of=/dev/rdsk/c0t11d0s2 bs=128
Disk to Tape
#dd if=/dev/rdsk/c0t10d0s2 of=/dev/rdsk/c0t11d0s2
Blocksize is configurable
#dd if=/dev/rdsk/c0t10d0s2 of=/dev/rmt/0 bs=128
Tuesday, April 24, 2007
Change Filename Extensions with Inline Script
Change filename extension
# cd /directory_with_datafiles
# csh
# foreach filename ( *.dta )
?set base=`basename $filename .dta`
?mv $filename $base.dat
?end
# chmod 444 *.dat
Here's an actual run
# csh
# touch t1.data t2.data t3.data t4.data t5.data
# foreach filename (*.data)
? set base=`basename $filename .data`
? mv $filename $base.dat
? end
# ls
t1.dat t2.dat t3.dat t4.dat t5.dat
Friday, April 20, 2007
Determine Why a Process is Hanging with truss
#truss -d unix_command
Wednesday, April 18, 2007
Repeat the Previous UNIX Argument
#csh
#ls -l /home/esofthub/scripts/user_sqlscript_dir
#cp -pr !$ /raid/mybackup/.
Saturday, April 14, 2007
Repeat the Previous UNIX Command
For C shell
#csh
#vi this_is_a_very_long_filename
text
:wq! (saves and quits vi)
Repeats the command
#!!
For ksh shell
#ksh
#vi this_is_a_very_long_filename
text
:wq! (saves and quits vi)
Repeats the command (r is a built-in alias fc -e -)
#r
Friday, April 13, 2007
Install a Solaris Boot Block
ok boot cdrom -s
# /usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0s0
Wednesday, April 11, 2007
Change Access and Modification Times on a File
If you ever needed to arbitrarily change the access and modification times on a file, here's how to do it. I can see this being useful when you are performing a find event. You can also use a reference file to set the times on a target file or directory.
Here's the time set to
#touch -t 200704101816 filename
#settime -f reference_file target_filename
Tuesday, April 10, 2007
Conduct Interactive Communications Between Workstations
#talk user@esofthub1_wkstn
Monday, April 09, 2007
Unlock Screenlock With a Group Account Named xlock
Create an xlock group in whatever name service (files, nis or nisplus) you are using, and then add your login to the group. You should be able to unlock user's screenlocks with your password.
This post is referring to the “lock” on the desktop panel.
Note: Your IT or security department may prohibit or restrict the use of an xlock group.
Sunday, April 08, 2007
Determine the Manual Page for a Given Command
#whatis ps
returns (1) /usr/bin/ps
and
(1b) /usr/ucb/ps
This is equivalent to the whatis command
#man -f command
Here's the man page for /usr/ucb/ps
#man -s1b ps
By the way, I was looking for /usr/ucb/ps -aux
Thursday, April 05, 2007
NEdit is a Multi-purpose Text Editor
It's a multi-platform application, too. NEdit was originally developed on a Unix system and is available on all major Unix and Linux systems, but it also runs on MacOS X, OS/2 and MS Windows.
Personally, I find it to be a very powerful tool, especially when it comes to manipulating columns.
NEdit.org
Wednesday, April 04, 2007
Determine Processes Accessing a File System
I was trying to unmount the /opt filesystem today, but I was prompted with a "device busy" message. Frankly speaking, I thought the file system was already in an inactive state, so I was curious as to what processes were hanging it. These processes were identified and subsequently killed.
# cd /
# umount /opt (device busy)
After realizing that processes were still accessing the /opt filesystem, here's what was done to umount it.
Determine which processes were accessing /opt
# cd /
# fuser -cu /opt
# kill -9 PID1 PID2
# umount /opt
Alternately, this could have been done, too.
# cd /
# fuser -ck /opt
# umount /opt
or simply force it
# cd /
# umount -f /opt
Tuesday, April 03, 2007
List User Login Information with listusers or logins
#listusers
#listusers -l login
#listusers -g xlock
The other command that list user and system login information is named logins
#logins
Monday, April 02, 2007
Skip the Power On Self Test (POST)
Reset NVRAM Parameters with set-defaults
ok set-defaults
If you only want to reset one particular parameter, note the example below.
Note the absence of an "s"
ok set-default boot-device
Sunday, April 01, 2007
Interesting UNIX Commands
ok slooflirpa
Here are some more interesting commands
ok slooflirpa
Remove Device Alias with nvunalias
ok nvunalias backup
Create a Device Alias with nvedit
Make sure that use-nvramrc variable is set to true. nvedit edits the NVRAMRC.
Here's the setup
ok printenv (get the variable name and its syntax)
ok setenv use-nvramrc? true
ok nvedit
devalias disk0 /pci@9,600000/SUNW,qlc@2/fp@0,0
control ^c (to exit nvedit)
ok nvstore
ok reset
ok boot disk0
Create a Device Alias with nvalias
ok nvalias backup /pci@9,600000/SUNW,qlc@2/fp@1,0
By the way, aliases are stored in the NVRAMRC, which is part of the NVRAM.
To boot off the backup
ok boot backup
Display NVRAM Parameters
If you have security enabled, you will be prompted for a password
ok printenv
Variable Name Value Default Value
...
boot-device disk disk net
...
Here's an example of changing the boot device.
ok setenv boot-device disk1
ok reset
Show the change
ok printenv
Variable Name Value Default Value
...
boot-device disk1 disk net
...