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.
Wednesday, February 28, 2007
Check the Status of a File or Directory on Tape
Archive files and directories into a tarball.
#tar cvfp esofthub.tar cgi-bin ircd zircon popper
Archive file (tarball) onto tape
#tar cvfp /dev/rmt/0 esofthub.tar
Check for status of file (esofthub.tar)
(Default)
#tar tvf /dev/rmt/0
For the second tape device with a tape in it
#tar tvf /dev/rmt/1
How to Rewind and Eject a Tape
To rewind a tape (default)
#mt /dev/rmt/0 rewind
To rewind and eject a tape
#mt /dev/rmt/0 offline
For the second tape drive
#mt -f /dev/rmt/1 rewind
#mt -f /dev/rmt/1 offline
Tuesday, February 27, 2007
Check the Local Tape Device
Default status (don't need the "-f" option)
#mt /dev/rmt/0 stat
For second tape device
#mt -f /dev/rmt/1 stat
For third tape device
#mt -f /dev/rmt/2 stat
Monday, February 26, 2007
Recover a File with vi After System Crash
# vi -r filename
Display the Status of Print Jobs Or Cancel a Job
Gives the status of all print jobs started with the lp command
#lpstat
myprinter_1-250 esofthub 9876 Feb 24 10:16
myprinter_1-251 esofthub 6754 Feb 24 10:45
myprinter_1-252 esofthub 5646 Feb 24 10:56
Cancel a print job started with lp
#cancel myprinter_1-250
Determine Computer Uptimes for Remote and Local
Run this command provided that security hasn't disabled it
#ruptime -a
For local uptime
#uptime
Here's an example of the output.
12:19pm up 65 day(s), 42 mins, 13 users, load average: 0.39, 0.56, 0.10
Sunday, February 25, 2007
Unix System Administration Task: Delete Log Files
Note: When I stated old log files, I meant terminated files--not ones with open file handles.
# cd /where_your_logs_are
# find . -name '*.deadlog' -exec rm {} \;
Create a Command Alias in .cshrc
# csh
# vi $HOME/.cshrc
...
alias ls 'ls -ltr'
alias lp 'lp -d not_primary_printer'
alias rm 'rm -i'
...
:wq! (saves and quits vi)
# ls
-rwxrw--r-- 1 esofthub mygroup 2345 Feb 21 01:34 esofthub
-rw-rw--r-- 1 esofthub mygroup 8078 Feb 21 01:35 esofthub1
# lp esofthub1
Note: You can unalias the command, too.
# unalias ls
# unalias rm
Add Third Monitor and Restart dtlogin (XVR-1000/XVR-1200)
If the /etc/dt directory does not exist, you may want to copy it to /etc.
#cp -pr /usr/dt /etc
#vi /etc/dt/config/Xservers
:0 local /usr/openwin/bin/X -dev /dev/fbs/jfb0a defclass TrueColor defdepth 24 -dev /dev/fbs/jfb0b defclass Truecolor defdepth 24 -dev /dev/fbs/gfb0 defclass TrueColor defdepth 24 right
:wq! (saves and quits vi)
Here's the restart. By the way, I executed these commands from a remote machine.
#cd /etc/init.d
#./dtlogin start
OR
#cd /etc/rc2.d
#./S99dtlogin start
The S99 script is linked to dtlogin.
OR
#reboot
Saturday, February 24, 2007
Create Large Files to Test Throughput Rates
Here's what was done.
Create a 1MB file
# mkfile 1m 1MB
Create a 5MB file
# mkfile 5m 5MB
Create 10MB file
# mkfile 10m 10MB
Create 100MB file
# mkfile 100m 100MB
Create 1GB file
# mkfile 1000m 1GB
Extra: Use Z Shell brace expansion to create multiple test files
Create Named Pipes for Interprocess Communications
This action creates a named pipe called mypipe.
# mknod mypipe p
In our case, the named pipe needed to be read and writable by everyone
# chmod 666 mypipe
An alternate way of creating the named pipe - suggested by ux-admin:
# mkfifo mypipe
# chmod 666 mypipe
Thursday, February 22, 2007
Change the Hostname of a Workstation
Last week, I was asked how to change the hostname of a workstation. There were a few modifications to some of the files in the /etc directory. In this example, I used the common vi editor or nedit to make the changes.
Here are the events that took place. I assumed the old workstation's hostname was esofthub
# vi /etc/nodename
# vi /etc/hostname.hme0
# vi /etc/inet/hosts
# vi /etc/inet/ipnodes
# mv /var/crash/esofthub /var/crash/newesofthub
# init 6
Remove NIS+ From a Workstation
Workstation or Server
# cp -p /etc/nsswitch.files /etc/nsswitch.conf
# /etc/init.d/rpc stop
# /etc/init.d/nscd stop
# rm -f /etc/.rootkey
# cd /var/nis
# rm -rf .*; rm -rf *
# /etc/init.d/rpc start OR perform a reboot
Alternate for workstation only:
# setenv PATH ${PATH}:/usr/lib/nis
# nisclient -r
Alternately, here is a link to Setup NIS+ server and populate its tables
Determine What a File Contains
Binary files can be quite annoying if opened with the incorrect application.
#file filename
Add Security Banners for Login Screen, Telnet, and FTP
Here's the example for the login screen.
#vi /etc/issue
YOUR NOTICE AND CONSENT BANNER GOES HERE
...
...
...
:wq! (saves and quits)
Here's the example for ftp
#vi /etc/default/ftpd
BANNER="YOUR NOTICE AND CONSENT BANNER GOES HERE"
:wq!
Here's the example for telnet
#vi /etc/default/telnetd
BANNER="YOUR NOTICE AND CONSENT BANNER GOES HERE"
:wq!
Wednesday, February 21, 2007
Display Non-printable Characters in Binary Files
Here's are some examples.
Displays in character format
# od -c a.out
Capture a serial stream and display in character format
# tip -9600 /dev/term/a | od -c
Capture a serial stream and display in hexadecimal format
# tip -9600 /dev/term/a | od -x
Related post
Display Printable Characters in a Binary File
#strings output_binary_file | more
Tuesday, February 20, 2007
Display Diagnostic Information to Sceen
#dmesg
Get Firmware, H/W Platform, RAM, Ethernet Address and Host ID
You can obtain the PROM revision level, hardware platform, RAM installed, serial number, Ethernet address, logo, and the host id by using the following command in the Open Boot Prom (OBP) mode: banner. The firmware information can be very useful, especially if you are upgrading processors. I used it to determine if a firmware update was required for new processors--That was the case.
Here's an example.
OBP mode
ok banner
Note: If you looking for the UNIX banner command, which outputs string information, here’s its post: Using UNIX banner to print to STDOUT
Display the PROM Versions for All Boards
OBP mode
ok .version
Display the NVRAM Configuration
Open Boot Prom (OBP) mode
ok printenv
(You might have a PROM password set. If so, you will have to enter it.)
setenv boot-device disk1
By the way, the eeprom command can do the same (set boot device) thing in the init 3 level.
Monday, February 19, 2007
Make a Filesystem Read Only
# vi /etc/vfstab
#
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
...(other entries go here)
/dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr ufs 1 no logging,ro
...(other entries go here)
:wq! (saves and quits vi)
To write to the filesystem
remove the "ro" option from the /etc/vfstab and reboot
OR to make it temporary ("ro" restored after reboot)
# mount -F ufs -o rw,remount /usr
Delete or Filter Lines in a File
Display the filtered output to the screen
# sed -e '/^#/d' -e '/^$/d' /etc/hosts | more
Write the filtered output to a file
# sed -e '/^#/d' -e '/^$/d' /etc/hosts > /tmp/hosts.filtered
Just blank lines
# sed -e '/^$/d' /etc/hosts > /tmp/hosts.filtered
Find Day of the Month for Years Past and Forward
#cal 10 1982
Sunday, February 18, 2007
Using the Banner Command to Print to STDOUT
One word per line
# banner Thank you for visiting and contributing to My SysAd Blog
On one line
# banner "My SysAd Blog"
If you trying to use the banner command to output something to the printer, then you can use this syntax.
# banner This message is outputting to the printer - My SysAd Blog – UNIX | lp
Note:
If you are trying to use the Open Boot Prom's banner command, that's a different command altogether and here's the post: Get hardware, Platform, RAM and Ethernet Information
Delete a Filename with an Invalid Character
Here is an example. This is a filename with an invalid character, "-", in front of it.
# cd /tmp
# ls
-esofthub
# rm /-esofthub
or
# rm -- -esofthub
or by inode
# ls -i
# find . -inum 968746 -exec rm -i {} \;
Rebuild the /etc/path_to_inst File
#init 0
ok boot -rav
Just answer the questions during the bootup sequence.
Boot to Single User Mode
From Open Boot Prom (OBP)
You will be prompt for a password if security-mode is set to command
ok boot -s
ok boot cdrom -s
From the init 3 level
This will automatically execute a boot -s at the OBP level
#reboot -- -s
Thursday, February 15, 2007
XVR-1200 Card with a Second Monitor Setup
If the /etc/dt directory does not exist, you may want to copy it to /etc.
#cp -pr /usr/dt /etc
#vi /etc/dt/config/Xservers
:0 local /usr/openwin/bin/X -dev /dev/fbs/jfb0a defclass TrueColor defdepth 24 -dev /dev/fbs/jfb0b defclass Truecolor defdepth 24 right
:wq! (saves and quits vi)
Mount the Backup Disk to Recover a File or Directory
Assume active disk is /dev/dsk/c0t0d0s0
#cd /
#mount /dev/dsk/c0t1d0s0 /mnt
#cp -p /mnt/etc/someconfig.cfg /tmp
#mkdir /a
#mount /dev/dsk/c0t1d0s6 /a
#cp -pr /a/USERS/esofthub /tmp
#umount /mnt
#umount /a
#rmdir /a
#cd /tmp
Copy Time of Day to IO Board(s)
Here's what we did at the Open Boot Prom level.
ok copy-clock-tod-to-io-boards
ok boot
Wednesday, February 14, 2007
Display Line Numbers for a File to STDOUT
Without options
# nl sysad.txt
1 This blog's
2 content
3 is primarily
4 a HOWTO for UNIX
5 system administration.
6 Its articles consist of Solaris,
7 Sybase, Oracle, and miscellaneous
8 tips and operating system information.
9 This blog's content
10 is primarily
11 a HOWTO for UNIX
12 system administration.
13 Its articles consist of Solaris,
14 Sybase, Oracle, and miscellaneous
15 tips and operating system information.
Show the blank line with a line number
# nl -ba sysad.txt
1 This blog's
2 content
3 is primarily
4 a HOWTO for UNIX
5 system administration.
6 Its articles consist of Solaris,
7 Sybase, Oracle, and miscellaneous
8 tips and operating system information.
9
10 This blog's content
11 is primarily
12 a HOWTO for UNIX
13 system administration.
14 Its articles consist of Solaris,
15 Sybase, Oracle, and miscellaneous
16 tips and operating system information.
Print the numbered output
# nl -ba sysad.txt | lp
Determine System Routing Tables
#netstat -rn
This shows the system routing tables and displays the IPs.
#netstat -i
This shows the statistics per interface, e.g. hme0, lo0, ce0, ge1, etc.
Tuesday, February 13, 2007
Creating a Symbolic Link or Removing a Symbolic Link
#cd /opt
#ln -s /raid/myexample_18 myexample
#ls
myexample (checking for the listing)
Start my shell script in the background.
#/opt/myexample/bin/start_program.sh &
To remove a symbolic link
#rm myexample
Prevent Remote Logins by root
vi /etc/default/login
#/dev/console
/dev/console
:wq! (saves and quits)
As you can see, the comment prefacing /dev/console has been removed. A user should not be able to remotely login as root.
Monitor CPU Usage for Each Process
# /usr/ucb/ps -aux | head -20
USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND
root 2412 1.5 2.1 2840 2512 pts/2 O 23:25:35 0:00 /usr/ucb/ps -aux
root 2411 0.1 0.6 952 664 pts/2 S 23:25:35 0:00 head -20
root 353 0.0 1.6 2384 1952 ? S Nov 06 3:31 mibiisa -r -p 3280
root 0 0.0 0.0 0 0 ? T Nov 06 0:17 sched
root 1 0.0 0.3 792 376 ? S Nov 06 0:00 /etc/init -
root 2 0.0 0.0 0 0 ? S Nov 06 0:00 pageout
root 3 0.0 0.0 0 0 ? S Nov 06 1:45 fsflush
root 56 0.0 1.0 1544 1144 ? S Nov 06 0:00 /usr/lib/sysevent/
# while true
do
/usr/ucb/ps -aux | head -20
sleep 5
done
In terms of CPU percentage, the aforementioned loop shows the top 20 processes every 5 seconds.
You might want look at prstat, too, to check out the active stats
# prstat
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
2413 root 1536K 1280K cpu0 58 0 0:00.00 0.1% prstat/1
207 root 3688K 3112K sleep 58 0 0:00.00 0.0% nscd/8
353 root 2384K 1952K sleep 48 0 0:00.00 0.0% mibiisa/12
240 root 3240K 1608K sleep 59 0 0:00.00 0.0% sendmail/1
228 root 1408K 944K sleep 53 0 0:00.00 0.0% powerd/5
326 root 3088K 2016K sleep 22 0 0:00.00 0.0% dmispd/5
193 root 2000K 1376K sleep 33 0 0:00.00 0.0% cron/1
187 root 3472K 2016K sleep 52 0 0:00.00 0.0% syslogd/9
167 root 1984K 1416K sleep 12 0 0:00.00 0.0% lockd/1
215 root 3072K 976K sleep 43 0 0:00.00 0.0% lpsched/1
Invoke a Remote Terminal via CDE's Main Panel
What's handy about this? You didn't have to rlogin, invoke xhost, or manually set DISPLAY. That was done automatically.
Here's what you need to put into the gui's field.
@remote_hostname
Setting the Terminal to Reasonable Values
At any rate, here's the reset command.
#stty sane
Check terminal values
#stty -a
Monday, February 12, 2007
Add a Net With a Static Route
Here's an example.
#vi /etc/rc3.d/S97static_routes
#!/usr/bin/sh
route add net 192.168.100.0 192.168.105.1 1
:wq! (quits and saves)
I just added the class C network 192.168.100.0 via the router 192.168.105.1. These IPs are only used for illustration purposes.
To manipulate the routing table
Route Add, Route Change, Route Delete, Route Monitor, Route Flush
Sunday, February 11, 2007
Determine Controller, Target, Disk Size, and Slice
Use care. It can be destructive if you don't know what you are doing. Amongst many other things, it's used to slice the hard drive.
#format
Create New Filesystems via Command Line
Here's the example.
Creates a new filesystem on slice 3. It will prompt you for a go ahead response, y or n.
#newfs /dev/rdsk/c0t0d0s3
Loop the task for multiple slices. It will prompt you for a go ahead response, y or n, for each iteration. Gives you a chance to abort your decision.
#for slice in 0 3 4 5 6 7
do
newfs /dev/rdsk/c0t0d0s$slice
done
Loop the task for multiple slices. It will NOT prompt you for a go ahead response, y or n, for each iteration. Assumes you know what you are doing.
#for slice in 0 3 4 5 6 7
do
echo y | newfs /dev/rdsk/c0t0d0s$slice
done
Saturday, February 10, 2007
Monitor Processor Statistics
Here’s an example of its use.
No arguments show 1 iteration of per processor statistics
#mpstat
This example updates per processor statistics every 3 seconds
#mpstat 3
Determine Times When a User Logged in and Out
Here's an example of its use.
No arguments will list all users and their times
# last
For a particular user
# last esofthub
esofthub pts/3 wkstn2 Wed Oct 31 23:57 - 01:07 (1+01:09)
esofthub console :0 Sun Oct 28 22:28 - 23:50 (4+01:22)
esofthub console :0 Wed May 30 22:16 - 22:37 (14+00:20)
esofthub console :0 Fri May 11 20:59 - 21:47 (00:47)
esofthub console :0 Tue Apr 24 23:03 - 07:32 (10+08:29)
esofthub console :0 Tue Apr 24 23:02 - 23:02 (00:00)
Tracing Network Paths
We use the traceroute command to ascertain this information. Here's an example of its use. Note: Some routers are programmed to block the traceroute action.
#traceroute esofthub.blogspot.com
Friday, February 09, 2007
Commit NIS+ Transaction Log
Here is an example of a run we did.
# nisping -Ca
Then we checked for the number of entries in the NIS+ transaction log.
# nislog | head -15
The NIS+ trans log contained 3 entries; therefore, it was fully checkpointed.
Replace Contents of a NIS+ Table
Here is an example (you can use relative or absolute path for dumping and replacement).
# cd /var/nis/backup (for relative path)
If C shell
# setenv PATH $PATH:/usr/lib/nis
If Bourne or Korn Shell
# PATH=$PATH:/usr/lib/nis; export PATH
Dump the NIS+ table to file
# nisaddent -d hosts > /var/nis/backup/hosts
Edit the file
# vi hosts
...
...
10.10.10.1 myaddedhost
:wq! (saves and quits vi)
Replace and populate the contents of hosts to the NIS+ hosts table.
# nisaddent -rv -f /var/nis/backup/hosts hosts
Here is another example
# nisaddent -d passwd > /var/nis/backup/passwd
# vi /var/nis/backup/passwd
# nisaddent -rv -f /var/nis/backup/passwd passwd
Backup NIS+ Tables
Here is a recommended procedure:
If C shell
# cd /var/nis/backup
# setenv PATH $PATH:/usr/lib/nis
If Bourne or Korn Shell
# PATH=$PATH:/usr/lib/nis; export PATH
# nisaddent -d aliases > aliases
# nisaddent -d bootparams > bootparams
# nisaddent -d ethers > ethers
# nisaddent -d group > group
# nisaddent -d hosts > hosts
# nisaddent -d netgroup > netgroup
# nisaddent -d netid > netid
# nisaddent -d netmasks > netmasks
# nisaddent -d networks > networks
# nisaddent -d passwd > passwd
# nisaddent -d protocols > protocols
# nisaddent -d publickey > publickey
# nisaddent -d rpc > rpc
# nisaddent -d services > services
# nisaddent -d trusted > trusted
# nisaddent -d timezone > timezone
# nisaddent -d auto_home.org_dir > auto_home
# niscat auto_master.org_dir > auto_master
# niscat auto_direct.org_dir > auto_direct
Confirm 64-bit Application Support
#isainfo -v
Thursday, February 08, 2007
Add Login to Sybase
For example, add login esofthub
#isql -Usa -Ppassword
>sp_addlogin esofthub, "mypassword", null, null, "A New Login"
>go
>quit
The user is assigned to the default database and the default language is used.
Add a User to a Database for Sybase
For example, add user esofthub to database named mysybasedb
#isql -Usa -Ppassword
>use mysybasedb
>go
>sp_adduser esofthub
>go
>quit
Automatically Dump the Database for Sybase
Ensure that you have permissions to write to the destination directory.
Create the SQL script
#vi /home/esofthub/dump.sql
1>use master
2>go
1>dump database databasename to '/raid/sybdumps/dump.dat'
2>go
:wq! (saves and quits vi)
Create the shell script
#vi /home/esofthub/dump.sh
#!/usr/bin/sh
isql -U login -P password -e < /home/esofthub/dump.sql > dump.out
:wq! (saves and quits vi)
Add entry to the crontab
#crontab -e
0 5 * * * /home/esofthub/dump.sh
:wq! (saves and quits vi)
This crontab entry invokes the dump.sh script every day at 0500.
Tuesday, February 06, 2007
Run Debugger and Verbose Modes in a Script
Here's a demo script to illustrate the aforementioned comments.
#!/usr/bin/sh -xv
#Name: SampleScript
#Purpose: Demonstrate debug and verbose options.
#
#Menu
echo "Choose either P, D, Q "
echo "[P]rint"
echo "[D]elete"
echo "[Q]uit"
#Get letter from user
read letter
#Match response
case $letter
in
P|p) echo "Name of file to print."
read file
lp $file;;
D|d) echo "Name of file to delete."
read file
rm $file;;
*) echo "Quitting program";;
esac
Print From the Buffer via the Command Line
Here's a partial description of My SysAd Blog header:
#lp (set for default printer)
UNIX stands for UNiplexed Information and Computing System--originally spelled UNICS. It supports such tasks as running hardware, device drivers, peripherals and third party applications. It's a multi-user, multi-tasking, multi-processing, and multi-threading environment. (press enter)
control ^d (control d)
Otherwise
#lp -d yourprinter
UNIX stands for UNiplexed Information and Computing System--originally spelled UNICS. It supports such tasks as running hardware, device drivers, peripherals and third party applications. It's a multi-user, multi-tasking, multi-processing, and multi-threading environment. (press enter)
control ^d (control d)
Monday, February 05, 2007
Count the Lines, Words and Characters in a File
# wc esofthub.dat
10 23 60 esofthub.dat
This file has 10 lines, 23 words and 60 characters.
# wc -lwc esofthub.dat esofthub1.dat
10 23 60 esofthub.dat
12 25 63 esofthub1.dat
22 48 123 total
This command totals the lines, words and characters.
or
This method also totals the lines, words and characters.
# wc *
7 7 38 user1.txt
9 9 47 user2.txt
11 11 66 user3.txt
5 5 31 user4.txt
32 32 182 total
Note: The Blogger application parsed out the less-than characters so an underscore was used to preserve the contiguous nature of the "<<_eof">
# wc <<_EOF
>
> number of lines, words
> and characters in this
> exercise
> _EOF
4 13 76
Methods of Accessing a Workstation
These are just a few examples...
Note: rlogin and rsh will prompt you for a password if the remote system does not trust the local system.
# rlogin -l esofthub_user myserver
# rsh myserver (invokes rlogin without command line arguments)
# ftp myserver (prompts you for a password unless it is anonymous ftp)
# telnet myserver (prompts you for a password)
Add a Scroll Bar to xterm
# xterm -bg black -fg green -title "My Blog Log" -sb &
If you make changes to the .Xdefaults file during your login session, you can load the changes by doing the following action:
# xrdb -load /home/esofthub/.Xdefaults
You might also want to increase the buffer space. In this example, I am increasing the buffer space to 3000 lines.
# xterm -bg black -fg green -title "My Blog Log" -sb -sl 3000 &
Remap Buttons on a Mouse
#xmodmap -e 'pointer= 3 2 1'
Sunday, February 04, 2007
Get System Identification for Solaris
#uname -a
Limit Access from Remote Workstations
vi /etc/hosts.allow
daemon_program:client_list:options
Here's an example:
#vi /etc/hosts.allow
in.telnetd:15.23.1.1,15.23.1.2:
in.ftpd:15.23.1.1,15.23.1.2:
in.rshd:15.23.1.1,15.23.1.2:
in.rlogind:15.23.1.1,15.23.1.2:
:wq! (saves and quits vi)
Copy Files to a Remote Workstation
If you copying a file to the root directory, ensure that the /.rhosts file is properly populated. Bear in mind that the login directory for the root account could be set to something else other than /, so check your /etc/passwd file to verify. Suppose I wanted to copy /etc/default/login to another workstation.
On remote workstation:
#vi /.rhosts
remote_workstation root
:wq! (saves and quits)
On local workstation:
#rcp -p /etc/default/login remote_workstation:/etc/default
Determine Who is Logged on
#who -r
Or
#finger
If you want to know who is logged onto remote machines, use this command.
#rusers
Set EDITOR Variable for vi
Do you ever have problems displaying vi in the xterm or cmdtool windows? Your EDITOR variable may have not been set correctly. Here is a simple fix.
Bourne shell:
# sh
# EDITOR=vi; export EDITOR
C shell:
# csh
# setenv EDITOR vi
I had to use these procedures today because I was having problems displaying text the crontab with crontab -e.
By the way, you can add this type of information into your initialization files ($HOME/.cshrc, $HOME/.kshrc, $HOME/.profile, etc).
Trouble With Strange Characters -- Might be TERM
#echo $TERM (see what value is in the variable)
If its output is not what you expected, set the correct value.
For Sun:
#sh
#TERM=sun
#export TERM
For most others:
#TERM=vt100
#export TERM
For C shell:
#csh
#setenv TERM sun
or
#setenv TERM vt100
Note: TERM must match one of the terminal types listed in the /usr/lib/terminfo directory.
Determine the Directory Size Recursively
Here's an example of what can be done:
#cd /huge_directory
#du -k . (current directory size given in kilobytes)
To find the sizes recursively (subdirectories):
#cd /huge_directory
#sh
#for size in 'ls'
do
du -k $size
echo $size done
done
Determine Available Space on a Filesystem
Here's the command:
#df -k
shows the space status of all the filesystems on the system in kilobytes
Or you can be specific about the filesystem
#cd /var
#df -k .
Perform a Network File System Mount
Here's an example of doing a simple automount:
On the server:
#vi /etc/dfs/dfstab
share "options go here" /export/exportdir
:wq! (saves and quits vi)
#share /export/exportdir
On the client workstation:
#vi /etc/auto_esofthub
/opt/mount_point "options go here" server:/export/exportdir
:wq! (saves and quits vi)
Add this entry into the /etc/auto_master.
#vi /etc/auto_master
/- "tab or space delimiter" /etc/auto_esofthub
:wq! (saves and quits vi)
#automount -v (mounts virtual directory or directories in verbose mode)
Note: These virtual mounts can be used to hide directories underneath them.
Saturday, February 03, 2007
Prevent Process Hangup on Log Out
Here's an example of how I ensure my process(es) will continue regardless of log on status:
#nohup sort esofthub.dat > esofthub.sorted &
OR I can even mail the results to myself.
#nohup sort esofthub.dat > esofthub.sorted | nohup mailx -s "esofthub's sorted file" &
Thursday, February 01, 2007
Problems Recovering Hard Drive with FSCK
After a hard crash today, a colleague of mine tried repeatedly (several hours) to recover a newly installed Sun v490 server (w/Solaris 8) and its Sun RAID with FSCK. However, each time he ran the FSCK command, the system returned UFS block read errors. The problem seemed somewhat familiar to me, and I asked him if he had logging configured. He said yes. I recommended temporarily removing the logging option from the /etc/vfstab file.
Here's what was done:
#cp –p /etc/vfstab /etc/vfstab.020107
OR
#cp -p /etc/vfstab /etc/vfstab.`date '+%m%d%y'`
#vi /etc/vfstab
change "logging" option to "-" where applicable
: wq! (quits and saves)
#init 0
boot
The system booted up and FSCK automatically invoked and was able to fix whatever UFS block errors that were present. Then the original /etc/vfstab file was manually restored.