1.
Type the command line to check the installed package mypackage for anyconfiguration file changes since install?
Explanation
Verifying a package compares information about the installed files in
the package with information about the files taken from the package metadata
stored in the rpm database. Among other things, verifying compares the size, MD5
sum, permissions, type, owner and group of each file. Any discrepancies are
displayed.
To verify the package:
rpm -Va or -verify -a packagename
2.
What command on an rpm-based system will upgrade any existing packages on asystem, but not add any packages? Type just the command and switch(es).
Explanation
-U or -F both option is used to upgrade the package. -U option upgrade if
lower version is installed otherwise install the new version package but -F option only
upgrade if lower version package installed. As well as it doesn't add(install) any other
packages.
3.
What command on an rpm-based system will upgrade any existing packages on asystem, and add any packages needed? Type just the command and switch(es).
Explanation
-U or -F both option is used to upgrade the package. -U option upgrade if
lower version is installed otherwise install the new version package but -F option only
upgrade if lower version package installed. As well as it doesn't add(install) any other
packages.
4.
Which command will allow you to find a specific installed package?
Correct Answer
D. Rpm -qv rpmname
Explanation
To query the package whether, package is installed or not :
rpm -qv rpmname
example: rpm -qv ncurses à It shows rpm fullname, version if installed otherwise it will
display package is not installed.
Installed package options:
rpm -qa à Lists all installed packages
rpm -qf filename à Shows owning package
rpm -qi rpmname à General Information of Package
rpm -ql rpmname à Shows all files owning by this package
5.
Which command will print to standard out only the lines that do notbegin with # (pound symbol) in the file foobar?
Correct Answer
B. /bin/grep -v ^# foobar
Explanation
rep stands for general regular processor, used to prints all lines
where pattern matched.
Achor symbol used by String Processor tools like sed, awk and grep
^ Ã Line begins with
$ Ã Line ends with
\word end with
-v option in grep is non matching.
6.
You have an updated RPM called screensaver-1.1.i386. rpm. Youhave version 1.0 installed. Using RPM, how do you view the changelog ofthis file to see if you should install the update?
Correct Answer
B. Rpm --changelog screensaver-1.1.i386.rpm
Explanation
Syntax of rpm command
rpm [options] package
-i à Install
-U Ã Upgrade package if lower version is installed otherwise install the new package.
-F Ã Upgrade package if only lower version is installed.
-l à List all files belongs to package
-p à Package Name
-q à Query
--changelog à Display change information for the package.
7.
You want to preview where the package file,apache- xml.I386.rpm, will install its files before installing it. Whatcommand do you issue?
Correct Answer
D. Rpm -qpl apache-xml.i386.rpm
Explanation
rpm -qpl apache-xml.i386.rpm
8.
You see following output while trying to install an updated package:[root@example pub]# rpm -i gthumb-2.2.0.i386.rpm package gthumb-1.0.1.i386.rpm is already installed.Which command will allow you to install the updated version?
Correct Answer
C. Rpm -U gthumb-2.2.0.i3S6.rpm
Explanation
Syntax of rpm command
rpm [options] package
-i à Install
-U Ã Upgrade package if lower version is installed otherwise install the new package.
-F Ã Upgrade package if only lower version is installed.
9.
You have to test a new kernel version. Which of the following is thebest way to add a new linux kernel in your system?
Correct Answer
B. Rpm -Uvh kernel_package
Explanation
Syntax of rpm command
rpm [options] package
-i à Install
-U Ã Upgrade package if lower version is installed otherwise install the new package.
-F Ã Upgrade package if only lower version is installed.
10.
You want to search the file myfile for all occurrences of a string containing at leastfive characters, where character number 2 and 5 are "a" and character number 3 isNOT "b". Which command would you use?
Correct Answer
B. Grep .a[^b].a myfile
Explanation
String Processing Tools like grep, sed, awk uses wildcard characters.
. Ã Any Single character from the range
[abc] Ã Any Single Character from the set
[a-c] Ã Any Single Character from the Range
[^abc] Ã Any Single Character except from the set.
[^a-c] Ã Any Single Character except from the range.
According to QUESTION, in 2nd and 5th position must be a and in 3rd position not b.
B. . means any single character in first postion., a means a must be in second postions,
[^b] means b must not be in third postion, . means any single character in fourth position
and a in fifth position.
11.
You installed a beta rpm package, but are experiencing some problems with it. Howcan you remove this package?
Correct Answer
D. Rpm -r rpmname
Explanation
To uninstall the package, we use the rpm -ev rpmname or rpm --erase
rpmname
To install package: rpm -ivh rpmname : where -I means install, -v means verbose, -h
means display the Hash marks.
To Upgrade rpm: rpm -Uvh rpmname: where -U means Upgrade.
To Freshen Upgrade : rpm -Fvh rpmname
12.
You wish to set your shell options so that the output from a redirect will NOToverwrite an existing file. Type the command including switches.
Correct Answer
set -o noclobber
Explanation
noclobber global option controls the file overwriting to an existing file.
set -o : Lists all options with on/off status
set -o noclobber : Set on the noclobber and restrict to use the redirect (>) symbol.
set +o noclobber : Set off the noclobber and allow to use the redirect (>) symbol.
13.
You wish to turn off the shell option that stops you overwriting exisiting files. Typethe command in that will do this including switches.
Correct Answer
set +o noclobber
Explanation
noclobber global option controls the file overwriting to an existing file.
set -o : Lists all options with on/off status
set -o noclobber : Set on the noclobber and restrict to use the redirect (>) symbol.
set +o noclobber : Set off the noclobber and allow to use the redirect (>) symbol.
14.
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/binprompt> pwd/home/anna/gamespromt> lsgame1 game2 game3You want to run the program game1, but get the response that it is not found.What did you forget to do?
Correct Answer
A. To type ./game1 rather than game1.
Explanation
/home/anna directory is not set on path. So to execute the program
from the directory not set in path, should execute by givin full path or use the ./ .
If you are in /home/anna use ./ means under current directory.
To set the directory on path
PATH=$PATH:/home/anna/
15.
What is the name and full path of the file that contains the system wideEnvironment variables and Startup programs?
Correct Answer
/etc/profile
Explanation
The /etc/profile shell scrpt is first startup script run when a login shell
is started. It only runs for the login shells, non-login shells do not invoke this script.
This script will set a series of variables including PATH, USER, LOGNAME, MAIL,
HOSTNAME, HISTSIZE, INPUTRC as well calls the startup programs to execute.
16.
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.
Correct Answer
fc
Explanation
fc command allows the history command to edit as well as when you
exit from the edit mode, It will executes the command.
17.
You wish to find out more information on a file e.g. Last accessed, Modifiedchanged, Inode. What is the simplest command that would show this informationfor a file called certkiller?
Correct Answer
stat certkiller
Explanation
stat command displays the meta information of file.
Example:
stat file1
File: file1
Size: 5 Blocks:8 IO Block: 409 regular file
Device: 30ch/780d Inode: 16217 Links: 2
Access: (0644/-rw-r-r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2006-04-16 12:50:44.000000000
Modify: 2006-04-16 12:50:44.000000000
Change: 2006-04-16 12:50:44.000000000
18.
Which command will output the exit status of the previous command (a 1 or a 0)?
Correct Answer
A. Echo $?
Explanation
$? is used to displays to catch the return value. When command
executes it returns 0 or other value. 0 means command is executed successfully and
other value means executed with error.
Example:
function test1()
{
echo "From test1 function"
return 1
}
echo "Retrun Value is " $?
19.
What 3 letter command will show you the values set by the /etc/profile script file forthe entire system?
Correct Answer
env
Explanation
env command is used to display the all environmentall variables as
well as values. Where /etc/profile file is used to set the value into the environmental
variable.
20.
What 3 letter command will show you the values set by the /etc/bashrc script file forthe entire system?
Correct Answer
set
Explanation
set command is used to display the all shell as well as environmental
variables as well as variables values. env command is used to display the all
environmentall variables as well as values.
21.
Your Linux machine has 2 monitors. Your second monitor is configures as thesecond screen of the first display. If you want the "netscape" program to bedisplayed on your second monitor, what command should you use before startingnetscape?
Correct Answer
C. Export set DISPLAY=:0:1; netscape
Explanation
Answer C is correct because:
export set DISPLAY=192.168.0.1:0 : means displays on first monitor of 192.168.0.1
host.
export set DISPLAY=192.168.0.1:1 : means on second monitor of 192.168.0.1 host.
22.
You have a dual-head workstation with two monitors. Your secondary monitor isdefined as the second screen of the first display. You want to start Mozilla anddisplay its window on the second display. Which command line would you use toachieve this?
Correct Answer
C. Export SECOND=1; mozilla
Explanation
Answer C is correct because:
export set DISPLAY=192.168.0.1:0 : means displays on first monitor of 192.168.0.1
host.
export set DISPLAY=192.168.0.1:1 : means on second monitor of 192.168.0.1 host.
23.
Which of the following are executed ONLY during a Login session? Select all thatapply.
Correct Answer(s)
A. /etc/profile
D. ~/.bash_profile
E. ~/.bash_logout
Explanation
Startup scripts: For Login shell
/etc/profile
/etc/profile.d
~/.bash_profile
~/.bashrc
/etc/bashrc
Non-Login Shell
~/.bashrc
/etc/bashrc
/etc/profile.d
/etc/profile, ~/.bash_profile file calls when login shell provided users logged in.
~/.bash_logout: File calls when user logout from the shells, useful for backup, clearing
/tmp etc.
24.
In which file are you likely to find the settings for umask, path, and ulimit on a peruser basis?
Correct Answer
C. ~/.bash_profile
Explanation
~/bash_profile and ~/bashrc file for user specific settings, common to
place variable settings, aliases, commands that places output to the screen, such as
date command, should go in .bash_profile not .bashrc.
25.
In Bash, inserting "1>&2" after a command redirects
Correct Answer
C. Standard output to standard error
Explanation
Statndard Input use < symbol and 0 is the integer value
Standard Output use > symbol and 1 is the integer value
Standard Error use 2> symbol and 2 is the integer value
Example:
find / - name passwd >allresult 1>&2 : Redirects all standard output as well as standard
error to allresult file. Where & is the logical operator.
26.
What three letter command in Bash will display all environment variables?
Correct Answer
env
Explanation
env command displays all environmental variables as well as it's value. Where set is another command displays all shell variables.
27.
Type in just the name of the default file that the command line history is stored infor a logged in user.
Correct Answer
.bash_history
Explanation
One environmental variable named HISTFILE carrying the name of
file to store the history command. By default the history commands stores in
~/bash_histroy.
You can displays using the variable:
echo $HISTFILE
28.
Type just the name of the file in a normal user's home directory that will set theirlocal user environment and startup programs on a default Linux system.
Correct Answer
.bash_profile
Explanation
~/bash_profile and ~/bashrc file for user specific settings, common to
place variable settings, aliases, commands that places output to the screen, such as
date command, should go in .bash_profile not .bashrc.
29.
On a default Linux system, what is the name of the file that sets users aliases andfunctions?
Correct Answer
.bashrc
Explanation
~/bash_profile and ~/bashrc file for user specific settings, common to
place variable settings, aliases, commands that places output to the screen, such as
date command, should go in .bash_profile not .bashrc.
30.
What is the name and full path of the file that contains the system wide aliases andfunctions for the default Linux shell?
Correct Answer
/etc/bashrc
Explanation
/etc/bashrc file sets the system wide aliases, functions as well as default
permission umask value for root as well as non-root user.
31.
What is the name of the file that runs on user logout, usually set to clear the screen?
Correct Answer
.bash_logout
Explanation
~/bash_logout file execute when exiting a login shell, Useful for
running programs automatically at logout ie, clear the screen, make backup files,
delete temporary files, display date and time etc
32.
You are in your home directory. You have made changes to your .bash_profile andincorporated a modified PATH variable. Type in the command that will reread the .bash_profile and set the changes you have made.
Correct Answer
source .bash_profile
.bash_profile
Explanation
~/.bash_profile executes when loggin shell provided users login. So, to
bring the changes made on ~/bash_login either user should re-login or manually
executest the shell scripts file ~/.bash_profile.
33.
When a user executes the command "ps ax", what is shown on the console? Chooseall that apply.
Correct Answer(s)
B. Processes without controlling terminals
D. All regular processes
Explanation
Process are running in two different methods: one is terminal
dependent (means controlled by terminal ) and second is terminal independent
(terminal independent).
ps -a: All process not including not controlled by terminal
ps -x : All process including not controlled by terminal
34.
Which shell built-in command can be used to create a shortcut orpseudonym for a longer command? Assume a modern bourne-like shell,such as bash.
Correct Answer
E. Alias
Explanation
Alias command is used to create like shortcut of long command.
Example: alias back="tar -cvf mytar.tar /root/*", here back will be the alias (shortcut) of
complete "tar -cvf mytar.tar /root/*" command.
35.
Which of the following commands will send output from the programmyapp to both standard output (stdout) and the file file1.log?
Correct Answer
E. All the other alternatives are incorrect.
Explanation
Answer should be like this: set | tee set.out à tee command helps to
redirect the output to file while piping. Here output of set will display as well as
output redirect to set.out file.
36.
In order to append the output of ls to a file called bazz, which of the followingcommand lines would you use?
Correct Answer
D. Ls >> bazz
Explanation
Common Redirection Operator:
Command >file à Redirect the Standard Output of command into file.
Command >>file à Append the Standard Output of command into file.
Command file à Redirect the error message to file.
Command 2>>file à Append the error message to file.
37.
You have two shell scripts, foo and bar. You wish to have bar execute if foo returnsan exit status of 0. Select the correct command:
Correct Answer
C. Foo && bar
Explanation
&& Ã Logical AND Operator
|| Ã Logical OR Operator
! Ã Logical NOT Operator
Correct Answer is C because first tried to execute foo. If foo executes without any error
then executes bar. If any error occurs in foo then exit from command.
38.
Which command will print line numbers before each line in a file?
Correct Answer
C. Cat -n
Explanation
cat command is used to display the contents of file in standard output.
Syntax: cat [option] filename.
Options: -n, -b à Display the line number before each line
-A Ã Show all characters including control characters.
-s à Squeeze multiple adjacent blank lines into one line
39.
You want to repeat command number 3 in your history. How would you do this?
Correct Answer
B. !3
Explanation
bash shell stores the history commands later we can re-execute the
commands from the history.
!! : To repeat the last entered command
!n : To execute the command from history having n numbered.
!-n : To execute the command entered n command back
!c : To execute the command started from history started by c character.
40.
What is the correct format for a proper command in the shell?
Correct Answer
C. Command Option Argument
Explanation
Syntax of executing the command in shell is
command [options] argument
example: ls -l /etc : Where ls is command, -l is option and /etc/ is the parameter or
argument for ls command.
41.
Which of the following will allow both the commands to execute, regardless of theirindividual exit status?
Correct Answer
D. Command1 ; command2
Explanation
; helps to execute the multiple commands in order.
example: clear;ls : First execute clear then ls.
&& is AND logical Operator
|| is OR logical operator
! is NOT logical Operator
42.
Which of the following will cause command2 not to execute if command1 fails?
Correct Answer
B. Command1 && command2
Explanation
&& is the Logical AND operator, whiche means second command
executes if first command excuted successfully.
Example: cat a && ls : if cat a executes successfully then only ls command will execute
other wise exit from the cat command.
43.
How can you execute two commands, the second one being executed only if the firstreturns a nonzero (program execution failed) exit status?
Correct Answer
A. Command1 || command2
Explanation
|| is called the Logical OR Operator, which means either in sense eiher
first or second. If first command exited with error then only second executes.
Example: cat a || ls : if cat command return the error code then start to execut the ls
command.
Remember that if command executes successfully then it returns zero value and if
command executes with error it returns the error code.
44.
You want to repeat the last command you entered. How would you do this?
Correct Answer
B. !!
Explanation
!! re-excutes the last entered command.
!n : executes the command from history n numbered in history list. You can use the
history command to list all history commands.
45.
You want to view a listing of previously entered commands. What command wouldyou use?
Correct Answer
D. History
Explanation
history command lists all commands in history. All history commands
stored in ~/.bash_history file.
46.
You want to run three commands one after the other, but don't care what exit theyhad. What command line would do this?
Correct Answer
D. Cmd1; cmd2; cmd3
Explanation
; symbol helps to separate the multiple commands. It never checks the
retrun value so not like the logical operator.
Example: cat a;ls;date : three commands are combined first executes cat command then ls
and then date.
47.
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 arecmd1 and cmd2.
Correct Answer
cmd1;cmd2
cmd1 ; cmd2
cmd1; cmd2
cmd1 ;cmd2
Explanation
symbol helps to separate the multiple commands. It never checks the
retrun value so not like the logical operator.
Example: cat a;ls;date : three commands are combined first executes cat command then ls
and then date.
48.
What command would execute cmd1 followed by cmd2, regardless of the exit statusof cmd1?
Correct Answer
C. Cmd1 ; cmd2
Explanation
; symbol helps to separate the multiple commands. It never checks the
retrun value so not like the logical operator.
Example: cat a;ls;date : three commands are combined first executes cat command then ls
and then date.
49.
Which keystrokes will move the cursor 3 lines down and 4 characters to the right?
Correct Answer
A. 3j4l
Explanation
Cursor Movement in vi editor:
h : Left
j : down
k : up
l : right
Example: when you press the h key it moves the cursor in left of one character.
3h: moves the cursor in 3 characters left
50.
You want to repeat a command that began with the letters 'ab'. How would you dothis?
Correct Answer
A. !ab
Explanation
bash shell stores the history commands later we can re-execute the
commands from the history.
!! : To repeat the last entered command
!n : To execute the command from history having n numbered.
!-n : To execute the command entered n command back
!c : To execute the command started from history started by c character.