Sunday, April 15, 2018

Week 6: Chapter 10 and 11

John George Bauer-Buis
2018-04-15
NET-140-001N

This first section is a synopsis of the chapters using the headings and subheadings from the textbook, with descriptions in my own words.

Chapter 10: I/O Redirection
There are three standardized streams for input and output (I/O): standard input (stdin), standard output (stdout), and standard error (stderr, which is a special output stream).  (They are also used in C/C++ programming, so they are familiar to Windows programmers from there.) Streams are assigned file descriptors: input is 0, output is one, and error is 2.  They each represent open files to make it possible to interact with them in the same way as files, reading from them and writing to them.  They can be redirected to be used as input or output for each other in as well, just like other programs.
Control d or Ctrl-d is the command to produce an End-Of-FIle (EOF) marker, if one is not present. This is important when ending something sourced from stdin, which doesn’t normally add one by default.
Chapter 11: Additional Command Line Concepts
    •    Aliases can be used to shorten repeated commands, or make more memorable names for commands.  An alias is only temporary unless it is added to a user’s personal initialization files.
    •    Personal Initialization Files can be used to customize the shell when logging in, and are placed in ~/.bashrc or ~/.bash_profile. They are obtained by the shell using the source command, which both reads and executes them.
    •    Shell History will save previous commands, which are written to the file ~/.bash_history, with a default size of 500.  The history command will display the commands saved in the shell history, and giving it a number (history N) as an argument will repeat the command from that line in the file, I have found that if the value is too large it is ignored. The command !! will repeat the previous command, the command !N with N being a numerical argument can be substituted for history N as well.  The command !characters or history characters will run the last command with those characters in the shell history.  The shell history can be searched with control r (Ctrl-r), which lets the user search through commands by typing some characters.  As is usual in the *NIX CLI, pressing Enter runs the command, and Control c (Ctrl-c) is used to quit without doing anything.
    •    Tab Completion is somewhat obvious, in that pressing the Tab key attempts to complete an incomplete command (not order a carbonated drink for you as Homer Simpson thinks).  In the case of multiple possibilities, pressing the tab key again will show them all.  This also works for the names of files and directories, which is quite convenient.
    •    Line Continuation is achieved by using the backslash (\) at the end of the line to extend it onwards.  The greater than symbol (>) is used to show this in the CLI so the user is aware that the line is being continued.

I may add to this post at a later date if I discover more useful information that I think I should feature here.

No comments:

Post a Comment