Sunday, April 15, 2012

My Basic Linux Commands

#####Shell, Basic linux Command#####
   1.tty     - reveals the current terminal
   2.whoami  - reveals the currently logged-in user
   3.which   - reveals where in the search path a program is located
   4.echo    - prints to the screen
      a. echo $PATH - prints out the current path to STDOUT
      b. echo $PWD  - dumps the contents of the $PWD variable
      c. echo $OLDPWD - dumps the
   5. set    - prints and optionally sets shell variables
   6. clear  - clears the screens or terminal
   7. reset  - clears the screen buffer
   8. history - reveal command history
          a. !600 - executes the 600th command in our history
          b. command histroy is maintained on a per-user basis via:~/.bash_history
          c. ~   - users's $HOME directory in the BASH shell
   9. pwd    - prints the working directory
   10. cd     - changes directory to desired directory
          a. 'cd ' with no options changes to the $HOME drectory
          b. 'cd ~' changes to the $HOME directory
          c. 'cd /' changes to root directory
          d.  'cd Desktop/' changes to the relative directory
          e. 'cd..' 'cd ../..' chages one-level/ two-levels up in the directory tree\
    11. Arrow ( up/down) keys
    12. Bash supports tab completions
          a. type unique characters in the command and press 'Tab' key
    13. copy and paste in GNOME terminal windows using:
          a. left button to block
          b. right button to paste OR Ctrl-Shift-v to past - lists directories
          a. ls / - lists the contens of the '/' mount point
          b. 'ls -l' - lists the contents of a direcotry in long format
          c. 'ls -ld' - lists the directory properties rather than the contents
          d. 'ls -ltr' sorts chronologically from older to newer ( bottom )
          e. 'ls -help'
          f. 'ls -a'  - reveal hiden files
       Note: files/directories prefixed with '.' are hidden
    15. cat - catenates files
          a. can dumps multiple files to STDOUT
    16. mkdir - creates a new directory
    17. cp - copies files
          By default, 'cp' does NOT preserve the original modification time
    18. mv - moves files
    19. rm - remove files/directories
            a. 'rm -rf' - removes recursively and enforces
    20. touch - creaes blank files / updates timestamp
           a. touch test.txt  - will create a 0 file if it didn't exist
                                Will update timestamp if it does exist
           b. touch -t 200901091530 test.txt - will change timestamp
    21. stat -  reveals statistics of files
    22. find - finds files using search patterns
           a. find / -name 'fstab*'             
       Note: 'find' can search for fields returned by the 'stat' command
    23. alias - returnsds/sets aliansed for commands

###Linux Redirection & Pipes###
    1. Ability to control input and output

  Input redirection '<'
Input redirection:
    1. cat < 123.tst    
   Note: Use input direction when program does NOT default to file

Output redirection '>'

    1. cat 123.txt > onetwothree.txt
  Note: Default nature is to:
       a. Clobber the target file
       b. Populate with information from input stream

   Append redirection '>>'
     1. cat 123.txt >> numbers.txt - creates 'numbers.txt' if it doesn't exist,
    or appends if it does

Pipes '|'
Features: Connects the output stream of one command to the input stream of a subsequent command
###Command Chaining###
   1. Permits the execution of multiple commands in sequence
   2. Also permits execution based on the success or failure of a previous command
Previous command
   1. cat 123.txt ; ls -l  - this runs first command, then second command without regards for exit status of the first command
   2. cat 123.txt && ls -l  - This will run second command, if the first command is successful
   3. cat 123.txt || ls -l  - This will run second command, if the first command failed.
24. more | less   - paginators, which display text on-page at a time
   1. more /etc/  
25. seq - echoes a sequence of numbers
   a. swq 1000 > 1000.txt
   b. seq 5 5 100 > 55.txt
26. su - switches users
   a. su  -  with on option will attempt to login to root
27. head  -  displays opening lines of the text files
28. tail  -  displays the closing lines of text files
29. wc    -  counts words and optionally lines of the text files
30. file - determines file type
    a file /var/log/messages

S3 replication cross region to another account

preparation create the above buckets in two AWS accounts source: leo-functions destination: leo-functions-rep Create IAM role in source acco...