Absolute Pathname
starts with a slash (/), which represents the root directory. The slash is followed by the name of a file located in the root directory. An absolute pathname can continue, tracing a path through all intermediate directories, to the file identified by the pathname. String all the filenames in the path together, following each directory with a slash (/). This string of filenames is called an absolute pathname because it locates a file absolutely by tracing a path from the root directory to the file.
Relative Pathname
traces a path from the working directory to a file. The pathname is relative to the working directory. Any pathname that does not begin with the root directory (represented by /) or a tilde (~) is a relative pathname
3 ways to return to your home directory
cd ~, cd, cd $HOME
Whatâs the arrangement of directories and files in the unix system?
a tree-like structure called the file system, called a directory tree. At the very top of the file system is a directory called ârootâ which is represented by a â/â. All other files are âdescendantsâ of root.
What directory does it take you to when you first log in?
The home directory.
Whatâs the command that gives helpful information on a utility?
man (eg: âman catâ will display a manual on the cat utility)
What symbol do hidden files in a directory start with?
dot character (.)
Whatâs the command that tells you the current name of the shell?
echo $0 (returns -bash)
Set a variable value in a borne shell. How do you display the variable?
echo $variname
What does echo $PATH display?
Which directories your shell is set to check for executable files. $PATH is the list of said directories.
What is the command and option that lets you see all the meta information of a file?
ls -l filename
Inside a borne shell script, whatâs the symbol used for the PID?
$$
Whatâs the command that can be used to change permission information for a file?
chmod
syntax: chmod a+r filename (makes filename readable to all)
Whatâs the command that copies files?
cp
syntax: cp ogfile copyfile
Whatâs the command that is used to tell the type information of a file?
file
eg: file filename (displays filename: ASCII text)
Whatâs the command used on a file to display one page of information of the file contents at a time?
more or less (less allows you to scroll up, more does not)
eg: cat filename | less
Whatâs the command to make soft links?
ln -s filename linkname
Allows multiple filenames to be linked to a file
Whatâs the command that outputs the contents of a text file?
cat filename
Whatâs the command that searches for patterns in a text file?
grep string filename
Basic redirection syntax.
cat >Â filename
Create a file called filename. Type the desired input and press CTRL+D to finish. The text will be in file filename.
cat < filename
Just cats the content of filename.
What is the command that makes a new subdirectory/directory?
Mkdir dirName
Whatâs the command that removes a file? Moves a file?
rm filename
mv filename newfile
Whatâs the command that displays the information about the users logged into the system?
who
Whatâs the command that deletes a non-empty directory?
rmdir or rm -d
If I touch a file name, and the file name doesn't already exist, does touch create it?
Yes, touch creates an empty file.
If you set the variable value in the shell and you want a program/script to read and display it, what command do you have to do on the variable to make it available to the script?
export
How do you read in a value in a shell prompt?
read
What does the command âfindâ do? find -name?
used to find files and directories and perform subsequent operations on them. It supports searching by file, folder, name, creation date, modification date, owner and permissions.
find -name searches filenames specifically.
What is the command to list all the files in your working directory that start with a dot?
ls -a lists all files including hidden files that start with a dot. do not try ls .* it broke my thing
Metacharacter for pipe?
|
Which key stroke will enter command mode in VIM?
esc
in VIM, which keystroke will allow you to enter editor mode?
i
What mode is VIM in at first?
command mode
Command to write (save) the contents of the files then quit the editor?
esc :wq!
What symbols do commands start with in VIM?
:
Can you chmod a file you donât own?
No
Can you list metadata on files you donât own?
Yes
What is a root?
A user that can do anything (ex: chmod any file)
What does touching an already existing file do? Does it reset itâs permissions?
if the file existed beforehand, touch will not change its permissions, just update its last edited timestamps
What is a token?
What symbol do options start with?
-
Identify commands with 0 arguments.
cd, pwd
What is an example of a built-in command?
echo, cd
How do you do piping?
A pipe is a form of redirection (transfer of standard output to some other destination). Allows you to use 2 commands at once
ex: history | tail
calls history command and tail to display the last 10 executed commands
Whatâs the comments you need on the first line of the script to ensure it gets executed on the bash shell?
#!/bin/bash
What are the 2 metasymbols you have to put at the beginning of a script for it to run correctly?
./
Whatâs the syntax for creating an alias?
alias âsomeAlias=someCommandâ
What does grep do? Syntax?
Identifies line with requested string.
grep âlâ filename
works on directories to search file names
Which file do you save variables, functions, and aliases to so they are available upon log in?
In the ~/.bashrc file
What are the single dot and double dot directory entries?
mkdir automatically adds these 2 entries.
The . is synonymous with the pathname of the-working directory and can be used in its place; the .. is synonymous with the pathname of the parent of the working directory. These entries are hidden because their filenames begin with a period.
num=875
number1=âAdd $numâ
number2=âAdd $numâ
What will echo $number1 and echo $number2 display?
Add 875
Add $num
ls -l info idk just memorize this
chmod symbols (just memorize this too)
Do I have to put symbols in front of a function name to run it or can I just put the name of the function?
Just name of function.
What is the shell metacharacter that matches 0 or more characters?
*
What is the shell metacharacter that matches 1 character?
?
Inside a script, what are the symbols that contain the arguments on the command line to the script?
$1, $2, ⌠, $n for each argument n on the command line