Readings

The readings for Monday, January 23 are:

  1. The Linux Command Line:

    • Chapter 6 - Redirection
    • Chapter 7 - Seeing the World as the Shell Sees it
    • Chapter 8 - Advanced Keyboard Tricks
    • Chapter 9 - Permissions
    • Chapter 10 - Processes

TL;DR

The focus of this reading is to review the basics of manipulating files and processes in the Unix Shell.

Bash

The default Unix shell on the student machines is TCSH. However, The Linux Command Line book and the course requires that you use Bash. To temporarily switch to Bash, simply run the following after logging in:


$ bash

In addition to reading the above chapters, it is recommended that you learn a command-line text editor such as one of the following:

  1. nano: This text editor is the easiest to get started with, but also has the least amount of features. It is what I recommend for newcomers to Linux.

  2. vim: This text editor has many features such as syntax highlighting, plugins, and even spell checking. That said, it has a steep learning curve due to its foreign keyboard interface.

  3. emacs: This text editor also has many features (perhaps too many). In fact, Emacs is so powerful, there is saying "Emacs is an excellent operating system. All it's missing is a decent text editor". Bazinga!

This is my editor

All joking aside, your exact choice in a text editor is not important. What is important, however, is that you become comfortable with at least one of them and are capable of editting text efficiently in terminal. As the creed goes:

This is my editor. There are many like it, but this one is mine.

My editor is my best friend. It is my life. I must master it as I must master my life.

Without me, my editor is useless. Without my editor, I am useless.

Additional Resources

The following are additional resources that you may find useful:

  1. Introduction to Linux

Questions

In your reading01/README.md file, answer the following questions:

  1. Given the following command:

    $ du -h /etc/ 2> /dev/null | sort -h > output.txt
    

    a. What is the purpose of the |?

    b. What is the purpose of the 2> /dev/null?

    c. What is the purpose of the > output.txt?

    d. What is the purpose of the -h flags?

    e. Is the following command the same as one above? Explain.

    $ du -h /etc/ | sort -h > output.txt 2> /dev/null
    

    macOS vs Linux

    While both macOS and Linux are both consider Unix systems and generally have the same commands, the actually implementations of each command is actually different. For instance, the sort command on macOS is derived from FreeBSD and does not support the -h flag. The sort command on Linux, however, is usually the GNU implementation and does support the -h flag.

    To see the difference, you can compare the manpages for the sort utility on the two different Unix systems:

    In this class, most of the assignments and examples will assume you are using a Linux system such as the student machines. That said, when possible, accommodations will be made to support other Unix systems such as macOS.

  2. Given the following output of ls:

    2002-01  2002-07  2003-01  2003-07  2004-01  2004-07  2005-01  2005-07  2006-01  2006-07
    2002-02  2002-08  2003-02  2003-08  2004-02  2004-08  2005-02  2005-08  2006-02  2006-08
    2002-03  2002-09  2003-03  2003-09  2004-03  2004-09  2005-03  2005-09  2006-03  2006-09
    2002-04  2002-10  2003-04  2003-10  2004-04  2004-10  2005-04  2005-10  2006-04  2006-10
    2002-05  2002-11  2003-05  2003-11  2004-05  2004-11  2005-05  2005-11  2006-05  2006-11
    2002-06  2002-12  2003-06  2003-12  2004-06  2004-12  2005-06  2005-12  2006-06  2006-12
    

    Note: These are all files in the format YEAR-MONTH.

    a. How would you concatenate all the files from 2002 into one file?

    b. How would you concatenate all the files from the month of December into one file?

    c. How would you view the contents of all the files from the month of January to June?

    d. How would you view the contents of all the files with an even year and odd month?

    e. How would you view the contents of all the files from 2002 to 2004 in the months of September to December?

    Matching

    For full credit, you must use globbing and brace expansion in your solutions.

  3. Given the following output of ls -l:

    -rw------- 1 pbui users 0 Jan 18 07:19 Beastie
    -rwxr-xr-x 1 pbui users 0 Jan 18 07:18 Huxley
    -rwxr-x--- 1 pbui users 0 Jan 18 07:18 Tux
    

    a. Which files are executable by the owner?

    b. Which files are readable by members of the users group?

    c. Which files are writable by anyone (ie. the world)?

    d. What command would you execute so that Tux had the same permissions as Huxley?

    e. What command would you execute so that Tux had the same permissions as Beastie?

  4. Suppose you run the bc command:

    $ bc
    

    a. How would you suspend the bc process?

    b. How would you resume the suspended bc process?

    c. How would you indicate the end of input to the bc process?

    d. If the bc process was still running, how would you terminate the bc process?

    e. If the bc process was still running, how would you terminate the bc process from another terminal?

Feedback

If you have any questions, comments, or concerns regarding the course, please provide your feedback at the end of your response.

Submission

To submit your assignment, please commit your work to the reading01 folder in your assignments GitLab repository:

$ cd path/to/repository                   # Go to assignments repository
$ cd reading01                            # Go to Reading 01 directory
...
$ $EDITOR README.md                       # Edit appropriate README.md
$ git add README.md                       # Mark changes for commit
$ git commit -m "reading01: complete"     # Record changes
...
$ git push                                # Send changes to GitLab