Card Set Information

2010-04-11 19:30:13
Regular expressions

Linux +
Show Answers:

  1. You know the file name, but don't know where the file is located. How can you find it?
    find <search point> -name 'filename' -print

    • If you only know part of the filename
    • find / -name '*partial*' -print
  2. How do you compress a file?
    • gzip <filename>
    • gunzip <filename.gz>
    • tar -cvf
    • c creates a new archive
    • v verbose
    • f makes it a file
  3. How do you use chmod? What are the numbers that determine permissions?
    chmod <nnn> filename

    • 0 = no access
    • 1 = execute only
    • 2 = write only
    • 3 = write and execute
    • 4 = read only
    • 5 = read and execute
    • 6 = read and write
    • 7 = read write and execute
  4. What are some common options that can be used with the command ls?
    • -a lists all filenames
    • -A lists most filenames (excludes . and .. files)
    • -C lists filenames in a column format
    • -d lists directory names instead of contents
    • -f lists file names unsorted
    • -F lists filenames classified by file type
    • -l lists filenames in long format
    • -lh lists filenames in long format and human readable
    • -lg lists filenams in long format but omits group information
    • -r lists filenames reverse sorted
    • -R lists filenames in the specified directory and subdirectories
    • -s lists filenames and their size in kilobytes
    • -S lists filenames assorted by size
    • -t lists filenames sorted by time modified
    • -U lists filenames without sorting
    • -x lists filenames in rows instead of columns
  5. What are some regular expressions used in linux?
    • *Matches 0 or more occurrences of the previous character
    • ?Matches 0 or 1 occurrences of the previous character
    • + Matches 1 or more
    • .Matches 1 character of any type
    • […]Matches one character from the range specified within the braces
    • [^…] Matches one character NOT from the range specified within the braces
    • {}Matches a specific number or range of the previous character
    • ^ Matches the following characters if they're the first characters on the line
    • $Matches the previous letter characters if they're the last
    • (…|…) Matches either of two sets of characters