30 Questions
2 Views
3.6 Stars

Linux Midterm Review 3

Assess your knowledge of Unix/Linux shell commands and pathnames with these challenging questions.

Created by
@LuxuryAbundance
1/30
Find out if you were right!
Create an account to continue playing and access all the benefits such as generating your own quizzes, flashcards and much more!
Quiz Team

Access to a Library of 520,000+ Quizzes & Flashcards

Explore diverse subjects like math, history, science, literature and more in our expanding catalog.

Questions and Answers

Which of the following is not an absolute pathname?

foo

What command copies the password file into your HOME directory under the name foo?

cp ../etc/passwd ./me/foo

What is the Linux command to rename a single file or directory?

mv

What is the basename of the pathname a/b/c?

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

Which of the following commands always returns you to your account HOME directory?

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

What is the result of the command 'cp foo bar' in a directory that contains only the file foo?

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

What is the output of the tree command?

<p>an indented, recursive list of directories and their contents</p> Signup and view all the answers

What is the output of the find command?

<p>a recursive list of pathnames</p> Signup and view all the answers

What happens after the command touch ./foo ; mv ./mt/../foo ../me/bar?

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

What is the simplified pathname for /home/me/../you/../../etc/../home/me/../you/../me/../foo?

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

What happens if a shell GLOB pattern fails to match anything?

<p>the shell passes the pattern unchanged to the command</p> Signup and view all the answers

What happens after the command date > foo/single ; mv foo/single double?

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

What is the purpose of the PS1 shell variable?

<p>to set the shell prompt</p> Signup and view all the answers

What is the result of the command mv foo bar?

<p>foo is renamed to bar</p> Signup and view all the answers

Which of the following characters is not a shell GLOB meta-character?

<h1></h1> Signup and view all the answers

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

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

What is the purpose of the .. notation in a pathname?

<p>to specify the parent directory</p> Signup and view all the answers

What is the result of the command 'echo /foo bar'?

<p>the two text strings /foo and bar will be displayed</p> Signup and view all the answers

Which command below is the best way to find a line containing a question mark (?) in the file /etc/passwd?

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

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

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

What is the Unix user name for the Super-User account?

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

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

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

What Linux command name copies files?

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

Which of these statements is true about Unix commands?

<p>They must be entered in lower-case letters.</p> Signup and view all the answers

What is the basic purpose of a shell?

<p>To find and run commands</p> Signup and view all the answers

If pig is a sub-directory that contains only the file dog, what happens after this command: mv pig/dog pig/././cat?

<p>The directory pig now contains only a file named cat</p> Signup and view all the answers

If I am in a directory named /home/me and mt is an empty sub-directory, what is true after this command line: touch./fil ; mv mt/../fil../me/cat?

<p>The directory ../me now has a file named cat in it</p> Signup and view all the answers

If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c?

<p>../home/a/b/c</p> Signup and view all the answers

Which command line displays the contents of the Unix passwd file one page at a time?

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

If my current working directory is /home, and my HOME directory is /home/foo, which command copies file /bin/ls into my HOME directory under the name xx?

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

Studying That Suits You

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

Quiz Team

Study Notes

Understanding Linux File Paths and Commands

  • A path can be absolute or relative, and it's essential to understand the difference between the two.

Absolute vs. Relative Paths

  • An absolute path always begins with a forward slash (/) and specifies the location of a file or directory from the root directory.
  • A relative path does not begin with a forward slash and specifies the location of a file or directory relative to the current working directory.

Understanding ../ and ./ in Paths

  • The notation ../ refers to the parent directory of the current working directory.
  • The notation ./ refers to the current working directory.

CD Command

  • The command cd /home/.. leads to the parent directory of /home, which is the root directory (/).
  • The command cd ~ leads to the user's home directory.
  • The command cd .. leads to the parent directory of the current working directory.

MV Command

  • The command mv source destination renames or moves the source file to the destination file.
  • The command mv can be used to rename a file or move a file to a different directory.

CP Command

  • The command cp source destination copies the source file to the destination file.
  • The command cp can be used to create a duplicate of a file.

Touch Command

  • The command touch creates a new empty file with the specified name.

MV and CP Commands Example

  • If mt is an empty sub-directory, the command touch ./foo ; mv ./mt/../foo ./mt/../bar renames the file foo to bar in the mt directory.
  • The command mv mt/../foo mt/../bar renames the file foo to bar in the mt directory.

Find Command

  • The find command is used to search for files based on various criteria such as name, size, and modification time.
  • The output of the find command is a recursive list of pathnames.

Glob Pattern

  • A glob pattern is a pattern used to match file names.
  • The character * is a wildcard character in glob patterns that matches any characters.
  • The character ? is a wildcard character in glob patterns that matches any single character.

Shell Variables

  • The shell variable PS1 is used to set the shell prompt.

Unix File System

  • The root directory is the top-most directory in the Unix file system.
  • The home directory is the default directory for a user.
  • The etc directory contains system configuration files.

Users and Permissions

  • The superuser account is the root account.
  • The root user has all privileges and can perform any operation on the system.

Commands

  • The command fgrep is used to search for patterns in a file.
  • The command ls is used to list the files and directories in the current working directory.
  • The command mv is used to rename or move a file.
  • The command cp is used to copy a file.
  • The command touch is used to create a new empty file.

Pathnames

  • The pathname ./etc/../pattern matches the file pattern in the parent directory of the current working directory.
  • The pathname ./etc/./pattern matches the file pattern in the etc directory of the current working directory.

Directory Navigation

  • The command cd can be used to navigate through the directory hierarchy.
  • The command pwd is used to print the current working directory.

File Systems

  • The Unix file system is a hierarchical system of files and directories.
  • The file system is divided into directories and subdirectories.

File Types

  • A directory is a file that contains a list of files and subdirectories.
  • A regular file is a file that contains data.

Unix Concepts

  • The concept of everything is a file means that devices, directories, and files are all represented as files in the Unix system.

Trusted by students at

More Quizzes Like This

Quiz sobre els fonaments de Linux
10 questions
Cron
5 questions

Cron

FairBinary avatar
FairBinary
CEST-CE Term_2 GNU/LINUX (Week 6)
40 questions
Use Quizgecko on...
Browser
Browser