Linux LPI 117-101 # 4 Of 9

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Tobyyy
T
Tobyyy
Community Contributor
Quizzes Created: 10 | Total Attempts: 1,456
| Attempts: 121
SettingsSettings
Please wait...
  • 1/53 Questions

    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).

Please wait...
About This Quiz

This quiz, part of the Linux LPI 117-101 series, focuses on RPM package management commands. It tests skills like verifying package changes, upgrading packages, and querying package information, essential for Linux system administrators.

Linux LPI 117-101 # 4 Of 9 - Quiz

Quiz Preview

  • 2. 

    What 3 letter command will show you the values set by the /etc/profile script file forthe entire system?

    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.

    Rate this question:

  • 3. 

    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.

    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.

    Rate this question:

  • 4. 

    You wish to turn off the shell option that stops you overwriting exisiting files. Typethe command in that will do this including switches.

    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.

    Rate this question:

  • 5. 

    What 3 letter command will show you the values set by the /etc/bashrc script file forthe entire system?

    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.

    Rate this question:

  • 6. 

    What three letter command in Bash will display all environment variables?

    Explanation
    env command displays all environmental variables as well as it's value. Where set is another command displays all shell variables.

    Rate this question:

  • 7. 

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

    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.

    Rate this question:

  • 8. 

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

    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

    Rate this question:

  • 9. 

    You wish to set your shell options so that the output from a redirect will NOToverwrite an existing file. Type the command including switches.

    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.

    Rate this question:

  • 10. 

    What is the name and full path of the file that contains the system wideEnvironment variables and Startup programs?

    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.

    Rate this question:

  • 11. 

    You want to repeat the last command you entered. How would you do this?

    • #

    • !!

    • #l

    • ##

    Correct Answer
    A. !!
    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.

    Rate this question:

  • 12. 

    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.

    Rate this question:

  • 13. 

    You want to repeat a command that began with the letters 'ab'. How would you dothis?

    • !ab

    • List ab

    • #ab

    • Show ab

    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.

    Rate this question:

  • 14. 

    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.

    Rate this question:

  • 15. 

    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).

    Correct Answer
    rpm -F
    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.

    Rate this question:

  • 16. 

    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

    Rate this question:

  • 17. 

    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

    Rate this question:

  • 18. 

    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.

    Rate this question:

  • 19. 

    You want to run three commands one after the other, but don't care what exit theyhad. What command line would do this?

    • Cmd1 cmd2 cmd3

    • Cmd1, cmd2, cmd3

    • Cmd1: cmd2: cmd3

    • Cmd1; cmd2; cmd3

    Correct Answer
    A. 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.

    Rate this question:

  • 20. 

    You want to view a listing of previously entered commands. What command wouldyou use?

    • Hist

    • Histfile

    • Showbuff

    • History

    Correct Answer
    A. History
    Explanation
    history command lists all commands in history. All history commands
    stored in ~/.bash_history file.

    Rate this question:

  • 21. 

    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?

    • Grep a*^b*a myfile

    • Grep .a[^b].a myfile

    • Grep .[a].*.[a] myfile

    • Grep .a*^b..a myfile

    Correct Answer
    A. 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.

    Rate this question:

  • 22. 

    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.

    Rate this question:

  • 23. 

    In order to append the output of ls to a file called bazz, which of the followingcommand lines would you use?

    • Ls > bazz

    • Ls >& bazz

    • Ls &> bazz

    • Ls >> bazz

    Correct Answer
    A. 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.

    Rate this question:

  • 24. 

    What command would execute cmd1 followed by cmd2, regardless of the exit statusof cmd1?

    • Cmd1 cmd2

    • Cmd1 | cmd2

    • Cmd1 ; cmd2

    • Cmd1 && cmd2

    • Cmd1 || cmd2

    Correct Answer
    A. 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.

    Rate this question:

  • 25. 

    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?

    • Rpm -i gthumb-2.2.0.i386.rpm

    • Rpm -ivh gthumb-2.2.0.i386.rpm

    • Rpm -U gthumb-2.2.0.i3S6.rpm

    • Rpm -qu gthumb-2.2.0.i386.rpm

    • Rpm -qiv gthumb-2.2.0.i386.rpm

    Correct Answer
    A. 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.

    Rate this question:

  • 26. 

    Type the command line to check the installed package mypackage for anyconfiguration file changes since install?

    Correct Answer
    rpm -V mypackage
    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

    Rate this question:

  • 27. 

    You want to repeat command number 3 in your history. How would you do this?

    • Repeat 3

    • !3

    • Show 3

    • #3

    Correct Answer
    A. !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.

    Rate this question:

  • 28. 

    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?

    • To type ./game1 rather than game1.

    • To switch the directory /home/anna first.

    • To unset your PATH before running the program.

    • To set execution permissions for the program game1.

    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/

    Rate this question:

  • 29. 

    What is the correct format for a proper command in the shell?

    • Option Argument Command

    • Command Argument Option

    • Command Option Argument

    Correct Answer
    A. 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.

    Rate this question:

  • 30. 

    Which command will print to standard out only the lines that do notbegin with # (pound symbol) in the file foobar?

    • /bin/grep ^# foobar

    • /bin/grep -v ^# foobar

    • /bin/grep #$ foobar

    • /bin/grep -v #$ foobar

    Correct Answer
    A. /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.

    Rate this question:

  • 31. 

    Which of the following will allow both the commands to execute, regardless of theirindividual exit status?

    • Command1 | command2

    • Command1 $ command2

    • Command1 & command2

    • Command1 ; command2

    • Command1 ^ command2

    Correct Answer
    A. 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

    Rate this question:

  • 32. 

    Which keystrokes will move the cursor 3 lines down and 4 characters to the right?

    • 3j4l

    • 3k4m

    • 3h4j

    • 3l4k

    • 3m4k

    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

    Rate this question:

  • 33. 

    In Bash, inserting "1>&2" after a command redirects

    • Standard error to standard input

    • Standard input to standard error

    • Standard output to standard error

    • Standard error to standard output

    • Standard output to standard input

    Correct Answer
    A. 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.

    Rate this question:

  • 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.

    • Shortcut

    • Ln

    • Sudo

    • Link

    • Alias

    Correct Answer
    A. 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.

    Rate this question:

  • 35. 

    What switch is used with the usermod command to change a user's secondary groups?

    • -G

    • -group

    • -d

    • -U

    Correct Answer
    A. -G
    Explanation
    Explanation: When we create the user, by default user belongs to it's private group
    as a primary group. After adding the user into the system, if you want to change:
    usermod -g groupname username
    To make user belongs to secondary group:
    usermod -G groupname username

    Rate this question:

  • 36. 

    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?

    • Export set display=:10; netscape

    • Export set DISPLAY=:0:0; netscape

    • Export set DISPLAY=:0:1; netscape

    • Export set DISPLAY=:1:0; netscape

    Correct Answer
    A. 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.

    Rate this question:

  • 37. 

    Which command will output the exit status of the previous command (a 1 or a 0)?

    • Echo $?

    • Echo $1

    • Echo $EXIT

    • Exitstatus

    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 " $?

    Rate this question:

  • 38. 

    You have to test a new kernel version. Which of the following is thebest way to add a new linux kernel in your system?

    • Rpm -fvh kernel_package

    • Rpm -Uvh kernel_package

    • Rpm -u kernel_package

    • Rpm -u kernel_package && make

    • Rpm -u kernel_package && make

    Correct Answer
    A. 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.

    Rate this question:

  • 39. 

    Which of the following will cause command2 not to execute if command1 fails?

    • Command1 & command2

    • Command1 && command2

    • Command1 || command2

    • Command1 | command2

    • Command1 ; command2

    Correct Answer
    A. 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.

    Rate this question:

  • 40. 

    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:

    • Foo; bar

    • Foo || bar

    • Foo && bar

    • Foo % bar

    Correct Answer
    A. 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.

    Rate this question:

  • 41. 

    What option is used with the useradd command to specify the user's home directory?

    • -d

    • -h

    • -u

    • -a

    Correct Answer
    A. -d
    Explanation
    useradd command is used to add the user in the system. By default it
    creates the user's home directory in /home if you want to specify the user's home
    directory in different location use the -d and name of directory with path.
    Example:
    useradd -d /var/user1 user1
    useradd -s /bin/sh user1 : Sets the sh shell as default shell to user user1
    After adding the user use the usermod command to change the user's home directory,
    login shell, account lock, account unlock etc.

    Rate this question:

  • 42. 

    How can you execute two commands, the second one being executed only if the firstreturns a nonzero (program execution failed) exit status?

    • Command1 || command2

    • Command1 && command2

    • Command1 $$ command2

    • Command1 @@ command2

    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.

    Rate this question:

  • 43. 

    Which command will print line numbers before each line in a file?

    • Ln

    • Nl

    • Cat -n

    • Numline

    Correct Answer
    A. 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

    Rate this question:

  • 44. 

    You are adding a new user. You want to create the user's home directory only if thedirectory does not exist. Which of the following would accomplish this?

    • Useradd -m

    • Useradd -h -y

    • Useradd -u

    • Useradd -h

    Correct Answer
    A. Useradd -m
    Explanation
    When we issue the useradd command, it creates the user by creating
    the user's home directory into /home.
    If you create the user's home directory into different location:
    useradd -d directory username
    If you want to check whether user's directory is already created or not :
    useradd -m

    Rate this question:

  • 45. 

    You want to preview where the package file,apache- xml.I386.rpm, will install its files before installing it. Whatcommand do you issue?

    • Rpm -qp apache-xml.i386.rpm

    • Rpm -qv apache-xml.i386.rpm

    • Rpm -ql apache-xml.i386.rpm

    • Rpm -qpl apache-xml.i386.rpm

    Correct Answer
    A. Rpm -qpl apache-xml.i386.rpm
    Explanation
    rpm -qpl apache-xml.i386.rpm

    Rate this question:

  • 46. 

    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?

    • Export DISPLAY=:1.0; mozilla

    • Export DISPLAY=:0.1; mozilla

    • Export SECOND=1; mozilla

    • Export SECOND=2; mozilla

    Correct Answer
    A. 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.

    Rate this question:

  • 47. 

    When a user executes the command "ps ax", what is shown on the console? Chooseall that apply.

    • Process's user-related information

    • Processes without controlling terminals

    • Processes used by the XFree86 System

    • All regular processes

    • Processes on remote machines

    Correct Answer(s)
    A. Processes without controlling terminals
    A. 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

    Rate this question:

  • 48. 

    Which command will allow you to find a specific installed package?

    • Rpm -- list rpmname

    • Rpm -qvl rpmname

    • Rpm rpmname

    • Rpm -qv rpmname

    • Rpm -f rpmname

    Correct Answer
    A. 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

    Rate this question:

  • 49. 

    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?

    • Rpm -qp --changelog screensaver-1.1.i386.rpm

    • Rpm --changelog screensaver-1.1.i386.rpm

    • Rpm -qc screensaver-1.1.i386.rpm

    • Rpm -showchangelog screensaver-1.1.i386.rpm

    Correct Answer
    A. 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.

    Rate this question:

Quiz Review Timeline (Updated): Jul 23, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jul 23, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 02, 2009
    Quiz Created by
    Tobyyy
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.