Chapter 3 Flashcards
What does man file do?
Determines file type
How do we create a directory with a subdirectory?
Mkdir -p dir/subdir
When working with directories (as opposed to files), which command does not need a recursive flag?
mv
What are the five key flags in the tar command?
- c create archive
- x extract archive
- r append to an archive
- f read from or write to a file
- t list the contents of the archive
How to get a big picture overview of the filesystem?
df -h
How to get a big picture overview of the filesystem?
df -h
How do we create an archive with tar and all the files that are called “file_[smth]?
tar cf archive.tar file_*
How do we add a file to an archive?
tar rf archive.tar
How do we check an archive for a specific file with tar? hint: first display the entire archive and then look for what you need
tar tvf archive.tar | grep extra.txt
t = tail v = verbose
How do we compress a normal archive to a maximum degree?
gzip -9 archive.tar
How do we create a bzip2 archive with tar?
tar cjf archive.tar.bz2
How to create a zip archive?
zip -r archive.zip file1_*
How do we determine number of words in a file?
wc
What does wc do?
It counts words
How can we count the number of lines rather than words in an input file?
wc -l
How do we list the recently used commands starting with cat? (or anything else really, cat si just one example)
!cat
What does the cut command do?
It removes sections from lines of files
What does the cut command do?
It removes sections from lines of files
What’s the basic syntax of reading input from a file?
command < file
What’s the basic syntax of sending input to a file?
command > file
What’s the basic syntax of appending input to a file?
command»_space; file
How do we look for all results that end - END! - with Apple or Ball?
grep -E “Apple$|Ball$”
What do we find when we look for grep -E “Ap*le”
A followed by 0 or more p’s followed by “le”
What’s the difference between looking for “Ap*le” and “Ap+le”?
the plus means 1 or more p’s and the star means 0 or more p’s
What’s the difference between looking for “Ap?le” and “Ap+le”?
question mark means looking for “maybe another p” followed by le;
plus means 1 or more ps
the ? won’t grep apple because we can only keep results with 1 or no p’s (but not 1+)
How do we match an A followed by p through z followed by le?
“Ap[p-z]le”
How to write down all words that end with “x”
x$
How to look for all three-letter words that start with a y or end with a z?
grep -E “^y..$|..z$”
What does the head command do?
Outputs the first 10 lines of a file
What does the tail command do?
Outputs the last 10 lines of a file
How do we go to the top of the file and bottom of the file in vim?
gg to the top and G to the bottom
How do we add line numbers to vim lines?
set nu
How do we switch into the insert mode and insert at the cursor in vim?
i
How do we switch into the insert mode and insert at the start of the line in vim?
I
How do we switch into the insert mode and insert under the current line in vim?
o
How do we write a file in vim?
:w
How do we quit vim?
:q
How do we write and quit?
:wq
How do we find the amount of available storage space on the hardware?
df -h
Where does the CPU information live on a linux machine?
cat /proc/cpuinfo
How do you find out how much RAM is installed?
sudo cat /proc/meminfo
which command displays the total amount of free and used physical and swap mem‐
ory in the system, as well as the buffers and caches used by the ker‐
nel?
free
How to determine the BIOS version?
sudo lshw
how do we start a shell script?
!/bin/bash