Intro to Unix Test 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

To explicitly invoke the shell in the script file, the first line should read #!# !# /bin/sh #! /bin/sh ###shell

#! /bin/sh

If /home/user1 is the home directory for user1, what is the output of the following command executed by user1? echo '$HOME is my home directory' $HOME is my home directory $ is my home directory HOME is my home directory /home/user1 is my home directory

$HOME is my home directory

In UNIX the shell script myscript can be executed by: execute myscript run myscript myscript > run ./myscript

./myscript

Which character should not be part of an ordinary file name? / 9 _ .

/

Which of the following numbers is an ethernet address? 13-84-0A-10-CE-23 13.82.40.23.12.43 13 84 0A 10 CE 23 13:84:0A:10:CE:23

13:84:0A:10:CE:23

What is the file descriptor for the standard error? 2 0 3 1

2

Given the following computer name bug.st.aum.edu and its corresponding IP address 131.95.115.204, what of the numbers in the IP address corresponds to the name bug? 95 115 131 204

204

What is the character for redirecting the standard error? < 2> 2< >

2>

What are makefiles used for? For helping with editing programs. For helping with the translation of a code from one programming language to other. For helping with organizing code compilation. For helping with debugging codes.

For helping with organizing code compilation.

The most popular desktops in a UNIX Windows systems are: BASH and TERM GUI and WIN GNOME and KDE WindowManager and SawFish

GNOME and KDE

What are the outputs of the following sequence of statements echo Hi $there echo Hi ${there:-John} echo Hi $there Hi Hi John Hi John Hi Hi John Hi echo echo echo Hi Hi Hi

Hi Hi John Hi

What is a collection of networks not accessible from the Internet that it may be connected through a firewall. WAN LAN Internet Intranet

Intranet

What does the following command do? ls /etc/passwd >> myfile It creates a password for the file myfile Writes all passwords in file myfile It overwrites the file myfile with the output of the listing command ls /etc/passwd . Removes the password of the file myfile It appends the output of the listing command ls /etc/passwd into the file myfile

It appends the output of the listing command ls /etc/passwd into the file myfile.

Select the command that compiles the C++ program with the option that enables gdb debugging. g++ -g mycode.cpp -o mycode g++ -o mycode mycode.cpp g++ -debug -o mycode mycode.cpp -set gdb g++ -gdb -o mycode mycode.cpp

g++ -g mycode.cpp -o mycode

Explain the following shell command, where myprog1 and myprog2 are executable programs. myprog1 < file1 | myprog2 > file2 file1 and file2 are the outputs of myprog1 and myprog2 respectively. myprog1 and myprog2 have as input the files file1 and file2 respectively. file1 is saved in myprog1 and myprog2 is saved in file file1 is the input for myprog1 and then the output of myprog1 is piped as the input for myprog2, finally the output of myprog2 is redirected to file2. myprog1 gets its input from both file1 and myprog2 and then the output of myprog1 is redirected to file2.

file1 is the input for myprog1 and then the output of myprog1 is piped as the input for myprog2, finally the output of myprog2 is redirected to file2.

Give a command to find files which have their names ending with .f in the directory ./myprograms find *.f ./myprograms find -n *.f ./myprograms find -name '*.f' -d ./myprograms find '*.f' -d ./myprograms find ./myprograms -name '*.f' -print

find ./myprograms -name '*.f' -print

What will be output of the following awk command if the file myfile contain a 2 b c 3 a d 5 x y 3 z awk '{ $2 ~ /[0-9]/ {print "found in line ", NR }' myfile found in line 2 found in line 1 found in line 3 There is no output

found in line 1

Which of the following commands compiles and produces the object file of the program myCode.c g++ -o myCode myCode.c gcc -c myCode.c gcc -o myCode myCode.c gcc myCode.c

gcc -c myCode.c

If the executable file myprog was generated compiling the code myprog.cpp with the option to enable gdb debugging, select the command that will start the debugging process. start gdb myprog debug myprog.cpp gdb myprog.cpp gdb myprog

gdb myprog

After starting the ftp program, what command will copy the file remoteFile from the ftp server to the local computer? put remoteFile cp remoteFile get remoteFile copy remoteFile

get remoteFile

Select the command that provides a versioning control system and is available in a UNIX system. vcontrol version git vcs

git

What is the output of the following statement? false || echo got it true echo got it false got it

got it

The following command will display a digital clock for the X window system. clock -digital display -d clock xclock -digital showclock -d

xclock -digital

The following statement will allow anyone on the remote computer called mycomputer to use the display of the local computer. display +mycomputer allow +mycomputer -display allow display mycomputer xhost +mycomputer

xhost +mycomputer

Select the command that creates the file myFile. create myFile echo this line > myFile create -file myFile echo myFile

echo this line > myFile

Select the text editor. awk perl sed emacs

emacs

Select the command that reads from standard input and write to standard output and to files at the same time. write2 tee tree save

tee

What is the output of the following statement? false && echo got it There is no output got it echo got it false

There is no output

Select the command that gives the number of characters in the file myFile. wc -l myFile wc -c myFile wc -w myFile wc -m myFile

wc -m myFile

Given the following content in the text file : theData 123?4567987\9988788 1111331\?7171679-2892111--34580909099341{3}-8932{4} Which lines will be displayed when you run the following command? grep "[[:digit:]]\{3\}[ ]\?[[:digit:]]\{4\}" theData 123?4567331\?7171 341{3}-8932{4} 788 1111679-28920909099 788 1111 0909099 123?4567987\9988331\?7171

788 1111 0909099

The width and height of a terminal created by the following command xterm -geometry 80x48+20+186 -title me is 20 columns by 186 rows 80 pixels by 48 pixels 20 pixels by 186 pixels 80 columns by 48 rows

80 columns by 48 rows

In vi, how do we save and quit from editing a file? In command mode we type _________________ and hit enter. :xw :wq :sq :wx

:wq

What is a preemptive multitasking operating system? A system that prevents processes to stop when a problem occurs. A system that prevents tasks to run simultaneously. A system that allows processes to cooperate in order to finish a task. A system that allows processes to run at any time. A system that prevents that any one process monopolizes the control. The operating system switch from one process to another.

A system that prevents that any one process monopolizes the control. The operating system switch from one process to another.

Select the CORRECT statement. The pointer is usually the keyboard. A window has the input focus if it is the active window. The desktop or root window is the screen behind the terminal window. It normally covers half of the screen. The X window system uses only 2 buttons.

A window has the input focus if it is the active window.

How do you run a process in the background? Adding $ at the end of the command (program) Adding % at the end of the command (program) Adding & at the end of the command (program) Adding * at the end of the command (program) Adding ^ at the end of the command (program)

Adding & at the end of the command (program)

What is the UNIX Shell? An interactive command interpreter. A powerful programming language. A principal system utility program. All the above.

All of the above.

What does the following command do? cd ../dir3 It changes the date for dir3 It copies current directory to dir3, which is under the parent directory It changes the current working directory to dir3, which is under the parent directory. It displays where the dir3 is located. It changes the current working directory to dir3, which is under the current directory.

It changes the current working directory to dir3, which is under the parent directory.

What is the output of the following command, where mydata is a file: awk 'NR == 3, NR == 5' mydata It displays lines 3 and 5 from the file mydata. It displays line 5 from the file mydata. It displays lines 3, 4 and 5 from the file mydata. It displays line 3 from the file mydata.

It displays lines 3, 4 and 5 from the file mydata.

What does the following command do? chmod -R 755 ./mydirectory It removes the string 755 from ./mydirectory It grants permissions recursively to the folder ./mydirectory and its contents. For the user gives read and execute permissions; and for the group and others gives read, write and execute permissions. It grants permissions recursively to the folder ./mydirectory and its contents. For the user gives read permission; and for the group and others gives read, write and execute permissions. It grants permissions recursively to the folder ./mydirectory and its contents. For the user gives read, write and execute permissions; and for the group and others gives read and execute permissions. It grants permissions recursively to the folder ./mydirectory and its contents. For the user, group and others gives read, write and execute permissions.

It grants permissions recursively to the folder ./mydirectory and its contents. For the user gives read, write and execute permissions; and for the group and others gives read and execute permissions.

What are the characteristics of the UNIX system? It was conceived to be used in single computers and isolated from the network. It is a multiuser, multitasking, secure, stable, networking ready operating system It is an operating system that is not stable and needs continuous updates. It is a single user dynamic operating system. It is a multitasking operating system that can be used by at most 2 users.

It is a multiuser, multitasking, secure, stable, networking ready operating system

What is a cooperative multitasking system? It is a system in which processes cooperate to finish a task. It is a system in which processes run at the control of the operating system. It is a system in which processes never gives up the control voluntarily. It is a system that prevents that any one process monopolizes the control. It is a system in which each process operates at its will, and then gives the control voluntarily.

It is a system in which each process operates at its will, and then gives the control voluntarily.

What is not a characteristic of an operating system? It provides means for users to communicate with the computer. It organizes files. It is used as word processor. It provides means for users to communicate with other application software. Set of programs that coordinates all activities among computer hardware devices.

It is used as word processor.

If the current directory contains the folder folder1 and the files file1 and file2. What is the effect of the command: mv file1 folder2 It gives an error because there is no folder2 It creates folder2 and moves file1 to folder2 It renames file1 to folder2 It removes file1 from the current directory

It renames file1 to folder2

What is the output of the following command? time myprog It runs myprog and reports user, system and elapsed times. It displays when myprog was created. None of the above. It schedules myprog to be run in a later time. It gives the current time and then runs myprog.

It runs myprog and reports user, system and elapsed times.

Who created the UNIX operating system? Dennis Ritchie Western Electric Ken Thompson Multics John McCarthy

Ken Thompson

In 1991, L. Torvalds created a UNIX-like operating system. What is the name of that operating system? OS X UNIX LINUX MINIX SunOS

Linux

What does the command: ls -t do? Lists the files in the long format with detailed information. Lists the top five files by size. Lists all files including those starting with . . Lists files names sorted by their modification time with the most recently changed first.

Lists files names sorted by their modification time with the most recently changed first.

What is the output of the following sequence of statements: me=Luis echo $me $me echo Luis echo me Luis

Luis

Select the device that is NOT used for adding a computer to the network with twisted pair cables. Router Hub Switch Modem

Modem

Suppose that the current directory contains the following files: ch1 ch2 ch3 ch4 abc ab.c ch3.a 33.doc the command ls ch* will list the following files: ch3 ch3.a ch3.a ch1 ch2 ch1 ch2 ch3 ch4 ch1 ch2 ch3 ch4 ch3.a

ch1 ch2 ch3 ch4 ch3.a

Select the statement that is NOT correct. A program is a set of instructions given to a computer in order to perform a task. Only one process per program is allowed in a UNIX system. To perform complicated tasks, it is necessary to run a set of programs. A process is a program running. It is possible to have one program and many processes. Most UNIX system programs perform just one single function.

Only one process per program is allowed in a UNIX system.

What is the action of the following command? ps -A Prints all post script files in the current folder. Prints all files that start their names with A. Prints all processes started by the user. Prints all processes currently running in the UNIX system.

Prints all processes currently running in the UNIX system.

Select the statement that is FALSE. The X Window System is a networked, device-independent system. The X server is a program with display capabilities. The X client is an application running (displaying in an X window) possibly on another computer. Requests are sent by the X server to the X client to do things like draw lines.

Requests are sent by the X server to the X client to do things like draw lines.

What does the following command do? scp file1 file2 Start a concurrent process from file1 and places in file2. Securely prints both file1 and file2. Prints file1 after file2 on the screen. Synchronizes file1 with file2. Securely copies file1 into file2.

Securely copies file1 into file2.

What is the Shell in a UNIX operating system? The Shell is a word processor. The Shell is a folder that is located in the root folder. The Shell is a command interpreter (Interactive program that executes command scripts). The Shell helps to print documents on a printer. The Shell is used to install the UNIX operating system.

The Shell is a command interpreter (Interactive program that executes command scripts).

If the following awk command is given in a shell script, what is the file that it will read? awk '{ if( $5 > 10000 ) n++; }' $* The file named input in the current directory. The first file listed in the current directory. It will not read any file. The file that is passed as argument for the script in the command line.

The file that is passed as argument for the script in the command line.

Select the correct statement. The kernel in a UNIX operating system contains functions that are required occasionally. The kernel in a UNIX operating system contains only one function (booting the system). The kernel in a UNIX operating system contains functions that are required constantly. The kernel in a UNIX operating system contains functions that never are used. The kernel in a UNIX operating system contains a set of utilities.

The kernel in a UNIX operating system contains functions that are required constantly.

What is the value that is stored in the awk's build-in variable NR? The total number of records. The number of records read so far. The number of records pending to be read. The number of records that are non-readable.

The number of records read so far.

Select the statement that is NOT correct. The first word in a shell command is actually a command and the rest are arguments. The shell will know that an argument is a file or a folder. A semicolon (;) is used to separate commands, it is called the command terminator. Shell commands are sequence of words separated by blanks, spaces or tabs.

The shell will know that an argument is a file or a folder.

What are network protocols? They are rules for exchanging messages between two or more computers. They are rules for setting up connections between two web servers. They are rules for exchanging emails between two computers. They are rules for connecting two o more computers using coaxial cables.

They are rules for exchanging messages between two or more computers.

Select the INCORRECT statement. UNIX has a horizontal file system. The UNIX file system is represented by a file system tree. Files are collection of data (bytes) stored on a disk. A file system is the organizational framework for storing files.

UNIX has an horizontal file system.

Choose the correct statement. UNIX is a cooperative multitasking system and MS Windows is a preemptive multitasking system. UNIX is not a preemptive multitasking system. UNIX and MS Windows are cooperative multitasking systems. UNIX is a preemptive multitasking system and MS Windows is a cooperative multitasking system. UNIX is a preemptive and cooperative multitasking system.

UNIX is a preemptive multitasking system and MS Windows is a cooperative multitasking system.

Suppose that the current directory contains the following files: ch1 ch2 ch3 ch4 abc ab.c ch3.a 33.doc the command ls *3* will list the following files: ch3 ch3.a 33.doc ch3 ch3.a 33.doc ch3 ch3.a

ch3 ch3.a 33.doc

Select the command that will install the git version control system in an Ubuntu Linux platform. linux install git ubuntu install git apt-get install git zypper install git

apt-get install git

If the file mydata contains 2 4 6 8 10 12 3 5 Select the awk command that displays the sum of the values per line. awk ' { sum=0; for(i=1;i<=NF;i++){ sum = $i; } print sum } ' mydata awk ' { sum=0; for(i=1;i<=NF;i++){ sum = sum + $i; } END{print sum } ' mydata awk ' { sum=0; for(i=1;i<=NR;i++){ sum = sum + $i; } print sum } ' mydata awk ' { sum=0; for(i=1;i<=NF;i++){ sum = sum + $i; } print sum } ' mydata

awk ' { sum=0; for(i=1;i<=NF;i++){ sum = sum + $i; } print sum } ' mydata

Select the command that gives the following permissions to the file myFile: For the user: permission to read, write and execute. For the group: permission to read and execute only. For others: permission to execute only. chmod 571 myFile chmod 744 myFile chmod 654 myFile chmod 751 myFile

chmod 751 myFile

Give a command to add read and execute permissions (to group and others) to the file myfile located in the directory mydirectory, which is in your current working directory. chmod ago+rwx ./mydirectory/myfile chmod rx+go ./mydirectory/myfile chmod ugo+rx ./mydirectory/myfile chmod u+wx ./mydirectory/myfile chmod go+rx ./mydirectory/myfile

chmod go+rx ./mydirectory/myfile

The vi text editor has the following modes: background and silent modes test and production modes command and text entry (insert) modes graphical and non-graphical modes

command and text entry (insert) modes

The following vi command will delete the characters from the current cursor position to the end of the line. dw dd de d$

d$

Suppose that the current directory contains the following files: dark* light blue* red*red tel *tled the command ls *\* will list the following files: dark* blue* dark* blue* dark* blue* red*red *tled red*red

dark* blue*

Give the command to set the date of the system to April 24, 8:32PM, 2021. setdate 202104242032 date 202104242032 setdate 042420322021 date 042420322021

date 042420322021

Give a command to compare line by line file1 with file2 ignoring case. diff -i file1 file2 diff -c file1 file 2 compare -l file1 file2 diff -line file1 file2 comp -c file1 file2

diff -i file1 file2

Select the statement that will display the number of positional arguments. echo $# echo $$ echo $arg echo $!

echo $#

Select the command that displays the content of the variable SHELL. echo SHELL cat SHELL echo $SHELL echo @SHELL

echo $SHELL

Give a command to display lines from the file /usr/dict/words containing either string abc or string 123 grep "abc \| 123" /usr/dict/words None of the above grep ( abc ) (\| ) (123) /usr/dict/words grep ( abc ) \| (123) /usr/dict/words grep "abc" \| "123" /usr/dict/words

grep "abc \| 123" /usr/dict/words

Select the command that shows on the standard output the first 10 lines of the file myFile. display -10 myFile first10 myFile head myFile tail myFile

head myFile

What is the command to get the Ethernet and IP addresses of a UNIX computer system? ipconfig get ntw etherIP ifconfig

ifconfig

How do you kill the job number 5? kill 5 kill %5 kill job 5 kill -9 5 kill -j 5

kill %5

Select the command that kill/stop/remove the process with ID number 12345 without any complain(warning). kill -a 12345 kill -9 12345 kill -proc 12345 kill -anyway 12345

kill -9 12345

Give the command to kill the process number 2829 without complain (no mercy). kill -x 2829 kill -9 2829 kill! 2829 xkill 2829 kill -nm 2829

kill -9 2829

Select the command that displays the content of a simple text file. ps ls less bash

less

How do you run a makefile ? run makefile make ./makefile make makefile

make

How do you invoke the on-line reference manual for the man command? man command man online man reference man man ls man

man man

Select the command that creates the directory/folder myBooks. mkdir myBooks mkfolder myBooks create -dir myBooks create -folder myBooks

mkdir myBooks

What is the output of the following command? javac myCode.java myCode.o myCode myCode.class a.out

myCode.class

Give the command to run the program myprog while logged out. nohup & myprog nohup myprog & nohup -b myprog myprog & myprog nohup &

nohup myprog &

Enumerate the type of files you can find in a UNIX system. ordinary files, directory files, device files, pseudo-terminal device files and symbolic links. plain text files. executable files with set permissions. programs and scripts. pdf files, doc files, xlsx files, and pictures.

ordinary files, directory files, device files, pseudo-terminal device files and symbolic links.

Give the command to change your password in a UNIX system? password -u passwd change password pwd password

passwd

In order to test connectivity and performance the following command will send ICMP (Internet Control Message Protocol) Echo Request message to a remote host www.cnn.com icmp www.cnn.com ping www.cnn.com ping localhost www.cnn.com icmp localhost www.cnn.com

ping www.cnn.com

Select the command that formats the file myFile for printing with line numbers. pr -n myFile format -n myFile pr -numbers myFile print -n myFile

pr -n myFile

What does the following command do? lpr -#2 -Pprinter2 myFile prints on the screen the file myFile numbering the lines. prints on the screen Pprinter2 the file myFile in two columns. prints on the printer printer2 the file myFile numbering the lines. prints on the printer printer2 two copies of the file myFile. prints on the printer Pprinter2 the file myFile in two columns.

prints on the printer printer2 two copies of the file myFile.

What does the following command do? pr -2 file1 None of the above. prints/formats on the screen file1 in two columns. prints/formats on the screen file1 in double space. prints on the printer file1 in double space. prints on the printer two copies of file1.

prints/formats on the screen file1 in two columns.

Give the command to copy the file remoteFile.txt to your folder myFolder located in your home directory at your local computer named anaconda with IP address: 192.45.36.173. The file remoteFile.txt is located in the folder theFolder in the home directory of the user lcuevapa at the remote computer named otorongo with IP address: 195.88.10.123. Enter the command from your local computer. scp ~/myFolder [email protected]:~/theFolder/remoteFile.txt scp [email protected]:~/theFolder/remoteFile.txt ~/myFolder scp [email protected]:~/theFolder/remoteFile.txt ~/myFolder scp ~/myFolder/remoteFile.txt [email protected]:~/theFolder

scp [email protected]:~/theFolder/remoteFile.txt ~/myFolder

Give a command to sort the contents of the file myFile starting at field 2 and ending before field 4. sort f2 f4 myFile sort +1 -3 myfile sort +2 -4 myfile sort 2,4 myFile sort [2-4] myFile

sort +2 -4 myfile

What does the following command do? sort -r myfile1 sorts myfile1 in reverse order. sorts myfile1 removing spaces. sorts myfile1 recursively. sorts myfile1 without considering numerical characters. sorts myfile2 removing tabs.

sorts myfile1 in reverse order.

While a gdb debugging process, what is the command that will allow to step into a function call? go next into step

step

In a long format listing (using ls), if the first character is l, then the file is a(an) ______________________. ordinary file. directory file. symbolic link. block device.

symbolic link.

How do you extract the files from myArchive.tar.gz ? untar myArchive.tar.gz tar -zcvf myArchive.tar.gz tar -zxvf myArchive.tar.gz unzip myArchive.tar.gz unzip -t myArchive.tar.gz

tar -zxvf myArchive.tar.gz

The following command will show the route over the network between two hosts (local host and remote host server2.name.com). It shows all intermediate routers. showroute server1.name.com server2.name.com traceroute server2.name.com route server2.name.com showroute server2.name.com

traceroute server2.name.com

Select the command that lists the current directory contents in a tree-like format up to 2 levels. tree . -L 2 treelist ~ -level 2 tree -current -L 2 tree . -level 2

tree . -L 2


Conjuntos de estudio relacionados

AH3 Exam 3: EOL/Parkinsons NCLEX

View Set

APUSH 1945-present day Unit and Period 7, 8, 9 (Postwar Communism and Present) Alan Brinkley

View Set

Biochemistry Chapter 15 - Translation: Synthesis of Proteins

View Set