Intro to UNIX Final Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The Command Line is:

The point at which the Shell accepts user input. The Command Line is the place in the Shell in which you type commands for Unix to execute.

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?

These are the Standard Streams: 1. Standard Input 2. Standard Output 3. Standard Error • The "Streams" are streams of text, so there is no "standard graphics". • "Standard Error" and "Standard Output" are both output streams. They're separated for convenience. It's handy to see either normal output or errors rather than both intermingled. • "Standard Input" flows into a program, "Standard Output" and "Standard Error" flow out of a program.

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 file link is

A File Link (which can be a Hard Link or a Symbolic Link) is an additional name for a file. We use it to make a file that resides in a different directory appear to reside in a more convenient directory.

A Hard Link can point to a file only if it's on the same physical hard disk. 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 hard disk 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.

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

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

A dependency is:

A dependency occurs when the source code in file A uses 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.

The "Shell" is

A program that provides a command line user interface. The "Shell" provides a command line user interface. Since it's a user interface, it's the part of Unix you can see.

A Shell Script is:

A script file has all of these characteristics: • It's a text file you write using a text editor. • It's a file of commands you want to re-run. • It's executable - You have to use chmod to make it executable.

The alternative to Interactive Computing is:

Batch processing The alternative to Interactive Computing is Batch Processing. Instead of using a terminal to have a two-way dialog with a computer, you submit a job, and come back later to pick up the results. Software development in this environment is very tedious.

The full-screen editor that Richard Stallman wrote is called

Emacs is Richard Stallman's editor. Stallman (and many other contributors under the influence of 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.

Many have heard of the "Unix Wars" but few know what it was. The "Unix Wars" was an attempt by AT&T to:

Gain commercial licensing and standards control of Unix In 1983, a consent decree that forbade AT&T from entering the commercial computing business was lifted, and suddenly Unix became a valuable property. Since AT&T had made investments in Unix, it wanted to reap the rewards, too. It struggled against other companies and especially against UC Berkeley to assert ownership.

"GPL" means

General Public License which guarantees the freedom to study and share a program's source code. The GPL is Richard Stallman's "General Public License". It's a legally binding license that guarantees the freedom to run, study, share, and modify the source code of a piece of software.

Why was the C language created?

It was needed for writing Unix because other languages weren't adequate. C was created because other languages were either too large (PL/1 and BCPL) to fit on the small machines that Thompson and Ritchie were working with, or inappropriate (FORTRAN) for systems programming. Ritchie used BCPL as the starting point for a smaller language he called B, which he enhanced to New-B, and then to C.

The reason that hidden files are "hidden" is because:

It's a convenience feature to keep configuration files from cluttering file listings. "Hidden" files aren't very well hidden, so it's not a security feature or much of a safety feature. Hiding files is a convenience feature to keep the numerous configuration files in a user's home directory from cluttering the file listing when using ls

Who originated Linux?

Linus Torvalds Linus Torvalds started working on Linux, his version of Unix, while a student at the University of Helsinki in Finland. He wanted a complete operating system, but the Unix Wars put BSD under a legal cloud, Unix was too expensive, and Minux was a training system... ...So Torvalds wrote his own!

The dominant Unix variant today is:

Linux Linux is wildly popular in web servers, smart phones, supercomputers, set-top boxes (Roku-like devices), and home network routers. On the desktop, however, there are many more Apple OS-X (BSD-like) installations than Linux installations.

The inspiration for Unix was this operating system:

Multics Ken Thompson and Dennis Ritchie worked on the Multics operating system project. Multics provided both positive and negative examples of what an operating system should be, though it provided more negative examples than positive.

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

Nano has typical text editor characteristics: • No typeface formatting such as bold or italics. • No (or optional) word wrapping - long lines of text run off the end of the screen. • Optional language syntax highlighting. This makes Nano handy for editing configuration files and computer language source code files. 1. Does not have font or typeface formatting, such as bold or italics. 2. Optional line-wrapping - long lines run off the end of the screen. 3. Optional language syntax highlighting. 4. All of the above. The correct answer was intended to be #4. However, of all the hosts, only Shell has Optional Line-Wrapping; The Linprog and Program hosts don't wrap!

The GNU rewrite of the pico editor is called nano. The feature that nano has that pico doesn't is

Nano supports syntax highlighting for many programming languages. Many users find this helpful, a few consider it annoying.

The "Open Source" movement is an ideology that holds that the source-code of all computer programs should be available for anyone to use or modify. This ideology was founded by:

Richard Stallman Richard Stallman is a veteran of the MIT Artificial Intelligence Lab, and was mightily rubbed the wrong way by source code treated as a proprietary secret. He started the GNU Project to create a free Unix, founded the Free Software Foundation, and wrote the GNU Manifesto to explain his ideas.

To ask a process to shut down nicely, we use signal 15 the SIGTERM termination signal. But the 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" the "9mm bullet". This signal tells Unix to take away all resources from a process and remove it from the list of executing processes. Poof! Gone.

ARPA is the federal undertaking that funded much operating system research and development. What event triggered the creation of ARPA?

The Soviet launch of Sputnik The effect that the Soviet launch of Sputnik had on the US can hardly be overstated. ARPA was established as a result, with a mission to guide and fund technological research and development.

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. >> Appends output to the end of an existing file

Which is the proper grep command for searching a file?

The command comes first on the command line, all the parameters follow after it. grep searchString filename

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 (or flags) follow right 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

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 as 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: 1. Compile - the compiler translates the source code to machine language 2. Link - the linker resolves addresses (calculates the addresses of function calls from one file to another)

SSH is called Secure Shell because it uses encryption to protect authentication and communication.

True

Apple's operating system for its Macintosh compiuters (OS X) is qualified to use the UNIX trademark.

True Apple's OS X, the operating system for the Macintosh, has met The Open Group's trademark certification and has paid the licensing fees to use the UNIX trademark.

SSH is called Secure Shell because it uses encryption to protect authentication and communication.

True Older communication protocols used either weak protection of user interaction, or no protection at all. SSH correctly implements strong protection via key exchange and encryption.

The program hosts run Sun's Solaris (aka SunOS), and the others (linprog and shell) run Linux.

True The CS Department provides two Unix environments: • The program hosts are older Sun machines that run an older version of Solaris, a popular commercial Unix. • The linprog hosts run Linux, the open-source and most widespread Unix variant today.

Your single Unix login account works with all the Unix hosts that the Computer Science Department provides for students. You don't need a separate account for each one.

True The CS Department uses an authentication server that allows you to log into any of several hosts without needing a separate account for each one.

The mv command is used to both move a file to a new directory, and to rename a file.

True The mv command both moves a file or renames it. Moving and renaming are the same operation; to move a file you really just rename its directory. For example: The full name of Smith's myFile.txt is: /home/majors/smith/myFile.txt To move this file, you rename the directory part of its name. To rename the file, you rename the part after the last slash. The syntax is: mv oldFileName newFileName

You have the same home directory regardless of which CS Unix host you log into.

True Your home directory is on a central file server. When you log into a CS host, the login process attaches your home directory to the host's filesystem. You get the very same home directory no matter which CS host you log into.

Unix was created by

Two guys with a discarded minicomputer Ken Thompson and Dennis Richie of AT&T created Unix on an obsolete PDP-7 minicomputer in the aftermath of the disappointing Multics project with MIT and GE. They had help from the other AT&T systems programmers.

When Unix was passed around to anyone who asked for a copy, it massively caught on in the academic world. The institution that did more than any other to advance the development of Unix was:

University of California at Berkeley While all of these schools participated in Unix development to an extent, it was UC Berkeley that really raced forward with development. They were the ones who integrated it into the early Internet, and distributed their Unix advancements in both free and commercial environments.

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

Unless instructed otherwise, make looks for its instructions in a file named makefile orMakefile in the current directory.

You can undo a patch if you change your mind.

Use patch -R < patchFile to undo a patch. The name of the file to be undone is coded in the patch file.

What's the proper grep command for searching the output of another command instead of searching a file?

Use the pipe symbol to send the output of one command to the input of grep. cat filename | grep searchString

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

When we redirect a program's output, we use separate symbols to explicitly tell the shell what to do with the output: • > means find or create a file to write the output to • | means start another program to send the output to

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.

When you use top to see your processes, you have to know which host your processes are running on, and you run top on that host. top can't search over the network to other hosts.

The same command is used to concatenate files as well as list a file to the screen:

cat cat both lists a file to the screen, and concatenates files together. These are actually the same operation. The syntax is: cat fileName Lists a file to the screen. cat fileName1 fileName2 Lists two files to the screen. cat fileName1 fileName2 > fileName3 Concatenates two files to produce a third

The command to copy a file is

cp cp is the command to copy a file. The syntax is: cp sourceFile destinationFile

Before using a wildcard in a destructive command like rm *, you can preview what it will do by using:

echo * Using echo * shows you how a wildcard will expand before using the wildcard in a command that deletes things, like rm *

There are a number of ways to connect to a remote host. The reason we use SSH for our connections is because it's:

encrypted and secure Now-a-days, security ranks above just about every other system characteristic. SSH is an encrypted protocol, hence the name "Secure Shell".

To log out of a session, the command is:

exit or logout or ctrl-d

To log out of a session, the command is:

exit or logout or ctrl-d exit logs you out of your session, as does logout and ctrl-d

What is grep used for?

grep reads a file line-by-line looking for a string you specify. It prints the lines in which it finds the string.

It's handy to see a list of everything you typed into the command line. You can get this by using this command:

history The history command shows you a numbered list of your past commands. To replay a command from the numbered list, type an exclamation point followed by the number like this: history Show a list of commands you typed, preceded by a sequence number !123 Replay the command that has the number 123 in the history list

"Directory" is the original name for a folder. The command to list the files in a directory is:

ls ls is the command to list the files in a directory. it's name comes from it's original function, "List Segments", referring to directory structures on the disk.

The command to list files in a directory is

ls ls lists the files in the current directory. The syntax is: ls lists the files in an abbreviated, compact format ls -l lists the files with much more information ls -a lists all files, including hidden ones ls -la combination of the above

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

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

Unix has a built in manual of commands. To call it up, use this command:

man There are actually two manuals, man and info. man gives command syntax, info often gives supplementary information. Use them like this: man commandName info commandName

The command to make a new directory is:

mkdir The command to make a new directory is mkdir. Given that most of the fundamental commands are only two or three letters long, mkdir is a surprisingly long name. The syntax is: mkdir NewDirectoryName

The command for changing your password is:

passwd

The command for changing your password is:

passwd passwd is the command to change your password. If you forget it, you'll have to open a helpdesk ticket to get an administrator to change it to a known value.

An easy to use email client for the command line environment is:

pine pine is an easy to use email client for the command line. It has a text-based GUI-like interface that lets you select mail from a list, a menu that lets you move among your folders, and an editor that uses the standard cursor keys to navigate and compose an email message.

The command to delete a file is

rm The command to delete a file is rm. The syntax is: rm fileName

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

top Use top to see all the jobs running on the host. By default it's sorted by share of CPU that each job is consuming.

top is used to

top lets you see all the processes running on a host, but it's handy to filter the view to just your own processes. You can sort processis by the percent of CPU time they're using or the amount of memory they occupy. You can also send a "signal" to a process to control it, usually to shut it down. You can either signal the process to shut down normally, or if it's malfunctioning, you can signal the operating system to forcibly kill the process.

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 instructions to vi 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.

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.

sdiff is for ________ diff is for ________

• sdiff produces output optimized for visually (interactively) comparing two files. • diff produces output intended to be read by another program, usually patch.


Set pelajaran terkait

Accounting 203 Final- Chapter 11,12 & 5 Quiz Q

View Set

The Atlantic Slave Trade (crash course)

View Set

Phase Transfer Catalysis Chem 237

View Set