IT 244: Introduction to Linux/Unix
Answers Final Exam Questions - Odd Columns


  1. What do [ and ] mean when used in an if statement?
    they stand for the test command
  2. Is there any limit to the number of blocks of commands you can have in an if ... else ... elif statement?
    no
  3. When does a while loop stop running?
    when the command following while returns an exit status that is not 0
  4. What does the break command in a loop do?
    jumps completely out of the loop
  5. Write the command you would use to create the files foo1.txt to foo5.txt using brace expansion and the touch command.
    touch  foo{1,2,3,4,5}.txt
  6. Can an alias be made global?
    no
  7. What is the value of the exit status returned by test to indicate that the expression is true?
    0
  8. Does the command that follows if need to be test?
    no, it can be any command that returns an exit status
  9. What parameter gives the total number of arguments passed to a script from the command line?
    #
  10. What parameter gives the full pathname of the script that is currently being run?
    0
  11. What is special about a GLOBAL variable?
    you can use it in any subshell of the shell in which it was created.
  12. What are the limitations of a LOCAL variable?
    you can only use it in the shell in which it was created
  13. What would you type at the command line if you wanted to suspend a job running in the foreground?
    Control Z
  14. What command would you use to see all currently running jobs?
    jobs
  15. By default, where does Standard Input come from?
    the keyboard
  16. By default, where does Standard Output go?
    to the screen
  17. By default, where does Standard Error go?
    to the screen
  18. What does the PATH shell variable contain?
    the list of directories the shell must search 
    to find the file to run a command
  19. What is a process?
    a running program
  20. What does a program do just before it stops running?
    it sends an exit status to the shell
  21. Look at the diagram at the back of this exam.
    Assume that you are in the directory it244.
    Write the ABSOLUTE pathname you would use to reference the directory proj1 inside the directory jimbo.
    I do not want a command, just the pathname.
    /home/jimbo/proj1
  22. Look at the diagram at the back of this exam.
    Assume that you are in the directory courses.
    Write the RELATIVE pathname you would use to reference the directory ghoffman under the directory home.
    I do not want a command, just the pathname.
    ../home/ghoffman
  23. Look at the diagram at the back of this exam.
    Assume that you are in the directory tmp inside ghoffman.
    Write the RELATIVE pathname you would use to reference the root directory.
    I do not want a command, just the pathname.
    ../../..
  24. Look at the diagram at the back of this exam.
    Assume that you are in the directory courses.
    Write the RELATIVE pathname you would use to reference the directory mary under f21 under it117.
    I do not want a command, just the pathname.
    it117/f21/mary
  25. Assume that you are in a directory that contains the files listed at the bottom of the diagram at the back of this exam.
    What ARGUMENT USING META-CHARACTERS would you give to ls to list all files with a .sh extension in this directory?
    I do not want the full command, just the argument to that command.
    *.sh
  26. Assume that you are in a directory that contains the files listed at the bottom of the diagram at the back of this exam.
    What ARGUMENT USING META-CHARACTERS would you give to ls to list all files whose name starts with "foo" followed by one character and ".txt" in this directory?
    I do not want the full command, just the argument to that command.
    foo?.txt
  27. Assume that you are in a directory that contains the files listed at the bottom of the diagram at the back of this exam.
    What ARGUMENT USING META-CHARACTERS would you give to ls to list the files whose name starts with "bar" followed by the digits 3 through 7, followed by ".txt"?
    I do not want the full command, just the argument to that command.
    bar[3-7].txt
  28. Write the format string you would give to chmod to give a FILE the following permissions.
    Give the owner read, write and execute permissions.
    Give the group read permissions.
    Give read and execute permissions to anyone else.
    I just want the format string NOT the whole command.
    745
  29. Write the format string you would give to chmod to give a DIRECTORY the following permissions.
    Give the owner all permissions.
    Give the group permission to see and change the contents of the directory.
    Give everyone else no permissions for that directory .
    760
  30. If you ran the script bother.sh as shown below, what command would you use to stop this script?
    $ ./bother.sh &
    [1] 26422
    kill 26422 or kill %1
  31. Write a command that will print ALL global variables and their values.
    env
  32. Write the command that will find all the lines in the file memo.txt that contain the word "mountain" but not the word "range".
    grep mountain memo.txt | grep -v range
  33. What is the name of the process that starts automatically whenever pe15 is turned on?
    systemd