1/78
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What do we call the type of path name that begins with a slash?
absolute pathname
Does a relative pathname start from the current working directory (wd)?
YES, it does start from current wd (no slash to start it)
What if you enter a cd command with no arguments?
It takes you to the home directory
What's the organizational arrangement of the directories of files of the UNIX system?
hierarchy
When you login and the prompt comes up, what is the directory called that you are in?
Home
What does cd.. do?
Moves you to the parent directory
What does cd. do?
Keeps you in the current directory
SAMPLE QUESTION:
Given the following directory structure:
/home/user
│── a
│ ├── b
│ │ ├── c
│ │ ├── d
│ ├── e
Starting from /home/user, what will be displayed by the pwd command after executing the following commands?
-cd a
-cd b
-cd d
-pwd
/home/user/a/b/d
SAMPLE QUESTION:
Given the following directory structure:
/home/user
│── a
│ ├── b
│ │ ├── c
│ │ │ ├── d
│ │ │ │ ├── e
│ │ │ │ │ ├── f (Current Directory)
Starting from /home/user/a/b/c/d/e/f, what will be the current working directory after executing the following command?
-cd ../../../../b
-pwd
/home/user/a/b
Identify a command that provides additional helpful information
-help (for built-in commands)
-man (for manual pages)
SAMPLE QUESTION:
Which of the following commands can provide additional information or explanations about other commands?
A) ls
B) cd
C) man
D) pwd
C) man
Hidden files in a directory start with what character?
.
What's the command when you do an echo with a dollar sign ($) that causes the shell you are running to display its name?
echo $0
What command uses man and cp utility and sends the output to a pipeline to less?
man cp | less
--> man cp : Displays the manual (help) page for the cp (copy) command.
--> | : The pipe symbol takes the output of the man cp command and sends it as input to the next command.
--> less : Displays the content of the man cp output one screen at a time, allowing you to scroll through it.
If I have a variable 'total' that I have defined in the shell as equal to 10, which of the following commands will display the value of total?
echo $total
If you type echo $PATH in the bash shell command line, what does the display?
displays the current value of the PATH environment variable
If I have a command 'ls -l myfile', what list of permissions associated with the file 'myfile'?
SAMPLE OUTPUT:
-rw-r--r-- 1 user group 1024 Feb 24 12:34 myfile
command displays files permissions, owner, group, size, and modification date
SAMPLE OUTPUT ANALYSIS:
owner = read and write
group = read
others = read
If your search path does not include the path to a particular program and you try to run that program by typing its name on the command line, what happens?
You will get an error message, "command not found"
In a bash shell script, you can access the process id (PID of the script) with the which environment variable?
echo $$
What's the command that changes permissions information associated with the file?
chmod
This command changes your current directory to the home directory location.
cd ~
This command copies a file, preserving the original and creating an identical copy.
cp
This command displays the classification of a file (also known as the file type).
file
This command displays the text files one screen at a time (or holds it one screen at a time).
less
This command is most commonly used to list all the files that have a certain name in the tree structure below the specified directory.
find
Choose the correct command that makes a link named 'myfilelink' to a file named 'myfile'.
ln myfile myfilelink --> hard link
ln -s myfile myfilelink --> symbolic link
What's the acronym for the command that displays the contents of a text file?
cat
What's the acronym name of the command that searches for a pattern in files?
grep
What command lists the files and subdirectories in a directory?
ls
What's the command for creating a new subdirectory in your current directory?
mkdir
What's the command that will rename or move a file?
mv
What's the command that displays information about users that have logged in?
who
Given the command 'rm mydir', does this command remove the non empty directory 'mydir'?
FALSE
--> 'rm -r directoryname' will remove non empty directories
--> 'rm directoryname' will remove ONLY empty directories
What command removes files?
rm
The following command 'touch myfile' will create the file 'myfile' if it does not exist?
TRUE, the command will create the new file
In the bash shell, the values of all command line arguments (args) are passed to a shell script int eh following shell variable. What is this variable?
$*
In the bash shell, the following command creates the user-defined shell variable called 'name' and initializes it to "johndoe".. Which statement does this?
name="johndoe"
Given the following command 'echo who | more', what does this command do?
Will only display 'who' (no more pages)
--> echo who : This command outputs the string who. It's not executing the who command, but just printing the word who.
--> | (pipe) : The pipe sends the output of the echo who command as input to the next command (more).
--> more : This command displays the input one screen at a time. Since the output from echo who is just a simple string (who), more will display it and immediately exit because the output is only one line.
In the bash shell, you can use the following command to read a line from standard in into a variable, which we are going to call 'word'. What command in the bash shell reads in to a variable from the keyboard?
read word
On the bash shell, the environment variable 'home' contains the absolute path of what directory?
HOME directory
If I do a find command with the -name option, what does it do?
-find /path/to/search -name "file.txt"
finds files by their name, or in other words, allows you to search for files and directories that match a specific name or pattern.
What command line lists all your hidden files in the current directory?
ls .* --> Lists only files and directories that start with a dot (.), including hidden files and special entries (current directory and parent directory)
--> NOTE: ls -a also works but lists ALL files and directories, including hidden ones
A meta character matches 0 or more characters. What is this meta character?
*
What is the meta character symbol on UNIX that matches to 1 character?
?
What's the shell character or symbol that creates a pipe between commands?
pipe symbol --> |
When vim is in edit mode, what keystroke do you enter in order to go to native mode?
escape (esc)
When vim is in native mode, what keystroke do you enter to be able to use the editor?
i
When vim starts up from the shell command, what mode is the editor in?
native mode
In vim native mode, what keystroke do you enter to go into command mode?
:
In vim native mode, the following command writes out the file contents and quits the editor. Which command is this?
:wq! --> Forces the file to be written and then quits Vim. (used when the file is read-only or you don't have write permissions for the file. It forces the save and exit even if Vim warns you that you don't have permission to write the file)
:wq --> Saves the file and quits Vim. (works when you have permission to write the file or if the file is not read-only)
When in vim native mode, the following command deletes the line the cursor is located on. Which command is this?
:dd
The command vim can only open on files that already exist. True or false?
FALSE, vim will create a new file if trying to open an non-existing file
Which of the following displays directories and hidden files?
ls -a
Given the results of an 'ls -l' command on a file, identify the permissions:
- If the first character is a dash '-', what does that first character in the permissions indicate?
the first character indicates file
Given the results of an 'ls -l' command on a file, identify the permissions:
- If the first character is a 'd', what does that first character in the permissions indicate?
the first character indicates directory
SAMPLE QUESTION:
Given the results of an 'ls -l' command on a particular file, identify the permissions that the owner has. Output shown after file is '-rwxr-xr-- 1 user group 1024 Feb 24 12:34 myfile'.
The owner does read, write, and execute permissions
--> First character: File type (- for regular file, d for directory, l for symbolic link)
--> Next three: Owner's permissions (r = read, w = write, x = execute)
--> Middle three: Group's permissions
--> Last three: Others' permissions
SAMPLE QUESTION:
Given the results of an 'ls -l' command on a particular file, identify the group from the file. Output shown after file is '-rwxr-xr-- 1 user1 developers 1024 Feb 18 12:34 myfile'
The group is developers
--> File type: - (Regular file)
--> Owner's permissions: rwx (Read, Write, Execute)
--> Group's permissions: r-x (Read, Execute)
--> Others' permissions: r-- (Read-only)
--> Links: 1 (One hard link)
--> Owner: user1 (The owner of the file)
--> Group: developers (This is the group that the file belongs to)
--> Size: 1024 bytes (File size in bytes)
--> Date: Feb 18 12:34 (Last modification date)
--> File name: myfile (The name of the file)
SAMPLE QUESTION:
Given the 'ls -l' command on a file and the chmod command, what results when the following chmod command is run on the file?
--> Output shown after file is '-rw-r--r-- 1 user1 developers 2048 Feb 18 12:34 myfile'
--> the following command is 'chmod u+x,g-w,o-r myfile'
The updated permissions are '-rwxr----- 1 user1 developers 2048 Feb 18 12:34 myfile'
--> u+x: Add execute (x) permission for the user (owner).
--> g-w: Remove write (w) permission for the group.
--> o-r: Remove read (r) permission for others
--> Owner: rwx (Now has read, write, and execute permissions)
--> Group: r-- (Read-only, write permission removed)
--> Others: --- (Read permission removed)
A user can only use 'ls -l' to see permissions on the files they own. True or false?
FALSE, user can use the command to see the permissions on all files in the directory
The root can modfiy permissions on any directory or file. True or false?
TRUE, root user has unrestricted access
The command 'rmdir' removes or deletes a directory and its files. True or false?
FALSE, rmdir can only remove empty directories
Touching the file that already exists resets the permissions to the default permissions. True or false?
FALSE, only updates the file's access time and modification time without changing its content or permissions
On a command line, each sequence of nonblank characters is called a token or word. True or false?
TRUE, tokens (sequence of nonblank characters) can be commands, options, or arguments
What character symbol do options start with on commands?
-
Pwd is a command that has 0 arguments. True or false?
TRUE, just write pwd
Echo is an example of a builtin command. True or false?
TRUE, echo is implemented directly in the shell itself
the following command 'ls -l lsout' redirects the output of the 'ls -l' command to a file named 'lsout'. True or false?
FALSE, only lists the details of a file called 'lsout'
--> NOTE: to redirect output to a file, use the command 'ls -l > lsout'
What's the comment line that you stick at the first/front of a script file that causes the script to be run by the bash shell?
#!/bin/bash
If you want to run a script in your current working directory, do you have to put './' before the script name?
TRUE, for example, you can run a script called myscript.sh by writing './myscript.sh'
If I have a function that I defined in the shell, how do I run the function?
Run by simply typing the function's name. For example, you can run a function called 'greet' by just typing 'greet' in the command line (also followed by any necessary arguments)
Given the alias command 'alias l='ls -l'' this command sets 'l' as an alias for 'ls -l'. True or false?
TRUE, new the 'ls -l' can be run using 'l' in the bash shell
We cat a file and it produces 'Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday' and then we give the command 'grep myfile myfile t'. Does this command produce the results 'Tuesday/Thursday'?
FALSE, the correct structure for grep is 'grep "pattern" file name', so the correct command would be 'grep T myfile'
Variables, functions, and aliases the are set up in your .bashrc file will exist at login start up. True or false?
TRUE, but they MUST be set up in .bashrc or less they will not appear
If I have a command in the shell of 'echo $HOME', does that display the home directory for the current user? True or false?
TRUE, because $HOME holds the home directory path in its variable
Symbolic links can only link to files. True or false?
FALSE, can point to both files and directories
Only the owner of a file can change a file's permissions with the chmod command. True or false?
FALSE, the root user can change permissions on ANY file
What is a user that can change any file or any directory's permission?
Root user
All variables that you define and use in a script file are global by default. True or false?
FALSE, variables in a script are local unless explicitly exported
Functions created and defined in a current bash shell session will still exist in the next sessions log on after you log off. True or false?
FALSE, functions exist only in the current session unless defined in .bashrc