Unix Exam 1

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

[Sobell] With ls command, use this option to list all the "dot" files (configuration files that begin with a period, such as .login or .profile).

-a

[Unix&Shell1] This "find" command option will go and look at all the files first before hitting any of the directories or sub-directories.

-depth

The figure below shows a sample of ____ file. oracle:x:1021:1020:oracle user:/data/network/oracle:/bin/bash

/etc/passwd

[Sobell1-4] Which of the following represents an absolute path?

/usr/bin/cat

Only Others can execute the file

0001

Only Others can write the file

0002

Only Others can read the file

0004

Only Group can execute the file

0010

Only Group can write the file

0020

Only Group can read the file

0040

Only Owner can execute the file

0100

Only Owner can write to the file

0200

Only Owner can read the file

0400

[Sobell] With this option of chmod command, Owner can read, and write the file; group can read the file, and other cannot access the file.

0640

[Sobell] With this option of chmod command, Owner can read, and write the file; group and other can read the file.

0644

[Sobell] With this option of chmod command, Owner can read, write, and execute the file; group and other can execute the file.

0711

[Sobell] With this option of chmod command, Owner can read, write, and execute the file; group and other can read and execute the file.

0755

[Sobell] With this option of chmod command, Owner, group, and others can read, write, and execute the file.

0777

[Korn08] PID of init process is ___

1

[Unix&Shell4grep] What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '^[0-9][0-5][0-6]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

1

Sticky bit

1000

[Korn08] Consider the following program code. How many times will it output "Hello"? main() { fork( ); fork( ); fork( ); fork( ); printf("Hello"); }

16

[Unix&Shell4grep] What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '[Ss]ept' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

2

[Unix&Shell4grep] What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '^[^48]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

2

Sets the group ID when the program is executed

2000

[Unix&Shell4grep] What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '48[34]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

3

[Unix&Shell4grep] What would be the result (the number of the output lines) of the following grep command with the data.txt as shown below. grep '[0-9][0-5][0-6]' data.txt where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 CPPX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234

4

Sets the user ID when the program is executed

4000

[Korn08] How many times printf() is executed in the following program code? main() { for (int i=0;i<3;i++) fork(); printf("pid= %d\n",getpid()); }

8

* (an asterisk symbol)

A single character followed by an *, will match zero or more occurrences.

[Korn08] This points out the one which is not a section of "man" page.

BRIEF

[Sobell1-4] Which of the following is not a UNIX file type?

Batch file

[Korn08] What is not an advantage or a feature of CVS?

CVS can manage well a complex distributed source control

chmod

Change file security setting.

[Sobell1-4] What will the following command do? chmod og+r *.jpg

Change the permissions on any file ending with .jpg to be readable by all others

cd

Change to another directory.

[ ] (a square-bracket open-close symbol)

Character enclosed inside it will be matched. One can use the - to include a range inclusively.

rmdir

Delete a directory.

rm

Delete a file.

pwd

Display current working directory - i.e. where am I?

[Sobell1-4] The file "assign4.html" has permissions set as: "r w x r w x r w x". This means that:

Everyone can read, write, and execute the file.

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the command "chmod o+x abc", the file "abc" is executable by group

False

[Sobell1-4] (T/F) The command "grep -i hello" prints all the lines in file, not containing the string "hello".

False

[Sobell1-4] (T/F) The command pwd is normally used to change the password.

False

[Sobell1-4] The command history prints ALL the commands you typed.

False

[Unix&Shell1] _____ is a very powerful tool and command, searching through the system or just current directory, locating all or certain files or directories.

Find

man

Help manual.

[Korn08] If a program executing in background attempts to read from the default STDIN (that is, keyboard), then ____

Its execution will be suspended.

ls

List filenames and directories.

. (a dot symbol)

Matching any single character.

[Korn08] What is the output of the below code? void exit_handler1(); void exit_handler2(); int main() { int pid; atexit(exit_handler1); atexit(exit_handler2); pid = fork(); if(pid == 0) { _exit(0); } else { sleep(2); exit(0); } return 0; }

Only parent executes the exit_handler1 and exit_handler2.

[Sobell1-4] Which of these expressions shows the proper way to add the directory /usr/bin to your path?

PATH=$PATH:/usr/bin

[Korn08] Which mode of the gdb debugger ascertains the cause of the crash by examining the core files?

Post-mortem mode

[Korn08] Which of the following signals cannot be handled or ignored?

SIGKILL

[Korn08] Default action of SIGSEGV is _____

Start Core dump

[Korn08] Which of the following values for STAT (status) column of ps command is NOT correct?

Status E means exited

[Sobell] ____ Displays strings of printable characters from files

Strings

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the command "chmod og+rx abc", the file abc executable and readable by all.

True

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the following command: "chmod g+x abc", the result will be is equivalent to the result of command: chmod 710 abc.

True

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. The result of the following command "chmod 700 abc" is equivalent to "chmod og-rwx abc".

True

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. The result of the following command "chmod og+rx abc" is equivalent to the command "chmod 755 abc"

True

[Sobell1-4] (T/F) The command "grep hello file" prints all lines in "file" that contains hello.

True

[Sobell1-4] (T/F) The command "ls" lists the contents of a directory.

True

[Sobell1-4] (T/F) UNIX supports a hierarchical directory structure.

True

\ (a back-slash symbol)

Use this to escape the special meaning of a metacharacter.

{n}

Use this to match a specific number of occurrences specified by n that contains the preceding pattern

{n,m}

Use this to match any number of occurrences between n and m of the preceding pattern.

{n,}

Use this to match at 'least' n occurrence of the preceding pattern.

^ (a cap/caret symbol)

Will match the beginning of the line only.

$ (a dollar symbol)

Will match the end of the line only.

[Sobell1-4] In Unix, if you wanted to allow a user to delete a file, you would give the file the what permission?

Write

[Sobell1-4] In Unix, if you wanted to allow a user to modify file permissions in a directory, you would give the directory what permission?

Write

Make the file executable only if it is a directory

X

[Korn08] A Graphical User Interface supported by every Unix system is generally known as ____.

X Windows

[Sobell1-4] When creating a directory as an ordinary user, which of the following is true?

You must be in your home directory or its subdirectories.

[[:digit:]]

[0-9]

[[:alnum:]]

[0-9a-zA-Z]

[[:upper:]]

[A-Z]

[[:alpha:]]

[a-zA-Z]

[[:lower:]]

[a-z]

[Korn08] A new line (in echo) will be done with this ___.

\n

[Sobell1-4] When you use the ln command, which of the following occurs?

a file is created that points to an existing file

[Shell] What is a shell in UNIX?

a program through which users can issue commands to UNIX

[[:space:]]

a space or a tab

[Korn08] Mark one (of the choices below) which is not a help facility.

about

[Korn08] Which command option (of ar command) is used to add a file to the library?

ar -r

[Sobell] This will print a calendar for a specified month and/or year.

cal

[Sobell] This outputs the contents of a text file. You can use it to read brief files or to concatenate files together.

cat

[Sobell1-4] Which command will print the contents of all files in the current directory whose names start with the character "a" and end with a period (".") followed by any two characters followed by a number?

cat a*.??[0-9]

[Sobell1-4] To create a new file "new.txt" that is a concatenation of "file1.txt" and "file2.txt" is done by which command?

cat file1.txt file2.txt > new.txt

[Sobell] This changes your current directory location.

cd

[Sobell1-4] Change the current directory to /usr/local/bin

cd /usr/local/bin

[Sobell] This changes the permission information associated with a file.

chmod

[Sobell1-4] The file "mypage.html" has permissions set for read and write only for owner. Which of the following command will change the permissions so that the file can be viewed on the WWW?

chmod og+r mypage.html

[Sobell] This displays the differences between two files on a byte-by-byte basis.

cmp

[Korn08] Which command is used to check out the files in RCS?

co -l

[Korn08] The delimiter (to separates one piece of path name from other path name) in PATH variable is ___

colon (":")

[Sobell] This compares sorted files

comm

[Sobell1-4] What is the generic syntax for all UNIX commands?

command name, followed by options, followed by arguments

[Korn08] Which command is used to update the files in CVS?

commit

[Sobell] This configures the source code automatically.

configure

cp

copy a file.

[Sobell] This copies a file, preserving the original and creating an identical copy.

cp

[Sobell1-4] Make a copy of file "upper" in the directory two levels up

cp upper ../..

[Sobell] This creates an archive, restores files from an archive, or copies a directory hierarchy.

cpio

[Sobell] This selects characters or fields from input lines and writes them to standard output.

cut

[Korn08] Which is NOT a version control tool used in UNIX?

cygwin

[Sobell] This displays the current day, date, time, and year.

date

[Korn08] To show only the current month-name is: ____

date +%h

[Sobell] For each mounted file system, this reports the file system device, the number of blocks, the number of blocks available, and the directory where the file system is mounted.

df

[Sobell] This reports file system disk usage (i.e., the amount of space taken up on mounted file systems).

df

[Korn08] Which command is used to display lines of source code in gdb debugger?

display

[Sobell] This reports disk usage (i.e., the amount of space taken up by a group of files).

du

[Korn08] The directory "a" contains its subdirectory "b" and there is no other entry in the directory "a". You want to display "the contents of directory a are: b". The contents are to be displayed using "ls" command. Which command helps you accomplish that?

echo "The contents of directory a are: `ls a`"

[Korn08] There is a variable "var". Its value is set to the number 5. If one tries to print "The value: 5". Which one of the commands will do that?

echo "The value: $var"

[Sobell] This (utility) evaluates an expression and sends the result to standard output.

expr

[Sobell] This displays the classification of a file

file

[Sobell] This is most commonly used to find all of the files that have a certain name.

find

[Unix&Shell1] This ___ is to find all '*.txt' files in the current directory you are in and any sub-directories,

find . -name "*.txt" -print

[Unix&Shell1] This is ___ to find files with a permission of ____ which is "read, write and executable" by owner and "read and execute" by everyone else.

find . -perm 755 -print

[Unix&Shell1] To find files that are over 10 blocks in length (that's 512 bytes a block) use:

find . -size +10 -print

[Unix&Shell1] To find files that are over 10 bytes in length using the character format use:

find . -size +10c -print

[Unix&Shell1] To find files in /var/adm directory that have not been modified in the last five days:

find / -mtime +5 -print

[Unix&Shell1] To find all files that have been modified in the last five days:

find / -mtime -5 -print

[Unix&Shell1] This find command does find all the ordinary files and then test each file for its type.

find / -type f -print | xargs file

[Unix&Shell1] This is to find all the files in the /apps directory but do not search in /apps/bin:

find /apps -name "/apps/bin" -prune -o -print

[Unix&Shell1] To find all files but not directories in /etc

find /etc !-type d -print

[Unix&Shell1] This find command does find first for all 'passwd*' files, for example passwd, passswd.old, passwd.bak, then runs grep to see if there is a user 'richard' located in the files.

find /etc -name "passwd*" -exec grep "richard" {} \;

[Unix&Shell1] To find all directories in /etc

find /etc -type d -print

[Unix&Shell1] To find all symbolic linked files in /etc:

find /etc -type l -print

[Unix&Shell1] This find command does find all ordinary files older then 7 days in /var/logs and delete them.

find /var/logs -type f -mtime +7 -exec rm {} \;

[Sobell] This utility displays the usernames of users, together with their full names, terminal device numbers, times they logged in, and other information.

finger

[Korn08] ___ creates a process by spawning a process.

fork

[Sobell1-4] Which of these is not a common UNIX shell discussed in class (or textbook or lecture)?

fresh

[Sobell] This utility verifies the integrity of a filesystem and reports on and optionally repairs problems it finds.

fsck

Sets the specified permissions to those of the group

g

[Sobell] This ___ will compile C and C++ programs

gcc

[Sobell] This searches for a pattern in files

grep

[Sobell1-4] What is the command to search all files in your current directory for the word "hello"?

grep hello *

The figure below shows a sample of a passwd file. The field #4 is _____.

group identifier

[Sobell] The ___ utility compresses files, the ___ utility restores files compressed with gzip, and the ___ utility displays files compressed with this utility.

gzip, gunzip, zcat

[Sobell] This displays the beginning of a file

head

[Sobell1-4] How do you print the first 15 lines of all files ending by ".txt"?

head -15 *.txt

[Sobell1-4] The figure below shows a sample of a passwd file. The field #6 is _____.

home directory

[Korn08] A user issues the following command sequence: $ a.out & $ bash $ a.out & If the user kills the bash process, then which of the following is true?

init process becomes parent of second a.out process

[Sobell] This reports any programs that you suspended and still have running or waiting in the background (if you had pressed Ctrl-z to suspend an editing session, for example).

jobs

[Sobell] This joins lines from two files based on a common field

join

[Sobell] This terminates a process by PID

kill

[Sobell] Use This as a last resort to destroy any jobs or programs that you suspended and are unable to restart.

kill

[Sobell] This displays text files, one screen at a time

less

[Sobell] This lets you read text without it scrolling quickly off your screen.

less

[Sobell] This makes a link to a file

ln

[Sobell] This sends files to printers

lpr

[Sobell] This lists all of the files within a directory and its subdirectories that match a set of conditions.

ls

[Sobell] This will list the files and the subdirectories in a directory.

ls

[Sobell] ___ Displays information about one or more files

ls

[Sobell1-4] To list the permissions on files, which of the following commands will work?

ls -l

[Sobell] To output only the permissions of the files in the working directory, which of the following commands will do it?

ls -l | cut -c2-10

[Sobell1-4] Count the files that you own in all your directories (where your userid is myusername).

ls -lR | grep myusername | wc -l

[Unix&Shell2] To match all your .files (that is, any hidden files begins with a period).

ls .*

[Unix&Shell2] To list filenames where the first two characters can be any character, followed by an 'R', followed by any string:

ls ??R*

[Unix&Shell2] To match filenames that start with 'CPP', followed by any two characters, followed by any non-digit string:

ls CPP??[!0-9]*

[Unix&Shell2] To match filenames that start with 'CPP', where the next two characters can be anything, but the next character must be a '1':

ls CPP??[1]

[Unix&Shell2] To match only numbered filenames use:

ls [0-9]*

[Unix&Shell2] To match filenames starting with an upper case letter only:

ls [A-Z]*

[Unix&Shell2] To match filenames starting with a lower case letter only:

ls [a-z]*

[Unix&Shell2] To list all filenames that start with an 'i' or 'o':

ls [io]*

[Unix&Shell2] To match all filenames that start with 'f', followed by any two characters, followed by any string; the end character must be an 's':

ls f??*s

[Unix&Shell2] To list all filenames (log followed by some string) but with no numbers.

ls log.[!0-9]*

[Unix&Shell2] To match filenames that begin with 'log.', followed by a single number, followed by any character (including none).

ls log.[0-9]*

[Korn08] Mail utility that POSIX requires all unix systems to support is ____.

mailx

[Korn08] Which command/tool is used for building and maintaining groups of programs from source code?

make

[Sobell] ____ Keeps a set of programs current (to compile, link edit, clean, etc).

make

mkdir

make directory.

[Sobell] ___ Displays documentation for utilities

man

[Sobell1-4] How do you get help about the command "cp"?

man cp

[Sobell] This will make a new subdirectory.

mkdir

[Sobell] ___Creates a directory

mkdir

[Sobell1-4] Which command is used to create the directory "abc" in the previous (parent) directory?

mkdir ../abc

[Sobell1-4] How do you create a new directory called "flower"?

mkdir flower

[Sobell] ___Creates a filesystem on a device

mkfs

[Sobell] This displays the contents of a file one screen at a time, waiting for you to press the Spacebar between screens.

more

[Sobell1-4] Which of the following is not a benefit of the fact that many UNIX commands operate on plain ASCII text files?

most current UNIX installations have a graphical user interface

mv

move a file to another location.

[Sobell] This will move a file.

mv

[Sobell] ___Renames or moves a file

mv

[Sobell1-4] To rename the file "a.html" to "b.html", which command do you use?

mv -i a.html b.html

[Sobell1-4] How do you rename file "new" to be "old"?

mv new old

[Sobell] ___ Changes the priority of a command

nice

[Sobell] ___ Numbers lines from a file

nl

[Sobell] ___ Runs a command that keeps running after you log out

nohup

Sets the specified permissions to those of others

o

[Sobell] ___ Dumps the contents of a file

od

[Sobell] ___ Opens files, directories, and URLs

open

[Korn08] A Command used for changing user password is ____.

passwd

[Sobell] ___ Joins corresponding lines from files

paste

[Sobell] ___ Creates an archive, restores files from an archive, or copies a directory hierarchy

pax

[Korn08] Which one of the following methods is NOT correct for two processes to communicate each other?

pipe

[Korn08] Process attributes are stored in ___

process table

[Korn08] ps fetches attributes from ___

process table

[Sobell] This displays information about programs (i.e., processes) that are currently running.

ps

[Sobell] ___ Displays process status

ps

[Sobell1-4] Which of the following commands displays the full pathname of the directory you are currently positioned in?

pwd

Sets read permission

r

In Unix, the octal number "5" corresponds to which ___ file permission.

r - x

[Sobell1-4] In Unix, if you wanted to allow a user to list the contents of a directory, you would give the directory what permission, at least?

read

[Korn08] The priority of a running process can be changed using ____.

renice

[Sobell] ___ Changes the priority of a process

renice

[Sobell] This will remove (delete) a file.

rm

[Sobell] ___ Removes a file (deletes a link)

rm

[Sobell1-4] To delete a file called mynotes.txt, which command do you use?

rm -i mynotes.txt

[Sobell] This will remove (delete) a subdirectory.

rmdir

[Sobell] ___ Removes directories

rmdir

[Sobell] ___ Securely copies files and directory hierarchies over a network

rsync

Set the user ID or group ID of the file while the file is being executed

s

[Sobell] ___ Securely copies one or more files to or from a remote system

scp

[Korn08] A Command to record your session is ____.

script

[Sobell] ___ Edits a file noninteractively

sed

[Sobell] This displays or changes various settings and options associated with your Unix session.

set

The figure below shows a sample of a passwd file. The field #7 is _____.

shell

[Sobell] ___ Creates a process that sleeps for a specified interval

sleep

[Sobell] ___ Sorts and/or merges files

sort

[Sobell] ____ Divides a file into sections

split

[Sobell] ___ Securely runs a program or opens a shell on a remote system

ssh

[Sobell] ___ Displays information about files

stat

[Korn08] Which command in debugger is used to execute the next statement but descends into a function?

step

[Sobell1-4] What is the default datatype of variables in bash or ksh shell scripts?

string

[Sobell] ___ Displays or sets terminal parameters

stty

[Korn08] A Command to display current terminal settings is ____.

stty -a

Sets the sticky bit

t

[Sobell] ___ Displays the last part (tail) of a file

tail

[Sobell] ___ Stores or retrieves files to/from an archive file

tar

[Sobell] ___ Copies standard input to standard output and one or more files

tee

[Sobell] ___ Check file types and compare values

test

[Unix&Shell1] The -follow option with find command is ____.

to chase down the source of the files for symbolic linked files

[Unix&Shell1] The -name option with find command is ____.

to find files by filename

[Unix&Shell1] The -user option with find command is ____.

to find files by user ownership

[Unix&Shell1] The -type option with find command is ____.

to find files that are a certain type

[Unix&Shell1] The -newer option with find command is ____.

to find files that are newer than one file but older than the other file

[Unix&Shell1] The -mtime option with find command is ____.

to find files that were accessed or modified some days ago

[Unix&Shell1] The -perm option with find command is ____.

to find files with different access or permission bits on a file

[Korn08] Which command is used to display (and update) a dynamic list of currently running processes of a system in real-time?

top

[Sobell] ___ Dynamically displays process status

top

[Sobell1-4] What UNIX command is used to update the modification time of a file?

touch

[Sobell] ___ Creates a file or changes a file's access and/or modification time

touch

[Sobell] ___ Replaces specified characters

tr

[Korn08] This command shows which version of a particular command(example: echo) will be executed.

type echo

[Sobell1-4] What is the effect of the command alias up2="cd ../.."?

typing "up2" at a shell prompt takes you up two levels in the directory tree

Sets the specified permissions to those of the owner

u

[Sobell] ___ Specifies the file-creation permissions mask

umask

[Korn08] A Command to get the version or release of your operating system is ____.

uname -r

[Sobell] ____ Displays unique lines from a file

uniq

[Sobell1-4] The figure below shows a sample of a passwd file. The field #3 is _____.

user identifier

Sets write permission

w

[Sobell] If you use this, you also get a list of what they are doing.

w

[Sobell] This lists all users logged into the computer.

w

[Sobell] ____ Displays information about local system users

w

[Sobell] ___ Displays the number of lines, words, and bytes in one or more files

wc

[Sobell] ___ Shows where in PATH a utility is located

which

[Sobell] If you use this, you also get the IP numbers or computer names of the terminals they are using.

who

[Sobell] ___ Displays information about logged-in users

who

[Korn08] A Command to get your userid is ____.

who am i

Sets execute permission

x

[Sobell] ____ Converts standard input to command lines

xargs

[Korn08] When parent process doesn't wait till child's death, the child enters into ____

zombie state


Kaugnay na mga set ng pag-aaral

How to Read Charts and Graphs - InQuizitive Answers

View Set

VIERNES 5/5-Comparaciones de igualdad (WRITE)

View Set

Pathophysiology Exam 1 Questions (Mentimeter)

View Set

Sadlier Oxford Vocabulary Workshop Level B Review Units 13-15

View Set

Computing I: Multiple Choice packet 1,2,3

View Set