RH124 Chapter 3: Managing Files From the Command Line

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which command is used to return to the current user's home directory, assuming the current working directory is /tmp and their home directory is /home/user? A. cd B. cd .. C. cd . D. cd * E. cd /home

A

What is the match for metacharacter [[:lower:]]?

Any lowercase character.

Which directory contains user home directories? A. / B. /home C. /root D. /user

B

What is the Linux directory /usr?

Installed software, shared libraries, include files, and read-only program data. Important subdirectories include: - /usr/bin: User commands. - /usr/sbin: System administration commands. - /usr/local: Locally customized software.

What are the limitations of hard links?

1. Hard links can only be used with regular files. 2. Hard links can only be used if both files are on the same file system.

What are the 4 terms to help describe file-system directory content?

1. Static content remains unchanged until explicitly edited or reconfigured. 2. Dynamic or variable content may be modified or appended by active processes. 3. Persistent content remains after a reboot, like a configuration settings. 4. Runtime content is process- or system-specific content that is delete by a reboot.

What are some uses for variable expansion?

1. You can assign data as a value to a variable using the following syntax: [user@host ~]$ VARIABLENAME=value 2. You can use variable expansion to convert the variable name to its value on the command line. If a string starts with a dollar sign ($), then the shell will try to use the rest of that string as a variable name and replace it with whatever value the variable has. [user@host ~]$ USERNAME=operator [user@host ~]$ echo $USERNAME operator 3. To help avoid mistakes due to other shell expansions, you can put the name of the variable in curly braces, for example ${VARIABLENAME}. [user@host ~]$ USERNAME=operator [user@host ~]$ echo ${USERNAME} operator

Which command will always return you to the working directory used prior to the current working directory? A. cd - B. cd -p C. cd ~ D. cd ..

A

Which directory contains persistent, system-specific configuration data? A. /etc B. /root C. /run D. /usr

A

Which directory contains temporary files? A. /tmp B. /trash C. /run D. /var

A

Which pattern will match only filenames at least three characters in length? A. ???* B. ??? C. \3* D. +++* E. ...*

A

Which pattern will match only filenames beginning with "b"? A. b* B. *b C. *b* D. [!b]*

A

What is an absolute path?

A fully qualified name, specifying the files exact location in the file system hierarchy. - Example: /var/log/messages

What are the two ways to create multiple names that point to the same file?

A hard link to the file or by creating a soft link (or symbolic link) to the file.

What is globbing?

A shell command-parsing operation that expands a wildcard pattern into a list of matching path names. The most powerful name-matching capability.

What is variable expansion?

A variable acts like a named container that can store a value in memory. Variables make it easy to access and modify the stored data either from the command line or within a shell script.

What is pattern matching?

A way of expanding a command line through home directory expansion, string expansion, and variable substitution.

What is the Linux directory /tmp?

A world-writable space for temporary files. Files which have not been accessed, changed, or modified for 10 days are deleted from this directory automatically. Another temporary directory exists, /var/tmp, in which files that have not been accessed, changed, or modified in more than 30 days are deleted automatically.

What is a file-system hierarchy?

All files on a Linux system are stored on file systems, which are organized into a single inverted tree of directories, known as a file-system hierarchy. This tree is inverted because the root of the tree is said to be at the top of the hierarchy, and the branches of directories and subdirectories stretch below the root.

What is a directory?

Also called a folder, contains other files and other subdirectories.

What is the match for metacharacter [[:alnum:]]?

Any alphabetic character or digit.

What is the match for metacharacter [[:alpha:]]?

Any alphabetic character.

What is the match for metacharacter [abc...]?

Any one character in the enclosed class (between the square brackets).

What is the match for metacharacter [!abc...]?

Any one character not in the enclosed class.

What is the match for metacharacter [^abc...]?

Any one character not in the enclosed class.

What is the match for metacharacter [[:punct:]]?

Any printable character not a space or alphanumeric.

What is the match for metacharacter '?'?

Any single character.

What is the match for metacharacter [[:digit:]]?

Any single digit from 0 to 9

What is the match for metacharacter [[:space:]]?

Any single white space character. This may include tabs, newlines, carriage returns, form feeds, or spaces.

What is the match for metacharacter *?

Any string of zero or more characters.

What is the match for metacharacter [[:upper:]]?

Any uppercase character.

Which command displays the absolute path name of the current location? A. cd B. pwd C. ls ~ D. ls -d

B

Which command will always change the working directory to /bin? A. cd bin B. cd /bin C. cd ~bin D. cd -bin

B

Which command will always change the working directory to the parent of the current location? A. cd ~ B. cd .. C. cd ../.. D. cd -u1

B

Which directory is the top of the system's file system hierarchy? A. /etc B. / C. /home/root D. /root

B

Which pattern will match only filenames ending with "b"? A. b* B. *b C. *b* D. [!b]*

B

Which pattern will match only filenames that contain a number? A. *#* B. *[[:digit:]]* C. *[digit]* D. [0-9]

B

What is brace expansion?

Brace expansion is used to generate discretionary strings of characters. Braces contain a comma-separated list of strings, or a sequence expression. The result includes the text preceding or following the brace definition. Brace expansions may be nested, one inside another. Also double-dot syntax (..) expands to a sequence such that {m..p} will expand to m n o p.

Which command will always change the working directory up two levels from the current location? A. cd ~ B. cd ../ C. cd ../.. D. cd -u2

C

Which command will change the working directory to /tmp if the current working directory is /home/student? A. cd tmp B. cd .. C. cd ../../tmp D. cd ~tmp

C

Which directory contains installed software programs and libraries? A. /etc B. /lib C. /usr D. /var

C

Which directory contains non-persistent process runtime data? A. /tmp B. /etc C. /run D. /var

C

Which directory contains regular commands and utilities? A. /commands B. /run C. /usr/bin D. /usr/sbin

C

Which pattern will match all filenames containing a "b"? A. b* B. *b C. * b * D. [!b]*

C

What is command substitution?

Command substitution allows the output of a command to replace the command itself on the command line. Command substitution occurs when a command is enclosed in parentheses, and preceded by a dollar sign ($). The $(command) form can nest multiple command expansions inside each other.

What is the Linux directory /etc?

Configuration files specific to this system.

What is the Linux directory /dev?

Contains special device files that are used by the system to access hardware.

Which command lists files in the current location, using a long format, and including hidden files? A. llong ~ B. ls -a C. ls -l D. ls -al

D

Which directory contains dynamic data, such as for databases and websites? A. /etc B. /run C. /usr D. /var

D

Which directory is the administrative superuser's home directory? A. /etc B. / C. /home/root D. /root

D

Which pattern will match only filenames that begin with an uppercase letter? A. ^?* B. ^* C. [upper]* D. [[:upper:]]* E. [[CAP]]*

D

Which pattern will match only filenames where the first character is not "b"? A. b* B. *b C. *b* D. [!b]*

D

What is a hard link?

Every file starts with a single hard link, from its initial name to the data on the file system. When you create a new hard link to a file, you create another name that points to that same data. The new hard link acts exactly like the original file name. Once created, you cannot tell the difference between the new hard link and the original name of the file. - Example: [user@host ~]$ ln newfile.txt /tmp/newfile-hlink2.txt [user@host ~]$ ls -l newfile.txt /tmp/newfile-hlink2.txt -rw-rw-r--. 2 user user 12 Mar 11 19:19 newfile.txt -rw-rw-r--. 2 user user 12 Mar 11 19:19 /tmp/newfile-hlink2.txt

What is the Linux directory /boot?

Files needed in order to start the boot process.

What is the Linux directory /home?

Home directories are where regular users store their personal data and configuration files.

What is the Linux directory /root?

Home directory for the administrative superuser, root.

What is a relative path?

Like an absolute path, a relative path identifies a unique file, specifying only the path necessary to reach the file from the working directory. Recognizing relative path names follows a simple rule: A path name with anything other than a forward slash as the first character is a relative path name. A user in the /var directory could refer to the message log file relatively as log/messages.

What is the Linux directory /run?

Runtime data for processes started since the last boot. This includes process ID files and lock files, among other things. The contents of this directory are recreated on reboot. This directory consolidates /var/run and /var/lock from earlier versions of Red Hat Enterprise Linux.

What is the echo command?

The echo command can also be used to display the values of brace and variable expansion characters, and others. - Example: [user@host glob]$ ls ~root /root [user@host glob]$ ls ~user /home/user [user@host glob]$ ls ~/glob able alfa baker bravo cast charlie delta dog easy echo [user@host glob]$ echo ~/glob /home/user/glob [user@host glob]$

What is a soft link?

The ln -s command creates a soft link, which is also called a "symbolic link." A soft link is not a regular file, but a special type of file that points to an existing file or directory. Soft links have some advantages over hard links: - They can link two files on different file systems. - They can point to a directory or special file, not just a regular file.

What is a path?

The path of a file or directory specifies its unique file system location. Following a file path traverses one or more named subdirectories, delimited by a forward slash (/), until the destination is reached.

What is tilde expansion?

The tilde character (~), matches the current user's home directory. If it starts a string of characters other than a slash (/), the shell will interpret the string up to that slash as a user name, if one matches, and replace the string with the absolute path to that user's home directory. If no user name matches, then an actual tilde followed by the string of characters will be used instead.

How can you protect arguments from expansion?

To keep the shell from performing shell expansions on parts of your command line, you can quote and escape characters and strings. The backslash (\) is an escape character in the Bash shell. It will protect the character immediately following it from expansion.

What is the Linux directory /var?

Variable data specific to this system that should persist between boots. Files that dynamically change, such as databases, cache directories, log files, printer-spooled documents, and website content may be found under /var.

What is a working or current working directory?

When a user logs in and opens a command window, the initial location is normally the user's home directory. System processes also have an initial directory. Users and processes navigate to other directories as needed; the terms working directory or current working directory refer to their current location.

Are file names case sensitive?

Yes

How do you copy a directory and its content in Linux?

cp -r directory new-directory

How do you copy a file in Linux?

cp file new-file

How do you create a directory in Linux?

mkdir directory The mkdir command will fail with an error if the directory already exists, or if you are trying to create a subdirectory in a directory that does not exist. The -p (parent) option creates missing parent directories for the requested destination. Use the mkdir -p command with caution, because spelling mistakes can create unintended directories without generating error messages.

How do you move or rename a file or directory in Linux?

mv file new-file

How do you remove a directory containing files in Linux?

rm -r directory

How do you remove a file in Linux?

rm file

How do you remove an empty directory in Linux?

rmdir directory


Set pelajaran terkait

Women's Health Menses/EDC/Ovulation

View Set

Elements of Argument InQuizitive

View Set

HK319 Standards/ Skill cues & Skill elements QUIZ 2

View Set

California Real Estate Practices

View Set

Chapter 26- Urinary System (Physiology)

View Set