Linux Midterm Review 4
29 Questions
1 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

What command line puts the date in a file in your HOME directory?

  • date >../../../date.txt (correct)
  • date >/../../../home/date.txt
  • date >/HOME/date.txt
  • date >../../../home/date.txt
  • If my current working directory is /home, and my HOME directory is /home/me, which command copies the password file into my HOME directory under the name foo?

  • cp me/../../etc/passwd me/foo (correct)
  • cp ../../etc/passwd /me/foo
  • cp ./me/../etc/passwd /home/me/foo
  • cp ../etc/passwd ../me/foo
  • If foo is a sub-directory that contains only the file bar, what happens after this command: mv foo/./bar foo/././me?

  • the directory foo now contains only a file named me (correct)
  • the command fails because the name me does not exist
  • the directory foo is now empty
  • there is a second copy of the file bar in the file named me
  • In the output of the command ls -a, the one-character name . signifies what?

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

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

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

    What can you do to get back (redo) the last command you typed?

    <p>Use the 'UpArrow' key.</p> Signup and view all the answers

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

    <p>ls bat</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>../passwd</p> Signup and view all the answers

    What does quoting mean on a shell command line?

    <p>turning off the special meaning of shell meta-characters</p> Signup and view all the answers

    How many arguments does the shell pass to this echo command: echo one two three >four five?

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

    Which of the following pathnames almost always leads to the same file named: /bin/ls

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

    In which section of the manual do you find super-user and admin commands?

    <p>Section 8</p> Signup and view all the answers

    What is the correct interpretation of the command: wc -wc wc

    <p>Two command line arguments, one of which contains two bundled options.</p> Signup and view all the answers

    What Linux command displays the contents of a file?

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

    What is true after the command line: touch new ; mv ./mt/../new ../me/old

    <p>The parent directory of mt now has a file named old in it</p> Signup and view all the answers

    What is an operating system?

    <p>A computer program that manages the hardware.</p> Signup and view all the answers

    Which pathname almost always leads to the same file named: /etc/shadow

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

    What option to ls shows inode (index) numbers?

    <p>-i</p> Signup and view all the answers

    If my current working directory is /var, which command copies the password file into directory /var/ian under the name bar?

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

    In which section of the manual do you find standard commands?

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

    If my current directory is /etc, which of these pathnames is equivalent to the pathname /etc/x/y?

    <p>/etc/x/y</p> Signup and view all the answers

    What is the correct syntax to redirect both standard output and standard error into the same output file?

    <p>date 2&gt;&amp;1 &gt;out</p> Signup and view all the answers

    What command can you use to delete an empty directory?

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

    What is the simplified pathname for /../../var/./a/../../var/b/../../etc/./bar/../foo?

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

    The option to ls that shows which names are directories is:

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

    How do I search for the string foo in the text display output from the man command?

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

    Which pathname almost always leads to the same file named /etc/passwd?

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

    What Linux command copies an entire directory?

    <p>cp -r d1 d2</p> Signup and view all the answers

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

    <p>the directory foo is now empty</p> Signup and view all the answers

    Study Notes

    ###UNIX Commands and Pathnames

    • The section of the manual to find standard commands is 1.
    • The pathname /etc/x/y is equivalent to ./etc/x/y when the current directory is /etc.
    • To redirect both standard output and standard error into the same output file, use the syntax date 2&gt;&amp;1 &gt;out.
    • The command to delete an empty directory is rmdir.
    • The pathname /../../var/./a/../../var/b/../../etc/./bar/../foo simplifies to ./etc/foo.
    • The option to ls that shows which names are directories is -l.
    • To search for the string "foo" in the text display output from the man command, use ./foo.
    • The pathname /etc/./etc/../passwd almost always leads to the same file named /etc/passwd.
    • The Linux command that copies an entire directory is cp -r d1 d2.
    • The pathname /usr/./bin/../lib/../../etc/../usr/./lib/../bin/.. simplifies to ./usr/lib.
    • If foo is a sub-directory that contains only the file bar, the command mv ./foo/bar foo/../me will leave the directory foo empty.
    • To copy the password file into the HOME directory under the name foo, use cp ../../etc/passwd ../../../home/me/foo.
    • The pathname ./etc/../passwd almost always leads to the same file named /etc/passwd.

    ###More Pathnames and Commands

    • If the current working directory is /home, the command cp ../../etc/passwd ../../../home/me/foo copies the password file into the HOME directory.
    • The command ls /foo bar displays the names of the pathnames /foo and bar.
    • To redo the last command typed, use the "UpArrow" key.
    • The command ls bat does not show any lines from inside the file bat.
    • If the current directory is /etc, the pathname ../passwd is equivalent to the file name /etc/passwd.

    ###Quoting, Searching, and More Commands

    • Quoting on a shell command line means turning off the special meaning of shell meta-characters.
    • To search for the word "nongraphic" in the man page for ls, type man ls at the shell, then /nongraphic.
    • The bash shell expands a leading tilde (~) in a pathname to be the HOME directory.
    • To make the bash shell complete commands or file names, type the first part of the command or file name and then press [TAB].
    • The command cd /home/dir ; mkdir one ; mkdir two ; pwd outputs /home/dir.

    ###More Commands, Pathnames, and File Manipulation

    • The option to ls that shows hidden names is -a.
    • The command echo one two three &gt;four five passes 4 arguments to the echo command.
    • The command mv ./ian/./foo ./ian/../bar will leave the directory ian empty.
    • The operating system is a computer program that manages the hardware.

    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 commands and pathnames with these questions. Learn how to navigate and use standard commands in Unix.

    More Like This

    Use Quizgecko on...
    Browser
    Browser