Thursday, 2 April 2015

UNIX COMMANDS

UNIX RECAP NOTES
UNIX FEATURES

Unix has been a popular OS for more than two Decades because of its Multi User,Multi Tasking Environment, Stability ,Portability and Powerful Networking Capability.

Multiuser    –  More than one user can use the machine.
Multitasking –More than one program can be run at a time.
Portability – This means the Operating System can be easily converted to run on different browsers.
Handling Files and Directories
Ls command
ls command is most widely used command and it displays the contents of directory.
options
ls will list all the files in your home directory, this command has many options.
ls -l will list all the file names, permissions, group, etc in long format.
ls -a will list all the files including hidden files that start with . .
ls -lt will list all files names based on the time of creation, newer files bring first.
ls -Fxwill list files and directory names will be followed by slash.
Mkdir command.
mkdir sandeep will create new directory, i.e. here sandeep directory is created.
Cd command.
cd sandeep will change directory from current directory to sandeep directory.
Use pwd to check your current directory and ls to see if sandeep directory is there or not.
You can then use cd sandeep to change the directory to this new directory.
n  To change the directory to /tmp directory.
$ pwd
/home/scripter
$ cd /tmp/
$ pwd
/tmp
$

Head command.
head filename by default will display the first 10 lines of a file.
If you want first 50 lines you can use head -50 filename or for 37 lines head -37 filename and so forth.

Tail command.
tail filename by default will display the last 10 lines of a file.
If you want last 50 lines then you can use tail -50 filename.
Realtime Exmple
a.  tail /ods/sap_spt_rel/logs/update_cust_determination20100819


Wc command
wc command counts the characters, words or lines in a file depending upon the option.
Options
wc -l filename will print total number of lines in a file.
wc -w filename will print total number of words in a file.
wc -c filename will print total number of characters in a file.

How to Set File Permissions Using `chmod'
Files and directories in Unix may have three types of permissions:
read (`r'), write (`w'), and execute (`x').
Each permission may be `on' or `off' for each of three categories of users:
 the file or directory owner;
 other people in the same group as the owner;
and all others.
n  Read – access to view the file.
n  Write – access to write and delete the file.
n  Execute – access to run a file or program.
Chmod 775 Pipebyrep
When using the numeric system, the code for permissions is as follows:
    r = 4 w = 2 x = 1      rwx = 7
The first 7 of our chmod775 tells Unix to change the user's(owner) permissions to rxw (because r=4 + w=2 + x=1 adds up to 7.
The second 7 applies to the group, and the last number 5,
refers to others (4+1=5).
 When doing an ls -l on the file, telnet always shows the permissions this way:
 
Example1 :  -rwxr-xr-x
1. Ignore First digit
2. Then break up the above into three groups of letters. If there's a dash where a letter should be, it means that there is no permission for those people.
3. Remember: the first 3 apply to user, the second 3 apply to group, and the third 3 apply to others.
Ps command – Process Status
n  Prints information about active processes. (Status of the process on the server,wht are the processes are running)
-f                   Generate a full listing.
-l                   Generate a long listing.
-u                List only process data whose effective user ID number or login name is given in uidlist

GREP COMMAND
n  It’s a Search command Used to find pattern in a file or to find processes running on system.
  Options
n  -i          Case-insensitive search
n  -n         Display line number
Example  grep   -i    unix   plc
Grep can also be used Conjunction with other commands
n  ps   –ef   |   grep   sleep
1.Output of ps command is passed to grep command.
2.It will search all processes in system and find pattern sleep.
Result  -à Ops 12964 258  ttyae/aes 0:00 sleep 60
Ssb 27049  335 ttyah/aahs 0:00 sleep 60

Pwd command.
pwd command will print your home directory on screen, pwd means print working directory.
 /home/temp>
is output for the command when I use pwd in /home/temp directory.

kill  command- terminate procs

 Syntax
nkill   [-signal]   pid . . .
nkill   –l  (the letter ‘L’ in lowercase)
Description
Sends a signal to the specified processes.
The value of signal may be numeric or
symbolic.
Signal 15 is the default signal.
kill –l  lists the defined signals.

No comments:

Post a Comment