C U T B H P N

Note - Linux Bash Shell Commands

commands and links to more information

Web Resources:

Linux Tutorials eclipse Code Project SysInternals Best SysInternals Tools Dr. Dobb's Journal Windows Forms COM at MSDN IDL Language base MIDL types OLE data types IDL attributes MIDL data types MIDL Language Reference

Content:

This page provides information about Linux, the bash shell, commands, header files etc. A lot of the information comes from "Linux Phrasebook, Scott Granneman, Addison-Wesley, 2006"
  1. Linux Bash Shell Commands
    Command Action options:     command -abc or command -a -b -c
    man command Enter the Manual Page application at command. Example: man ls f - whatis, k - apropos,
    man command | less - pages command output
    whereis file find path(s) to a file or application
    apropos keywords find man pages with keywords
    whatis command show man page summary for command w - supports wild cards, e.g.,
    whatis -w ls*
    which if more than one instance of executable tells which will run and shows where it is b - show only binaries, a - show all locations
    clear clear terminal screen
    ls [pattern w/ wildcards] display directory listing l - long, R - recursive, r - reverse, a - show hidden, F - classify, X - sort by extension, t - sort by date/time, S - sort by size
    pwd path of current(working) directory
    cd path change to path may be absolute or relative
    mkdir name create name directory p - create nested dirs, e.g., name1/name2/name3
    cp src dest copy file(s) or directory from src to dest i - interactive when overwriting, R - copy directory recursively, a - don't follow soft links
    mv src dest move and rename files
    rm delete files i - interactive, Rf - remove files and directories
    rmdir delete empty directories
    su account impersonate another account if you have password
    sudo elevate priviledges to root for single operation with your credentials
    whoami current account
    cat file1 file2 concatenates and displays contents of all files in set, e.g.,
    cat -n *.h main.cpp
    n - numbers lines
    less file displays one page of text, then supports navigation with up/down and PageUp/PageDown keys.
    Search by entering /regexpression.
    N - number lines
    head file1 file2 display top few lines n 5 - number of lines to display, default is 10
    tail file1 file2 display last few lines n 5 - number of lines to display, default is 10
    tail -f logfile continuously displays the last 10 lines of changing file
    Ctrl+c terminates display
    lpr file sends file text to default printer P printerName - sends to non-default printer
    chown account file change owner of file
    chmod [ugo][+-=][rwx] change permisions for user, group, others R change recursively
    zip name.zip src src can be a list of files or directories [1-9] - degree of compression. 1 is none, 9 is max
    unzip name.zip unzips in place l - list contents without unzipping
    grep regExp file(s) displays lines that match regExp, e.g.,
    grep "^#" main.cpp finds preproc statements
    R searches recursively for files to search
    grep -R thread *.h *.cpp
    C 3 - shows context
    v - inverts pattern
    locate filename finds file by looking up in database so it's fast. i - case insensitive search
    updatedb reindex file system to include new files
    find -name patter recursively searches for files matching pattern, displaying path Searches filesystem, not database so it's slower.
    history show commandline history
    alias display list of all aliases defined in .bashrc or .bash_aliases
    ps aux show running processes
    top show summary stats then a dynamic list of processes with high %cpu and %mem
    kill pid kill process
    apt-get install package install package and all its dependencies
    apt-get update update available package list
    apt-get upgrade install more recent versions of installed packages
    apt-get remove package removes package and its dependencies if not needed for other packages
    apt-cache search package searches repositories for package versions and related packages apt-cache search gcc | less
    Note: case is important
  2. Shell Operations with Commands
    Operation Action Example
    command1; command2 run several commands sequentially mkdir path; mv file1 path; mv file2 path
    command1 && command2 execute command2 only if command1 succeeds mkdir path && mv file path
    command1 || command2 execute command2 only if command1 fails mkdir path || echo 'mkdir failed'
    command1 $(command2) puts command2 on commandline of command1 mkdir $(date '+%m-%d-%Y)
    command1 | command2 connects stdout of command1 to stdin of command2 man -k thread | grep ^pthread
    shows pthread functions documented in man pages
    text > file
    text >> file
    > redirects text to file
    >> appends text to file
    cat tokenizer.* > tok.txt
    set -o noclobber prevents overwriting
    command < text sends text to command's stdin grep ^# < main.cpp
    shows all preprocessor directives
  3. Linux Command Summaries:
  4. Bash Scripting
  5. Complete Documentation:
  6. Regular Expressions:
  7. Tutorials:
  8. Programming References:

CST strip