Applying Thoughts

"Sometimes I Win, Other times I learn. but I never lose."
Showing posts with label UNIX Notes. Show all posts
Showing posts with label UNIX Notes. Show all posts

February 24, 2011


Networking Tools
1. ARP:  In computer networking, the Address Resolution Protocol (ARP) is the method for finding a host's link layer (hardware) address when only its Internet Layer (IP) or some other Network Layer address is known.
            ARP has been implemented in many types of networks; it is not an IP-only or Ethernet-only protocol. It can be used to resolve many different network layer protocol addresses to interface hardware addresses, although, due to the overwhelming prevalence of IPv4 and Ethernet, ARP is primarily used to translate IP addresses to Ethernet MAC addresses. It is also used for IP over other LAN technologies, such as Token Ring, FDDI, or IEEE 802.11, and for IP over ATM.

2. FTP: File Transfer Protocol (FTP) is a standard network protocol used to exchange and manipulate files over an Internet Protocol computer network, such as the Internet. FTP is built on a client-server architecture and utilizes separate control and data connections between the client and server applications. Client applications were originally interactive command-line tools with a standardized command syntax, but graphical user interfaces have been developed for all desktop operating systems in use today. FTP is also often used as an application component to automatically transfer files for program internal functions. FTP can be used with user-based password authentication or with anonymous user access.
3. TELENT: Telnet (teletype network) is a network protocol used on the Internet or local area networks to provide a bidirectional interactive communications facility. Typically, telnet provides access to a command-line interface on a remote host via a virtual terminal connection which consists of an 8-bit byte oriented data connection over the Transmission Control Protocol (TCP). User data is interspersed in-band with TELNET control information.
4. RLOGIN: rlogin is a software utility for Unix-like computer operating systems that allows users to log in on another host via a network, communicating via TCP port 513.It was first distributed as part of the 4.2BSD release. rlogin is also the name of the application layer protocol used by the software, part of the TCP/IP protocol suite. Authenticated users can act as if they were physically present at the computer. RFC 1258, in which it was defined, states that: "The rlogin facility provides a remote-echoed, locally flow-controlled virtual terminal with proper flushing of output." rlogin communicates with a daemon, rlogind, on the remote host. rlogin is similar to the Telnet command, but has the disadvantage of not being as customizable and being able to connect only to Unix hosts

February 23, 2011

UNIX COMMANDS
 CAL [month] year                   Print calendar
               cal                             displays calendar
                                                                            month = 1 to 12
                                                                            year = 1 to 9999
 CAT                                                       Concatenate and Print
               $cat file                       displays file
 CD                                                         Change working directory
               cd                              return to login directory
               cd dirname                      change working directory to dirname
 CHMOD                                                 Change permission mode for file
               chmod [who] op-code permission... file...
                who:
                               o       others
                               g       group
                               u       Login owner
                               a       all of above
                op-code:
                               +       add permission
                               -       remove permission
                               =       assign absolute permission
                permission:
                               r       read
                               w       write
                               x       execute
 CP                                                         Copy File
                cp file1 file2                  copy file1 and name new copy as file2
 
DIFF                                                      Differential File Comparator
               diff [options] file1 file2      find difference between file1 and file2
                options:
                               -b      ignore spaces and tabs in comparison
                               -e      ed script option
                               -f      opposite order script
                               -h      simple, fast, less-rigorous comparison
 
ECHO                                                    Echo arguments
               echo [arg]...                   echo arg to standard output
 
FIND                                                      Find Files
               find pathname-list... condition...
                options:
                               -atime n                last accessed day n
                               -exec cmd               execute cmd if file meets conditions
                               -group gname            file owner gname
                               -links n                number of links to file
                               -mtime n                last modified day n
                               -name file              specify filename
                               -newer file             file modified more recently than file
                               -ok cmd                   execute cmd only on 'y' response
                               -print                  display the file pathname
                               -size n                 file size in blocks
                               -type c                 specify file-type
                                                                                            b       block
                                                                                            c       character
                                                                                            d       directory
                                                                                            f       plain file
                               -user uname             file owner uname
 
GREP                                                    Search file for pattern
               grep [options] pattern file...  find lines in file matching pattern
                options:
                               -c      count of matching lines
                               -e      use if pattern begins with '-'
                               -h      header display suppressed
                               -l      list of filenames containing pattern
                               -n      line number of lines which match
                               -v      variant: all lines except matches
                               -y      lowercase pattern will match uppercase
 
LP                                                         Line print spooler
               lp [options] file...            place file in line printer queue
                options:
                               -c                      make copy of file for queue
                               -ddestprn               specify destprn as destination printer
                               -fformname              use the form specified by formname
                               -m                      report by mail when printed
                               -nx                     print x copies
                               -r                      remove file after placing in queue
                               -ttitle                 specify title as banner
                               -w                      write message on terminal after printing
 
LS                                                         List Contents of Directory
               ls [options] name...            list contents of directory
                options:
                               -a      all entries
                               -d      directory status information
                               -l      long format
                              -r      reverse order listing
                               -s      size in blocks
                               -t      sort by time modification
                               -u      sort by last access time
                               -x      multi-column across page
 
MAN                                                      On-line Manual
               man [options] section title     locates and displays pages of unix manual
                options:
                               -a      all matching title
                               -f      first matching title
                               -w      prints pathname to manual section
 
MESG                                                   Permit or Deny Messages
               mesg [options]          report or set write permission on terminal
                options:
                               -n      deny non-user write permission
                               -y      enable non-user write permission
 
MKDIR                                                   Make a Directory
               mkdir dirname...                create directory
 
MV                                                        Move a file or directory
               mv file1 file2                  change name of file1 to file2
               mv dir1 dir2                    rename dir1 directory to dir2 directory
               mv file... dname                move one or more files to directory dname
 
PASSWD                                               Change Login Password
               passwd                          change your password
 
PR                                                         Print File with Pagination
               pr [options] file...            formatted printing of file...
                options:
                               -a                      multi-column across page
                               -d                      double space output
                               -f                      use form-feed character as page break
                               -h "title"              customized page heade title
                               -ln                     page length n lines
                               -m                      print all files... in multiple columns
                               -n                      produce n-column output
                               +n                      start printing at page n
                               -sc                     seperate columns with character c
                               -t                      no header printed
                               -wn                     page width n characters
 
PS                                                         Process Status
               ps [options] processnumber      print information about active processes
               options:
                               -a      all processes except group leaders and non-terminal processes
                               -e      all processes
                               -l      long listing
 
PWD                                                      Print Working Directory
               pwd                             display current working directory
 
RM                                                        Remove files or directories
               rm [options] file...            remove one or more files
               options:
                               -f      force removal of write-protected files
                               -i      interactive delete
                               -r      recursively delete directory
 
SORT                                                    Sort or Merge Files
               sort [options] [+pos1] [-pos2] [-ofileout] filein...
               options:
                               -b      ignore leading blanks and tabs
                               -c      check if sorted
                               -d      dictionary order
                               -f      ignore case
                               -i      ignore non-printable characters in non-numeric comparisons
                               -M      compare as months
                               -m      merge the files, input files are already sorted
                               -n      sort on first numeric field
                               -r      reverse order of sort
                               -tx     field seperator is x
                               -u      eliminate duplicate lines
               +pos1, -pos2            restrict sort key to beginning at pos1 and ending at pos2
               -ofileout               write output to outfile
 
TAIL                                                      Deliver last part of a file
               tail [+-n] file                 copy file to stdout +n from beginning to -n from end of file
 
TEE                                                       Pipe fitting
               tee [options] file...           divert a copy into file...
               options:
                               -a      append to file
                               -i      ignore interrupt signals
                               -u      unbuffered output
 
UNIQ                                      Remove repeated lines in a sorted file
                uniq [options] input [output]     remove repeated adjacent lines in input file when copying to output file 
               options: 
                               -u             display lines not repeated in input 
                               -d             display one copy of repeated lines in input 
                               -c             precede each line with number of times repeated 
                               -n             ignore the first n fields 
                               +n            ignore the first c characters
 
 WC                                                       Word Count 
                               wc [options] file... count lines, words and characters in file... 
               options: 
                               -c             count characters 
                               -l              count lines 
                               -w            count words
 
 WHO                                     Who is on the system 
               who                                        list user login name, terminal and login time 
 
WRITE                                   Write to another user
                write user [ttyname]                write to user on terminal, ttyname the ttyname is optional. 
HEAD
This is used to view the first few lines of a file. It accepts a switch specifying the number of lines to view.
NEWS
The news command keeps the user informed of current events.
DF
it reports number of free disk blocks, and i-nodes
DU
Summarizes disk usage in a specified directory hierarchy
LN
Creates a hard link (default), or a soft link (with -s option)
MOUNT, UMOUNT
Attaches, or detaches, a file system (super user only)
MKFS
Constructs a new file system (super user only)
FSCK
Evaluates the integrity of a file system (super user only)

FINGER

finger displays information about one or more Linux users. GNU finger supports a single host that can act as the finger server host in sites that have multiple hosts. This host collects information about who is logged into other hosts at that site. Thus, a query to any machine at another site will return complete information about any user at that site.

NICE
            run a program with modified scheduling priority  
SET
Typing the set command will print out a list of all the current shell environments. This is a list of all the variables and settings that the shell currently has.
SHELL VARIABLES
The shell supports user and system variables. An example of system variables are,
        PS1             system prompt
        PS2             secondary line shell prompt
        HOME            home directory
        LOGNAME         login name
Variables are assigned values using the = sign.

vi

vi (pronounced vee-eye) is UNIX's standard editor. The purpose of the following exercises is to expose you to some of vi's features. vi provides a window of 20 lines into the file being edited. You can move to any line and make changes (insert, delete, over-write).
Unix was designed to support simple ASCII terminals, thus the original editors (ed) were line based. vi is a command line editor, in that it has two basic modes of operation, command mode and edit mode.
The default mode for vi is the command mode. In this mode, editing of user text cannot be performed. vi awaits the appropriate command from the user before performing the operation.
In general, vi will return to the command mode after executing the command.
The advantage of this approach is that commands can be executed from files, and documents can be formatted or re-arranged by simply running a menu script of commands in vi.
Pressing the ESC key will cause the terminal to beep. When this happens, you are in command mode.
Loading vi
To load vi and begin an editing session, type,
        vi   newfile
This command loads the editor and because the file does not already exist, creates it ready for use. The editor is now in command mode and is awaiting a command.
Moving the cursor
The following keys control cursor movement. DO NOT TRY TO USE THE CURSOR ARROW KEYS TO MOVE THE CURSOR!
        k       up
        j       down
        h       left
        l       right
When vi is loaded on a new file, the cursor is restricted to the upper left position on the screen, and cannot be moved using the cursor keys.
Text input mode (append, insert, open)
The commands
        a       appends to the last line of the file
        i       inserts at the current cursor position
        o       inserts one line down from the current cursor position
        O       inserts one line up from the current cursor position
allow text to be entered starting at the upper left corner of the screen, for a new file. When used on an existing file, the commands act like,
Deleting and Changing text
The three most used commands to alter text are,
        x       erase the character at the cursor
        r       replace the character at the cursor
        dd      delete the entire line where the cursor is
All three commands are executed in command mode, and return to the command mode after executing.
Undoing changes
There are times that you make changes and immediately realize a mistake has been made. The vi editor provides means to undo previous commands.
The u command undoes the previous command.
The U command undoes all the changes made on the current line.
Saving the editor buffer and remaining in vi
You are strongly encouraged to save editing changes regularly. The command to write the editor buffer is
        :w
If you decide that you do want to over-write the existing file, but rather save the changes to a new file, then follow the :w command with the name of the new file,
        :w  newfile2
Leaving vi
The commands used to leave vi are,
        ZZ      writes the buffer to disk into the original file, then returns to the shell
       
        :wq     same as ZZ
       
      :q!   quits the editor, abandons the buffer, and returns to the shell