Shell bash commands

Card Set Information

Author:
MyPenname
ID:
289151
Filename:
Shell bash commands
Updated:
2014-11-14 02:43:30
Tags:
shell bash commands
Folders:

Description:
Bash commands for linux system, csse2310
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user MyPenname on FreezingBlue Flashcards. What would you like to do?


  1. grep
    grep [options] pattern [file]

    searches named input FILE (or stdin if no file or - is given) for lines containing a match to given PATTERN. By default, grep prints matching lines.
  2. grep [-v] [$ ^ . *]
    • -v --invert match i.e. select non-matching lines
    • * --preceding item matched zero or more times
    • ^ --matches empty string at beginning of a line
    • $ --matches empty string at end of line
  3. ls [-ladi]
    • ls [OPTION]... [FILE]...
    • lists information about the FILEs, normally sorts alphabetically
    • -a --all (dont ignore entries starting with .)
    • -i --inode (print index no. of ea file)
    • -l --long (use long listing format)
    • -d --drectory (list directory entries instead of contents, and do not dereference symbolic links)

    Note, you an use multiple options together
  4. ps [-ef]
    ps [OPTIONS]

    ps displays information about a selection of active processes

    • -e --select all processes, like -A
    • -f --does full format listing

    • Note, format for -f is:
    • UID, PID, PPID, C, STIME, TTY, TIME, CMD
  5. sort [-r -k]
    • sort [OPTION]...[FILE]...
    • writes sorted concatenation of all FILE(s) to stdout

    • -r --reverse (reverse result of comparisons)
    • -k --key=POS1[,POS2] starts a key at POS1 end it at POS2 (default end of line) i.e. sort by POS1 column
  6. uniq [-c]
    • uniq [OPTIONS]...[INPUT[OUTPUT]]
    • filters adjacent matching lines from INPUT (or stdin) writing to output (or stdout)

    -c --count (prefix lines by no. of occurences)
  7. cat
    • cat [OPTION]...[FILE]...
    • concatenates FILE or stdin to stdout

    putting a - between files will wait for input until ^D given, at which file after - will print
  8. head [-]
    • head [OPTION]...[FILE]...
    • prints first ten lines of each FILE to stdout. with more than one FILE, precede ea. with a header giving the file name. With no FILE or -, read stdin.

    -n (number) prints out first n lines of first 10
  9. tail [-]
    does exactly the same as head but ten lines from the bottom of the file
  10. cut [-f -d]
    • cut OPTION...[FILE]...
    • removes sections from each line of files

    -f --fields=LIST (select only these fields; also print any line containing no delimiter character, unless -s option is specified)

    -d --delimiter= DELIM (use DELIM instead of TAB for the field delimiter)
  11. wc [-l]
    • wc [OPTION]...[FILE]...
    • print newline, word, and byte counts or ea. FILE and a total if more than one FILE is specified. reads stdin if no FILE or - is given

    -l --lines (print the newline counts)

    • Note, format is:
    • newlines words bytecount filename
  12. diff
    diff [OPTION]...FILES

    compares files line by line

    • output:
    • 1st line: a added, d deleted and c changed. Line numbers of the original file appear before these letters and those of the modified file appear after the letter.
    • < means something in first thats not in second
    • ---
    • > means something in second thats not in first
  13. chmod [modes]
    • chmod [OPTION]...MODE[,MODE]..FILE...
    • changes file mode bits of ea. given file according to MODE which can also be octal
    • e.g. chmod u+rwx foo

    +add, -take

    • ugoa (user, group, others, all)
    • rwxX (read, write, execute or search for directories, X x only if dirctory or already has execute permissions)
  14. chmod [options]
    • -v --verbose (output diagnostic for every file)
    • -c --changes (only report when change is made, otherwise like verbose)
    • -f --silent (suppress most error messages)
    • -R --recursive (change files and directories recursively)
  15. ln [-s]
    • ln make links between files
    • ln [OPTION]...TARGET or
    • ln [OPTION]...TARGET...DIRECTORY

    -s --symbolic link instead of hard
  16. rm [-rf]
    • rm [OPTION]...FILE...
    • removes specified file but does not remove directories by default

    • -f --force (ignore nonexistent files, no prompting, remove whether protected or not)
    • -r --recursive (remove directories and contents)
  17. mkdir
    • mkdir [OPTIONS] DIRECTORY
    • creates the DIRECTORIES if they do not already exist
  18. rmdir
    • rmdir [OPT] DIRECTORIES
    • removes empty directories
  19. cp [-r]
    • copy files and directories from SOURCE to DEST or to DIRECTORY
    • cp [OPTION] SOURCE DIRECTORY/DEST

    -r --recursive (copies recursively)
  20. mv
    • mv [OPTION] SOURCE DIR/DEST
    • renames SOURCE to DEST, or moves SOURCE to DIRECTORY
  21. vi/pico
    • vi like vim is a text editor
    • pico is also a text editor
  22. svn [commit add remove move]
    svn add files: puts files and directories under version control, scheduling them for addition to repository on the next commit

    svn commit [path]: sends changes from working copy to repository

    svn remove path/url: removes files and directories from version control
  23. svn [move update info log status diff]
    svn move SRC DST: moves or renames something in working copy or repository

    svn update [path]: brings changes from repository into working

    svn info [target]: displays info about local or remote item

    svn status [path]: print status of working copy files and directories

    svn diff FILES: displays differences between revisions or paths
  24. less
    • less [OPTIONS]
    • displays output one screen at a time, searches through output, edits command line

What would you like to do?

Home > Flashcards > Print Preview