General Purpose Tools

 

For these questions, construct a subdirectory under ~/cp1300 called "gentool".

  1. Identify all users logged onto the system that have a user name beginning with "sci" (Hint: you could pipe the output of a system resource command into a general purpose tool)

    who | grep sci
  2. What command will list all lines of text with line numbers, in the hidden files of your main account directory that contain the (case-insensitive) text "ls" (Hint: hidden files always start with a dot, and there is no need to pipe commands...)

    grep -i -n ls ~/.*
  3. From your main account directory, find all files that have a .cpp extension (and try this for various other file extensions....)

    find ~/ -name "*.cpp"
    or....
    cd ~     and then         find . -name "*.cpp"
  4. Construct two files: "first.txt" and "second.txt". Into "first.txt" place the contents of the command "ls -lsa", and into "second.txt" place the contents of the command "ls -ls". Find the differences between "first.txt" and "second.txt".

    ls -lsa > first.txt
    ls -ls > second.txt
    diff first.txt second.txt    or    diff second.txt first.txt        note how the file being overwritten has zero size! at the time it is listed
  5. Sort "first.txt" by the "size in bytes" column, in descending order

    sort -r +5 first.txt
  6. What command will repeat the previous sort command, but replaces "first" by "second" ?

    ^first^second
  7. Apply the command(s) to make the subdirectory gentools a compressed archive file.

    cd ~/cp1300
    tar cf gentool.tar gentool
    gzip gentool.tar gentool.tar.gz        (or, you could gzip gentool.tar to produce gentool.tar.gz, or you could use the single command: "tar czf gentool.tar.gz gentool")
  8. List the contents of the gentool archive.

    gunzip gentool.tar.tgz
    tar tf gentool.tar                            (or: "tar tzf gentool.tgz")