Sunteți pe pagina 1din 3

To view the contents of a file named myfile, enter:

cat myfile
To display the contents of a file, one screen at a time, at the UNIX prompt, typ
e
more filename
replacing filename with the name of the file. To see the next screen of text, pr
ess the SPACEBAR key. To quit, press the Q key. To display a list of commands, p
ress the H key.

Just a "nice to know". If you have an id in UNIX and want to know who it belon
gs to, you can do a "finger" command on the id. (see below in red). If you hav
e a name, and need to know what his UNIX id is, you can do a "finger" command on
his/her name (see below in blue). It comes in handy occasionally, Linda
zlw0008@c3f1n2:/home/zlw0008-> finger ymz0001
Login name: ymz0001 In real life: Maury Zuber
Directory: /home/ymz0001 Shell: /usr/bin/ksh
On since Sep 17 07:34:04 on pts/6 from 172.18.181.99
7 minutes 20 seconds Idle Time
Mail last read Fri Jul 20 06:33:56 2001
No Plan.
--
Change owner(chown
)cchown ranga: /home/httpd/html/users/ranga
changes the owner of the given directory to the user ranga.
----
ftp to connect to a remote machine,
----
how to check the number of instances running on a box:
pmon
--------
EVery process is assigned a unique 5 digit id called process id (PID)
if the number gets exhausted it rolls over...
------
Ctrl+Z - suspend the foreground process
for more details:
determine which key performs which function by using the stty command. By enteri
ng
$ stty -a
----------
an exit status of 0 is successful, whereas nonzero values indicate some type of
failure. The exit status of the last command is stored in the variable $?, so yo
u can check whether a command was successful as follows:
if [ $? -eq 0 ] ; then
echo "Command was successful." ;
else
echo "An error was encountered."
exit
fi
If the command exits with an exit code of 0, issue the "good" message; otherwise
, issue an error message and then exit. This can be simplified as follows:
if [ $? -ne 0 ] ; then
echo "An error was encountered."
exit
fi
echo "Command was successful."
Here you check to see whether the command failed. If so, you echo an error messa
ge and exit: otherwise, the if statement completes and the "good" message is iss
ued. This is slightly more efficient than using an else clause.
-----------

for chmod owner,group


Read permission has a value of 4
Write permission has a value of 2
Execute permission has a value of 1
so 641 would mean:
r/w for owner,read for group,and only execute for others
ask devesh about text searching command
grep -i 'text'
$# gives the no of paramaters are entered by the user
--------
Sometimes you want to match words regardless of the case that you specify. To do
this, use the -i option.
grep -i word file
-------------
sometimes you want to acquire a list of all the lines that do not match a partic
ular word
so u use -v option
One common use of the -v option is to parse the output of the ps command. For ex
ample, if I were looking for all instances of bash that were running on a system
, I could use the following command:
$ /bin/ps -ef | grep bash
Sometimes the output looks like the following:
ranga 3277 3276 2 13:41:45 pts/t0 0:02 -bash
ranga 3463 3277 4 18:38:26 pts/t0 0:00 grep bash
The second process in this list is the grep that I just ran. Because it is not r
eally an instance of bash, I can get rid of it as follows:
$ /bin/ps -ef | grep bash | grep -v grep
This removes the extraneous output:
ranga 3277 3276 0 13:41:45 pts/t0 0:02 -bash
----------
A regular expression is a string that can be used to describe several sequences
of characters.
----
------------
if u are accessing man pages of a command and u want to look for a specific para
meter then you write
man <command>
then
/<parameter name>
eg:
man if
/-f
will show u the details of -f parameter for if command
-----------------------------find command----
Please see if this one helps on the same directory tree. If not then do tell me
what error message it is showing
find . -type f -print0 | xargs -0 grep "imran"
In the above example the find command finds all files in the current directory e
ach file that is found is then searched using grep for the text "imran".
This will print the path of all those files having string "imran" within the fi
les of current folder and all the sub-directories. U can check it on the attach
ed directory tree
find . -exec grep "DELETE FROM PS_CAG_EE_POLICY" '{}' \; -print
find . -exec grep "PS_CAG_DEPT_TBL" '{}' \; -print

S-ar putea să vă placă și