Linux Midterm Review 2
30 Questions
2 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

If the current directory is /usr/local/bin, what happens when you execute cd../../sbin/?

  • /usr/local/sbin
  • /usr/sbin (correct)
  • /sbin
  • /local/sbin
  • /usr/bin
  • What happens after executing the command mkdir a b c ; mv a b c in an empty directory?

  • the directories a, b, and c are moved to the directory c
  • the directories a and b are appended to the directory c
  • an error message: mv: target 'c' is not a directory
  • the directories a and b are moved into the directory c (correct)
  • the directories a, b, and c are moved to the current directory
  • What do three dots (...) mean in a manual page SYNOPSIS section?

  • a hidden directory
  • no special meaning
  • something that is repeated (correct)
  • the parent directory
  • something that is optional
  • What is the simplified pathname for /../../var/./a/../../var/b/../../etc/./bar/../a./etc?

    <p>/etc/a</p> Signup and view all the answers

    What is the Linux command name apropos a synonym for?

    <p>man -k</p> Signup and view all the answers

    What happens after this command: cp foo/bar ./foo/../me?

    <p>there is a second copy of the file bar in the file named me</p> Signup and view all the answers

    If the current directory is Assignments, what pathname could you use to change to directory CST8207-19W?

    <p>.../../CST8207-19W</p> Signup and view all the answers

    If you are in directory /home/me and mt is an empty sub-directory, what is true after this command line: touch foo ; mv ./mt/../foo../me/bar?

    <p>the parent directory of mt now contains a file named bar</p> Signup and view all the answers

    What happens when you execute the command mkdir a b c; mv a b c?

    <p>the directories a and b are moved into the directory c</p> Signup and view all the answers

    What is the function of the mv command in Linux?

    <p>to move or rename files and directories</p> Signup and view all the answers

    When you first log in to a Linux system, which directory are you placed in?

    <p>The home directory</p> Signup and view all the answers

    What is the command to search for a pattern inside files?

    <p>fgrep</p> Signup and view all the answers

    If your current directory is /bin, which of the following pathnames is equivalent to the file name /bin/ls?

    <p>ls</p> Signup and view all the answers

    What command creates a directory and all parent directories?

    <p>mkdir -p a/b/c</p> Signup and view all the answers

    What do you do to erase an entire line of typing in the shell?

    <p>type [CTRL-U]</p> Signup and view all the answers

    What is the shell meta-character used to separate multiple separate commands on the same line of typing?

    <p>;</p> Signup and view all the answers

    What is the minimum number of directories in this pathname: /a/b/c/d

    <p>4</p> Signup and view all the answers

    What is the absolute pathname of the Unix/Linux password (account) file?

    <p>/etc/passwd</p> Signup and view all the answers

    What command can you use to delete a directory that isn’t empty?

    <p>rm -r dir</p> Signup and view all the answers

    To indicate End-of-File (no more input) to a program, what do you type?

    <p>[CTRL-D]</p> Signup and view all the answers

    What does a dot (period) that begins a name signify in the output of the command ls -a?

    <p>A name that is hidden.</p> Signup and view all the answers

    If my current directory is /etc, which of these pathnames is equivalent to the file name /etc/passwd?

    <p>../../../etc/./passwd</p> Signup and view all the answers

    To leave a shell and let the terminal window close, what command should be typed?

    <p>exit</p> Signup and view all the answers

    In an empty directory, what happens after this command line: touch a b c ; mv a b c

    <p>an error message: mv: target 'c' is not a directory</p> Signup and view all the answers

    If a shell token with a GLOB pattern contains two slashes, how many slashes can be in each matched pathname?

    <p>exactly two</p> Signup and view all the answers

    If /etc/passwd is a file name, which pathname almost always leads to the same file?

    <p>./../etc/./passwd</p> Signup and view all the answers

    Which command line below does not show any lines from inside the file out?

    <p>wc out</p> Signup and view all the answers

    If my current directory is /home, and my HOME directory is /home/me, which command copies the password file into my HOME directory under the name foo?

    <p>cp me/../../etc/passwd me/foo</p> Signup and view all the answers

    What command displays the sizes of files in the current directory?

    <p>ls -l</p> Signup and view all the answers

    What is the result of this exact command line: cat /foo bar

    <p>the contents of the files /foo and bar will be displayed</p> Signup and view all the answers

    Study Notes

    Linux Command Line Essentials

    • To move up two directories, use cd ../../ (question 81)
    • The mkdir command creates directories, and mv command moves or renames files/directories (question 82)
    • In a manual page SYNOPSIS section, ellipsis (...) means something is repeated (question 83)

    Pathnames and Directories

    • cd ../../sbin/ leads to /usr/sbin (question 81)
    • mkdir a b c ; mv a b c moves directories a and b into directory c (question 82)
    • /../../var/./a/../../var/b/../../etc/./bar/.. simplifies to /etc/bar (question 84)
    • apropos is a synonym for man -k (question 85)

    File Operations

    • cp foo/bar ./foo/../me copies the file foo/bar to me (question 86)
    • mkdir creates directories, and touch creates empty files (question 87)
    • mv foo/bar ./mt/../foo../me/bar moves the file foo/bar to me/bar (question 88)
    • ls -a displays all files, including hidden files with dot (.) prefix (question 89)

    Shell and Utilities

    • To exit a shell, type exit (question 91)
    • man -k compile lists all utilities available for compiling programs (question 99)
    • cat /foo bar displays the contents of files /foo and bar (question 101)

    File Systems and Navigation

    • cd changes the current directory, and pwd displays the current directory (question 104)
    • .. refers to the parent directory (question 105)
    • mkdir -p a/b/c creates directory a/b/c and all parent directories (question 107)

    Shell Shortcuts and Meta-Characters

    • ; is used to separate multiple commands on the same line (question 109)
    • CTRL-U erases an entire line of typing (question 108)
    • a. is used to indicate the current directory (question 110)

    File Management

    • rmdir -r a/b/c removes directory a/b/c and all parent directories (question 107)
    • rm -r dir deletes a directory and all its contents (question 114)
    • del is not a standard Unix/Linux command (question 114)

    Miscellaneous

    • CTRL-D sends an EOF (end-of-file) and takes you back to the command prompt (question 113)
    • cd /home/foo ; mkdir bar ; touch bar/a ; pwd outputs /home/foo (question 116)
    • file command determines the type of a file or directory (question 119)
    • TAB key can be used to complete commands or file names in bash (question 120)

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge of Unix command line navigation and file management with these questions.

    More Like This

    Use Quizgecko on...
    Browser
    Browser