Homework Quiz Questions Flashcards

1
Q

Linux is a free operating system developed for the __________
processor that is intended to replicate the functionality of ________

A

80X86, Unix

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Linux was first released by ___________ , who was a student at University of Helsinki at the time.

A

Linus Torvalds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

C was developed at _________ in the early 1970’s simultaneously with
_______.

A

Bell Labs, Unix

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The command ____________ prints the absolute path to your current working directory.

A

pwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The ____________ command is used to change permissions on a file.

A

chmod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

________ changes the working directory to the root directory

A

cd /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

________ changes the working directory to the user’s home without using tilde expansion.

A

cd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

______ changes the working directory to the user’s home directory using tilde expansion.

A

cd ~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

______ changes the working directory to the user bob’s home directory using tilde expansion.

A

cd ~bob

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain the differences between a static C library and a C shared library

A

Static libraries are libraries that can be used in multiple programs, inside of a program when it is compiled. Conversely, shared libraries exist completely separate from the compiled program as a separate file or files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write a command that assigns the value “CSI 3336” to an environment variable named classNumber.

A

classNumber=”CSI 3336”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Write a command that assigns the value “Systems Programming” to an environment variable named className.

A

className=”Systems Programming”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Write a command that concatenates the values found in classNumber and className into a new environment variable named class

A

class=”$classNumber$className”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Write a command that lists the directory contents of the local directory and all subdirectories.

A

ls -r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Write a command that creates a new directory named cs3336 in the current working directory.

A

mkdir cs3336

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Write a command that displays the current system time.

A

date

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Write a command that changes the permissions of a file named output rwxr-xr— using octal numbers in combination with chmod.

A

chmod 754 output

18
Q

Write a command that changes the permissions of a file named output rwxr-xr— using characters (not octal numbers) in combination with chmod (without octal numbers).

A

chmod u=rwx,g=rx,o=r output

19
Q

Write a command that displays all exported environment variables

A

env

20
Q

Explain what cat does

A

cat reads the files you provide and writes them out sequentially to stdout. It can be used to quickly examine the contents of a file, or a few small files.

21
Q

Explain what less does

A

less is a quicker version of more. It displays the contents of a file in a page-by-page format, but doesn’t load the whole file at once which makes it faster. This makes it a much better option for just viewing files than opening them up in something like vi or vim.

22
Q

Write a command that displays the first 5 lines of a file named classList.txt.

A

head -n 5 classList.txt

23
Q

Write a command that displays the last 10 lines of a file named classList.txt.

A

tail -n 10 classList.txt

24
Q

Write a command that changes the status time (this includes access, modify, and change times) of a file named myFile to the current system time.

A

touch myFile

25
Q

Write a command that removes all files in the current directory that end with .del

A

rm *.del

26
Q

What command can be used to copy files from one system to another (e.g. your local computer to the department Linux boxes)?

A

scp

27
Q

Explain how bash manages execution of commands with regards to processes.

A

When a command is executed, a new child process is created and put in the foreground. Other processes are put in the background. You can switch between these different commands being executed similarly to switching tabs on a computer by moving processes to the foreground/background.

28
Q

Provide the proper filename expansion for the following (assume local directory) for all files ending in .sh

A

*.sh

29
Q

Provide the proper filename expansion for the following (assume local directory) for all files beginning with assign

A

assign*

30
Q

Provide the proper filename expansion for the following (assume local directory) for all files beginning with assign, containing any number of characters, and ending with .tar.gz.

A

assign*.tar.gz

31
Q

Provide the proper filename expansion for the following (assume local directory) for all files beginning with assign, containing a single digit, and ending with .tar.gz.

A

assign[0-9].tar.gz

32
Q

Provide the proper filename expansion for the following (assume local directory) for all files in bob’s home directory ending with .csv.

A

~bob/*.csv

33
Q

Provide the proper regular expression (regex) for the following (assume single match per line) for all items that contain the string “file”.

A

.file.

34
Q

Provide the proper regular expression (regex) for the following (assume single match per line) for all items that begin with the string “file”.

A

^file.*

35
Q

Provide the proper regular expression (regex) for the following (assume single match per line) for all items that end with the string “ing”.

A

.*ing$

36
Q

Provide the proper regular expression (regex) for the following (assume single match per line) for all items that contain the same 4 or 5 letter sequence twice.

A

.([a-zA-Z]{4,5}).\1

37
Q

Provide the proper regular expression (regex) for the following (assume single match per line) for all items that starts with a number (multiple digits possibly) immediately followed by a colon (don’t worry about 0: )

A

^[0-9]+:

38
Q

Provide a one-liner to print all processes being run by the first user listed by who.

A

ps -u who | head -n 1 | sed "s/ .*//"

39
Q

Provide a one-liner to send email with the subject, “welcome”, to all users listed in a tab delimited file, named “folks.csv” (the third value in the record is the email address). The body for the email is found in a file named “welcome”.

A

awk -F’\t’ ‘{print $3}’ folks.csv | xargs -I{} mail -s “welcome” {} < welcome

40
Q

What must be provided to execute a program located in the local directory (assuming the local directory is not in the path and the file is set as executable)? Why?

A

./ must be provided before the filename. This is because the shell only searches for executable files in the PATH, so it won’t be able to find anything outside of the PATH without some kind of explicit instruction. The ./ tells the shell that the executable file is in the current directory. This is done for security as files outside the PATH could be tampered with, so it is best to make sure what you are executing is something that you have cleared and put in your PATH, or are sure that you are running from the current directory.