cbt3.txt

Upload: kundan-kumar

Post on 03-Jun-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 cbt3.txt

    1/1

    Note: 'cat -' does the same as: 'cat'b. 'cat test.txt > helloworld.txt' - bypasses STDOUT (Standard

    OUTPUT)c. 'cat test.txt >> helloworld.txt' - - connects

    output stream of command a to input stream - pipes

    - parses '/var/log/messages'forkeyword 'kernel' then pipes the output to 'less' to display one pageful at atimeNote: When piping, STDIN

    -l'b.

    'rm -rf temp* ; ls -l' - runs both commands independentlyNote: Command Chaining is not dependent

    upon the exit status of the most-recently exe

    'rm - -l' - run 'ls -l' if 'rm -rf temp*' failsb. 'rm -rf temp* && ls -l' - run 'ls -l' if and only if 'rm

    -rf temp*' works10. Command History - built-in command (BASH)a. 'history'Note: BASH maintains a

    number of variables per shella. 'OLDPWD' - updated as you navigate the directory treeb. 'LOGNAME'c.

    'SHELL'etc.11. 'export' exports varsa. 'export PATH=$PATH:/tmp' -appends '/tmp' to current shell's

    PATH12. 'more' - similar to 'less'13. 'cp' - copies dataa. 'mkdir temp && cp -v test.txt temp/ && ls -l

    temp/'14. 'mv' - moves dataa. 'mv test.txt temp/ && ls -l . && ls -l temp/ && echo $?'Note: In scripts,prefix exit status with meaningful text:i.e. 'echo "EXIT STATUS: " $? 'Note: BASH Shell allows simple

    navigation using:a. 'CTRL-a' - takes you to the beginning of the lineb. 'CTRL-e' - takes you to the end of

    the linec. 'CTRL-b' - back one characterd. 'CTRL-f' - forward one character15. 'dmesg' - Kernel Ring Buffer

    - Pre-Sysloga. '/var/log/dmesg' - 'dmesg'Note: Also contains how the most recent invocation of the

    kernel took place (command- -i 'command line' ' - returns current kernel command

    line16. 'head & tail' - Returns header and footer of text documentsa. 'head /var/log/messages' - returns

    first 10 linesb. 'tail /var/log/messages' - returns last 10 lines17. 'file' - returns the type of data stored in a

    file18. 'ps' - lists processesa. 'ps' -lists processes for current user19. 'top' - dynamic 'ps', 'free', 'uptime',

    'vmstat'20. 'free' - memory allocation - RAM & SWAP

    21. 'uptime' - shows system uptime and load average22. 'df' - shows disk allocation and mount pointa.

    'df -h' - human-readable formatNote: '-h' often means human-readable for many commands23. 'cat

    /proc/cpuinfo' - enumerates detected CPUsNote: '/proc' is a virtual (in-RAM) FS which houses system

    statisticsNote: System utilities read from: /proc to display values: i.e. 'free', 'top', etc.24. 'uname' -

    enumerates kernel version25. 'seq' - generates a sequence of numbers - useful with looping in the

    $SHELL