Tuesday, December 13, 2016

Case studies


  • How to find if the directory/folder exist in a specific directory using linux commands.
         Tried
         [datastoreg@lgpbd1070(IPC2-Gold-EDGE) /idn/home/dlyelgg] $ ls -ltr *srik*
         o/p: 
         total 2

         -rw-r--r-- 1 dlyelgg dlyelgm7 202 Nov 15 10:40 1
         drwxr-xr-x 2 dlyelgg dlyelgm7   6 Dec  6 10:21 Shell_Scripting
         drwxr-xr-x 2 dlyelgg dlyelgm7   2 Dec  8 09:59 Python_Scripting


          

Sunday, May 8, 2016

Unix commands that could be used in Putty


5/8/2016

Below are commands based of my knowledge:

  • cd ..
    • Will go to parent director
  • cd /folder1
    • Make you get to the child folder1
  • ls
    • Will list the files available in the current directory
    • ls -ltr   --- will list down only file names (working)
  • ll  ------ will list down file names and respective exact size.(working)
  • head
    • chops the first 10000 lines in the post.xml file and put it in posts_small.xm
      • head -n 10000 post.xml > posts_small.xml   ---- working
    • head -1000f <file name> ----- will list the first 1000 lines in same putty window.  ---- working
  • tail
    • chops the last 10000 lines in the post.xml file and put it in posts_small.xm
      • tail -n 10000 post.xml > posts_small.xml   ---- working
    • tail -1000f <file name> ----- will list the last 1000 lines in same putty window.  ---- working
  •  ls -lah   ----- working
    • This will give(o/p):
      •  4 Feb 27 11:46 <file name>
    • The command  is similar to ll but ll will give exact size of the file.
  • ssh
    • I generally use this to connect to server
    • ssh <servername>  ---- this will help to login to specific server (working)
  • wc -l <file_name>    --- this will give the number of records in a mentioned file (working)
  • less?
  • scp
    • scp <complete source path of file>  <complete destination path of file>  ------ working
    • The above command will copy the file in source path to the destination.  
  • grep --  search a file for a pattern
    • or you can filter the output for keywords (e.g. "apples") an then redirect to a file:
      • ./script1.sh | grep apples > ./only-apples
    • grep -r -e 'text1'  -e 'text2' <file name -string>* > output_file_name   ---- working
      • Here the output_file_name will have all records that has text1 or text2  in file_name file
      • By adding additional -e <string1>  ----- we could add more strings for for search.

  • To get Information related to command:
    • Type: info <command_name> ----- this will give information of the command. Little bit of syntax too.
    • Ex: info ls ----- is giving what ls means, what is the output of the command...working
  • How to get syntax of the command?
    • man <command_name>  ---- this will give syntax details
  • List of commands that can be used with 'ls
          http://www.computerhope.com/unix/uls.htm

  • 10/13/2016:
    • Give execute permission to your script??
      • chmod +x /path/to/yourscript.sh
      • Once you are in the correct current folder you can run the script like this:
        • sh ./script1.sh
      • or you can run and redirect the output to a file:
        • sh ./script1.sh > out.txt
      • To run shell file:
        • sh <name of file>.sh
          • ./filename.sh
          • . filename.sh

Below information to know list of commands available in Unix:(that could be used in Putty)

Source: http://mally.stanford.edu/~sr/computing/basic-unix.html

      Unix commands

      Note that there are thousands of commands available on a typical unix box. In bash, just hit the "Tab" key twice and say yes, to display the the commands currently available on your machine. A standard unix operating system lists currently thousands of commands. Type x to list all commands starting with x. The following list contains some of the more frequently used programs.

      Access Control

      exit - terminate a shell (see "man sh" or "man csh")
      logout - sign off; end session (C shell and bash shell only;)
      passwd - change login password
      rlogin - log in remotely to another UNIX system
      ssh - secure shell
      slogin - secure version of rlogin
      yppasswd - change login password in yellow pages
      

      Communications

      mail - send and receive mail
      mesg - permit or deny terminal messages and talk requests
      pine - send and receive mail 
      talk - talk to another logged-in user
      write - write to another logged-in user
      

      Programming Tools

      as - assembler, specific to each machine architecture
      awk - pattern scanning and processing language
      bc - online calculator
      cc - C compiler 
      csh - C shell command interpreter
      dbx - source-level debugging program
      f77 - Fortran compiler 
      gdb - GNU Project debugger
      gprof - display profile of called routines
      kill - kill a process
      ld - the UNIX loader
      lex - generate lexical analysis programs
      lint - check C source code
      make - maintain large programs
      maple - symbolic mathematics program
      math - symbolic mathematics program
      nice - run a command at low priority (see "man nice" or "man csh")
      nohup - run a command immune to hangups
      pc - Pascal compiler (xlp on ADS)
      perl - Popular script interpreter
      prof - display profile data
      python - Python programming language
      sh - Bourne shell command interpreter
      yacc - generate input parsing programs
      xcalc - graphical calulator under x
      

      Documentation

      apropos - locate commands by keyword lookup
      find - locate file (i.e. find . -name *.tex -print)
      info - start the info explorer program 
      man - find manual information about commands
      whatis - describe what a command is
      whereis - locate source, binary, or man page for a program
      
      Editors
      emacs - screen-oriented text editor
      pico - screen-oriented text editor (renamed called nano)
      sed - stream-oriented text editor
      vi - full-screen text editor
      vim - full-screen text editor ("vi-improved")
      
      File and Directory Management
      cd - change working directory
      chmod - change the protection of a file or directory
      chown - change owner (or group) of a file or directory
      chgrp - change group of a file or directory
      cmp - compare two files
      comm - select/reject lines common to two sorted files
      cp - copy files
      crypt - encrypt/decrypt files (CCWF only)
      diff - compare the contents of two ASCII files
      file - determine file type
      grep - search a file for a pattern
      gzip - compress or expand files
      ln - make a link to a file
      ls - list the contents of a directory
      lsof - list of open files    
      mkdir - create a directory
      mv - move or rename files and directories
      pwd - show the full pathname of your working directory
      quota - display disk usage and limits
      rm - delete (remove) files
      rmdir - delete (remove) directories
      stat - status of file (i.e. last access)
      sync - flush filesystem buffers   
      sort - sort or merge files
      tar - create or extract archives
      tee - copy input to standard output and other files
      tr - translate characters
      umask - change default file protections
      uncompress - restore compressed file
      uniq - report (or delete) repeated lines in a file
      wc - count lines, words, and characters in a file
      

      File Display and Printing

      cat - show the contents of a file; catenate files
      fold - fold long lines to fit output device
      head - show first few lines of a file
      lpq - examine the printer spooling queue
      lpr - print a file
      lprm - remove jobs from the printer spooling queue
      more - display a file, one screen at a time
      less - like more with more features 
      page - like "more", but prints screens top to bottom
      pr - paginate a file for printing
      tail - show the last part of a file
      zcat - display a compressed file
      xv - show print, manipulate images
      gv - show ps and pdf files
      xpdf = shopw pdf files (use gv) 
      

      File Transfer

      ftp - transfer files between network hosts
      rsync -  fast and flexible sync between computers
      scp - secure version of rcp
      

      Miscellaneous

      alias - define synonym commands
      chquota - change disk quota on ACITS UNIX systems
      chsh - change default login shell
      clear - clear terminal screen
      echo - echo arguments
      pbm - portable bitmap manipulation programs
      popd - pop the directory stack (C shell only)
      pushd - push directory on stack (C shell only)
      script - make typescript of terminal session
      setenv - set an environment variable (C shell only)
      stty - set terminal options
      

      News/Networks

      netstat - show network status
      rsh - run shell or command on another UNIX system
      ssh - secure-shell version of rsh
      

      Process Control

      bg - put suspended process into background
      fg - bring process into foreground
      jobs - list processes
      ^y - suspend process at next input request
      ^z - suspend current process 
      

      Status Information

      clock - determine processor time
      date - show date and time
      df - summarize free disk space
      du - summarize disk space used
      env - display environment
      finger - look up user information
      history - list previously issued commands 
      last - indicate last login of users
      lpq - examine spool queue
      manpath - show search path for man pages
      printenv - print out environment
      ps - show process status
      pwd - print full pathname of working directory
      set - set shell variables (C shell, bash, or ksh)
      spend - lists year-to-date ACITS UNIX charges
      stty - set terminal options
      time - timing programs
      top - list  top  cpu processes
      uptime - show system load, how long system has been up
      w - show who is on system, what command each job is executing
      who - show who is logged onto the system
      whois - Internet user name directory service
      whoami - who owns the shell
      

      Image Processing

      gimp - photoshop type image processing program
      xfig - drawing program
      xv - image viewer
      xvscan - scan picture 
      xpaint - paint program
      kpaint - kde paint program 
      

      Sound

      mplayer - mpg player 
      realplay - realaudio player
      timidity - midi to wav converter and player
      xmms - mp3 player 
      

      Text Processing

      abiword - open source word processor
      addbib - create or extend bibliographic database
      col - filter reverse line feeds
      diction - identify wordy sentences 
      diffmk - mark differences between files
      dvips - convert TeX DVI files into PostScript
      explain - explain phrases found by diction program
      grap - pic preprocessor for drawing graphs 
      hyphen - find hyphenated words 
      ispell - check spelling interactively
      latex - format text in LaTeX (based on TeX)
      pdfelatex - latex with pdf output 
      latex2html - Latex to html
      lookbib - find bibliography references
      macref - make cross-reference listing of nroff/troff macro files
      ndx - create a subject-page index for a document
      neqn - format mathematics with nroff
      nroff - format text for simple display
      pic - make simple pictures for troff input
      psdit - filter troff output for Apple LaserWriter
      ptx - make permuted index (not on CCWF)
      refer - insert references from bibliographic databases 
      roffbib - run off bibliographic database 
      sortbib - sort bibliographic database 
      spell - find spelling errors
      ispell - interactive spell checker
      style - analyze surface characteristics of a document 
      tbl - format tables for nroff/troff
      tex - format text
      tpic - convert pic source files into TeX commands 
      wget -  grab webpage
      

      X windows

                  
      grabmode - info on screen: i.e. "1152x864"  51.213kHz/56.59Hz
      import - grab window (i.e. import ppm:- >out.ppm)
      xdpyinfo -  number of colors 
      xkill - kill xwindow
      xlock - lock screen
      xterm - xterminal
      xwininfo - information on open window
      

      Web

      html2ps - html to ps
      latex2html - latex to html translator
      lynx - text based webbrowser
      netscape - webbrowser
      sitecopy - sitecopy is for easily maintaining remote web sites.
      weblint - html sytax and style checker