HW 1

1. What is free software? List three characteristics of free software.

  • The software with free source code. You are free to study it, redistribute it, and modify it. As a result, the code is available free of cost—no charge for the software, source, documentation, or support (via newsgroups, mailing lists, and other Internet resources).

3. What are multiuser systems? Why are they successful?

  • A computer system that can be used by more than one person at a time. Linux is a multiuser operating system.
  • On a small, multiuser system, you or another user act as the system administrator, or this job may be shared. On a large, multiuser system or network of systems, there is frequently a full-time system administrator. When extra privileges are required to perform certain system tasks, the system administrator logs in as the root user by entering the username root and the root password; this user is called Superuser or administrator.

5. In what language is Linux written? What does the language have to do with the success of Linux?

  • More than 95 percent of the Linux operating system is written in the C programming language.
  • To make UNIX portable, Thompson developed the B programming language, a machine-independent language, from the BCPL language. Dennis Ritchie developed the C programming language by modifying B and, with Thompson, rewrote UNIX in C in 1973. The revised operating system could be transported more easily to run on other machines.That development marked the start of C. Its roots reveal some of the reasons why it is such a powerful tool. C can be used to write machine-independent programs. A programmer who designs a program to be portable can easily move it to any computer that has a C compiler. C is also designed to compile into very efficient code. With the advent of C, a programmer no longer had to resort to assembly language to get code that would run well (that is, quickly, although an assembler will always generate more efficient code than a highlevel language).C is a good systems language. You can write a compiler or an operating system in C. It is highly structured but is not necessarily a high-level language. C allows a programmer to manipulate bits and bytes, as is necessary when writing an operating system. But it also has high-level constructs that allow efficient, modular programming.

7. What is a shell? How does it work with the kernel? With the user?

  • Shell is a piece of software that provides an interface for users of an operating system. Shell provides access to the services of a kernel. Shell makes the user’s job faster and easier in many ways.

9. Why is the Linux filesystem referred to as hierarchical?

  • Because it uses a  hierarchical  structure in shape of a pyramid or (up-rooted) tree to make director and subdirectories.

11. Give an example of when you would want to use a multiprocessing system.

  • Using 2 or more CPU and multi-tasking 

13. What are the key terms of the GNU General Public License (GPL)?

  • The GPL says you have the right to copy, modify, and redistribute the code covered by the agreement. If you redistribute the code, you must also distribute the same license with the code, making the code and the license inseparable. If you get the source code off the Internet for an accounting program that is under the GPL, modify the code, and then redistribute an executable version of the program, you must also distribute the modified source code and the GPL agreement with it. Because this is the reverse of the way a normal copyright works (it gives rights instead of limiting them), it has been termed a copyleft.


HW 2

1. The following message is displayed when you attempt to log in with an incorrect username or an incorrect password:

Login incorrect

This message does not indicate whether your username, your password, or both are invalid. Why does it not tell you this information?

  • It does not differentiate between an unacceptable login name and an unacceptable password to discourage unauthorized people from guessing names and passwords to gain access to the system.

2. Give three examples of poor password choices. What is wrong with each? Include one that is too short. Give the error message the system displays.

  • admin, me123 and PCMAN are poor passwords. admin is easy to guess, short, without capital letter, number punctuation character.
  • A good password is seven or eight characters long and contains a combination of numbers, uppercase and lowercase letters, and punctuation characters without using control characters (such as CONTROL-H) because they may have a special meaning to the system, making it impossible to log in. Not to use names, words from English or other languages, or other familiar words that someone can easily guess.
  • When we enter “me” as password system error shows: 
  • BAD PASSWORD: it is too short

3. Is fido an acceptable password? Give several reasons why or why not.

  • No, It stands for:  
  • FIlter Device Object, “FiDO”

4. What would you do if you could not log in?

  • If we forget our password, Superuser can change it and tell us our new password.


HW 3

2. How can you keep other users from using write to communicate with you? Why would you want to?

  • Give the command mesg n to keep ordinary users from writing to your terminal. You can take this action when you do not want to be disturbed or when you are viewing something on your screen that you do not want overwritten.

4. How can you find out which utilities are available on your system for editing files? Which utilities are available for editing on your system?

  • Give the command apropos editor. Typical editors are vim, ex, ed, and gedit.

6. What happens when you use diff to compare two binary files that are not identical? (You can use gzip to create the binary files.) Explain why thediff output for binary files is not the same as the diff output for ASCII files.

  • When you compare binary files with diff, the utility displays a message saying the files differ when the files differ or no message when the files are the same. The diff utility compares ASCII files on a line-by-line basis; it is not designed to compare binary files on a byte-by-byte basis. Use cmp to compare binary files in that manner.

8. What is the result of giving the which utility the name of a command that resides in a directory that is not in your search path?

  • The which utility displays a message saying that the command you are looking
    for is not in the list of directories in your search path. For example,

$ which me
/usr/bin/which: no me in (/usr/bin/which: no me in

10. Experiment by calling the file utility with names of files in /usr/bin. How many different types of files are there?

  • Approximately 20.
  • file /usr/bin/* | awk -F: '{print $2}' | sort -u 9 different file types


HW 4  – [] p285

2. What is the Work buffer? Name two ways of writing the contents of the Work buffer to the disk.

  • The Work buffer is the area of memory where vim stores the text you are editing. A :w command writes the contents of the Work buffer to disk but does not end your editing session. A ZZ command writes the contents of the Work buffer to disk and ends your editing session.

ZZ Writes contents of Work buffer to the current file and quits vim.

:w filename Writes contents of Work buffer to filename (or to current file if there is no filename)

4. While working in vim, with the cursor positioned on the first letter of a word, you give the command x followed by p. Explain what happens.

  • The commands exchange the first two letters of the word. First the x command copies the character the cursor is on to the General-Purpose buffer and deletes the character, leaving the cursor on the character to the right of where the deleted character was. Then the p command inserts the contents of the General-Purpose buffer after the character the cursor is on.

6. Which command would you use to search backward through the Work buffer for lines that start with the word it?

  • Give the command ?^itRETURN to search backward (?) for a line beginning with (^) it.

8. Consider the following scenario: You start vim to edit an existing file. You make many changes to the file and then realize that you deleted a critical section of the file early in your editing session. You want to get that section back but do not want to lose all the other changes you made. What would you do?

  • This problem assumes that you have not written out the Work buffer since you deleted the critical section. There are a few ways to approach this problem. To be safe, make copies of the Work buffer and the original file under names other than the name of the original file. If you then make a mistake, you can easily start over. For example, give the command :wq changedfile to save the Work buffer as changedfile and exit from vim. Then use cp to copy the original file to, for example, file.orig and changedfile to changedfile.orig. Start vim with the following command, which instructs it to edit the original file first and the modified file second:

$ vim originalfile changedfile

  • Once you are editing the original file, search for and copy the part of the file you want to save into the General-Purpose buffer or a Named buffer.
  • For example, to save five lines, starting with the line the cursor is on, into the Named buffer a, give the command “a5yy. Then edit the modified file by giving the command :n!RETURN (edit the next file without writing out the Work buffer). Position the cursor where you want to insert the text and give the command “ap or “aP, depending on where you want to place the copied text.

10. Use vim to create the letter_e file of e’s used on page 56. Use as few vim commands as possible. Which vim commands did you use?



HW 5

2. What are two ways you can execute a shell script when you do not have execute access permission for the file containing the script? Can you execute a shell script if you do not have read access permission for the file containing the script?

You can give the name of the file containing the script as an argument to the shell (for example, bash scriptfile, where scriptfile is the name of the file containing the script).

Under bash you can give either of the following commands: $ . scriptfile $ source scriptfile

Because the shell must read the commands from the file containing a shell script before it can execute the commands, you must have read permission for the file to execute a shell script.

3. What is the purpose of the PATH variable?

a. Set the PATH variable so that it causes the shell to search the following directories in order:

  • /usr/local/bin
  • /usr/bin/X11
  • /usr/bin
  • /bin
  • /usr/kerberos/bin
  • The bin directory in your home directory
  • The working directory

b. If there is a file named doit in /usr/bin and another file with the same name in your ~/bin, which one will be executed? (Assume that you have execute permission for both files.)

c. If your PATH variable is not set to search the working directory, how can you execute a program located there?

d. Which command can you use to add the directory /usr/games to the end of the list of directories in PATH?

4. Assume that you have made the following assignment:

$ person=jenny

Give the output of each of the following commands:

echo $person


echo ‘$person’


echo “$person”


5. The following shell script adds entries to a file named journal-file in your home directory. This script helps you keep track of phone conversations and meetings.

$ cat journal

# journal: add journal entries to the file

# $HOME/journal-file


date >> $file

echo -n “Enter name of person or group: ”

read name

echo “$name” >> $file

echo >> $file

cat >> $file

echo “—————————————————-” >> $file

echo >> $file

What do you have to do to the script to be able to execute it?

Why does the script use the read builtin (page 487) the first time it accepts input from the terminal and the cat utility the second time?


HW 6

2. The special parameter “$@” is referenced twice in the out script (page 442). Explain what would be different if the parameter “$*” were used in its place.

If you replace “$@” with “$*” in the out script, cat or less would be given a single argument: a list of all files you specified on the command line enclosed within single quotation marks. This list works when you specify a single filename. When you specify more than one file, the shell reports No such file or directory because there is not a file named the string you specified on the command line (the SPACEs are not special characters when they are enclosed within single quotation marks).


a. Write a function that takes a single filename as an argument and adds execute permission to the file for the user.

$ function perms () {

> chmod u+x $1 >


b. When might such a function be useful?

When you are writing many shell scripts, it can get tedious to give many chmod commands. This function speeds up the process.

c. Revise the script so that it takes one or more filenames as arguments and adds execute permission for the user for each file argument.

$ function perms {

> chmod u+x $* >


d. What can you do to make the function available every time you log in?

Put the function in the ~/.bash_profile and/or ~/.bashrc file to make it available each time you log in (using bash).

e. Suppose that, in addition to having the function available on subsequent login sessions, you want to make the function available now in your current shell. How would you do so?

Use source to execute the file you put the function in, for example,

$ source ~/.bash_profile

6. Write a shell script that displays the names of all directory files, but no other types of files, in the working directory.

There are many ways to solve this problem. The listdirs script uses file to identify directory files and grep to pull them out of the list. Then sed removes everything from file’s output, starting with the colon.

$ cat listdirs

file “$@” |

grep directory |

sed ‘s/:.*//’

7. Write a script to display the time every 15 seconds. Read the date man page and display the time, using the %r field descriptor. Clear the window (using the clear command) each time before you display the time.

while :


Time=’date +%r’

echo -n $Time

sleep 15




CS534 HW 7

1. Write a gawk program that numbers each line in a file and sends its output to standard output.

2. Write a gawk program that displays the number of characters in the first field followed by the first field and sends its output to standard output.

3. Write a gawk program that uses the cars file (page 537), displays all cars priced at more than $5000, and sends its output to standard output.

4. Use gawk to determine how many lines in /etc/termcap contain the string vt100. Verify your answer using grep.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s