________________________________________
Advance Unix Management
________________________________________
xyx:/>compress
-command compresses a file and returns the original file with .z extension, to uncompress this filename’s file use uncompress filename command.
Available Options
-bn limit the number of bits in coding to n
-c write to standard output
-f compress conditionally, do not prompt before overwriting files
-v Print the resulting percentage of reduction for files
________________________________________
xyx:/>uncompress
- command file uncompresses a file and return it to its original form.
uncompress filename.Z this uncompressed the compressed file to its original name.
-c write to standard output without changing files
________________________________________
xyx:/>cpio
- command is useful to backup the file systems. It copy file archives in from or out to tape or disk, or to another location on the local machine.
cpio flags [options]
It has three flags, -i, -o, -p
cpio -i [options] [patterns]
-> cpio -i copy in files who names match selected patterns
-> If no pattern is used all files are copied in
-> It is used to write to a tape
cpio -o
-> Copy out a list of files whose name are given on standard output
cpio -p
-> Copy files to another directory on the same system.
Options
-a reset access times of input files
-A append files to an archive (must use with -o)
-b swap bytes and half-words. Words are 4 bytes
-B block input or output using 5120 bytes per record
-c Read or write header information as Ascii character
-d create directories as needed
-l link files instead of copying
-o file direct output to a file
-r rename files interactively
-R ID reassign file ownership and group information to the user's login ID
-V print a dot for each file read or written
-s swap bytes
-S swap half bytes
-v print a list of filenames
Imp Examples
-> find . -name "*.old" -print | cpio -ocvB > /dev/rst8 will backup all *.old files to a tape in /dev/rst8
-> cpio -icdv "save"" < /dev/rst8 will restore all files whose name contain "save" -> find . -depth -print | cpio -padm /mydir will move a directory tree.
________________________________________
xyx:/>dump
- command is useful to backup the file systems, copies all the files in file system that have been changed after a certain date. This command is good for incremental backups on HP Unix
date is derived from /var/adm/dump dates and /etc/fstab.
/usr/sbin/dump [option [argument ...] file system]
Options where
where 0-9 dump level. 0 option causes entire file system to be dumped or copied
b blocking factor taken into argument
d density of tape, default value is 1600
f place the dump on next argument file instead of tape
________________________________________
xyx:/>pack
- command compacts each file and combine them together into a filename.z file. The original file is replaced. pcat and unpack will restore packed files to their original form.
Available Options
-p Print number of times each byte is used
-f Force the pack even when disk space isn't saved
To display Packed files in a file use pcat command
-> pcat filename.z
To unpack a packed file use unpack command as unpack filename.z
________________________________________
xyx:/>tar
- command creates an archive of files into a single file. tar copies and restore files to a tape or any storage media.
Examples:
xyx:/>tar cvf /dev/rmt/0 /bin /usr/bin creates an archive of /bin and /usr/bin, and store on the tape in /dev/rmt0.
xyx:/>tar tvf /dev/rmt0 will list the tape's content in a /dev/rmt0 drive.
xyx:/>tar cvf - 'find . -print' > backup.tar will creates an archive of current directory and store it in file backup.tar.
Functions and options:
c creates a new tape
r append files to a tape
t print the names of files if they are stored on the tape
x extract files from tap
b n use blocking factor of n
l print error messages about links not found
L is symbolic links
v print function letter (x for extraction or a for archive) and name of files.
________________________________________
xyx:/>mt
- command is used for tape and other device functions like rewinding, ejecting, etc. It give commands to tape device rather than tape itself. mt command is BSD command and is seldom found in system V unix versions.
syntax is
mt [-t tapename] command [count]
mt for HP-UX accept following commands.
Important Examples to use
mt -t /dev/rmt/0mnb rew will rewind the tape in this device
mt -t /dev/rmt/0mnb offl will eject the tape in this device
________________________________________
xyx:/>calendar
- command reads your calendar file and displays only lines with current day.
Examples:-
12/20 Test new software.
1/15 Test newly developed 3270 product.
1/20 Install memory on HP 9000 machine.
On dec 20th the first line will be displayed. you can use this command with your crontab file or in your login files.
________________________________________
xyx:/>nohup
- command, is used with prefix of any command, which continue running the command even if you shut down your terminal or close your login session.
xyz:/>nohup top
________________________________________
xyx:/>tty
- command is used to display terminal information.
-l will print the synchronous line number
-s will return only the codes: 0 (a terminal), 1 (not a terminal), 2 (invalid options) (good for scripts)
________________________________________
Handy for Unix Shell Programming
________________________________________
Shell programming concepts and commands:
Shell programming is an integral part of Unix operating system. It is command line user interface to Unix system, User have an option of picking an interface on Unix such as ksh, csh, or default sh, these are called shells. Shell programming is used to automate many tasks. ________________________________________
Bourne Shell (sh shell):-
sh or Bourne shell is default shell of Unix operating systems and is the simplest shell in Unix systems.
Ksh shell (Korn):-
Ksh or Korn shell is widely used shell.
csh or c shell:-
csh is second most used shell.
echo command
The echo utility writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. If there are no arguments, only the NEWLINE character will be written.
echo is useful for producing diagnostics in command files, for sending known data into a pipe, and for displaying the contents of environment variables.
line command
The line utility copies one line (up to and including a new-line) from the standard input and writes it on the standard output. It returns an exit status of 1 on EOF and always prints at least a new-line. It is often used wwithin shell files to read from the user's terminal.
sleep command
The sleep utility will suspend execution for at least the integral number of seconds specified by the time operand.
Example 1: Suspending command execution for a time
To execute a command after a certain amount of time:
example% (sleep 105; command)&
Example 2: Executing a command every so often
example% while true
do
command
sleep 37
done
test command
The test utility evaluates the condition and indicates the result of the evaluation by its exit status. An exit status of zero indicates that the condition evaluated as true and an exit status of 1 indicates that the condition evaluated as false.
cc compiler (c programming language compiler).
Since Unix is itself is written in C programming language, most Unix operating systems come with c compiler called cc.
Advance Unix Management
________________________________________
xyx:/>compress
-command compresses a file and returns the original file with .z extension, to uncompress this filename’s file use uncompress filename command.
Available Options
-bn limit the number of bits in coding to n
-c write to standard output
-f compress conditionally, do not prompt before overwriting files
-v Print the resulting percentage of reduction for files
________________________________________
xyx:/>uncompress
- command file uncompresses a file and return it to its original form.
uncompress filename.Z this uncompressed the compressed file to its original name.
-c write to standard output without changing files
________________________________________
xyx:/>cpio
- command is useful to backup the file systems. It copy file archives in from or out to tape or disk, or to another location on the local machine.
cpio flags [options]
It has three flags, -i, -o, -p
cpio -i [options] [patterns]
-> cpio -i copy in files who names match selected patterns
-> If no pattern is used all files are copied in
-> It is used to write to a tape
cpio -o
-> Copy out a list of files whose name are given on standard output
cpio -p
-> Copy files to another directory on the same system.
Options
-a reset access times of input files
-A append files to an archive (must use with -o)
-b swap bytes and half-words. Words are 4 bytes
-B block input or output using 5120 bytes per record
-c Read or write header information as Ascii character
-d create directories as needed
-l link files instead of copying
-o file direct output to a file
-r rename files interactively
-R ID reassign file ownership and group information to the user's login ID
-V print a dot for each file read or written
-s swap bytes
-S swap half bytes
-v print a list of filenames
Imp Examples
-> find . -name "*.old" -print | cpio -ocvB > /dev/rst8 will backup all *.old files to a tape in /dev/rst8
-> cpio -icdv "save"" < /dev/rst8 will restore all files whose name contain "save" -> find . -depth -print | cpio -padm /mydir will move a directory tree.
________________________________________
xyx:/>dump
- command is useful to backup the file systems, copies all the files in file system that have been changed after a certain date. This command is good for incremental backups on HP Unix
date is derived from /var/adm/dump dates and /etc/fstab.
/usr/sbin/dump [option [argument ...] file system]
Options where
where 0-9 dump level. 0 option causes entire file system to be dumped or copied
b blocking factor taken into argument
d density of tape, default value is 1600
f place the dump on next argument file instead of tape
________________________________________
xyx:/>pack
- command compacts each file and combine them together into a filename.z file. The original file is replaced. pcat and unpack will restore packed files to their original form.
Available Options
-p Print number of times each byte is used
-f Force the pack even when disk space isn't saved
To display Packed files in a file use pcat command
-> pcat filename.z
To unpack a packed file use unpack command as unpack filename.z
________________________________________
xyx:/>tar
- command creates an archive of files into a single file. tar copies and restore files to a tape or any storage media.
Examples:
xyx:/>tar cvf /dev/rmt/0 /bin /usr/bin creates an archive of /bin and /usr/bin, and store on the tape in /dev/rmt0.
xyx:/>tar tvf /dev/rmt0 will list the tape's content in a /dev/rmt0 drive.
xyx:/>tar cvf - 'find . -print' > backup.tar will creates an archive of current directory and store it in file backup.tar.
Functions and options:
c creates a new tape
r append files to a tape
t print the names of files if they are stored on the tape
x extract files from tap
b n use blocking factor of n
l print error messages about links not found
L is symbolic links
v print function letter (x for extraction or a for archive) and name of files.
________________________________________
xyx:/>mt
- command is used for tape and other device functions like rewinding, ejecting, etc. It give commands to tape device rather than tape itself. mt command is BSD command and is seldom found in system V unix versions.
syntax is
mt [-t tapename] command [count]
mt for HP-UX accept following commands.
Important Examples to use
mt -t /dev/rmt/0mnb rew will rewind the tape in this device
mt -t /dev/rmt/0mnb offl will eject the tape in this device
________________________________________
xyx:/>calendar
- command reads your calendar file and displays only lines with current day.
Examples:-
12/20 Test new software.
1/15 Test newly developed 3270 product.
1/20 Install memory on HP 9000 machine.
On dec 20th the first line will be displayed. you can use this command with your crontab file or in your login files.
________________________________________
xyx:/>nohup
- command, is used with prefix of any command, which continue running the command even if you shut down your terminal or close your login session.
xyz:/>nohup top
________________________________________
xyx:/>tty
- command is used to display terminal information.
-l will print the synchronous line number
-s will return only the codes: 0 (a terminal), 1 (not a terminal), 2 (invalid options) (good for scripts)
________________________________________
Handy for Unix Shell Programming
________________________________________
Shell programming concepts and commands:
Shell programming is an integral part of Unix operating system. It is command line user interface to Unix system, User have an option of picking an interface on Unix such as ksh, csh, or default sh, these are called shells. Shell programming is used to automate many tasks. ________________________________________
Bourne Shell (sh shell):-
sh or Bourne shell is default shell of Unix operating systems and is the simplest shell in Unix systems.
Ksh shell (Korn):-
Ksh or Korn shell is widely used shell.
csh or c shell:-
csh is second most used shell.
echo command
The echo utility writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. If there are no arguments, only the NEWLINE character will be written.
echo is useful for producing diagnostics in command files, for sending known data into a pipe, and for displaying the contents of environment variables.
line command
The line utility copies one line (up to and including a new-line) from the standard input and writes it on the standard output. It returns an exit status of 1 on EOF and always prints at least a new-line. It is often used wwithin shell files to read from the user's terminal.
sleep command
The sleep utility will suspend execution for at least the integral number of seconds specified by the time operand.
Example 1: Suspending command execution for a time
To execute a command after a certain amount of time:
example% (sleep 105; command)&
Example 2: Executing a command every so often
example% while true
do
command
sleep 37
done
test command
The test utility evaluates the condition and indicates the result of the evaluation by its exit status. An exit status of zero indicates that the condition evaluated as true and an exit status of 1 indicates that the condition evaluated as false.
cc compiler (c programming language compiler).
Since Unix is itself is written in C programming language, most Unix operating systems come with c compiler called cc.