Linux LPI 117-101 # 5 Of 9

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Tobyyy
T
Tobyyy
Community Contributor
Quizzes Created: 10 | Total Attempts: 1,394
Questions: 57 | Attempts: 168

SettingsSettingsSettings
Linux Quizzes & Trivia

Linux lpi testing


Questions and Answers
  • 1. 

    What switch is used with the useradd command to specify a user's initial group?

    • A.

      -g

    • B.

      -i

    • C.

      -u

    • D.

      -ig

    Correct Answer
    A. -g
    Explanation
    When we create the user it creates the group same username and
    make user belongs to that group as a private group. If you want to chage the private
    group at user creating time:
    useradd -g groupname username

    Rate this question:

  • 2. 

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

    • A.

      -u

    • B.

      -s

    • C.

      -ui

    • D.

      -id

    Correct Answer
    A. -u
    Explanation
    By default 0-499 user id reserved for system user and starts to assign
    from 500 to normal user. To set the user id at useradd command use the -u option.
    Example:
    useradd -u 1000 user1 : Which creates the user user1 having user id 1000.
    You can display user id as well as group id using the id command

    Rate this question:

  • 3. 

    What option is used with the useradd command to specify the user's login shell?

    • A.

      -s

    • B.

      -l

    • C.

      -u

    • D.

      -sh

    Correct Answer
    A. -s
    Explanation
    When we create the user it assign the bash shell to user, to assign the
    different shell use the -s option.
    Example:
    useradd -s /bin/sh user1 : which creates the user user1 by assigning the /bin/sh shell.
    You can check the /etc/passwd file to check the user id, user's private group id, home
    directory and login shell.

    Rate this question:

  • 4. 

    Which of the following can be used to change a user's home directory?

    • A.

      Usermod -d

    • B.

      Usermod -h

    • C.

      Usermod -u

    • D.

      Usermod -c

    Correct Answer
    A. Usermod -d
    Explanation
    To change the user's home directory use the -d option in usermod
    command.
    Example:
    usermod -d /var/user1 user1 : Which sets the home directory of user user1 into the
    /var/user1.
    usermod -s /bin/sh user1 : Which sets the default shell of user user1 sh shell.
    usermod -L user1 : Which locks the user account
    usermod -U user1 : Which unlocks the user account

    Rate this question:

  • 5. 

    You had a contractor come into your company. You originally set his account to expireafter thirty days. You now need to change this. How can you do this?

    • A.

      Usermod -e

    • B.

      Usermod -a

    • C.

      Usermod -x

    • D.

      Usermod -d

    Correct Answer
    A. Usermod -e
    Explanation
    To set the account expire date:
    usermod -e "date" username
    Example: usermod -e "May 20 2006" user1

    Rate this question:

  • 6. 

    You are logged in as user tux1, but now you want to switch users to tux2 with tux2'senvironment. How would you do this?

    • A.

      Su tux2

    • B.

      Su -e tux2

    • C.

      Su - tux2

    • D.

      Su -m tux2

    • E.

      Su -f tux2

    Correct Answer
    C. Su - tux2
    Explanation
    su means switch user. To switch from one user to another user with
    another user's environment and home directory use - option. Here switching to tux2
    , then su - tux2 is answer.

    Rate this question:

  • 7. 

    You logged in as user linux1, but now you want to switch users to linux2 with linux'senvironment. How would you do this?

    • A.

      Su linux2

    • B.

      Su -e linux2

    • C.

      Su - linux2

    • D.

      Su -m linux2

    • E.

      Su -f linux2

    Correct Answer
    C. Su - linux2
    Explanation
    su means switch user. To switch from one user to another user with
    another user's environment and home directory use - option. Here switching to
    linux2 , then su - linux2 is answer.

    Rate this question:

  • 8. 

    Which of these commands would report how many total accounts (including specialaccounts) there are?

    • A.

      Count /etc/passwd

    • B.

      Nl /etc/passwd | head

    • C.

      Wc --users /etc/passwd

    • D.

      Wc --lines /etc/passwd

    • E.

      Expand --lines /etc/passwd

    Correct Answer
    D. Wc --lines /etc/passwd
    Explanation
    wc command displays the number of lines, words and characters.
    wc filename : prints number of lines, words and characters.
    wc -l or --lines filename : prints the number of lines in file.
    wc -w or --words filename : prints the number of words in file.
    wc -c filename : prints the number of characters in file.

    Rate this question:

  • 9. 

    What does the following command do?            cat '$TEST'

    • A.

      Displays a bash syntax error message.

    • B.

      Displays the contents of the file named $TEST if it exists.

    • C.

      Waits for the user to enter text and then echos the text back.

    • D.

      Displays the contents of the file named inside the back quotes.

    • E.

      Displays the contents of the named by the environment variable TEST.

    Correct Answer
    B. Displays the contents of the file named $TEST if it exists.
    Explanation
    Varaible is called the memory location containing the value. In linux
    we can read the value of variable starting by $ symbol at starting of variable name.
    Example: FILENAME=test.txt
    echo $FILENAME : Displays the value of variable FILENAME
    cat $FILENAME : Displays the contents of file of $FILENAME

    Rate this question:

  • 10. 

      file1 and file2 are text files in your local directory.            file1 contains this:            allan            bart            ceasar            file2 contains this:            alicia            beatrice            Cecilia            What would the output of the following command be?            tac file1 file2

    • A.

      Allan/ bart/ ceasar/ alicia/ beatrice/ cecilia

    • B.

      Alicia/ beatrice/ cecilia/ allan/ bart/ ceasar

    • C.

      Alicia/ beatrice/ cecilia/ ceasar/ bart/ allan

    • D.

      Cecilia/ beatrice/ alicia/ ceasar/ bart/ allan

    • E.

      Ceasar/ bart/ allan/ cecilia/ beatrice/ alicia

    Correct Answer
    E. Ceasar/ bart/ allan/ cecilia/ beatrice/ alicia
    Explanation
    tac command concatenate and print files in reverse order.
    Example:
    file1 contains :
    a
    b
    c
    and file2 contains
    1
    2
    3
    if you use tac file1 file2
    Output is like:
    c
    b
    a
    3
    2
    1

    Rate this question:

  • 11. 

    Which of the following would copy the file file1.txt to file2.txt?

    • A.

      Cp file1.txt | file2.txt

    • B.

      Cat file1.txt | file2.txt

    • C.

      Cat file1.txt > file2.txt

    • D.

      Copy file1.txt | file2.txt

    • E.

      Cat | file1.txt | file2.txt

    Correct Answer
    C. Cat file1.txt > file2.txt
    Explanation
    We can redirect the standard output into the file using the redirect (>)
    symbol.
    Example: ls -l >result : Redirects the standard output of ls -l command into the result file.
    Similarly cat redirect the contents of one file into another.
    cat file1 >file2 : cat reads the contents of file1 and creates the new file file2, which
    contains the text of file1.
    Similarly you can append into the existing file using append (>>) symbol.

    Rate this question:

  • 12. 

    What command would help you identify the I/O address range being used by thenetwork card?

    • A.

      Cat /proc/modules

    • B.

      Cat /proc/devices

    • C.

      Cat /proc/meminfo

    • D.

      Cat /io/dma

    • E.

      Cat /proc/ioports

    Correct Answer
    E. Cat /proc/ioports
    Explanation
    /proc is called the virtual file system, which contains the information
    about the running kernel.
    /proc/ioports file contains the I/O address range being used by the network card.
    When you read the file /proc/ioports :
    d800-d8ff : 8139too : Where 8139too is the module of Realtek Ethernet card.

    Rate this question:

  • 13. 

    Type the command will identify the io address range used by a NIC?

    Correct Answer
    cat /proc/ioports
    Explanation
    /proc is called the virtual file system, which contains the information
    about the running kernel.
    /proc/ioports file contains the I/O address range being used by the network card.
    When you read the file /proc/ioports :
    d800-d8ff : 8139too : Where 8139too is the module of Realtek Ethernet card.

    Rate this question:

  • 14. 

     What is the result of the following command?# cat 'echo "$ Certkiller

    • A.

      A syntax error

    • B.

      The value of $ Certkiller

    • C.

      Cat followed by the value of $ Certkiller

    • D.

      Echo followed by the value of $ Certkiller

    • E.

      Echo followed by $ Certkiller

    Correct Answer
    A. A syntax error
    Explanation
    Varaible is called the memory location containing the value. In linux
    we can read the value of variable starting by $ symbol at starting of variable name.
    Example: Certkiller =test.txt
    echo $ Certkiller : Displays the value of variable Certkiller
    cat $ Certkiller : Displays the contents of file of $ Certkiller
    In QUESTION ' is started which is incorrect syntax.

    Rate this question:

  • 15. 

    To convert all uppercase letters in stream to lowercase, pipe the stream into which

    • A.

      Tr A-Z a-z

    • B.

      Tac A-Z a-z

    • C.

      Sed /A-Z a-z

    • D.

      Sed -tolower

    • E.

      Conv [A-Z] [a-z]

    Correct Answer
    A. Tr A-Z a-z
    Explanation
    tr command translate the characters, that is given ranges of
    characters, any time a character in range 1 is found, it is translated into the
    equivalent character in range 2.
    Example:
    tr 'a-z' 'A-Z'

    Rate this question:

  • 16. 

     Which of the following command would most likely be used to output a file inreverse? Choose TWO correct answers.

    • A.

      Tac

    • B.

      Pr

    • C.

      Rev

    • D.

      Sed

    • E.

      Back

    Correct Answer(s)
    A. Tac
    B. Pr
    Explanation
    file1 contains :
    a
    b
    c
    and file2 contains
    1
    2
    3
    if you use tac file1 file2
    Output is like:
    c
    b
    a
    3
    2
    1
    pr command reformat the text for printing.

    Rate this question:

  • 17. 

    You have a file with the following contents:            A. allan            B. bart            C. ceasar            D. alicia            E. beatrice            F. ceciliaWhat single command could you use to list the file contents in reverse order? (Includeonly the command without options or arguments)

    Correct Answer(s)
    tac
    Explanation
    file1 contains :
    a
    b
    c
    and file2 contains
    1
    2
    3
    if you use tac file1 file2
    Output is like:
    c
    b
    a
    3
    2
    1

    Rate this question:

  • 18. 

    You have a file with the following contents:            A. allan            B. bart            C. ceasar            D. alicia            E. beatrice            F. CeciliaWhat single command could you use to list the file contents in reverse order? Pleaseinclude only the command without options or arguments.

    Correct Answer(s)
    tac
    Explanation
    tac command concatenate and print files in reverse order.
    Example:
    file1 contains :
    a
    b
    c
    and file2 contains
    1
    2
    3
    if you use tac file1 file2
    Output is like:
    c
    b
    a
    3
    2
    1

    Rate this question:

  • 19. 

    What command will easily convert tabs in files to spaces?

    • A.

      Convert

    • B.

      Expand

    • C.

      Tr

    • D.

      Sed

    • E.

      None of the above

    Correct Answer
    B. Expand
    Explanation
    The command "expand" can be used to easily convert tabs in files to spaces.

    Rate this question:

  • 20. 

    Which of the following would do the same as the command cat < file1.txt > file2.txt?

    • A.

      Cat < file1.txt file2.txt

    • B.

      Cat file1.txt >file2.txt

    • C.

      Cat

    • D.

      Cat file 1.txt | file2.txt

    • E.

      Cp file1.txt>file2.txt

    Correct Answer
    B. Cat file1.txt >file2.txt
    Explanation
    cat file1.txt >file2.txt cat command takes input from the file file1 and
    redirect the output into the file file2 which is similar to cat file2.txt.

    Rate this question:

  • 21. 

    Which of the commands will show you only the middle 10 lines of a 30 line text filenamed 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

    Correct Answer
    B. Head -n 20 textfile | tail
    Explanation
    head command displays default 10 lines from the top of file and tail
    displays the default 10 lines from the bottom of file.
    To display the custom number of lines:
    head -n 20 filename
    To displays the contents of file from middle:
    head -n 20 a | tail : displays middle 10 lines
    head -n 30 a | tail : displays middle 10 lines from 20-30.

    Rate this question:

  • 22. 

    What command will show the first 10 lines of a file by default?

    • A.

      Head

    • B.

      Cat

    • C.

      Tac

    • D.

      Nl

    • E.

      Tail

    Correct Answer
    A. Head
    Explanation
    ead command by default displays 10 lines from the top of file and tail
    command by default display 10 lines from the bottom of file.
    head -n or --lines 20 filename : Displays 20 lines from the top of file.

    Rate this question:

  • 23. 

    What command will show the last 10 lines of a file by default?

    • A.

      Tail

    • B.

      Head

    • C.

      Cat

    • D.

      Prstat

    • E.

      Ps

    Correct Answer
    A. Tail
    Explanation
    head command by default displays 10 lines from the top of file and tail
    command by default display 10 lines from the bottom of file.
    tail -n or --lines 20 filename : Displays 20 lines from the top of file.

    Rate this question:

  • 24. 

    Your lead sysadmin has asked you to add a second NIC to a Linux machine.Which of the following commands would be best to determine which interrupts arecurrently in use on this machine?

    • A.

      Cat /proc/ioports

    • B.

      Cat /proc/interrupts

    • C.

      Cat /proc/memoryinfo

    • D.

      Which interrupts

    • E.

      Tail /var/log/messages

    Correct Answer
    B. Cat /proc/interrupts
    Explanation
    The Linux /proc Directory is a Virtual Filesystem provided by linux
    kernel. /proc contains files and directories that let system administrators and
    programmers access system information.
    The file /proc/interrupts file contains information on interrupts and IRQs. First Ethernet
    card device name is eth0, second Ethernet card device name is eth1 ..., to identify that
    dev will conflict or not , see the contains of file. Already eth0 is appeared or not ?
    Here is the output of /proc/interrupts
    CPU0
    0: 380893 XT-PIC timer
    1: 843 XT-PIC i8042
    2: 0 XT-PIC cascade
    5: 0 XT-PIC uhci_hcd

    8: 1 XT-PIC rtc
    11: 48 XT-PIC Intel 82801AA-ICH, eth0
    14: 6086 XT-PIC ide0
    NMI: 0
    ERR: 0
    For a multi-processor machine, this _le may look slightly different:
    CPU0 CPU1
    0: 1366814704 0 XT-PIC timer
    1: 128 340 IO-APIC-edge keyboard
    2: 0 0 XT-PIC cascade
    8: 0 1 IO-APIC-edge rtc
    12: 5323 5793 IO-APIC-edge PS/2 Mouse
    13: 1 0 XT-PIC fpu
    16: 11184294 15940594 IO-APIC-level Intel EtherExpress Pro
    10/100 Ethernet
    20: 8450043 11120093 IO-APIC-level megaraid
    30: 10432 10722 IO-APIC-level aic7xxx
    31: 23 22 IO-APIC-level aic7xxx
    NMI: 0
    ERR: 0
    Appeared Number of CPU, Number of Ethernet card.

    Rate this question:

  • 25. 

    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

    Correct Answer(s)
    A. Cat file1.txt > file2.txt
    D. Cp file1.txt file2.txt
    Explanation
    We can redirect the standard output into the file using the redirect (>)
    symbol.
    Example: ls -l >result : Redirects the standard output of ls -l command into the result file.
    Similarly cat redirect the contents of one file into another.
    cat file1 >file2 : cat reads the contents of file1 and creates the new file file2, which
    contains the text of file1. cp (copy) command also copy the file.
    Similarly you can append into the existing file using append (>>) symbol.

    Rate this question:

  • 26. 

     What utility would use to remove/display columns from each line of a file?

    • A.

      Pwd

    • B.

      Col

    • C.

      Cut

    • D.

      Tail

    • E.

      Extract

    Correct Answer
    C. Cut
    Explanation
    cut command displays the specific column from the text file.
    Example: cut -d: -f 1 /etc/passwd : Displays the first column from the file /etc/passwd
    where -d means delimeter and -f means field number.

    Rate this question:

  • 27. 

    After executing the following command line, what will be the contents of the filemyout.txt?echo \" Certkiller \" | cat > myout.txt

    • A.

      Certkiller

    • B.

      " Certkiller "

    • C.

      Certkiller cat

    • D.

      The file is empty

    Correct Answer
    B. " Certkiller "
    Explanation
    The contents of myout.txt will be Certkiller .
    echo command displays into the standard output and cat command redirects the output of
    echo into the file myout.txt

    Rate this question:

  • 28. 

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

    Correct Answer
    cut -d : -f 3,7 my Certkiller
    cut -d: -f3,7 my Certkiller
    cut -f3,7 -d: my Certkiller
    cut -f 3,7 -d : my Certkiller
    Explanation
    cut command displays the specific column from the text file.
    Example: cut -d: -f 1 /etc/passwd : Displays the first column from the file /etc/passwd
    where -d means delimeter and -f means field number. To display the contents of multiple
    column, comma separator can use.

    Rate this question:

  • 29. 

    What command returns the first few lines of a given file?

    Correct Answer
    head
    Explanation
    head command displays the few lines from the top of file. By default
    displays 10 lines.
    Example: head myfile
    head -n or --lines 20 myfile

    Rate this question:

  • 30. 

    What command is used to display a file in octal format?

    Correct Answer
    od
    Explanation
    od filename

    Rate this question:

  • 31. 

    You need to replace all instances of the word Certkiller with Certkiller in a file calledfile.txt, and send the output to a file named Certkiller .txt. Type the simplest commandstring to accomplish this.

    Correct Answer
    sed 's/ Certkiller / Certkiller /g' file.txt > Certkiller.txt
    Explanation
    sed also called the stream editor, generally use for find and replace.
    sed 's/ Certkiller / Certkiller /g' file.txt > Certkiller .txt means search the Certkiller and
    replace into Certkiller globally and redirects the replced output into Certkiller .txt file.

    Rate this question:

  • 32. 

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

    Correct Answer
    tail
    Explanation
    tail command displays the few lines from the bottom of file. By default
    it displays the 10 lines.
    Example
    tail filename
    tail -n 30 filename >anotherfilename : Redirects the last 30 lines into another file.

    Rate this question:

  • 33. 

    Which line below would count the total number of lines with the word " Certkiller " in/var/log/maillog?

    • A.

      Wc -l ' Certkiller /var/log/maillog'

    • B.

      For " Certkiller " in [maillog (count) +1]

    • C.

      Wc -l /var/log/maillog | grep ' Certkiller '

    • D.

      Cat /var/log/maillog | grep ' Certkiller ' | wc -l

    • E.

      Cat /var/log/mailog | grep ' Certkiller ' | wc -r

    Correct Answer
    D. Cat /var/log/maillog | grep ' Certkiller ' | wc -l
    Explanation
    grep command displays the lines matching the criteria.
    Example: grep root /etc/passwd : displays all lines having root pattern.
    Wc command counts the lines, words and characters into the file.
    Example: wc filename : displays number of lines, words and characters
    wc -l filename : displays only the number of lines from the file.
    Were Pipe symbol helps to combine the command, which sends the output of first
    command as input to second command.
    Answer D is correct because cat reads the contents of /var/log/maillog and sends the
    standard output to grep command, g rep command filters the output only the lines having
    Certkiller pattern sends to wc which counts the number of lines containing the Certkiller
    pattern.

    Rate this question:

  • 34. 

    To prevent a command run as root from sending both standard out (stdout) andstandard error (stderr) to any terminal or other file or device, which of thefollowing strings should be appended to the command?

    • A.

      >/dev/null

    • B.

      >/dev/null 1>&2

    • C.

      >/dev/null 2>&1

    • D.

      1>&2 >/dev/null

    • E.

      2>&1 >/dev/null

    Correct Answer
    C. >/dev/null 2>&1
    Explanation
    Command> file à Redirect the standard Output to file.
    Command>>file à Append the standard output to file.
    Commandfile à Redirect the standard error to file.
    Command 2>>file àAppend the Standard Error to file.

    Rate this question:

  • 35. 

    Which of the following sed commands will replace all instances of thestring foo with the string foobar changing the file file1.txt in place?

    • A.

      Sed 's/foo/foobar/g' file1.txt

    • B.

      Sed 's/foo/foobar/g' file1.txt > file1.txt

    • C.

      Sed 's/foo/foobar/g' file1.txt | file1.txt

    • D.

      Sed -i 's/foo/foobar/g' file1.txt

    • E.

      Sed -i 's/foo/foobar/g' file1.txt > file1.txt

    Correct Answer
    A. Sed 's/foo/foobar/g' file1.txt
    Explanation
    ed called Stream Editor, usually used to search and replace the string pattern in
    file.
    Syntax: sed 's/whattofind/replacewith/globally' filename
    Example: sed 's/cat/dog/g' test àIt will replace all cat occurance to dog fron test file.

    Rate this question:

  • 36. 

    What command will print a list of usernames (first column) and theircorresponding user id (uid, third column) from /etc/passwd?

    • A.

      Cut -d: -f 1,3 /etc/passwd

    • B.

      Chop -c 1,3 /etc/passwd

    • C.

      Tac 1-3 /etc/passwd

    • D.

      Fmt -u /etc/passwd

    Correct Answer
    A. Cut -d: -f 1,3 /etc/passwd
    Explanation
    Cut command helps to display certain fields value from file. In cut
    command -d option is used to specify the filed delimiter and -f specify the filed
    number.

    Rate this question:

  • 37. 

    What command will remove duplicate lines from a sorted file?

    • A.

      Filter

    • B.

      Trim

    • C.

      Uniq

    • D.

      Wc

    Correct Answer
    C. Uniq
    Explanation
    uniq - remove duplicate lines from a sorted file

    Rate this question:

  • 38. 

    Ýou have a text file with tab-separated values, but your application needs themspace-separated. What command would you use from the Bash shell to achieve this?Please fill in the command only, without any options.

    Correct Answer
    expand
    Explanation
    The expand command is used to convert from tab to space.
    Example: expand -t 2 test à It will convert the tab into two spaces.

    Rate this question:

  • 39. 

    Which command is used to dump files in octal format?

    • A.

      Od

    • B.

      Octdump

    • C.

      Dumpoct

    • D.

      Cat -o

    Correct Answer
    A. Od
    Explanation
    nswer A is correct. od command dump files in octal and other
    formats. Example: od test it will display the all contents of file in octal format.

    Rate this question:

  • 40. 

    You enter the command date +%M. Wat does the output show you?

    • A.

      The current year

    • B.

      The current month

    • C.

      The current hour

    • D.

      The current minute

    • E.

      The current second

    Correct Answer
    D. The current minute
    Explanation
    date command displays the current date and time information as well
    as we can set new date and time to system by supplying -s option.
    To display time: date +%T
    To display Minute: date +%M
    To display Month : date +%m
    %% a literal %
    %a locale's abbreviated weekday name (Sun..Sat)
    %A locale's full weekday name, variable length (Sunday..Saturday)
    %b locale's abbreviated month name (Jan..Dec)
    %B locale's full month name, variable length (January..December)
    %c locale's date and time (Sat Nov 04 12:02:33 EST 1989)
    %C century (year divided by 100 and truncated to an integer)
    [00-99]
    %d day of month (01..31)
    %D date (mm/dd/yy)
    %e day of month, blank padded ( 1..31)
    %F same as %Y-%m-%d
    %g the 2-digit year corresponding to the %V week number
    %G the 4-digit year corresponding to the %V week number
    %h same as %b
    %H hour (00..23)
    %I hour (01..12)
    %j day of year (001..366)
    %k hour ( 0..23)
    %l hour ( 1..12)
    %m month (01..12)
    %M minute (00..59)
    %n a newline
    %N nanoseconds (000000000..999999999)
    %p locale's upper case AM or PM indicator (blank in many locales)
    %P locale's lower case am or pm indicator (blank in many locales)
    %r time, 12-hour (hh:mm:ss [AP]M)
    %R time, 24-hour (hh:mm)
    % seconds since a 00:00:00 1970-01-01 UTCa (a GNU extension)
    %S second (00..60); the 60 is necessary to accommodate a leap sec-
    ond
    %t a horizontal tab
    %T time, 24-hour (hh:mm:ss)
    %u day of week (1..7); 1 represents Monday
    %U week number of year with Sunday as first day of week (00..53)
    %V week number of year with Monday as first day of week (01..53)
    %w day of week (0..6); 0 represents Sunday
    %W week number of year with Monday as first day of week (00..53)
    %x locale's date representation (mm/dd/yy)
    %X locale's time representation (%H:%M:%S)
    %y last two digits of year (00..99)
    %Y year (1970...)
    %z RFC-2822 style numeric timezone (-0500) (a nonstandard extension)
    %Z time zone (e.g., EDT), or nothing if no time zone is determinable

    Rate this question:

  • 41. 

    Which of the following commands can you use to rename a file in Linux?

    • A.

      N

    • B.

      Mv

    • C.

      New

    • D.

      Rm

    Correct Answer
    B. Mv
    Explanation
    mv file1 file2 : Which renames the file1 to file2.
    mv file1 /tmp : Which moves the file file1 into /tmp
    mv file1 /tmp/file2 : Which moves as well as rename the file file1

    Rate this question:

  • 42. 

    What dose the command cd~foo do?

    • A.

      It will take you to the ~foo directory.

    • B.

      It will create the foo directory and change to it

    • C.

      It will take you to the home directory of the user "foo"

    • D.

      It will change the directory to the system foo directory.

    • E.

      It will change to the foo directory in your home directory.

    Correct Answer
    C. It will take you to the home directory of the user "foo"
    Explanation
    ~ symbol represents the user's home directory.
    Example: cat ~/test.txt : Which reads the file resident in user's home directory.
    cd ~/foo : Which enters into the foo directory resident into the user's home directory.

    Rate this question:

  • 43. 

    As root you have navigated to directory /B. You wish to move all of the files anddirectories from directory /A to directory /B. Which of the following options wouldbe the most appropriate command line to execute this task?

    • A.

      Cp /a/*

    • B.

      Mv -f /A/* .

    • C.

      Mv -Rf /a/* .

    • D.

      Cp -f /a/* ..

    • E.

      Cp -rf /A/* /b/

    Correct Answer
    B. Mv -f /A/* .
    Explanation
    mv command is used to move as well as to rename the file.
    Example:
    mv file1 file2 : Which renames the file1 to file2.
    mv file1 /tmp : Which moves the file file1 into /tmp
    mv file1 /tmp/file2 : Which moves as well as rename the file file1
    -f option of mv command is used for forcely move.

    Rate this question:

  • 44. 

    One of the lines in the output from the command 'ls -l/home/pomes' is:drwxrwsr-x 3 devel poms 1024 Oct 22 16:28 fooThe output from the command groups bubba is:bubba : bubba poms actsIf user bubba executes the command touch/home/poms/foo/bar, which TWO of thefollowing must be true?

    • A.

      The group for /home/poms/foo/bar will be poms.

    • B.

      The owner for /home/poms/foo/bar will be devel

    • C.

      The owner for /home/poms/foo/bar will be bubba.

    • D.

      The group for /home/poms/foo/bar will be bubba.

    • E.

      The permissions for /home/poms/foo/bar will allow group read.

    Correct Answer(s)
    A. The group for /home/poms/foo/bar will be poms.
    C. The owner for /home/poms/foo/bar will be bubba.
    Explanation
    See carefully on output that, SGID bit is set on directory and group
    owner of that directory is poms. When SGID bit is set on directory, automatically
    all new creating files/directories group owner is same as parent directory means
    same as foo.
    To set the SGID bit:
    chmod g+s directory
    To Remove the SGID bit:
    chmod g-s directory
    So, when bubba user executes the touch /home/poms/foo/bar the group owner
    automatically poms and owner user is that user who executed the command means
    bubba.

    Rate this question:

  • 45. 

    Which command removes all subdirectories in /tmp, regardless ofwhether 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/*,*

    Correct Answer
    D. Rm -rf /tmp/*
    Explanation
    rm command removes the files/directorires.
    Syntax: rm [options] file/directory
    -f : forcely
    -r : Recursively
    -i : Interactively.
    rm -rf /tmp/* : Which removes all files as well as directories forcely from /tmp directory.

    Rate this question:

  • 46. 

    A directory contains the following files:#lsratas saran jacaw cabal cabinYou issue the command "ls | grep .a[^b]a.", what files are returned by thecommand? Choose all that apply.

    • A.

      Ratas

    • B.

      Jacaw

    • C.

      Saran

    • D.

      Cabal

    • E.

      Cabin

    Correct Answer(s)
    A. Ratas
    B. Jacaw
    C. Saran
    Explanation
    Remember the wildcard Character in string processing
    * : Zero or more character
    . : Any Single Character
    [a-z] : Any single Character from the range
    [^a-z] : Any single Character except from the range
    ls | grep .a[^b]a. means that word having five characters, starting with any character but a
    should be in second position, third position shouldn't be b and fourth character should be
    a and any single character in fifth position.
    grep command is use to process the string with different pattern.

    Rate this question:

  • 47. 

    You need to display all files in the current directory that start with a "a" and endwith 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]

    Correct Answer
    A. Ls a*v
    Explanation
    Wildcard characters :
    * Zero or more character
    ? Any Single Character
    [a-z] Any Single Character from the range
    [^a-z] Any Single Character except from the range
    ls a*v means list all files/directories starting with a character and ended with v character.

    Rate this question:

  • 48. 

    You want to move all files in /dir1 to /dir2 that begin with a and end with v. What isthe 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

    Correct Answer
    A. Mv /dir1/a*v /dir2
    Explanation
    Wildcard characters :
    * Zero or more character
    ? Any Single Character
    [a-z] Any Single Character from the range
    [^a-z] Any Single Character except from the range
    mv /dir1/a*v /dir2 means all the contents of /dir1 starting name with a character and
    ended with v character will move into the /dir2 directory.

    Rate this question:

  • 49. 

    You wish to copy the full contents of the /home/jack directory and all subdirectoriesto the /home/bill directory.Type in the simplest command to do this.

    Correct Answer
    cp -r /home/jack/* /home/bill
    Explanation
    cp command copies files/directorires.
    Syntax: rm [options] file/directory
    -f : forcely
    -r : Recursively
    -i : Interactively.
    cp -r /home/jack/* /home/bill : Which copy all the contents of /home/jack into the
    /home/bill.

    Rate this question:

  • 50. 

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

    Correct Answer
    mv /home/john/* /home/certkiller
    mv /home/john/* /home/certkiller/
    Explanation
    mv command is used to move as well as to rename the file.
    Example:
    mv file1 file2 : Which renames the file1 to file2.
    mv file1 /tmp : Which moves the file file1 into /tmp
    mv file1 /tmp/file2 : Which moves as well as rename the file file1
    mv /home/john/* /home/certkiller : Moves all the contents of /home/john into
    /home/certkiller.

    Rate this question:

Quiz Review Timeline +

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

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 04, 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.