COP3353 Exam 2

Ace your homework & exams now with Quizwiz!

What is grep used for?

Search for a string of text in a file, even if you don't know what file to look in.

In addition to searching for text in a file, grep can also search for text in Standard Input (on the command line): 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 two commands to find only the times you entered nano at the command line, rather than all your history?

history | grep nano

What is the difference between sdiff and diff?

sdiff: produces output for visually comparing two files side-by-side on the screen diff: produces output that can be read by another program, usually patch

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

top

How do you pass output from a command to the input of another command?

use the pipe | operator ex: history | grep nano This passes the output of history to the input of the grep command.

What typical text editor characteristics does nano have?

1) No formatting such as bold or italics 2) Optional language with syntax highlighting

What are the two styles of line-ending codes for text files?

1) Pressing Enter while editing text in Unix (Linux & Mac) inserts a single LF (Line-feed) character 2) Pressing Enter in Windows inserts two characters: CR + LF (Carriage-Return + Line-Feed)

What are the two names for SFTP?

1) Secure File Transport Protocol 2) SSH File Transport Protocol

What are all the actions that top lets you do?

1) See all the processes running on a host 2) Filter to see just your own processes 3) Sort processes by how much CPU or memory resources they use 4) Send "signals" to a process to shut it down (either normally or force the OS to forcibly kill a process)

What are the two types of redirection?

1) Sends the output to a file: cal > myFile 2) Sends the output to another program: cal | mail

When do we use a link?

1) To make a file appear to reside in a more convenient directory 2) To make a file appear to have a different name

What is the order of a command line?

1. Command comes first 2. Options follow after the command 3. Arguments (such as search strings & file names) are last

When you press Enter to end a line while editing a file, Linux and Windows act differently: 1. Pressing Enter in Unix inserts ______ 2. Pressing Enter in Windows inserts _____ (CR means Carriage Return) (LF means Line Feed)

1. LF 2. CR/LF

What are the three standard streams?

1. Standard Input 2. Standard Output 3. Standard Errors

What are the steps for an executable program?

1. You write source code files. 2. The compiler converts source code to object code files (individual binary files). 3. The Linker combines object files into a single executable by setting memory addressing. Source code files>>Compile>>Object code files>>Link>>Executable file

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?

9 SIGKILL - the kill signal

What is the difference between > and >>?

> : Intercepts output destined for the screen and sends it to a new file (or empties an existing file) >> : Appends out to the end of an existing file (Creates the file if it doesn't exist) Ex: date > myFile : Creates a new file (or empties an existing one) and writes the date into it. date >> myFile : Tacks the date onto the end of an existing file.

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?

>>

What is the append operator?

>>

What is the idea behind make?

Efficiency as it recompiles only what is necessary - Source code files were changed. - Source code files that depend on other files were changed.

What is Richard Stallman's editor?

Emacs

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

Entering vi Commands, such as to save the file.

Why does the typical text editor characteristics make nano handy for?

For editing configuration files and computer language source code files

Why do we use make?

For speed

When can hard link point to a file vs when can a symbolic link point to a file?

Hard link -> Only if it is on the same file system because it points to physical disk blocks Symbolic -> Anywhere since it contains a pathname which, like any pathname, can point anywhere

What is vi's normal typing mode? How do you know you are in it?

Insert Mode You know you're in this mode when the bottom-left says --INSERT--

How does make determine the freshness of the compiled object files?

It just compares timestamps of the source and object files without doing any deep analysis (FRESHNESS CHECK)

What does grep do?

It reads each file line-by-line looking for a match to the text and when it finds one, it prints the file name and the line of matching text

What does the Signal 9 do?

It tells Unix to remove all resources from a process and delete it from the list of executing processes.

Unless being instructed otherwise, what does make look for?

Its instructions in a file named makefile or Makefile in the current directory

What is object code?

Machine code that is almost ready to run, except that addresses aren't established to other code files... Object code files come from code you write, or "library" files of programming language functions

How do we get maximum speed with make?

Make does the least work to determine the freshness of the compiled object files

What is the command line to make the patch vs to apply the patch?

Making the patch: diff -u originalFile changedFile > patchFile Applying the patch: patch < patchFile (You don't need to provide the name of the file to be patched because it's coded into the patchFile.)

What did Stallman and many of his programmers write?

Many of the modules needed to make a complete operating system (except the kernel) ... GNU

What does a linker read?

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 does the watch command do?

Repeatedly runs another command so you can see how its output changed over time.. This is super handy!

What is the "G" in "GNU"?

Richard Stallman likes to remind everyone that lots of the things in GNU/Linux (apart from the kernel) are from the GNU folks in his project. THEREFORE, the "g" in g++ stands for GNU

GNU/Linux corresponds to:

User-Space/Kernel-Space

What do you use when we redirect a program's output?

We use symbols to tell the shell what to do with the output.

When does a dependency occur?

When the code in file A calls something in file B and if you change and recompile file B, then you must recompile file A too "A depends on B"

When is grep handy?

When you have a directory of files and you can't remember which is the one you need: grep 'searchString'

How are most commands typed?

command first then argument after

When do you use 'top'?

(1) To see a full-screen interactive view of all the jobs running on the host (2) To kill processes

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

-Compile -Link

What is the acronym for a symbolic link?

-s

What are the two symbols and what do the redirect the output to?

1) > creates a file and writes the output to it: cal > myFile 2) | starts another program and sends the output to it: cal | less

What are the two steps to transform source code into an executable file?

1) Compile - The compiler translates the source code to machine language. 2) Link - The linker resolves addresses (calculates the address of function calls)

What does the touch command do?

1) If an already existing file, changes its date/time stamp to current date/time. 2) If non-existing file, creates a new, zero-length file.

How is Signal 9 different from the other signals?

A process can ignore other signals, but it does not have a chance to ignore Signal 9.

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

A program made of Unix commands written for shell, usually used to automate a task, and the commands are run one-by-one by a person.

Use top for this:

ALL OF THE ABOVE -See your own processes -See all processes regardless of who owns them -Send a "signal" to a process, such as to shut it down

What is a file link?

An addition name for a file; a "shortcut"; either a hard link or a symbolic link

What is a script?

An executable file that you write that contains commands that you would ordinarily enter at the command line and it automates a task that you perform over and over

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

BOTH OF THESE -Does not have font of typeface formatting, such as bold or italics. -Has optional syntax highlighting.

Why is there no value to a soft link if the original file is deleted?

Because it points to a non-existent file

Why must we compile first and link second to make an executable program?

Because linking is performed on object code, not source code and linker doesn't work with source code

Why is SFTP called "Secure"?

Because the connection is authenicated and encrypted using the same mechanisms as SSH

Which streams are output?

Both standard error and standard output, separated for convenience

How do we see file permissions?

By using the "long" parameter (lower case L) of the ls command: ls -l

A Linker does this:

Combines separate object files into a single executable file

What Vi's other mode that is not normal? What does it do?

Command mode It is the mode in which you enter codes for functions such as undo and save.

What does redirection mean?

Send a program's Standard Output somewhere other than the screen

sdiff is for _____ diff is for _____

Side-by-side viewing of the differences between two files... Making patches

What is the difference between a symbolic/soft link and a hard link?

Soft link: An actual link to the original file Hard link: A mirror copy of the original file

A compiler translates _____ into _____

Source Code --- Object Code

What is the difference of Standard Input vs Standard Output and Error?

Standard Input flows into a program while Standard Output and Standard Error flow out of a program.

What are the streams?

Streams of text so there is no "Standard graphics"

What goes first in a symbolic link?

The Real file is first, then the Link name is second

A dependency is:

The code in file A uses (calls) something in the code of File B. A depends on B.

What does SFTP program display?

The directory of a remote host and copies files back and forth

What is the output of the compiler?

The input to the linker

What does Linux refer to?

The kernel-space component that interacts with the hardware and runs processes on behalf of user-space.

What is Signal 9 SIGKILL?

The kill signal, the "kill hammer"

Before you use top to see your processes, what do you have to log onto?

The same host your processes are running on since top cannot see other hosts

What does GNU refer to?

The user-space programs you execute at the command line, such as ls, cd, etc. It is part of the operating system that you can "see" and use to interact with the system.

Where are the permissions on display?

They are the letters on the left-hand side of the display.. file is considered executable indicated by the x permissions and the green filename coloring

How many standard streams are there?

Three 1. Standard Input 2. Standard Output 3. Standard Error

What is the proper grep command for searching a file?

grep searchString filename

What does a compiler translate source code files to?

To object code files

What is the main job of 'top'?

To show the resources consumed by each process

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.

Tru

Redirection: (T/F) -Use > to redirect a command's output to a file: cal > myFile -Use | to redirect a command's output to a program: cal | mail

Tru

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.

Tru

You can undo a patch if you change your mind.

Tru

You have to manually set a script's permission to make it executable.

Tru

How do we make a grep case insensitive?

Use the -i option which goes right after the command Command line: grep -i searchString filename

Why do Windows and Unix use different line endings in text file?

Windows was patterned after CPM which followed the mainframe/teleprinter line ending convention composed of two characters. Unix followed the Multics convention having a simplified line ending composed of a single character.

How do Unix and Windows use different line endings in text files?

Windows was patterned after a microcomputer operating system named CPM, which followed the mainframe/teleprinter line ending convention: CR/LF Unix follows the Multics convention of simplified line endings of a single character: LF WINDOWS: CR/LF UNIX: LF

In a makefile, what must a Unix command (the action line) start with?

With a Tab character

What happens if you leave the -s out of the symbolic link?

You get a hard link

How do you type a command for 'grep'?

You type command first and then argument after. grep searchString filename

What commands do you use in SFTP?

You use the same commands (ls,cd) to navigate the remote host's file system as you would your own. You use put and get to upload and download files.

A File Link is:

a shortcut to a file, usually one in another directory.

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

diff patch

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

grep -i searchString filename

The command to make a Symbolic Link is:

ln -s fileName linkName

What is the syntax to create a Symbolic Link?

ln -s fileName linkName

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

ls -l (lower case "L")

How do you undo a patch?

patch -R < patchFile (Don't specify the file to unpatch since its name is coded in the patch file)

The command that repeatedly runs a command so you can watch its output over time is:

watch


Related study sets

TERP10 - Unit 6: Plan-to-Produce Processing

View Set

Fundamentals of nursing test #2 ch. 30, 31, 41, 44, 49

View Set

Social Media Marketing Midterm Review

View Set

chapter 16: the endocrine system

View Set

1.2 Science in Context assessment

View Set

Product Owner role and responsibilities

View Set

образование платное или бесплатное

View Set

RN Nursing Care of Children ATI CH 22-43

View Set