EXAM 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

sdiff is for ________ diff is for ________

sdiff produces output for visually comparing differences between two files side-by-side on the screen. diff produces output intended to be read by another program, usually patch.

top is used to

top lets you: See all the processes running on a host. Filter to see just your own processes. Sort processes by how much CPU or memory resources they use. Send "signals" to a process to shut it down. You can signal a process to shut down normally, or signal the operating system to forcibly kill a process.

A compiler translates ________ into ________

A Compiler translates Source Code Files into Object Code Files. Object code is machine code that's almost ready to run, except that addresses to other object code files aren't established yet. These other object code files may come from source code that you wrote, or "library" files that contain functions belonging to a programming language.

A File Link is

A File Link (which can be a Hard Link or a Symbolic Link) is an additional name for a file, a "shortcut" to a file. We use a Link to cause a file: to appear to reside in a more convenient directory. to appear to have a different name.

The full-screen editor that Richard Stallman wrote is called

Emacs is Richard Stallman's editor. Stallman (and many other contributors influenced by his ideas) wrote a great many of the modules needed to make a complete operating system. The part of the operating system they didn't write is the Kernel, the virtual machine in which programs run

How does make know that a source code file needs to be recompiled?

Freshness Check: Speed is the reason we use make. For maximum speed, make does the least amount of work to determine the freshness of the compiled object code. It just compares the timestamp of the source code file against the timestamp of the object code file. make doesn't do any deep analysis.

To recompile only the source code files that were changed (or depend on other files that were changed) you use a program called:

Make: The idea behind make is efficiency; it recompiles only what is necessary. Source code files were changed. Source code files that depend on other files that were changed.

By default, the make program gets its instructions from a file named:

Makefile: Unless instructed otherwise, make looks for its instructions in a file named makefile or Makefile in the current directory

Nano is a typical text editor, and has these characteristics:

Nano has typical text editor characteristics: No typeface formatting such as bold or italics. Optional language syntax highlighting. This makes Nano handy for editing configuration files and computer language source code files.

Use > to redirect a command's output to a file: cal > myFile Use | to redirect a command's output to a program: cal | mail

When we redirect a program's output, we use symbols to tell the shell what to do with the output. There are different symbols depending on whether the output is redirected to a file or to another program: > means create a file to write the output to: cal > myFile | means start another program to send the output to: cal | mail

A dependency is

Dependency occurs when the code in file A uses (calls) something in the code of file B. If you change and recompile file B, then you must recompile file A, too. A depends on B.

Culture Question - Not in the ReadMe or the Homework: We used the g++ compiler to compile our C++ source code. The letter "g" pops up all the time in the Linux world. What do you think the "g" in g++ stands for?

"G" is for "GNU". Richard Stallman likes to remind everyone that lots of the things in Linux (apart from the kernel) are from the GNU folks

A Hard Link can point to a file only if it's on the same physical file system. A Symbolic Link can point to a file anywhere.

A Hard Link can point to a file only if it's on the same physical file system because it points to physical disk blocks. A Symbolic Link can point to a file anywhere because it contains a pathname which, like any pathname, can point anywhere.

A Linker does this

A Linker reads multiple separate object code files which have been separately compiled, computes their addressing to each other, and combines them into a single executable file that's ready to run.

What is a Script (also called a Shell Script)?

A Script is: An executable file that you write. It contains commands that you would ordinarily enter at the command line. It's handy to make a script to automate a task that you perform over and over.

To use top to see your processes, you have to know which host the process is running on. top can't see beyond a single host.

Before you use top to see your processes, you have to log into the same host your processes are running on. top can't see other hosts.

To ask a process to shut down nicely, we use signal 15 the SIGTERM termination signal - but a process can ignore this signal. To tell Unix to "pull the plug" on a process we use a signal that some call the "Hammer". What signal is this?

Signal 9 SIGKILL - is the kill signal, the "kill hammer". This signal tells Unix to remove all resources from a process and delete it from the list of executing processes. Poof! Gone. A process can ignore other signals, but not Signal 9. To see an overivew of the signals, enter man 7 signal at the Unix prompt. (This reads the Signal page from Chapter 7 of the manual).

In a makefile, every action line (Unix command) begins with

Tab: In a Makefile, a Unix command (the action line) must start with a Tab character. Make looks for this to find it's bearings.

The redirect operator > empties a file before redirecting output to it. What's the symbol to append output to the end of an existing file *without* emptying it first?

The append operator is >> > Intercepts output destined for the screen and sends it to a newly created file (or empties an existing file). >> Appends output to the end of an existing file. (Creates the file if it doesn't exist). ls > dirListing Creates a new file (or empties an existing one) and puts the directory listing into it. date >> dirListing Tacks the date onto the end of our directory listing.

The command to make a Symbolic Link is:

The syntax to create a Symbolic Link is: ln -s fileName linkName Things to remember about the syntax: -s is for a Symbolic Link. If you leave it out, you get a Hard Link. The Real File is named first, the Link second.

You used touch in your homework. touch performs these functions depending on whether the filename you specified exists or not

The touch command shows up all the time, usually to create a new, empty file. Here's what it does: If the file exists, changes its date/time stamp to the current date/time. If the file doesn't exist, creates a new, zero-length file.

How many Standard Streams are there?

There are three Standard Streams: Standard Input Standard Output Standard Error The "Streams" are streams of text, so there is no "standard graphics". "Standard Error" and "Standard Output" are output streams, separated for convenience. "Standard Input" flows into a program. "Standard Output" and "Standard Error" flow out of a program.

When you press Enter to end a line while editing a file, Linux and Windows act differently: Pressing Enter in Unix inserts ________ Pressing Enter in Windows inserts ________

There are two styles of line-ending codes for text files: Pressing Enter while editing a text file in Unix (e.g. Linux & Mac) inserts a single LF (Line-Feed) character. Pressing Enter in Windows inserts two characters: CR + LF (Carrage-Return + Line-Feed). Downloading a file with the wrong line endings for your system will cause problems until you convert them.

Open a terminal and connect to linprog. In your home directory, create a new directory named quiz4. There's a single file located in this directory: /home/courses/cop3353p/LIB/quiz4/ Navigate to your home directory. Copy the file to your quiz4 directory without using the file's name in your command. Hint: Use the same wildcard as for copying all the files from the source directory. Copy-and-paste (or just type) the command you used as the answer to this question.

There is a single file in the source directory. Your current directory is neither the source nor the destination directory. The command to copy the file to another directory without using its name is: cp /home/courses/cop3353p/LIB/quiz4/* quiz4/ ← Relative destination path cp /home/courses/cop3353p/LIB/quiz4/* ~/quiz4/ ← Absolute destination path

Extending the problem above: Navigate to your quiz4 directory. Copy the file to your quiz4 directory. In your command use the shortcut for the current directory. Copy-and-paste (or just type) the command you used as the answer to this question

There is a single file in the source directory. Your current directory is the destination directory. The command to copy the file to the current directory without using its name is: cp /home/courses/cop3353p/LIB/quiz4/* . ← The period means "Current directory"

Extending the problem above: Navigate to the /home/courses/cop3353p/LIB/quiz4/ directory. Copy the file to your quiz4 directory. Use the shortcut symbol for the home directory. Copy-and-paste (or just type) the command you used as the answer to this question.

There is a single file in the source directory. Your current directory was the source directory. The command to copy the file to another directory without using its name is: cp * ~/quiz4/

Why do we compile source code files before we can link them? Why this order?

To make an executable program, we compile first and link second because linking is performed on object code, not source code. (The linker doesn't work with source code). You write source code files. The Compiler converts source code files to object code files (individual binary files). The Linker combines the object files into a single executable file by setting the object files' memory addressing. Source code files >> Compile >> Object code files >> Link >> Executable file The linker uses the output of the compiler.

grep is case sensitive by default. How do you make it case insensitive?

To make grep case insensitive, use the -i option, which goes right after the command. The command comes first. The options follow after the command. Arguments, such as search strings & file names, are last. grep -i searchString filename

history prints the last hundred or so commands you entered at the command prompt. grep nano searches for all the lines that contain the string "nano". How would you combine these to find only the times you entered nano at the command line?

To pass the output from one command to the input of another, use the pipe | operator. history | grep nano This passes the output of history to the input of grep

To examine the permissions (such as "executable") of a file, use this command:

To see the permissions of one or more files, use the "long" parameter of the ls command: ls -l The permissions are the letters on the lefthand side of the display. Notice below that the file "hello" is executable, indicated by the "x" in the permissions, and the green filename coloring. -rw------- 1 lockwood CS-Faculty 93 Aug 30 16:06 factorial.cpp -rw------- 1 lockwood CS-Faculty 43 Aug 30 16:27 functions.h -rwx------ 1 lockwood CS-Faculty 10388 Aug 30 19:03 hello -rw------- 1 lockwood CS-Faculty 93 Aug 30 16:25 hello.cpp -rw------- 1 lockwood CS-Faculty 194 Aug 30 16:26 main.cpp -rw------- 1 lockwood CS-Faculty 241 Aug 30 16:38 makefile

The two steps in transforming source code into an executable file are:

To transform source code into an executable file requires two steps: Compile - the compiler translates the source code to machine language Link - the linker resolves addresses (calculates the addresses of function calls from one file to another)

The program that gives a full-screen interactive view of the processes running on a linux host is

Use top to see a full-screen interactive view of all the jobs running on the host. By default it's sorted by share of CPU that each job is consuming. You can also kill processes using top.

Which is the proper grep command for searching a file?

With grep, as with other commands, you type command first on the command line, and all the arguments after it. grep searchString filename

You can undo a patch if you change your mind.

You can undo a patch if you change your mind. Use patch -R < patchFile to undo a patch. You don't have to specify the name of the file to be unpatched - it's coded within the patch file.

To make a patch, use ________ To apply a patch to a file, use ________

diff -u originalFile changedFile > patchFile makes the patch. patch < patchFile applies the patch. The name of the file to be patched is coded in the patchFile.

What is grep used for?

grep is handy when you have a bunch of files and you can't remember which is the one you need. grep reads each file line-by-line looking for a match to the text you specify. When it finds a match, it prints the file name along with the line with the matching text.

The editor vi has two modes of operation, Command Mode, and Insert Mode. Insert Mode is used for:

vi's Insert Mode is normal typing mode. When the bottom left corner of the screen says -- INSERT -- then you're in this mode. The other mode is Command Mode, in which you can enter codes for funcrtions such as undo, cut-and-paste, and save. Command Mode has two forms: Single-key mode in which you press a letter key or control key combination; and Last-line mode in which a colon prompt appears and accepts more lengthy save and quit commands.


Kaugnay na mga set ng pag-aaral

1.1 Explain the purposes and uses of ports and protocols

View Set

Chapter 1: Introduction to Nursing

View Set

test 2 - Right Hemisphere Syndrome - ch 8

View Set

Parcial 2: Dinámica del comportamiento de las organizaciones

View Set

Financial Accounting Module 7: Forecasting and Valuation

View Set