Preparación para el examen LPI 101

Temas 103.x

Test de repaso para el examen

Créditos y licencia de uso

Coordinación:

Manuel Guillán (xLekOx) lpi@xlekox.org

Maquetación:

Manuel Guillán (xLekOx) lpi@xlekox.org

Versión 1.0 (03-08-2004 – 2:14)

Distribuido por FreeUOC (www.freeuoc.org) bajo licencia: Attribution-NonCommercial-ShareAlike2.0 de commons creative

http://creativecommons.org/licenses/by-nc-sa/2.0/

ÍNDICE

Índice de contenido

Temas 103.x	1

Test de repaso para el examen	1

Créditos y licencia de uso	2

ÍNDICE	3

PREGUNTAS TEST – EXAMEN	4

RESPUESTAS TEST EXAMEN	14

PREGUNTAS TEST – EXAMEN

You want to repeat the last command you entered. How would you do this ?
A. #
B. !!
C. #l
D. ##

You want to view a listing of previously entered commands. What command would you use?
A. hist
B. histfile
C. showbuff
D. history

You want to repeat a command that began with the letters 'ab'. How would you do this?
A. !ab
B. list ab
C. #ab
D. show ab

You want to repeat command number 3 in your history. How would you do this?
A. repeat 3
B. !3
C. show 3
D. #3

When a user executes the command "ps ax", what is shown on the console? Choose atl that apply.
A. Process's user-related information
B. Processes without controlling terminals
C. Processes used by the XFree86 System
D. All regular processes
E. Processes on remote machines

To change all lower case characters in a file to upper case, pick the correct command.
A. tr 'a-z' 'A-Z' file
B. tr [a-z] [A-Z] < file
C. tr "a-z" "A-Z" file
D. tr 'a-z' 'A-Z' < file
E. tr {a-z} {A-Z} > file

Which of the following commands will duplicate the contents of the /A directory in the existing and empty /B directory?
A. mv /A/* /B
B. mv /A/ /B
C. mv /A /B
D. mv /A/* .

What will the command "kill -HUP 1354" do?
A. Kill the process 1354 destructively
B. Kill the process 1354, allowing cleanup of memory
C. Restart the process 1354, re-reading it's config files
D. Restart the process 1354, resetting it's associated modem

You need to have all the output from the executable myprog written to a text log named file1.out. This program must not send any output to the console. Which of the commands listed will accomplish this?
A. myprog > file1.out 2>&1
B. myprog > file1.out 1>&2
C. myprog > file1.out 1> /dev/null
D. myprog 1&2> file1.out
E. myprog 1> /dev/null > file1.out

Which of the following will copy file1.txt to file2.txt? Choose Two.
A. cat file1.txt > file2.txt
B. cat file1.txt | file2.txt
C. cp file1.txt > file2.txt
D. cp file1.txt file2.txt
E. cpio < file1.txt > file2.txt

You need to display all files in the current directory that start with a "a" and end with a "v", regardless of their length or use of delimiters. Choose the best answer.
A. ls a*v
B. ls a.v
C. ls a-v
D. ls [a-v]

Which of the commands will show you only the middle 10 lines of a 30 line text file named textfile?
A. head -n 11-20 textfile
B. head -n 20 textfile | tail
C. tail -n 11-20
D. cat textfile | pr -n 11-20
E. nl -n 11-30 textfile

Which command will display in reverse order a file that is numbered from 1 to End of File?
A. cat file | nl | pr
B. cat file | nl | tac
C. cat file | tac | nl
D. cat file | pr -n | reverse
E. None of the above

What command will show the first 10 lines of a file by default?
A. head
B. cat
C. tac
D. nl
E. tail

What command will show the last 10 lines of a file by default?
A. tail
B. head
C. cat
D. prstat
E. ps

What is the result of the following command? # cat 'echo "$AGUA
A. A syntax error
B. The value of $AGUA
C. cat followed by the value of $AGUA
D. echo followed by the value of $AGUA
E. echo followed by $AGUA

What is the result of the command: # kill 9 13459
A. Kill PID 13459 with a signal 15
B. Kill PID 13459 with a signal 1
C. Kill PID 13459 with a signal 9
D. None of the above

How can you execute two commands, the second one being executed only if the first returns a nonzero (program execution failed) exit status?
A. command1 || command2
B. command1 && command2
C. command1 $$ command2
D. command1 @@ command2

What command will easily convert tabs in files to spaces?
A. convert
B. expand
C. tr
D. sed
E. None of the above

What does the command "foo < bar | foobar" do?
A. foo reads bar as stdin, pipes output to foobar
B. foo and bar are fed to foobar as stdin
C. foo's output is sent to bar, output is written to foobar
D. None of the above

What will the command "cd ~agua do?
A. Changes directory to the user agua's home directory
B. Changes to a directory named agua in the current user's home directory
C. Changes to directory /etc/agua
D. Produces a syntax error
E. None of the above

You want to move all files in /dir1 to /dir2 that begin with a and end with v. What is the correct command to do this?
A. mv /dir1/a*v /dir2
B. mv -r /dir1/a.v /dir2
C. move /dir1/a?v /dir2
D. ls a*v | cp /dir2
E. mv /dir1/[a-v] /dir2

What does the following command's characters do? # cmd > file.out 2>&1
A. Sends the stdout of cmd to file.out
B. Sends the stdout and stderr of cmd to file.out
C. Sends the stderr to the bit bucket and stdout of cmd to file.out
D. None of the above

What two files are used to configure a user's environment that was created with the default options?
A. ~/.profile, ~/.bashrc
B. /etc/profile, /bashrc
C. ~/.bash_profile, ~/.bashrc
D. /etc/.login, ~/.login
E. None of the above

You set a variable's value with the command "export TEST=snuffy" and then after executing the following script file, you type the command "echo $TEST".
scriptfile1
#!/bin/bash
USER=agua
TEST=$USER
What is the variable's value that is returned?
A. snuffy
B. agua
C. empty
D. variable undeclared
E. TEST

A directory contains the following files:
#ls
ratas saran jacaw cabal cabin
You issue the command "ls | grep .a[^b]a.", what files are returned by the command? Choose all that apply.
A. ratas
B. jacaw
C. saran
D. cabal
E. cabin

Which of the following will allow both the commands to execute, regardless of their individual exit status?
A. command1 | command2
B. command1 $ command2
C. command1 & command2
D. command1 ; command2
E. command1 ^ command2

Which of the following will cause command2 not to execute if command1 fails?
A. command1 & command2
B. command1 && command2
C. command1 || command2
D. command1 | command2
E. command1 ; command2

A user needs to search a file for lines that contain the asterisk (*) character. Which grep search command will accomplish this? Choose all that apply.
A. grep \* textfile
B. grep '*' textfile
C. grep "*" textfile
D. grep \<*\> textfile
E. grep "'*'" textfile

What is the correct format for a proper command in the shell?
A. Option Argument Command
B. Command Argument Option
C. Command Option Argument

What is the result of the following command? command > file1.out 2>&1
A. Redirects stderr to file1.out
B. Redirects the stderr to the same location as the stdout.
C. Redirects stdout to the screen and stderr to file.out
D. Redirects all the output to the same location as the stderr

What will the command "kill -HUP 1354" do? Select all the apply
A. The same as kill -9 1354
B. The same as kill 15 1354
C. The same as kill -15 1354
D. The same as kill -SIGHUP 1354
E. The same as kill -1 1354

Which command will output the exit status of the previous command (a 1 or a 0)?
A. echo $?
B. echo $1
C. echo $EXIT
D. exitstatus

Select all the ways of exiting and saving a vi session.
A. :wq
B. :w
C. :ZZ
D. Shift ZZ
E. :x
F. :exit

You have just typed the following three commands and got the following output:
prompt> echo $PATH
/usr/bin:/usr/local/bin:usr/sbin:opt/kde/bin
prompt> pwd
/home/anna/games
promt> ls game1 game2 game3
You want to run the program game1, but get the response that it is not found. What did you forget to do?
A. To type ./game1 rather than game1.
B. To switch the directory /home/anna first.
C. To unset your PATH before running the program.
D. To set execution permissions for the program game1.

You have a file with the following contents: allan bart ceasar alicia beatrice cecilia What single command could you use to list the file contents in reverse order? (Include only the command without options or arguments)

After starting vi to edit an existing text file, you press A (shift +a). This will let you:
A. Insert text at the end of the current file.
B. Insert text at the end of the current sentence.
C. Insert text after your current cursor position.
D. Insert text at the end of the file. E. Insert text at the end of your current paragraph.

You are writing text in vi. Now you want to save your changes and exit. Which two sequence of inputs will accomplish this?
A. esc XX
B. ctrl :w!
C. esc zz
D. esc :wq!
E. ctrl XX

What command could be used to get a hierarchical view of all the processes running on the system without requiring your to provide any switches or options?

You run the following commands:
[user@prompt]$ nice n 1 program1
[user@prompt]$ nice n 5 program2
[user@prompt]$ nice n 10 program3
Which of the program started will have the highest priority?
A. program1
B. program2
C. program3

You want to redirect the last 30 lines of a file to another file. What single command would best fit your needs?

What symbol can be placed at the end of a line to indicate that the command continues on the next line?
A. /
B. \
C. ;
D. |
E. :

Which two programs will allow you to change the priority of a program already running? (Choose two)
A. top
B. nice
C. niceit
D. renice
E. chnice

Which command removes all subdirectories in /tmp, regardless of whether they are non-existent or in use?
A. del /tmp/*
B. m rf /tmp
C. rm Ra /tmp/*
D. rm rf /tmp/*
E. delete /tmp/*,*

The ______ command is typically used to search files for a specified string.

What utility would use to remove/display columns from each line of a file?
A. pwd
B. col
C. cut
D. tail
E. extract

After executing the following command line, what will be the contents of the file myout.txt? echo \”agua salada\” | cat > myout.txt
A. Agua saladA
B. “agua salada”
C. agua salada cat
D. the file is empty

You are writing a script to automate some tasks. You would like to be able to have a log of everything that you see printed to your console, yet you want to be able to see the output on the console as well. What textutils command would typically be used to accomplish this?

Which line below would count the total number of lines with the word testking in /var/log/maillog?
A. wc -l 'agua /var/log/maillog'
B. for “agua” in [maillog (count) +1]
C. wc -l /var/log/maillog | grep 'agua'
D. cat /var/log/maillog | grep 'agua' | wc -l
E. cat /var/log/mailog | grep 'agua' | wc -r

In the command 'agua < salada | aguasalada'.
A. The stdout from the command aguasalada is saved to the file agua.
B. The stdout from the command agua is saved to the file aguasalada.
C. The command aguasalada receives its stdin from the stderr of agua.
D. The command aguasalada receives its stdin from the stdout of agua.
E. The command salada receives its stdin from the contents of the file aguasalada.

To keep a process running after you logged out, you start it with the command:
A. nohup
B. fg
C. live
D. sh

You need to replace all instances of the word aguasalada with AguaSalada in a file called file.txt, and send the output to a file named aguasalada.txt. Type the simplest command string to accomplish this.

Type in the command line that will execute cmd2 regardless of exit status of cmd1. Assume these commands are on the systems PATH and the command names are cmd1 and cmd2.

Type in the VI command line that would open the file mytestfile.txt and line number it?

Type in the variable name that controls the size of the command line history. (Type the variable as it would be used on the command line.)

Type in the Variable name of the variable that stores the location of the command line history file. (Type the variable as it would be used on the command line.)

Type in just the name of the default file that the command line history is stored in for a logged in user.

You are building a system administration shell script and always want a particular line to read a file named agua1.txt that exists in the home directory of every user, regardless of who the user is. What would be the full path including the filename for this file, for the current user?

Type in the file name and full path of the configuration file where you would set the variable HISTSIZE for all users of the system.

Type in just the name of the command that allows you to edit the command history, and will execute the contents of the buffer when exited.

You wish to start a process and run it in the background. The binary executable is mybinary, and it's in your path. Type in the command in its simplest form to do this.

You have backgrounded a job called aguasalada. When you type jobs and the command line it comes back with the following info.
Jobs
[1] Running job1
[2] - Running aguasalada
[3]+ Stopped job5
Type the command any switch(es) that would bring bigtestking to the foreground.

You wish to see the processes that are taking up CPU resources and their PID numbers. Type in the command that would do this including the options/arguments to cause a refresh every second.

The process aguasalada is out of control, and efforts to cleanly stop it fail. You have executed a ps command and it displays the following info
PID TTY TIME CMD
3541 pts/0 10:10:10 aguasalada
3558 pts/0 00:00:00 ps
What command should you type to absolutely stop the runaway process?

You wish to edit the file 'mytextfile' with the VI editor and search for the string 'agua'. Type in the command line to open the file and highlight the first instance of agua, (and any others).

You wish to match instances of the word 'Many' that are at the begining of a line in the vi editor. What is the key combination to do this? Include the character to indicate a search in VI, and type the command as if you were in Command Mode in VI.

You wish to search for lines in VI that end with the string 'happy' Input the keystrokes to achive this, including the vi search character.

You wish to match the character string v2.1 v2.2 v2.3 through to v2.9 within VI. Type the search string to achieve this.

You wish to cut the 3rd and 7th fields from a colon (:) delimited text file called 'agua' and display them on the screen. Type the command that would do this?

You wish to move all files and directories from within /home/john to the directory /home/tessking. Type in the command line that would do this?

You wish to copy the full contents of the /home/tess directory and all subdirectories to the /home/king directory. Type in the simplest command to do this.

Type just the name of the file in a normal user's home directory that will set their local user environment and startup programs on a default Linux system.

On a default Linux system, what is the name of the file that sets users aliases and functions?

What is the name and full path of the file that contains the system wide aliases and functions for the default Linux shell?

What is the name of the file that runs on user logout, usually set to clear the screen?

You are in your home directory. You have made changes to your .bash_profile and incorporated a modified PATH variable. Type in the command that will reread the .bash_profile and set the changes you have made.

You wish to list all files within your current working directory that are of the type ASCII, showing just a single line for each of those files. Type in the command string that would accomplish this.

RESPUESTAS TEST EXAMEN

B

D

A

B

B,D

D

A

C

A

A,D

A

B

B

A

A

A

D

A

B

A

A

A

B

C

A

A,B,C

D

B

A,B,C

C

B

D,E

A

A,D,E

A

tac

B

D

top

A

tail Explanation: exact is: tail *n30 "file name"

B

B,D

D

grep

C

B

tee

D

D

A

sed 's/testking/TestKing/g' file.txt > testking.txt

Answer: cmd1;cmd2
Alternative correct answers:
cmd1 ; cmd2
cmd1; cmd2
cmd1 ;cmd2

vi +"set number" mytestfile.txt
Alternative correct answers:
-vi mytestfile.txt +"set number"
-vi "+set number" mytestfile.txt
-vi mytestfile.txt "+set number"

$HISTSIZE

$HISTFILE

.bash_history

~/testking1.txt
Alternative correct answer: $HOME/testking1.txt

/etc/profile

fc

mybinary &

fg %2

top -d 1
Alternative correct answers: top -d1

kill -9 3541

vi +/agua mytextfile
Alternative correct answer:
vi mytextfile +/agua

/^Many

/happy$

/v2\.[1-9]

cut -d : -f 3,7 agua
Alternative correct answers:
cut -d: -f3,7 agua
cut -f3,7 -d: agua
cut -f 3,7 -d : agua

mv /home/john/* /home/tessking
Alternative correct answer:
mv /home/john/* /home/tessking/

cp -R /home/tess/* /home/king

.bash_profile

.bashrc

/etc/bashrc

.bash_logout

source .bash_profile
Alternative correct answer:
. .bash_profile

file * | grep ASCII
Alternative correct answer: file * | grep -i ascii

Tema 103.3 Administración de archivos

Página 10 de 15

2004-07-21T14:39:00