Output Redirection, Regular Expressions Flashcards
What is the command to create a directory?
mkdir
What is the command to remove an empty directory?
rmdir
What is the command to remove a directory with contents
rm -r
What is the command to create a parent directory and subdirectory?
mkdir -p
i.e mkdir -p parent/child
What is the command to create a non existing file/ update the timestamp of an existing file/directory?
touch
i. e touch file
- m modify timestamp to specific date
What is the command to rename a file/directory?
mv
i.e mv oldname newname
What is the command to copy a directory and its contents?
cp -r
-R –recursive
What the command to archive multiple files/directories?
tar -cf archivename file1 file2
- c create -f file
- f must be the last parameter
What is the command to archive and compress multiple files/directories?
tar -cf
-z gzip -j bzip2
What is the command to extract a compressed tar file?
tar -xf
-x extract -f file -C destination
What is the command to list the contents of a tar file without extracting it?
tar -tf
How do you zip compress a file?
zip zipfilename file1 file2
- r recursively on directories
- creates a new compressed file
How do you uncompress a zip file?
unzip
How do you gzip compress a file?
gzip
*directly compresses file in place
How do you uncompress a gzip file?
gunzip
How do you bzip2 compress a file?
bzip2
*directly compresses file in place
How do you uncompress a bzip2 file?
bunzip2
What is the command to view a file will scrolling ability?
less
more
/ - search ? - reverse search
*when command is running
What is the command to view the top of a file?
head
-n number of lines
What is the command to view the last lines of a file?
tail
-f realtime update -n number of lines
Where are the logs stored for authentication attempts to the system?
/var/log/secure
How do you use output redirection to append to a file?
> >
i.e ls»_space; file
How do you use output redirection to overwrite a file?
>
i.e ls > file
How do you use output redirection to redirect only stdout?
1>
1»
How do you use output redirection to redirect only stderr?
2>
2»
What is the command to remove specified text from a file and print specific fields?
cut
- d delimiter -f field
i. e cut file -d ‘ ‘ -f 4-
i. e cut file -d : -f 1,5
What is the command to arrange a file in alphabetical order?
sort
How would you append a blank line to a file?
echo»_space; file
How do you count the number of word in a file?
wc
i. e cat file | wc
i. e wc file
What is the regular expression to search the beginning of a line with matching characters?
i.e grep ^In file
What is the regular expression to search the end of a line with matching characters?
$
i.e grep ing$ file
What is the regular expression to search for a set of characters including an unknown character?
.
i. e grep .ast file
* equivalent of ? in globbing
What is the regular expression to match zero or more preceding characters?
*
i. e grep www* file
* works opposite of globbing wildcard
How do you grep with case insensitivity?
grep -i
How do you input with stdin and output to stdout simultaneously?
tee
i. e date | tee file
- a append
* outputs piped input to a file and prints to shell