Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

Thursday, July 31, 2008

Unix File System configuration

$/etc/fstab
stores the filesystem mount point informations
A backup of the same comes in handy if we need to restore and mount the filesystem

# System /etc/fstab file. Static information about the file systems
# See fstab(4) and sam(1M) for further details on configuring devices.

The first column shows the Device, Second col. is its mount point, third is the type of device, mount options, dump options and filesystem check options.

Unix admin. has to maintain this file correctly.
This is used by the commands mount, umount & fsck

Monday, March 10, 2008

Unix Commands - Syntax

Some basic unix command usage examples


To delete files (with extension .dbf) in a folder which are older than 7 days. This may be put inside a shell script for executing as a cron job


#!/bin/ksh
$ find /u02/ora/archives -type f -mtime +7 -name \*.dbf -print -exec rm {} \;

Example usages link

To delete ALL files owned by a user:
$ find . -user USERID awk '{print "rm "$NF}' ksh

'find' command links

To Copy files matching certain criteria to another directory (just to practice grep, printf and awk features...)

$ ls -altr grep "Jul 3" grep -v ^d awk '{printf("cp %s ./new_dir/%s\n",$9,$9)}' sh

$ for mystatement in `cat myfile.dat awk '{print $1}'`; <<EOF!
do sqlplus / as sysadmin mystatement ;
EOF!

$ chown oracle:dba * : to change owner and group of all files in current dir

$ ps -ef grep 234 awk '{print $2}' xargs kill

$ ps -ef egrep 'pmonsmonlgwrdbwarc' grep -v grep

$ ls -altr

$ ptrace [processid]

$ pfiles [processid]

$ ptree [processid]

$ truss -p [processid]

$ top

$ sort -t: +2n -3 /etc/passwd
-t : separator
+2n : begin - nth occurance of separator
-3 : end

$ who sort +4n

$ vmstat interval 6

$ mpstat - for multiprocessor

$ sar

$ iostat

$ uname -a

$ at 8:15

$ uucp

$ du -h : Disk usage

$ bdf . : to find the disk free space on a particular mount volume (in %)

$ df : to find the disk free space on a particular mount volume

$ tail -100 filename.ext

$ tnsping INSTNAME

$ which top

$ bc : calculating arithmatics from command line

$ id -a : user id and group id

$ su - : switch to root user i.e. superuser

$ tar -cvvf tarfile.tar *.* for creating tarfile
$ tar -xvvf tarfile.tar for extracting from existing tarfile
$ tar -xvvzf tarfile.tar.gz for uncompress

$ rcp -r user@sourcehostname:sourcefileordir user@desthostname:destfileordir

$ gzip filename for compressing the file replaces the file with filename.gz
$ gzip -dvf zipfile.gz for uncompressing a .gz file


Useful link : Shell Programming

Tuesday, February 19, 2008

Paging vs. Swapping

Paging refers to paging out individual
pages of memory. Swapping is when an entire process is swapped out.
Paging is normal. Swapping happens when the resource load is heavy
and the entire proces is written out to disk. If you're swapping
a lot, you might want to look deeper into looking at things like
adding memory.

See article

Tuesday, January 29, 2008

crontab files location

The directory where the cron daemon will look for
/var/spool/cron/crontabs/{username}
Note: Do not edit directly. Needs root login for editing. Always use crontab -e
/usr/lib/cron/cron.allow - if file exists, username to be added, for user to use crontab
/usr/lib/cron/cron.deny - - if file exists, username if present will block user from using crontab

See Man Page>>

The following error condition encountered. How to correct?

-bash-3.00$ crontab -e
sh: /bin/vics: not found
The crontab file was not changed.

Set the following environment parameter to vi (if required provide complete path)
export VISUAL='vi'

The following also gives the same effect.
export EDITOR='vi'

Finding Unix OS Block Size

Block Size for different Operating Systems
512 bytes - Solaris, AIX, Windows NT/2000,
Linux, Irix, DG/UX OpenVMS, NetWare, UnixWare, DYNIX/ptx
1024 bytes - HP-UX, Tru64 Unix
2048 bytes - SCO Unix, Reliant Unix
4096 bytes - MVS, MPE/ix


The following commands give the block size

select max(lebsz) from sys.x$kccle;
(Note: The log block size is the unit for the setting of the log_checkpoint_interval, _log_io_size and max_dump_file_size parameters)

$ fstyp -v /dev/dsk/c1d0s6  | grep devbsize
$ df /opt/oracle
/opt/oracle (/dev/dsk/c1d0s6 ):42448742 blocks 6413020 files


DO NOT USE THE FOLLOWING :
df -g grep 'block size'

(Note: the available & used free blocks given by the command df -g are based on the OS block size -see list above ; also use the first 2 methods to find- not the BLOCK SIZE value returned by df -g )