Tuesday, 7 January 2014

Unix Commands - Consolidated




UNIX Commands


1) ^D - indicates end of data stream; can log a user off. The latter is disabled on many systems
^C - interrupt
^U -Control-U is normally the "line-kill" signal for your terminal. When typed it erases the entire input
logout - leave the system
exit - leave the shell
-----------------------------------------------------------------------------------------------------------------------------------------
2) id
 id - return user identity
You can determine your userid and the list of groups you belong to with the id and groups commands.
The format in which we get as o/p is

   "uid=%u(%s) gid=%u(%s)\n" <real user ID>, <user-name>,
         <real group ID>, <group-name>
eg :
$ id
uid=1005(tibadmin) gid=1(other)

$ id -a ( Reports user name, user  ID and all the  groups  to which the user belongs.)
uid=1005(tibadmin) gid=1(other) groups=1(other)
------------------------------------------------------------------------------------------------------------------------------------------
3) man
The Unix manual, usually called man pages, is available on-line to explain the usage of the Unix system and commands.
Syntax
man [options] command_name
------------------------------------------------------------------------------------------------------------------------------------------
4) cd [directory] ---change directory
You can change to a new directory with the cd command. cd will accept both absolute and relative path names.
cd -----changes to user's home directory
cd / ---changes directory to the system's root
cd .. ---goes up one directory level
cd ../.. --goes up two directory levels
cd /full/path/name/from/root changes directory to absolute path named (note the leading slash)
cd path/from/current/location changes directory to path relative to current location (no leading
slash)
cd ~--------username/directory changes directory to the named username's indicated directory
------------------------------------------------------------------------------------------------------------------------------------------
5) ls [options] [directory or file] list directory contents or file permissions
At any time you can determine where you are in the file system hierarchy with the pwd, print workingdirectory, command.
------------------------------------------------------------------------------------------------------------------------------------------
6) mkdir [options] --directory make a directory
You extend your home hierarchy by making sub-directories underneath it. This is done with the mkdir command. Again, you specify either the full or relative path of the directory:
Syntax
mkdir [options] directory
------------------------------------------------------------------------------------------------------------------------------------------
7) pwd ---- print working (current) directory
To find out your current location—that is the directory in which you are currently working
------------------------------------------------------------------------------------------------------------------------------------------
8) rmdir [options] directory -------remove a directory
A directory needs to be empty before you can remove it. If it’s not, you need to remove the files first.Also, you can’t remove a directory if it is your present working directory; you must first change outof it.
Syntax
rmdir directory
------------------------------------------------------------------------------------------------------------------------------------------
9) ls ------list
The command to list your directories and files is ls. With options it can provide information about the size, type of file, permissions, dates of file creation, change and access.
-a lists all files, including those beginning with a dot (.)---hidden files
-d lists only names of directories, not the files in the directory
-g displays Unix group assigned to the file, requires the -l option (BSD only)
-l long listing: lists the mode, link information, owner, size, last modification (time). If the file is a symbolic link, an arrow (-->) precedes the pathname
-c list in columns
-s to ascertain the size of the file,The size indicated is the number of kilobytes, rounded upward, for each file
-F Adding the -F flag to ls appends suffixes to certain filenames so that you can ascertain more easily what types of files they are.
-m This flag outputs the files as a comma-separated list

File syntax :
if file ends with /  ---directory
                        * ---executable prog
                        @---is a symbolic link to another file or directory

staying in the same directory and searching the file :
ls -F \tibco
ls -F ..
------------------------------------------------------------------------------------------------------------------------------------------
10) chgrp [options] group file change the group of the file
------------------------------------------------------------------------------------------------------------------------------------------
11) chown [options] owner file change the ownership of a file; can only be done by the superuser
------------------------------------------------------------------------------------------------------------------------------------------
12) Rmdir -remove any directory for which you have appropriate permissions
--To remove a directory, you must first remove all files therein using the rm command.
--There’s no way to restore a directory you’ve removed
--The rmdir command removes only directories that are empty
------------------------------------------------------------------------------------------------------------------------------------------
13) cp [options] file1 file2
copy file1 into file2; file2 shouldn't already exist. This command creates or overwrites file2.
The format of a cp command is to specify first the name of the file you want to copy and then the new filename. Both names must be either relative filenames or absolute filenames.
--Copy the contents of one file to another with the cp command.
--Cant copy directories
--Can copy many files at once if you specify a directory as the destination rather than specifying a new filename.
Syntax
cp [options] old_filename new_filename
Common Options
-i interactive (prompt and wait for confirmation before proceeding)
-r recursively copy a directory
------------------------------------------------------------------------------------------------------------------------------------------
14) mv [options] file1 file2
move file1 into file2
--Rename a file with the move command, mv.
--Rather than creating multiple copies of the files you’re copying, mv physically relocates them from the old directory to the new.
Syntax
mv [options] old_filename new_filename
Common Options
-i interactive (prompt and wait for confirmation before proceeding)
-f don’t prompt, even when copying over an existing target file (overrides -i)
------------------------------------------------------------------------------------------------------------------------------------------
15) rm [options] file remove (delete) a file or directory
(-r recursively deletes the directory and its contents)
(-i prompts before removing files)
--Remove a file with the rm, remove, command.
--The rm command removes files permanently
--You can remove more than one file at a time by specifying each of the files to the rm command
Syntax
rm [options] filename
Common Options
-i interactive (prompt and wait for confirmation before proceeding)
-r recursively remove a directory, first removing the files and subdirectories beneath it (but all files and directories inside it as well, to be removed.)
-f don’t prompt for confirmation (overrides -i)
------------------------------------------------------------------------------------------------------------------------------------------
16) chmod - change file permissions
The command to change permissions on an item (file, directory, etc) is chmod (change mode). The syntax involves using the command with three digits (representing the user (owner, u) permissions,the group (g) permissions, and other (o) user's permissions) followed by the argument (which may
be a file name or list of files and directories). Or by using symbolic representation for the permissions and who they apply to.

chmod [who]op[perm] [argument list]
--- No access is allowed
r-- Read-only access
r-x Read and execute access, for programs and shell scripts
rw- Read and write access, for files
rwx All access allowed, for programs
Interpretation of the following few examples should help:
-rw------- 1 taylor 3843 Oct 10 16:22 iecc.list
-rw-rw-r-- 1 taylor 280232 Oct 10 16:22 mailing.lists
-rw-rw---- 1 taylor 1031 Oct 7 15:44 newlists
-rwxr-x--- 1 taylor 64 Oct 9 09:31 the.script
The first file, iecc.list, has read and write permission for the owner (taylor) and is off-limits
to all other users. The file mailing.lists offers similar access to the file owner (taylor) and
to the group but offers read-only access to everyone else on the system. The third file,
newlists, provides read and write access to both the file owner and group, but no access to
anyone not in the group.
The fourth file on the list, the.script, is a program that can be run by both the owner and
group members, read (or copied) by both the owner and group, and written (altered) by the
owner. In practice, this probably would be a shell script, as described earlier, and these
permissions would enable the owner (taylor) to use an editor to modify the commands
therein. Other members of the group could read and use the shell script but would be denied
access to change it.
------------------------------------------------------------------------------------------------------------------------------------------
17) chown - change ownership
Ownership of a file can be changed with the chown command. On most versions of Unix this can only be done by the super-user, i.e. a normal user can’t give away ownership of their files. chown is used as below, where # represents the shell prompt for the super-user:
Syntax
chown [options] user[:group] file
------------------------------------------------------------------------------------------------------------------------------------------
18) cat [options] file concatenate (list) a file
Display the contents of a file with the concatenate command, cat.
Syntax
cat [options] [file]
Common Options
-n precede each line with a line number
-v display non-printing characters, except tabs, new-lines, and form-feeds
-e display $ at the end of each line (prior to new-line) (when used with -v option)
------------------------------------------------------------------------------------------------------------------------------------------
19) echo [text string] echo the text string to stdout
The echo command is used to repeat, or echo, the argument you give it back to the standard output device. It normally ends with a line-feed, but you can specify an option to prevent this.
Syntax
echo [string]
------------------------------------------------------------------------------------------------------------------------------------------
20) head [-number] file
--display the first 10 (or number of) lines of a file
head displays the head, or start, of the file.
head [options] file
Common Options
-n number number of lines to display, counting from the top of the file
21) more (or less or pg) [options] file page through a text file
------------------------------------------------------------------------------------------------------------------------------------------
22) tail [options] file display the last few lines (or parts) of a file
tail displays the tail, or end, of the file.
Syntax
tail [options] file
Common Options
-number number of lines to display, counting from the bottom of the file
------------------------------------------------------------------------------------------------------------------------------------------
23) date [options] report the current date and time
------------------------------------------------------------------------------------------------------------------------------------------
24) df [options] [resource] report the summary of disk blocks and inodes free and in use
df is used to report the number of disk blocks and inodes used and free for each file system. The
output format and valid options are very specific to the OS and program version in use.
Syntax
df [options] [resource]
Common Options
-l local file systems only (SVR4)
-k report in kilobytes (SVR4)
------------------------------------------------------------------------------------------------------------------------------------------
25) du [options] [directory or file] report amount of disk space in use+
du reports the amount of disk space in use for the files or directories you specify.
Syntax
du [options] [directory or file]
Common Options
-a display disk usage for each file, not just subdirectories
-s display a summary total only
-k report in kilobytes (SVR4)
------------------------------------------------------------------------------------------------------------------------------------------
26) hostname/uname display or set (super-user only) the name of the current machine
------------------------------------------------------------------------------------------------------------------------------------------
27) kill [options] [-SIGNAL] [pid#] [%job] send a signal to the process with the process id number (pid#) or job
control number (%n). The default signal is to kill the process.
kill sends a signal to a process, usually to terminate it.
Syntax
kill [-signal] process-id
------------------------------------------------------------------------------------------------------------------------------------------
28) man [options] command show the manual (man) page for a command
------------------------------------------------------------------------------------------------------------------------------------------
29) passwd [options] set or change your password
------------------------------------------------------------------------------------------------------------------------------------------
30) ps [options] show status of active processes
ps is used to report on processes currently running on the system. The output format and valid
options are very specific to the OS and program version in use.
Syntax
ps [options]
------------------------------------------------------------------------------------------------------------------------------------------
31) script file saves everything that appears on the screen to file until exit is executed
script creates a script of your session input and output. Using the script command, you can capture
all the data transmission from and to your terminal screen until you exit the script program. This can
be useful during the programming-and-debugging process, to document the combination of things
you have tried, or to get a printed copy of it all for later perusal.
Syntax
script [-a] [file] <. . .> exit
------------------------------------------------------------------------------------------------------------------------------------------
32) whereis [options] command report the binary, source, and man page locations for the command
named
----------------------------------------------------------------------------------------------------------------------------------------------
33) which command reports the path to the command or the shell alias in use
----------------------------------------------------------------------------------------------------------------------------------------------
34) who or w report who is logged in and what processes are running
J10BCPNCAP $ who
root       console      Apr 26 10:17
tibadmin   pts/17       Jun 30 09:37    (10.8.149.62)
oracle     pts/18       Jun 27 14:24    (10.8.85.140)
tibadmin   pts/19       Jun 30 10:09    (10.8.149.154)
tibadmin   pts/21       Jun 30 15:11    (10.8.149.91)
tibadmin   pts/26       Jun 30 12:10    (10.8.74.107)
tibadmin   pts/27       Jun 30 12:55    (10.8.74.107)
----------------------------------------------------------------------------------------------------------------------------------------------
35) grep
 The grep utility is used to search for generalized regular expressions occurring in Unix files.The egrep utility provides searching capability using an extended set of meta-characters. The syntax of the grep utility, some of the available options, and a few examples are
shown below.
Syntax
grep [options] regexp [file[s]]
Common Options
-i ignore case
-c report only a count of the number of lines containing matches, not the
matches themselves
-v invert the search, displaying only lines that do not match
-n display the line number along with the line on which a match was found
-s work silently, reporting only the final status:
0, for match(es) found
1, for no matches
2, for errors
-l list filenames, but not lines, in which matches were found
----------------------------------------------------------------------------------------------------------------------------------------------
36) whoami
J10BCPNCAP $ whoami
tibadmin
----------------------------------------------------------------------------------------------------------------------------------------------
37) who am i
J10BCPNCAP $ who am i
tibadmin   pts/21       Jun 30 15:11    (10.8.149.91)
----------------------------------------------------------------------------------------------------------------------------------------------
38) id
The purpose of
this command is to tell you what group or groups you’re in and the numeric identifier for your account name (known as your user ID number or user ID). Enter id and see what you get. I get the following result:
% id
uid=211(taylor) gid=50(users0) groups=50(users0)
%
J10BCPNCAP $ id
uid=1005(tibadmin) gid=1(other)
----------------------------------------------------------------------------------------------------------------------------------------------
39) users-which lists the account names of all people using the system:
J10BCPNCAP $ users  
root tibadmin oracle tibadmin tibadmin tibadmin tibadmin
----------------------------------------------------------------------------------------------------------------------------------------------
40) w
 w is a complex command which summarizes information
This is a much more complex command, offering more information than either users or who. Notice that the output is broken into different areas. The first line summarizes the status of the system and, rather cryptically, the number of programs that the computer is running at one time. Finally, for each user, the output indicates the user name, the tty, when the user logged in to the system, how long it’s been since the user has done anything (in minutes and seconds), the combined CPU time of all jobs the user has run, and the amount of CPU time taken by the
current job. The last field tells you what you wanted to know in the first place: what are the users doing?

  3:18pm  up 65 day(s), 11:12,  7 users,  load average: 1.39, 1.42, 1.43
User     tty           login@  idle   JCPU   PCPU  what
root     console      26Apr1165days                -sh
tibadmin pts/17        9:37am  5:40      1      1  tail -100f SUBSCRIPTION_DTH-Proc
oracle   pts/18       Mon 2pm 3days                oracleSDP (DESCRIPTION=(LOCAL=YE
tibadmin pts/19       10:09am  5:09      1      1  tail -f SUBSCRIPTION_DTH-Process
tibadmin pts/21        3:11pm                      w
tibadmin pts/26       12:10pm  3:07                -sh
tibadmin pts/27       12:55pm  2:22                less ICCM_BW-ICCM_BW.log
----------------------------------------------------------------------------------------------------------------------------------------------
41) cal
shows a simple calendar for the month or year specified.
eg:
$ cal
   June 2011
 S  M Tu  W Th  F  S
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

For a particular month cal [ [month] year ]
$ cal 3 1988
   March 1988
 S  M Tu  W Th  F  S
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

cal 2007
                                2007

         Jan                    Feb                    Mar
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
    1  2  3  4  5  6                1  2  3                1  2  3
 7  8  9 10 11 12 13    4  5  6  7  8  9 10    4  5  6  7  8  9 10
14 15 16 17 18 19 20   11 12 13 14 15 16 17   11 12 13 14 15 16 17
21 22 23 24 25 26 27   18 19 20 21 22 23 24   18 19 20 21 22 23 24
28 29 30 31            25 26 27 28            25 26 27 28 29 30 31

         Apr                    May                    Jun
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
 1  2  3  4  5  6  7          1  2  3  4  5                   1  2
 8  9 10 11 12 13 14    6  7  8  9 10 11 12    3  4  5  6  7  8  9
15 16 17 18 19 20 21   13 14 15 16 17 18 19   10 11 12 13 14 15 16
22 23 24 25 26 27 28   20 21 22 23 24 25 26   17 18 19 20 21 22 23
29 30                  27 28 29 30 31         24 25 26 27 28 29 30

         Jul                    Aug                    Sep
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
 1  2  3  4  5  6  7             1  2  3  4                      1
 8  9 10 11 12 13 14    5  6  7  8  9 10 11    2  3  4  5  6  7  8
15 16 17 18 19 20 21   12 13 14 15 16 17 18    9 10 11 12 13 14 15
22 23 24 25 26 27 28   19 20 21 22 23 24 25   16 17 18 19 20 21 22
29 30 31               26 27 28 29 30 31      23 24 25 26 27 28 29
                                              30
         Oct                    Nov                    Dec
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
    1  2  3  4  5  6                1  2  3                      1
 7  8  9 10 11 12 13    4  5  6  7  8  9 10    2  3  4  5  6  7  8
14 15 16 17 18 19 20   11 12 13 14 15 16 17    9 10 11 12 13 14 15
21 22 23 24 25 26 27   18 19 20 21 22 23 24   16 17 18 19 20 21 22
28 29 30 31            25 26 27 28 29 30      23 24 25 26 27 28 29
                                              30 31
----------------------------------------------------------------------------------------------------------------------------------------------

42) bc
The bc utility implements an arbitrary precision calculator.It  takes  input  from  any files given, then reads from the standard input.
J10BCPNCAP $ bc
4*2
8
5-8
-3
6+9
15
sqrt(25)         
5
----------------------------------------------------------------------------------------------------------------------------------------------
43) dc
The dc command works with the postfix notation, and each number or operation must be on its own line. Further, the result of an operation isn’t
automatically shown; you have to enter p to see the most recently calculated result.

J10BCPNCAP $ dc
9
*
p
81
----------------------------------------------------------------------------------------------------------------------------------------------
44) Directories

Any filename that ends with a slash (/) is a folder (UNIX calls these directories). Any filename that ends with an asterisk (*) is a program. Anything ending with an at sign (@) is a symbolic link, and everything else is a normal, plain file.directory .A type of UNIX file used to group other files. Files and directories can be placed inside other directories, to build a hierarchical system.

a) The bin Directory
This directory is used to store all the executable programs on the system.

b) The dev Directory
All device drivers—often numbering into the hundreds—are stored as separate files in the standard UNIX dev (devices) directory.

c) The etc Directory
The file system, security, device drivers, hardware configurations, and more. It designates the etc directory as the storage place for all administrative files and information

d) The lib Directory
UNIX has a central storage place for function and procedural libraries. These specific executables are included with specific programs, allowing
programs to offer features and capabilities otherwise unavailable.

e) The lost+found Directory
When files are recovered after any sort of problem or failure, they are placed here, in the lost+found directory, if the kernel cannot ascertain the proper location in the file system.

f) The mnt and sys Directories
The mnt directory is intended to be a common place to mount external media—hard disks, removable cartridge drives.

g) The tmp Directory
If you’re editing a file, for example, the program makes a copy of the file and saves it in tmp, and you work directly with that, saving the new file back to your original file only when you’ve completed your work.

h) The usr Directory
This directory was intended to be the central storage place for all user-related commands.

i) Home directory
This is your private directory, and is also where you start out when you log in to the system.

j) Root directory
The directory at the very top of the file system hierarchy, also known as slash.
----------------------------------------------------------------------------------------------------------------------------------------------
45) Absolute and relative file names
If it’s a slash, you’ve got an absolute filename (because the filename is rooted to the very top level of the file system). If you don’t have a slash as the first character, the filename’s a relative filename.
A hidden file is any file with a dot as the first character of the filename.
. current directory
.. parent directory
Absolute name :Specifying the location of a file in a hierarchy to ensure that the filename is unique is known in UNIX parlance as specifying its absolute filename. That is, regardless of where you are within the file system, the absolute filename always specifies a particular file. By contrast, relative filenames are not unique descriptors.
Relative name :Relative filenames describe files that are referenced relative to an assumed position in the file system.
----------------------------------------------------------------------------------------------------------------------------------------------
46) env
The env utility obtains the current environment, modifies it according  to  its arguments, then invokes the utility named by the utility operand with the modified environment.
Environment variables--
PATH-The PATH environment variable lists the set of directories, in left-to-right order, that the system searches to find commands and applications you request.
echo $PATH
HOME-Your home directory (as it’s known) is the name of the directory that you always begin your UNIX session within.
 echo $HOME
----------------------------------------------------------------------------------------------------------------------------------------------
47) dynamic linking Although most UNIX systems require all necessary utilities and library
routines (such as the routines for reading information from the keyboard and displaying it
to the screen) to be plugged into a program when it’s built (known in UNIX parlance as static
linking), some of the more sophisticated systems can delay this inclusion until you actually
need to run the program. In this case, the utilities and libraries are linked when you start the
program, and this is called dynamic linking.
----------------------------------------------------------------------------------------------------------------------------------------------
48) symbolic link A file that contains a pointer to another file rather than contents of its own.
This can also be a directory that points to another directory rather than having files of its own.
A useful way to have multiple names for a single program or allow multiple people to share
a single copy of a file.
----------------------------------------------------------------------------------------------------------------------------------------------
49) touch
The touch utility sets the access and modification times  of each  file.  The  file  operand  is  created  if it does not already exist.
----------------------------------------------------------------------------------------------------------------------------------------------
50) Compress
The compress program is given a list of filenames and then compresses each of the files, renaming them with a .Z suffix, which indicates that
they are compressed.
To reverse the operation, use the companion command uncompress, and specify either the current name of the file (that is, with the .Z suffix) or the name of the file before it was compressed (that is, without the .Z suffix.
----------------------------------------------------------------------------------------------------------------------------------------------
51) file
--similar to ls
J10BCPNCAP $ file SUBSCRIPTION_DTH-Process_Archive.log
SUBSCRIPTION_DTH-Process_Archive.log:   ascii text
----------------------------------------------------------------------------------------------------------------------------------------------
52) banner
banner prints its arguments (each up to 10 characters  long) in large letters on the standard output.
Print characters as a poster on the standard output. Each word supplied must contain ten characters or less.
Eg : banner archana
----------------------------------------------------------------------------------------------------------------------------------------------
53) finger
Display information about local and remote users.
----------------------------------------------------------------------------------------------------------------------------------------------
54) File Redirection
File redirection Most UNIX programs expect to read their input from the user (that is, standard input) and write their output to the screen (standard output). By use of file redirection, however, input can come from a previously created file, and output can be saved to a file instead of being displayed on the screen.
By placing a file-redirection command in a regular command line:
< redirects input,
> redirects output
 >> redirects output and appends the information to the existing file.

cat < file1 >file2
Copies from file 1 to file2
cat > new_filename
creates new file
----------------------------------------------------------------------------------------------------------------------------------------------
55) WC
It computes a word count for the file.
-w counts words
 -c counts characters
 -l counts
----------------------------------------------------------------------------------------------------------------------------------------------
56) uniq
Sometimes when you’re looking at a file, you’ll notice that there are many duplicate entries, either blank lines or, perhaps, lines of repeated information. To clean up these files and shrink their size at the same time, you can use the uniq command, which lists each unique line in the file.
Well, it sort of lists each unique line in the file. What uniq really does is compare each line it reads with the previous line. If the lines are the same, uniq does not list the second line. You can use flags with uniq to get more specific results: -u lists only lines that are not repeated.

The uniq command removes duplicate lines only if they’re adjacent.
-d lists only lines that are repeated (the exact opposite of -u),
-c adds a count of how many times each line occurred.
----------------------------------------------------------------------------------------------------------------------------------------------
57) Standard input and output
When a program is run, the default location for receiving input is called standard input. The default location for output is standard output. If you are running UNIX from a terminal, standard input and output are your terminal.
Standard input UNIX programs always default to reading information from the user by reading the keyboard and watching what’s typed. With file redirection, input can come from a file, and with pipelines, input can be the result of a previous UNIX command.
standard error.
Standard output, but you can redirect standard error to a different location than standard output.
Standard output When processing information, UNIX programs default to displaying the output on the screen itself, also known as standard output. With file redirection, output can easily be saved to a file; with pipelines, output can be sent to other programs.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
58)Sort
A program that reads information and sorts it alphabetically. The program sort also enables you to sort lists of numbers.

To sort filenames alphabetically regardless of case, you can use sort -f:
% ls -1 | sort -f
To sort lines of a file:
% sort < testme
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
59)Number Lines in Files Using cat -n and nl

To have a line number listed next to each line of a file. It’s quite simple to do with the cat program by specifying the -n flag to number lines in the file displayed.A program that prefaces each line with a line number isn’t much of an addition to the UNIX command toolbox.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
60) diff
compare two files
The diff utility will compare  the  contents  of  file1  and file2  and write to standard output a list of changes necessary to convert  file1  into  file2.
Eg : diff mon.logins tues.logins
2d1
< bsmith
4a4
> jdoe
7c7
< mschmidt
---
> proy
Note that the output lists the differences as well as in which file the difference exists. Lines in the
first file are preceded by "< ", and those in the second file are preceded by "> ".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
61) comm
select or reject lines common to two files
The comm utility  reads  file1  and  file2,  which  must  be ordered  in  the  current  collating  sequence, and produces three text columns as output: lines  only  in  file1;  lines only in file2; and lines in both files.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
62) nl
line numbering
The best option, though, is that nl can selectively number just those lines that contain a specified pattern.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
63) spell
 The spell command collects words from the  named  files  and looks  them  up in a spelling list. Words that neither occur
 among nor are derivable (by  applying  certain  inflections, prefixes,  or  suffixes) from words in the spelling list are written to the standard output.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
64)Filters
Filters are a particular type of UNIX program that expects to work either with file redirection or as part of a pipeline. These programs read input from standard input, write output to standard output, and often don’t have any starting arguments.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
65) Wild Cards
There are two wildcards to learn here: * acts as a match for any number and sequence of characters, and ? acts as a match for any single character. In the broadest sense, a lone * acts as a match for all files in the current directory (in other words, ls * is identical to ls), whereas a single ? acts as a match for all one-character-long filenames in a directory (for instance, ls?, which will list only those filenames that are one character long).

Eg :
1) ls -ld S*
2) ls -ld S
3)ls -ld a* b* k* o* s* t*
4)ls -ld [abkost]*
5)ls -ld [a-z]*
6)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
66) egrep
Sometimes a single regular expression can’t locate what you seek. For example, perhaps you’re looking for lines that have either one pattern or a second pattern. That’s where the egrep command proves helpful. The command gets its name from“expression grep,” and it has a notational scheme more powerful than that of grep.( use  the  full  set  of alphanumeric and special characters) to match the  patterns)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
67) fgrep

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
68) Expressions
Some text processing programs, such as grep, egrep, sed, awk and vi, let you search on patterns instead of fixed strings. These text patterns are known as regular expressions. You form a regular expression by combining normal characters and special characters, also known as meta-characters,
with the rules below. With these regular expressions you can do pattern matching on text data.
Regular expressions come in three different forms:
• Anchors which tie the pattern to a location on the line
• Character sets which match a character at a single position
• Modifiers which specify how many times to repeat the previous expression

1) . match any single character except <newline>
2) * match zero or more instances of the single character (or meta-character) immediately preceding it
3) [abc] match any of the characters enclosed
4) [a-d] match any character in the enclosed range
5) [^exp] match any character not in the following expression
6) ^abc the regular expression must start at the beginning of the line (Anchor)
7) abc$ the regular expression must end at the end of the line (Anchor)
8) \ treat the next character literally. This is normally used to escape the meaning of special characters such as "." and "*".

Example
1) To find lines which begin with 'O'
grep ^O time.sh
2) To find lines which begin with 'SMS'
grep ^SMS time.sh
3) To find lines which begin with OMS
grep OMS* time.sh
4) search for any instances of t followed by zero or more occurrences of e
grep 'te*' num.list
5) search for any instances of t followed by one or more occurrences of e
grep 'tee*' time.sh
6)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
69) sed - stream editor
The non-interactive, stream editor, sed, edits the input stream, line by line, making the specified changes, and sends the result to standard output.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
70) AWK
awk is a pattern scanning and processing language. Its name comes from the last initials of the threeauthors: Alfred. V. Aho, Brian. W. Kernighan, and Peter. J. Weinberger.
nawk is new awk, a newer version of the program
gawk is gnu awk, from the Free Software Foundation.
awk searches its input for patterns and performs the specified operation on each line, or fields of the line, that contain those patterns. You can specify the pattern matching statements for awk either on the command line, or by putting them in a file and using the -f program_file option.Each input line is checked for a pattern match with the indicated action being taken on a match. This continues through the full sequence of patterns, then the next line of input is checked.
Input is divided into records and fields.
Syntax
awk program [file]
where program is composed of one or more:
pattern { action }
fields.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
71)cmp [options] file1 file2
compare two files and list where differences occur (text or binary files)
Eg : % cmp mon.logins tues.logins
mon.logins tues.logins differ: char 9, line 2
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
72) cut [options] [file(s)]
The cut command allows a portion of a file to be extracted for another use.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
73) find
find files matching a type or pattern
The find command will recursively search the indicated directory tree to find files matching a type or pattern you specify. find can then list the files or execute arbitrary commands based on the results.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
74) paste - merge files
The paste command allows two files to be combined side-by-side. The default delimiter between the
columns in a paste is a tab, but options allow other delimiters to be used.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
75) sort [options] file sort the lines of the file according to the options chosen
The sort command is used to order the lines of a file. Various options can be used to choose the order
as well as the field on which a file is sorted. Without any options, the sort compares entire lines in the
file and outputs them in ASCII order (numbers first, upper case letters, then lower case letters).
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
76) ln
The ln command creates a "link" or an additional way to access (or gives an additional name to)
another file.
Syntax
ln [options] source [target]
If not specified target defaults to a file of the same name in the present working directory.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
77) tee
tee sends standard in to specified files and also to standard out. It’s often used in command pipelines.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
78) strings
To search a binary file for printable, ASCII, strings use the strings command. It searches for any sequence of 4 or more ASCII characters terminated
by a  <newline> or null character. I find this command useful for searching for file names and possible error messages within compiled programs
that I don’t have source code for.
Syntax
strings [options] file
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
79) tr
The tr command translates characters from stdin to stdout. With no options the characters in string1 are translated into the characters in string2, character by character in the string arrays. The first character in string1 is translated into the first character in string2, etc.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
80) File Compression
The compress command is used to reduce the amount of disk space utilized by a file. When a file has been compressed using the compress
command, a suffix of .Z is appended to the file name. The ownership modes and access and modification times of the original file are preserved. uncompress restores the files originally compressed by compress.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
81) tar - archive files
The tar command combines files into one device or filename for archiving purposes. The tar
command does not compress the files; it merely makes a large quantity of files more manageable
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
82) uuencode/uudecode - encode a file
To encode a binary file into 7-bit ASCII use the uuencode command. To decode the file back to binary use the uudecode command. The uu in the names comes because they are part of the
Unix-to-Unix CoPy (UUCP) set of commands. The uuencode and uudecode commands are
commonly used when sending binary files through e-mail. In e-mail there’s no guarantee that 8-bit
binary files will be transferred cleanly. So to ensure delivery you should encode the binary file, either
directly, on the command line and then include the encoded file, or indirectly, by letting your MIME
mailer program do it for you. In a similar manner, the user decodes the file on the receiving end.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
83) od - octal dump of a file
od dumps a file to stdout in different formats, including octal, decimal, floating point, hex, and
character format.
Syntax
od [options] file
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
84) TELNET and FTP - remote login and file transfer protocols
TELNET and FTP are Application Level Internet protocols. The TELNET and FTP protocol
specifications have been implemented by many different sources, including The National Center for
Supercomputer Applications (NCSA), and many other public domain and shareware sources.
The programs implementing the TELNET protocol are usually called telnet, but not always. Some
notable exceptions are tn3270, WinQVT, and QWS3270, which are also TELNET protocol
implementations. TELNET is used for remote login to other computers on the Internet.
The programs implementing the FTP protocol are usually called ftp, but there are exceptions to that
too. A program called Fetch, distributed by Dartmouth College, WS_FTP, written and distributed by
John Junod, and Ftptool, written by a Mike Sullivan, are FTP protocol implementations with graphic
user interfaces. There’s an enhanced FTP version, ncftp, that allows additional features, written by
Mike Gleason. Also, FTP protocol implementations are often included in TELNET implementation
programs, such as the ones distributed by NCSA. FTP is used for transferring files between
computers on the Internet.
rlogin is a remote login service that was at one time exclusive to Berkeley 4.3 BSD UNIX.
Essentially, it offers the same functionality as telnet, except that it passes to the remote computer
information about the user's login environment. Machines can be configured to allow connections
from trusted hosts without prompting for the users’ passwords. A more secure version of this
protocol is the Secure SHell, SSH, software written by Tatu Ylonen and available via
ftp://ftp.net.ohio-state.edu/pub/security/ssh.
From a Unix prompt, these programs are invoked by typing the command (program name) and the
(Internet) name of the remote machine to which to connect. You can also specify various options, as
allowed, for these commands.

85) Remote commands
A number of Unix machines can be connected together to form a local area network. When this is the
case, it often happens that a user of one machine has valid login access to several of the other
machines in the local network. There are Unix commands available to such users which provide
convenience in carrying out certain common operations. Because these commands focus on
communications with remote hosts in the local network, the command names begin with the letter
"r": rlogin, rsh, and rcp. The remote access capability of these commands is supported (optionally)
by the dotfile, ~/.rhosts, for individual users and by the system-wide file /etc/hosts.equiv. For
security reasons these may be restricted on some hosts.
The rlogin command allows remote login access to another host in the local network. rlogin passes
information about the local environment, including the value of the TERM environment variable, to
the remote host.
The rsh command provides the ability to invoke a Unix shell on a remote host in the local network for
the purpose of executing a shell command there. This capability is similar to the "shell escape"
function commonly available from within such Unix software systems as editors and email.
The rcp command provides the ability to copy files from the local host to a remote host in the local
network.
Syntax
rlogin [ -l username ] remote_host
rsh [ -l username ] remote_host [ command ]
rcp [ [user1]@host1:]original_filename [ [user2]@host2:]new_filename
where the parts in brackets ([]) are optional. rcp does not prompt for passwords, so you must have
permission to execute remote commands on the specified machines as the selected user on each
machine.

86)basename
deliver portions of path names
basename pathname [suffix]
Given a pathname, strip the path prefix and leave just the filename, which is printed on standard output. If specified, a filename suffix (e.g., .c) is removed also. basename is typically invoked via command substitution (`...`) to generate a filename. See also dirname.
The Solaris version of basename allows the suffix to be a pattern of the form accepted by expr. See the entry for expr for more detailsA command is a program that tells the Unix system to do something. It has the form:
command [options] [arguments]
An argument indicates on what the command is to perform its action, usually a file or series of files.
An option modifies the command, changing the way it performs.
Commands are case sensitive.
Options are generally preceded by a hyphen (-), and for most commands, more than one option can be strung together, in the form:
command -[option][option][option]

Any filename that ends with a slash (/) is a folder (UNIX calls these directories). Any filename that ends with an asterisk (*) is a program. Anything ending with an at sign (@) is a symbolic link, and everything else is a normal, plain file.

Advantages of UNIX

multitasking A multitasking computer is one that actually can run more than one
program, or task, at a time. By contrast, most personal computers lock you into a single
program that you must exit before you launch another.

multiuser Computers intended to have more than a single person working on them
simultaneously are designed to support multiple users, hence the term multiuser. By contrast,
personal computers are almost always single-user because someone else can’t be running a
program or editing a file while you are using the computer for your own work.
----------------------------------------------------------------------------------------------------------------------------------------------
1) ^D - indicates end of data stream; can log a user off. The latter is disabled on many systems
^C - interrupt
^U -Control-U is normally the "line-kill" signal for your terminal. When typed it erases the entire input
logout - leave the system
exit - leave the shell
----------------------------------------------------------------------------------------------------------------------------------------------
2) id
 id - return user identity
You can determine your userid and the list of groups you belong to with the id and groups commands.
The format in which we get as o/p is

   "uid=%u(%s) gid=%u(%s)\n" <real user ID>, <user-name>,
         <real group ID>, <group-name>
eg :
$ id
uid=1005(tibadmin) gid=1(other)

$ id -a ( Reports user name, user  ID and all the  groups  to which the user belongs.)
uid=1005(tibadmin) gid=1(other) groups=1(other)
----------------------------------------------------------------------------------------------------------------------------------------------
3) man
The Unix manual, usually called man pages, is available on-line to explain the usage of the Unix system and commands.
Syntax
man [options] command_name
------------------------------------------------------------------------------------------------------------------------------------------------
4) cd [directory] ---change directory
You can change to a new directory with the cd command. cd will accept both absolute and relative path names.
cd -----changes to user's home directory
cd / ---changes directory to the system's root
cd .. ---goes up one directory level
cd ../.. --goes up two directory levels
cd /full/path/name/from/root changes directory to absolute path named (note the leading slash)
cd path/from/current/location changes directory to path relative to current location (no leading
slash)
cd ~--------username/directory changes directory to the named username's indicated directory
----------------------------------------------------------------------------------------------------------------------------------------------
5) ls [options] [directory or file] list directory contents or file permissions
At any time you can determine where you are in the file system hierarchy with the pwd, print workingdirectory, command.
----------------------------------------------------------------------------------------------------------------------------------------------
6) mkdir [options] --directory make a directory
You extend your home hierarchy by making sub-directories underneath it. This is done with the mkdir command. Again, you specify either the full or relative path of the directory:
Syntax
mkdir [options] directory
----------------------------------------------------------------------------------------------------------------------------------------------
7) pwd ---- print working (current) directory
To find out your current location—that is the directory in which you are currently working
----------------------------------------------------------------------------------------------------------------------------------------------
8) rmdir [options] directory -------remove a directory
A directory needs to be empty before you can remove it. If it’s not, you need to remove the files first.Also, you can’t remove a directory if it is your present working directory; you must first change outof it.
Syntax
rmdir directory
----------------------------------------------------------------------------------------------------------------------------------------------
9) ls ------list
The command to list your directories and files is ls. With options it can provide information about the size, type of file, permissions, dates of file creation, change and access.
-a lists all files, including those beginning with a dot (.)---hidden files
-d lists only names of directories, not the files in the directory
-g displays Unix group assigned to the file, requires the -l option (BSD only)
-l long listing: lists the mode, link information, owner, size, last modification (time). If the file is a symbolic link, an arrow (-->) precedes the pathname
-c list in columns
-s to ascertain the size of the file,The size indicated is the number of kilobytes, rounded upward, for each file
-F Adding the -F flag to ls appends suffixes to certain filenames so that you can ascertain more easily what types of files they are.
-m This flag outputs the files as a comma-separated list

File syntax :
if file ends with /  ---directory
                        * ---executable prog
                        @---is a symbolic link to another file or directory

staying in the same directory and searching the file :
ls -F \tibco
ls -F ..
----------------------------------------------------------------------------------------------------------------------------------------------
10) chgrp [options] group file change the group of the file
----------------------------------------------------------------------------------------------------------------------------------------------
11) chown [options] owner file change the ownership of a file; can only be done by the superuser
----------------------------------------------------------------------------------------------------------------------------------------------
12) Rmdir -remove any directory for which you have appropriate permissions
--To remove a directory, you must first remove all files therein using the rm command.
--There’s no way to restore a directory you’ve removed
--The rmdir command removes only directories that are empty
----------------------------------------------------------------------------------------------------------------------------------------------
13) cp [options] file1 file2
copy file1 into file2; file2 shouldn't already exist. This command creates or overwrites file2.
The format of a cp command is to specify first the name of the file you want to copy and then the new filename. Both names must be either relative filenames or absolute filenames.
--Copy the contents of one file to another with the cp command.
--Cant copy directories
--Can copy many files at once if you specify a directory as the destination rather than specifying a new filename.
Syntax
cp [options] old_filename new_filename
Common Options
-i interactive (prompt and wait for confirmation before proceeding)
-r recursively copy a directory
----------------------------------------------------------------------------------------------------------------------------------------------
14) mv [options] file1 file2
move file1 into file2
--Rename a file with the move command, mv.
--Rather than creating multiple copies of the files you’re copying, mv physically relocates them from the old directory to the new.
Syntax
mv [options] old_filename new_filename
Common Options
-i interactive (prompt and wait for confirmation before proceeding)
-f don’t prompt, even when copying over an existing target file (overrides -i)
----------------------------------------------------------------------------------------------------------------------------------------------
15) rm [options] file remove (delete) a file or directory
(-r recursively deletes the directory and its contents)
(-i prompts before removing files)
--Remove a file with the rm, remove, command.
--The rm command removes files permanently
--You can remove more than one file at a time by specifying each of the files to the rm command
Syntax
rm [options] filename
Common Options
-i interactive (prompt and wait for confirmation before proceeding)
-r recursively remove a directory, first removing the files and subdirectories beneath it (but all files and directories inside it as well, to be removed.)
-f don’t prompt for confirmation (overrides -i)
----------------------------------------------------------------------------------------------------------------------------------------------
16) chmod - change file permissions
The command to change permissions on an item (file, directory, etc) is chmod (change mode). The syntax involves using the command with three digits (representing the user (owner, u) permissions,the group (g) permissions, and other (o) user's permissions) followed by the argument (which may
be a file name or list of files and directories). Or by using symbolic representation for the permissions and who they apply to.

chmod [who]op[perm] [argument list]

--- No access is allowed
r-- Read-only access
r-x Read and execute access, for programs and shell scripts
rw- Read and write access, for files
rwx All access allowed, for programs

Interpretation of the following few examples should help:
-rw------- 1 taylor 3843 Oct 10 16:22 iecc.list
-rw-rw-r-- 1 taylor 280232 Oct 10 16:22 mailing.lists
-rw-rw---- 1 taylor 1031 Oct 7 15:44 newlists
-rwxr-x--- 1 taylor 64 Oct 9 09:31 the.script
The first file, iecc.list, has read and write permission for the owner (taylor) and is off-limits
to all other users. The file mailing.lists offers similar access to the file owner (taylor) and
to the group but offers read-only access to everyone else on the system. The third file,
newlists, provides read and write access to both the file owner and group, but no access to
anyone not in the group.
The fourth file on the list, the.script, is a program that can be run by both the owner and
group members, read (or copied) by both the owner and group, and written (altered) by the
owner. In practice, this probably would be a shell script, as described earlier, and these
permissions would enable the owner (taylor) to use an editor to modify the commands
therein. Other members of the group could read and use the shell script but would be denied
access to change it.
----------------------------------------------------------------------------------------------------------------------------------------------
17) chown - change ownership
Ownership of a file can be changed with the chown command. On most versions of Unix this can only be done by the super-user, i.e. a normal user can’t give away ownership of their files. chown is used as below, where # represents the shell prompt for the super-user:
Syntax
chown [options] user[:group] file
----------------------------------------------------------------------------------------------------------------------------------------------
18) cat [options] file concatenate (list) a file
Display the contents of a file with the concatenate command, cat.
Syntax
cat [options] [file]
Common Options
-n precede each line with a line number
-v display non-printing characters, except tabs, new-lines, and form-feeds
-e display $ at the end of each line (prior to new-line) (when used with -v option)
----------------------------------------------------------------------------------------------------------------------------------------------
19) echo [text string] echo the text string to stdout
The echo command is used to repeat, or echo, the argument you give it back to the standard output device. It normally ends with a line-feed, but you can specify an option to prevent this.
Syntax
echo [string]
----------------------------------------------------------------------------------------------------------------------------------------------
20) head [-number] file
--display the first 10 (or number of) lines of a file
head displays the head, or start, of the file.
head [options] file
Common Options
-n number number of lines to display, counting from the top of the file
----------------------------------------------------------------------------------------------------------------------------------------------
21) more (or less or pg) [options] file page through a text file
----------------------------------------------------------------------------------------------------------------------------------------------
22) tail [options] file display the last few lines (or parts) of a file
tail displays the tail, or end, of the file.
Syntax
tail [options] file
Common Options
-number number of lines to display, counting from the bottom of the file
----------------------------------------------------------------------------------------------------------------------------------------------
23) date [options] report the current date and time
----------------------------------------------------------------------------------------------------------------------------------------------
24) df [options] [resource] report the summary of disk blocks and inodes free and in use
df is used to report the number of disk blocks and inodes used and free for each file system. The
output format and valid options are very specific to the OS and program version in use.

Syntax
df [options] [resource]
Common Options
-l local file systems only (SVR4)
-k report in kilobytes (SVR4)
----------------------------------------------------------------------------------------------------------------------------------------------
25) du [options] [directory or file] report amount of disk space in use+
du reports the amount of disk space in use for the files or directories you specify.

Syntax
du [options] [directory or file]
Common Options
-a display disk usage for each file, not just subdirectories
-s display a summary total only
-k report in kilobytes (SVR4)
----------------------------------------------------------------------------------------------------------------------------------------------
26) hostname/uname display or set (super-user only) the name of the current machine
----------------------------------------------------------------------------------------------------------------------------------------------
27) kill [options] [-SIGNAL] [pid#] [%job] send a signal to the process with the process id number (pid#) or job
control number (%n). The default signal is to kill the process.
kill sends a signal to a process, usually to terminate it.

Syntax
kill [-signal] process-id
----------------------------------------------------------------------------------------------------------------------------------------------
28) man [options] command show the manual (man) page for a command
----------------------------------------------------------------------------------------------------------------------------------------------
29) passwd [options] set or change your password
----------------------------------------------------------------------------------------------------------------------------------------------
30) ps [options] show status of active processes
ps is used to report on processes currently running on the system. The output format and valid
options are very specific to the OS and program version in use.

Syntax
ps [options]
----------------------------------------------------------------------------------------------------------------------------------------------
31) script file saves everything that appears on the screen to file until exit is executed
script creates a script of your session input and output. Using the script command, you can capture
all the data transmission from and to your terminal screen until you exit the script program. This can
be useful during the programming-and-debugging process, to document the combination of things
you have tried, or to get a printed copy of it all for later perusal.

Syntax
script [-a] [file] <. . .> exit
----------------------------------------------------------------------------------------------------------------------------------------------
32) whereis [options] command report the binary, source, and man page locations for the command
named
----------------------------------------------------------------------------------------------------------------------------------------------
33) which command reports the path to the command or the shell alias in use
----------------------------------------------------------------------------------------------------------------------------------------------
34) who or w report who is logged in and what processes are running
J10BCPNCAP $ who
root       console      Apr 26 10:17
tibadmin   pts/17       Jun 30 09:37    (10.8.149.62)
oracle     pts/18       Jun 27 14:24    (10.8.85.140)
tibadmin   pts/19       Jun 30 10:09    (10.8.149.154)
tibadmin   pts/21       Jun 30 15:11    (10.8.149.91)
tibadmin   pts/26       Jun 30 12:10    (10.8.74.107)
tibadmin   pts/27       Jun 30 12:55    (10.8.74.107)
----------------------------------------------------------------------------------------------------------------------------------------------
35) grep
 The grep utility is used to search for generalized regular expressions occurring in Unix files.The egrep utility provides searching capability using an extended set of meta-characters. The syntax of the grep utility, some of the available options, and a few examples are
shown below.
Syntax
grep [options] regexp [file[s]]
Common Options
-i ignore case
-c report only a count of the number of lines containing matches, not the
matches themselves
-v invert the search, displaying only lines that do not match
-n display the line number along with the line on which a match was found
-s work silently, reporting only the final status:
0, for match(es) found
1, for no matches
2, for errors
-l list filenames, but not lines, in which matches were found
----------------------------------------------------------------------------------------------------------------------------------------------
36) whoami
J10BCPNCAP $ whoami
tibadmin
----------------------------------------------------------------------------------------------------------------------------------------------
37) who am i
J10BCPNCAP $ who am i
tibadmin   pts/21       Jun 30 15:11    (10.8.149.91)
----------------------------------------------------------------------------------------------------------------------------------------------
38) id
The purpose of
this command is to tell you what group or groups you’re in and the numeric identifier for your account name (known as your user ID number or user ID). Enter id and see what you get. I get the following result:
% id
uid=211(taylor) gid=50(users0) groups=50(users0)
%
J10BCPNCAP $ id
uid=1005(tibadmin) gid=1(other)
----------------------------------------------------------------------------------------------------------------------------------------------
39) users-which lists the account names of all people using the system:
J10BCPNCAP $ users  
root tibadmin oracle tibadmin tibadmin tibadmin tibadmin
----------------------------------------------------------------------------------------------------------------------------------------------
40) w
 w is a complex command which summarizes information
This is a much more complex command, offering more information than either users or who. Notice that the output is broken into different areas. The first line summarizes the status of the system and, rather cryptically, the number of programs that the computer is running at one time. Finally, for each user, the output indicates the user name, the tty, when the user logged in to the system, how long it’s been since the user has done anything (in minutes and seconds), the combined CPU time of all jobs the user has run, and the amount of CPU time taken by the
current job. The last field tells you what you wanted to know in the first place: what are the users doing?

  3:18pm  up 65 day(s), 11:12,  7 users,  load average: 1.39, 1.42, 1.43
User     tty           login@  idle   JCPU   PCPU  what
root     console      26Apr1165days                -sh
tibadmin pts/17        9:37am  5:40      1      1  tail -100f SUBSCRIPTION_DTH-Proc
oracle   pts/18       Mon 2pm 3days                oracleSDP (DESCRIPTION=(LOCAL=YE
tibadmin pts/19       10:09am  5:09      1      1  tail -f SUBSCRIPTION_DTH-Process
tibadmin pts/21        3:11pm                      w
tibadmin pts/26       12:10pm  3:07                -sh
tibadmin pts/27       12:55pm  2:22                less ICCM_BW-ICCM_BW.log
----------------------------------------------------------------------------------------------------------------------------------------------
41) cal
shows a simple calendar for the month or year specified.
eg:
$ cal
   June 2011
 S  M Tu  W Th  F  S
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

For a particular month cal [ [month] year ]
$ cal 3 1988
   March 1988
 S  M Tu  W Th  F  S
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

cal 2007
                                2007

         Jan                    Feb                    Mar
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
    1  2  3  4  5  6                1  2  3                1  2  3
 7  8  9 10 11 12 13    4  5  6  7  8  9 10    4  5  6  7  8  9 10
14 15 16 17 18 19 20   11 12 13 14 15 16 17   11 12 13 14 15 16 17
21 22 23 24 25 26 27   18 19 20 21 22 23 24   18 19 20 21 22 23 24
28 29 30 31            25 26 27 28            25 26 27 28 29 30 31

         Apr                    May                    Jun
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
 1  2  3  4  5  6  7          1  2  3  4  5                   1  2
 8  9 10 11 12 13 14    6  7  8  9 10 11 12    3  4  5  6  7  8  9
15 16 17 18 19 20 21   13 14 15 16 17 18 19   10 11 12 13 14 15 16
22 23 24 25 26 27 28   20 21 22 23 24 25 26   17 18 19 20 21 22 23
29 30                  27 28 29 30 31         24 25 26 27 28 29 30

         Jul                    Aug                    Sep
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
 1  2  3  4  5  6  7             1  2  3  4                      1
 8  9 10 11 12 13 14    5  6  7  8  9 10 11    2  3  4  5  6  7  8
15 16 17 18 19 20 21   12 13 14 15 16 17 18    9 10 11 12 13 14 15
22 23 24 25 26 27 28   19 20 21 22 23 24 25   16 17 18 19 20 21 22
29 30 31               26 27 28 29 30 31      23 24 25 26 27 28 29
                                              30
         Oct                    Nov                    Dec
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
    1  2  3  4  5  6                1  2  3                      1
 7  8  9 10 11 12 13    4  5  6  7  8  9 10    2  3  4  5  6  7  8
14 15 16 17 18 19 20   11 12 13 14 15 16 17    9 10 11 12 13 14 15
21 22 23 24 25 26 27   18 19 20 21 22 23 24   16 17 18 19 20 21 22
28 29 30 31            25 26 27 28 29 30      23 24 25 26 27 28 29
                                              30 31
----------------------------------------------------------------------------------------------------------------------------------------------

42) bc
The bc utility implements an arbitrary precision calculator.It  takes  input  from  any files given, then reads from the standard input.
J10BCPNCAP $ bc
4*2
8
5-8
-3
6+9
15
sqrt(25)         
5
----------------------------------------------------------------------------------------------------------------------------------------------
43) dc
The dc command works with the postfix notation, and each number or operation must be on its own line. Further, the result of an operation isn’t
automatically shown; you have to enter p to see the most recently calculated result.

J10BCPNCAP $ dc
9
*
p
81
----------------------------------------------------------------------------------------------------------------------------------------------
44) Directories

Any filename that ends with a slash (/) is a folder (UNIX calls these directories). Any filename that ends with an asterisk (*) is a program. Anything ending with an at sign (@) is a symbolic link, and everything else is a normal, plain file.directory .A type of UNIX file used to group other files. Files and directories can be placed inside other directories, to build a hierarchical system.

a) The bin Directory
This directory is used to store all the executable programs on the system.

b) The dev Directory
All device drivers—often numbering into the hundreds—are stored as separate files in the standard UNIX dev (devices) directory.

c) The etc Directory
The file system, security, device drivers, hardware configurations, and more. It designates the etc directory as the storage place for all administrative files and information

d) The lib Directory
UNIX has a central storage place for function and procedural libraries. These specific executables are included with specific programs, allowing
programs to offer features and capabilities otherwise unavailable.

e) The lost+found Directory
When files are recovered after any sort of problem or failure, they are placed here, in the lost+found directory, if the kernel cannot ascertain the proper location in the file system.

f) The mnt and sys Directories
The mnt directory is intended to be a common place to mount external media—hard disks, removable cartridge drives.

g) The tmp Directory
If you’re editing a file, for example, the program makes a copy of the file and saves it in tmp, and you work directly with that, saving the new file back to your original file only when you’ve completed your work.

h) The usr Directory
This directory was intended to be the central storage place for all user-related commands.

i) Home directory
This is your private directory, and is also where you start out when you log in to the system.

j) Root directory
The directory at the very top of the file system hierarchy, also known as slash.
----------------------------------------------------------------------------------------------------------------------------------------------
45) Absolute and relative file names
If it’s a slash, you’ve got an absolute filename (because the filename is rooted to the very top level of the file system). If you don’t have a slash as the first character, the filename’s a relative filename.
A hidden file is any file with a dot as the first character of the filename.
. current directory
.. parent directory
Absolute name :Specifying the location of a file in a hierarchy to ensure that the filename is unique is known in UNIX parlance as specifying its absolute filename. That is, regardless of where you are within the file system, the absolute filename always specifies a particular file. By contrast, relative filenames are not unique descriptors.
Relative name :Relative filenames describe files that are referenced relative to an assumed position in the file system.
----------------------------------------------------------------------------------------------------------------------------------------------
46) env
The env utility obtains the current environment, modifies it according  to  its arguments, then invokes the utility named by the utility operand with the modified environment.
Environment variables--
PATH-The PATH environment variable lists the set of directories, in left-to-right order, that the system searches to find commands and applications you request.
echo $PATH
HOME-Your home directory (as it’s known) is the name of the directory that you always begin your UNIX session within.
 echo $HOME
----------------------------------------------------------------------------------------------------------------------------------------------
47) dynamic linking Although most UNIX systems require all necessary utilities and library
routines (such as the routines for reading information from the keyboard and displaying it
to the screen) to be plugged into a program when it’s built (known in UNIX parlance as static
linking), some of the more sophisticated systems can delay this inclusion until you actually
need to run the program. In this case, the utilities and libraries are linked when you start the
program, and this is called dynamic linking.
----------------------------------------------------------------------------------------------------------------------------------------------
48) symbolic link A file that contains a pointer to another file rather than contents of its own.
This can also be a directory that points to another directory rather than having files of its own.
A useful way to have multiple names for a single program or allow multiple people to share
a single copy of a file.
----------------------------------------------------------------------------------------------------------------------------------------------
49) touch
The touch utility sets the access and modification times  of each  file.  The  file  operand  is  created  if it does not already exist.
----------------------------------------------------------------------------------------------------------------------------------------------
50) Compress
The compress program is given a list of filenames and then compresses each of the files, renaming them with a .Z suffix, which indicates that
they are compressed.
To reverse the operation, use the companion command uncompress, and specify either the current name of the file (that is, with the .Z suffix) or the name of the file before it was compressed (that is, without the .Z suffix.
----------------------------------------------------------------------------------------------------------------------------------------------
51) file
--similar to ls
J10BCPNCAP $ file SUBSCRIPTION_DTH-Process_Archive.log
SUBSCRIPTION_DTH-Process_Archive.log:   ascii text
----------------------------------------------------------------------------------------------------------------------------------------------
52) banner
banner prints its arguments (each up to 10 characters  long) in large letters on the standard output.
Print characters as a poster on the standard output. Each word supplied must contain ten characters or less.
Eg : banner archana
----------------------------------------------------------------------------------------------------------------------------------------------
53) finger
Display information about local and remote users.
----------------------------------------------------------------------------------------------------------------------------------------------
54) File Redirection
File redirection Most UNIX programs expect to read their input from the user (that is, standard input) and write their output to the screen (standard output). By use of file redirection, however, input can come from a previously created file, and output can be saved to a file instead of being displayed on the screen.
By placing a file-redirection command in a regular command line:
< redirects input,
> redirects output
 >> redirects output and appends the information to the existing file.

cat < file1 >file2
Copies from file 1 to file2
cat > new_filename
creates new file
----------------------------------------------------------------------------------------------------------------------------------------------
55) WC
It computes a word count for the file.
-w counts words
 -c counts characters
 -l counts
----------------------------------------------------------------------------------------------------------------------------------------------
56) uniq
Sometimes when you’re looking at a file, you’ll notice that there are many duplicate entries, either blank lines or, perhaps, lines of repeated information. To clean up these files and shrink their size at the same time, you can use the uniq command, which lists each unique line in the file.
Well, it sort of lists each unique line in the file. What uniq really does is compare each line it reads with the previous line. If the lines are the same, uniq does not list the second line. You can use flags with uniq to get more specific results: -u lists only lines that are not repeated.

The uniq command removes duplicate lines only if they’re adjacent.
-d lists only lines that are repeated (the exact opposite of -u),
-c adds a count of how many times each line occurred.
----------------------------------------------------------------------------------------------------------------------------------------------
57) Standard input and output
When a program is run, the default location for receiving input is called standard input. The default location for output is standard output. If you are running UNIX from a terminal, standard input and output are your terminal.
Standard input UNIX programs always default to reading information from the user by reading the keyboard and watching what’s typed. With file redirection, input can come from a file, and with pipelines, input can be the result of a previous UNIX command.
standard error.
Standard output, but you can redirect standard error to a different location than standard output.
Standard output When processing information, UNIX programs default to displaying the output on the screen itself, also known as standard output. With file redirection, output can easily be saved to a file; with pipelines, output can be sent to other programs.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
58)Sort
A program that reads information and sorts it alphabetically. The program sort also enables you to sort lists of numbers.

To sort filenames alphabetically regardless of case, you can use sort -f:
% ls -1 | sort -f
To sort lines of a file:
% sort < testme
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
59)Number Lines in Files Using cat -n and nl

To have a line number listed next to each line of a file. It’s quite simple to do with the cat program by specifying the -n flag to number lines in the file displayed.A program that prefaces each line with a line number isn’t much of an addition to the UNIX command toolbox.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
60) diff
compare two files
The diff utility will compare  the  contents  of  file1  and file2  and write to standard output a list of changes necessary to convert  file1  into  file2.
Eg : diff mon.logins tues.logins
2d1
< bsmith
4a4
> jdoe
7c7
< mschmidt
---
> proy
Note that the output lists the differences as well as in which file the difference exists. Lines in the
first file are preceded by "< ", and those in the second file are preceded by "> ".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
61) comm
select or reject lines common to two files
The comm utility  reads  file1  and  file2,  which  must  be ordered  in  the  current  collating  sequence, and produces three text columns as output: lines  only  in  file1;  lines only in file2; and lines in both files.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
62) nl
line numbering
The best option, though, is that nl can selectively number just those lines that contain a specified pattern.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
63) spell
 The spell command collects words from the  named  files  and looks  them  up in a spelling list. Words that neither occur
 among nor are derivable (by  applying  certain  inflections, prefixes,  or  suffixes) from words in the spelling list are written to the standard output.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
64)Filters
Filters are a particular type of UNIX program that expects to work either with file redirection or as part of a pipeline. These programs read input from standard input, write output to standard output, and often don’t have any starting arguments.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
65) Wild Cards
There are two wildcards to learn here: * acts as a match for any number and sequence of characters, and ? acts as a match for any single character. In the broadest sense, a lone * acts as a match for all files in the current directory (in other words, ls * is identical to ls), whereas a single ? acts as a match for all one-character-long filenames in a directory (for instance, ls?, which will list only those filenames that are one character long).

Eg :
1) ls -ld S*
2) ls -ld S
3)ls -ld a* b* k* o* s* t*
4)ls -ld [abkost]*
5)ls -ld [a-z]*
6)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
66) egrep
Sometimes a single regular expression can’t locate what you seek. For example, perhaps you’re looking for lines that have either one pattern or a second pattern. That’s where the egrep command proves helpful. The command gets its name from“expression grep,” and it has a notational scheme more powerful than that of grep.( use  the  full  set  of alphanumeric and special characters) to match the  patterns)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
67) fgrep

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
68) Expressions
Some text processing programs, such as grep, egrep, sed, awk and vi, let you search on patterns instead of fixed strings. These text patterns are known as regular expressions. You form a regular expression by combining normal characters and special characters, also known as meta-characters,
with the rules below. With these regular expressions you can do pattern matching on text data.
Regular expressions come in three different forms:
• Anchors which tie the pattern to a location on the line
• Character sets which match a character at a single position
• Modifiers which specify how many times to repeat the previous expression

1) . match any single character except <newline>
2) * match zero or more instances of the single character (or meta-character) immediately preceding it
3) [abc] match any of the characters enclosed
4) [a-d] match any character in the enclosed range
5) [^exp] match any character not in the following expression
6) ^abc the regular expression must start at the beginning of the line (Anchor)
7) abc$ the regular expression must end at the end of the line (Anchor)
8) \ treat the next character literally. This is normally used to escape the meaning of special characters such as "." and "*".

Example
1) To find lines which begin with 'O'
grep ^O time.sh
2) To find lines which begin with 'SMS'
grep ^SMS time.sh
3) To find lines which begin with OMS
grep OMS* time.sh
4) search for any instances of t followed by zero or more occurrences of e
grep 'te*' num.list
5) search for any instances of t followed by one or more occurrences of e
grep 'tee*' time.sh
6)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
69) sed - stream editor
The non-interactive, stream editor, sed, edits the input stream, line by line, making the specified changes, and sends the result to standard output.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
70) AWK
awk is a pattern scanning and processing language. Its name comes from the last initials of the threeauthors: Alfred. V. Aho, Brian. W. Kernighan, and Peter. J. Weinberger.
nawk is new awk, a newer version of the program
gawk is gnu awk, from the Free Software Foundation.
awk searches its input for patterns and performs the specified operation on each line, or fields of the line, that contain those patterns. You can specify the pattern matching statements for awk either on the command line, or by putting them in a file and using the -f program_file option.Each input line is checked for a pattern match with the indicated action being taken on a match. This continues through the full sequence of patterns, then the next line of input is checked.
Input is divided into records and fields.
Syntax
awk program [file]
where program is composed of one or more:
pattern { action }
fields.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
71)cmp [options] file1 file2
compare two files and list where differences occur (text or binary files)
Eg : % cmp mon.logins tues.logins
mon.logins tues.logins differ: char 9, line 2
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
72) cut [options] [file(s)]
The cut command allows a portion of a file to be extracted for another use.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
73) find
find files matching a type or pattern
The find command will recursively search the indicated directory tree to find files matching a type or pattern you specify. find can then list the files or execute arbitrary commands based on the results.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
74) paste - merge files
The paste command allows two files to be combined side-by-side. The default delimiter between the
columns in a paste is a tab, but options allow other delimiters to be used.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
75) sort [options] file sort the lines of the file according to the options chosen
The sort command is used to order the lines of a file. Various options can be used to choose the order
as well as the field on which a file is sorted. Without any options, the sort compares entire lines in the
file and outputs them in ASCII order (numbers first, upper case letters, then lower case letters).
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
76) ln
The ln command creates a "link" or an additional way to access (or gives an additional name to)
another file.
Syntax
ln [options] source [target]
If not specified target defaults to a file of the same name in the present working directory.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
77) tee
tee sends standard in to specified files and also to standard out. It’s often used in command pipelines.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
78) strings
To search a binary file for printable, ASCII, strings use the strings command. It searches for any sequence of 4 or more ASCII characters terminated
by a  <newline> or null character. I find this command useful for searching for file names and possible error messages within compiled programs
that I don’t have source code for.
Syntax
strings [options] file
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
79) tr
The tr command translates characters from stdin to stdout. With no options the characters in string1 are translated into the characters in string2, character by character in the string arrays. The first character in string1 is translated into the first character in string2, etc.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
80) File Compression
The compress command is used to reduce the amount of disk space utilized by a file. When a file has been compressed using the compress
command, a suffix of .Z is appended to the file name. The ownership modes and access and modification times of the original file are preserved. uncompress restores the files originally compressed by compress.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
81) tar - archive files
The tar command combines files into one device or filename for archiving purposes. The tar
command does not compress the files; it merely makes a large quantity of files more manageable
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
82) uuencode/uudecode - encode a file
To encode a binary file into 7-bit ASCII use the uuencode command. To decode the file back to binary use the uudecode command. The uu in the names comes because they are part of the
Unix-to-Unix CoPy (UUCP) set of commands. The uuencode and uudecode commands are
commonly used when sending binary files through e-mail. In e-mail there’s no guarantee that 8-bit
binary files will be transferred cleanly. So to ensure delivery you should encode the binary file, either
directly, on the command line and then include the encoded file, or indirectly, by letting your MIME
mailer program do it for you. In a similar manner, the user decodes the file on the receiving end.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
83) od - octal dump of a file
od dumps a file to stdout in different formats, including octal, decimal, floating point, hex, and
character format.
Syntax
od [options] file
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
84) TELNET and FTP - remote login and file transfer protocols
TELNET and FTP are Application Level Internet protocols. The TELNET and FTP protocol
specifications have been implemented by many different sources, including The National Center for
Supercomputer Applications (NCSA), and many other public domain and shareware sources.
The programs implementing the TELNET protocol are usually called telnet, but not always. Some
notable exceptions are tn3270, WinQVT, and QWS3270, which are also TELNET protocol
implementations. TELNET is used for remote login to other computers on the Internet.
The programs implementing the FTP protocol are usually called ftp, but there are exceptions to that
too. A program called Fetch, distributed by Dartmouth College, WS_FTP, written and distributed by
John Junod, and Ftptool, written by a Mike Sullivan, are FTP protocol implementations with graphic
user interfaces. There’s an enhanced FTP version, ncftp, that allows additional features, written by
Mike Gleason. Also, FTP protocol implementations are often included in TELNET implementation
programs, such as the ones distributed by NCSA. FTP is used for transferring files between
computers on the Internet.
rlogin is a remote login service that was at one time exclusive to Berkeley 4.3 BSD UNIX.
Essentially, it offers the same functionality as telnet, except that it passes to the remote computer
information about the user's login environment. Machines can be configured to allow connections
from trusted hosts without prompting for the users’ passwords. A more secure version of this
protocol is the Secure SHell, SSH, software written by Tatu Ylonen and available via
ftp://ftp.net.ohio-state.edu/pub/security/ssh.
From a Unix prompt, these programs are invoked by typing the command (program name) and the
(Internet) name of the remote machine to which to connect. You can also specify various options, as
allowed, for these commands.

85) Remote commands
A number of Unix machines can be connected together to form a local area network. When this is the
case, it often happens that a user of one machine has valid login access to several of the other
machines in the local network. There are Unix commands available to such users which provide
convenience in carrying out certain common operations. Because these commands focus on
communications with remote hosts in the local network, the command names begin with the letter
"r": rlogin, rsh, and rcp. The remote access capability of these commands is supported (optionally)
by the dotfile, ~/.rhosts, for individual users and by the system-wide file /etc/hosts.equiv. For
security reasons these may be restricted on some hosts.
The rlogin command allows remote login access to another host in the local network. rlogin passes
information about the local environment, including the value of the TERM environment variable, to
the remote host.
The rsh command provides the ability to invoke a Unix shell on a remote host in the local network for
the purpose of executing a shell command there. This capability is similar to the "shell escape"
function commonly available from within such Unix software systems as editors and email.
The rcp command provides the ability to copy files from the local host to a remote host in the local
network.
Syntax
rlogin [ -l username ] remote_host
rsh [ -l username ] remote_host [ command ]
rcp [ [user1]@host1:]original_filename [ [user2]@host2:]new_filename
where the parts in brackets ([]) are optional. rcp does not prompt for passwords, so you must have
permission to execute remote commands on the specified machines as the selected user on each
machine.

86)basename
deliver portions of path names
basename pathname [suffix]
Given a pathname, strip the path prefix and leave just the filename, which is printed on standard output. If specified, a filename suffix (e.g., .c) is removed also. basename is typically invoked via command substitution (`...`) to generate a filename. See also dirname.
The Solaris version of basename allows the suffix to be a pattern of the form accepted by expr. See the entry for expr for more details

No comments:

Post a Comment