Here showing and sharing some basic commonly used Unix commands used in support purpose, Do refer regular Unix book or guide to know more about, below is just a quick reference.
cal
This command show a calendar for a specified month and/or year.
Example.
To show this month’s calendar, enter:
> cal
To show the twelve-month calendar for 2010, enter:
> cal 2010
To show a calendar for just the month of May 1963, enter:
> cal 5 1963
cat
This is one of the most flexible Unix commands. You can use to create, view and concatenate files.
Examples:
To create a file called test:
> cat >test
To view a file use cat in a different way:
> cat test
To write the contents of the file mytestfile to standard output with
each line numbered:
> cat -n mytestfile
To concatenate two files into one, files test1 and test2 and write the
result to test.all use:
> cat test1 test2 > test.all
cd
To change directory. Use this command to change directories.
Example:
To change FND_TOP directory enter:
> globsuptxxxxx:/home/globsupt cd $FND_TOP
cd ~ Go back to home directory, useful if you’re lost.
cd .. Go back one directory.
chmod
To changes the permissions on a file.
Example.
To change the permissions on file ‘test.txt’ to read only:
> chmod 444 test.txt
chmod 600 {filespec} You can read and write; the world can’t. Good for files.
chmod 700 {filespec} You can read, write, and execute; the world can’t. Good for scripts.
chmod 644 {filespec} You can read and write; the world can only read. Good for web pages.
chmod 755 {filespec} You can read, write, and execute; the world can read and execute. Good for programs you want to share, and your public_html directory.
clear
This command clears the terminal screen.
Example.
To clear the terminal screen, enter
> clear
cp
Use this to copy files.
Example.
To make a copy of the file ‘test.txt’ as ‘test.bak’:
> cp test.txt test.bak
date
Use this command to check the date and time.
Example.
> date
Thu Mar 11 19:42:14 GMT 2010
df
It shows the available disk space.
Example.
> df (-k will show values in kilobytes)
echo
The echo command echoes its arguments. Use it to determine if certain environment variables are set. Precede the variable you would like to see by a dollar sign ($).
Examples:
To find out the location of the AR_TOP:
> globsuptxxxxx:/home/globsupt echo $AR_TOP
To find the default printer:
> echo $PRINTER
hpx123
To show the contents of an environment variable, for example, ‘ORACLE_HOME’:
> echo $ORACLE_HOME
find
Use this command to find a particular file or groups of files.
Examples.
To find the file wfver.sql, you may use:
> find / -name filename.wfver.sql -print
Modify the above command to search the current directory and its
subdirectories by replacing the slash with a period.
> find . -name filename.wfver.sql -print
To list all files in your home directory by using the following:
> find $HOME -print
Other examples of usage:
find / -name filename.GLYRLJGE.rdf -print
find /$FND_TOP/sql -name wf* -print
find / -name wfver -type f -print
find -name wfver -type f -print
grep
Use this command to search for information in a file or files.
Example:
To check the status of the managers from the OS.
> ps -ef | grep LIB
To get a list of process on the unix machine corresponding for a user:
> ps -ef| grep <username>
If you are tracing a material transaction, you might want to grep for mtl_material_transactions to find the correct trace.
hostname
Provides the hostname of the box you are currently working on. This is particularly useful when you have telnet sessions to several boxes at one time and when there is confusion as to which box you are currently on.
Example:
> hostname
visgl03
lp
Prints a file on a printer connected to the computer network
Example:
To print the file test.txt to printer named hp123:
> lp -d hp23 test.txt
ls
This shows the contents of a particular directory.
man
Useful command that can help you figure out the syntax and purpose of most UNIX commands. Enter ‘man’ followed by the command you would like to execute, and you will get a quick rundown of what the command does and a description of how to use it.
Examples:
> man ls Displays details about the ls command.
mkdir
Use this command to create new directory.
Example:
To create a subdirectory in the home directory of your Unix account, use the mkdir
command. For example, to create a subdirectory called Test, at the Unix prompt from within your home directory, enter.
> mkdir Test
More
Shows listing one screen at a time. More is a command used to read text files.
mv
Use this command to move or rename files.
Examples:
To rename the file ‘test.txt’ to ‘test.old’:
> mv test.txt test.old
To move a file named Test from a subdirectory named my_new to another subdirectory named my_old (both subdirectories of the current directory), enter:
> mv -i my_new/Test my_old
ps
To see list of all the operating system processes that are running.
Example:
pwd
It means present working directory. Use this command to find out what directory you are working in.
setenv
Use this command to set envirorment variables.
Example:
To change the default printer from hpx123 to myprinter:
> echo $PRINTER
hpx123
> setenv PRINTER myprinter
> echo $PRINTER
myprinter
vi
The vi editor (short for visual editor) is a screen editor which is available on almost all Unix systems.
Example.
To see the file, afffcfb.sql in editor, enter:
> vi afffcfb.sql
:q is the command to exit vi editor
Screen Movement
To move the cursor to a line within your current screen use the following keys:
H moves the cursor to the top line of the screen.
M moves the cursor to the middle line of the screen.
L moves the cursor to the last line of the screen.
To scroll through the file and see other screens use:
ctrl-f scrolls down one screen
ctrl-b scrolls up one screen
ctrl-u scrolls up a half a screen
ctrl-d scrolls down a half a screen
Since oracle files are not to be modified, editing commands are omitted intentionally.
Miscellaneous Unix commands
chgrp – changes the group ownership of a file
chown – changes owner of file
r – To redo the last command typed. Useful when you have typed a long command and do not want to type the entire command again.
w – who is logged in, and what are they doing
wc – display a count of lines, words and characters in a file
which – locate a command; display its pathname or alias
who – who is on the system
whoami – display the effective current username
whois – Internet user name directory service
2 thoughts