Podcast
Questions and Answers
Which of the following is not an absolute pathname?
Which of the following is not an absolute pathname?
- $HOME/foo
- ~/foo
- /foo
- foo (correct)
What command copies the password file into your HOME directory under the name foo?
What command copies the password file into your HOME directory under the name foo?
- cp ../home/me/../etc/passwd ./me/./foo
- cp ./me/../etc/passwd ../home/me/foo
- cp ../etc/passwd ./me/foo (correct)
- cp ../etc/passwd ../me/foo
What is the Linux command to rename a single file or directory?
What is the Linux command to rename a single file or directory?
- rm
- mv (correct)
- chname
- move
What is the basename of the pathname a/b/c?
What is the basename of the pathname a/b/c?
Which of the following commands always returns you to your account HOME directory?
Which of the following commands always returns you to your account HOME directory?
What is the result of the command 'cp foo bar' in a directory that contains only the file foo?
What is the result of the command 'cp foo bar' in a directory that contains only the file foo?
What is the output of the tree command?
What is the output of the tree command?
What is the output of the find command?
What is the output of the find command?
What happens after the command touch ./foo ; mv ./mt/../foo ../me/bar?
What happens after the command touch ./foo ; mv ./mt/../foo ../me/bar?
What is the simplified pathname for /home/me/../you/../../etc/../home/me/../you/../me/../foo?
What is the simplified pathname for /home/me/../you/../../etc/../home/me/../you/../me/../foo?
What happens if a shell GLOB pattern fails to match anything?
What happens if a shell GLOB pattern fails to match anything?
What happens after the command date > foo/single ; mv foo/single double?
What happens after the command date > foo/single ; mv foo/single double?
What is the purpose of the PS1 shell variable?
What is the purpose of the PS1 shell variable?
What is the result of the command mv foo bar?
What is the result of the command mv foo bar?
Which of the following characters is not a shell GLOB meta-character?
Which of the following characters is not a shell GLOB meta-character?
If /etc/shadow is a file name, which pathname almost always leads to the same file?
If /etc/shadow is a file name, which pathname almost always leads to the same file?
What is the purpose of the .. notation in a pathname?
What is the purpose of the .. notation in a pathname?
What is the result of the command 'echo /foo bar'?
What is the result of the command 'echo /foo bar'?
Which command below is the best way to find a line containing a question mark (?) in the file /etc/passwd?
Which command below is the best way to find a line containing a question mark (?) in the file /etc/passwd?
If /bin/bash is a file name, which pathname almost always leads to the same file?
If /bin/bash is a file name, which pathname almost always leads to the same file?
What is the Unix user name for the Super-User account?
What is the Unix user name for the Super-User account?
If /bin/bash is a file name, which pathname almost always leads to the same file?
If /bin/bash is a file name, which pathname almost always leads to the same file?
What Linux command name copies files?
What Linux command name copies files?
Which of these statements is true about Unix commands?
Which of these statements is true about Unix commands?
What is the basic purpose of a shell?
What is the basic purpose of a shell?
If pig is a sub-directory that contains only the file dog, what happens after this command: mv pig/dog pig/././cat?
If pig is a sub-directory that contains only the file dog, what happens after this command: mv pig/dog pig/././cat?
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?
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?
If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c?
If my current directory is /home, which of these pathnames is equivalent to the pathname /home/a/b/c?
Which command line displays the contents of the Unix passwd file one page at a time?
Which command line displays the contents of the Unix passwd file one page at a time?
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?
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?
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.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Assess your knowledge of Unix/Linux shell commands and pathnames with these challenging questions.