bash Flashcards
Exit the history search.
ctrl + g
See the previous command in the history.
ctrl + p
See the next command in the history.
ctrl + n
Go to the beginning of the line in bash prompt
ctrl + a
Go to the end of the bash prompt line
ctrl + e
move cursor forward on bash prompt by 1 character
ctrl + f
move cursor backward on bash prompt by 1 character
ctrl + b
deletes forward to end of bash line
ctrl + k
deletes backwards to beginning of bash line
ctrl + u
delete backwards to the start of a word in bash prompt
ctrl + w
delete the character under the cursor in the bash prompt
ctrl + h
paste in the last item that you deleted or killed from the bash prompt, like when you ctrl + w, u, k, h, etc
ctrl + y
count words in a file
wc -w file
count lines in a file
wc -l file
count characters in a file
wc -c file
or
wc -m file … if you want to take multi-byte character sets into account
explain:
cat > trumpet «_space;stop
this will change the terminal to input for the file “trumpet” and let you keep creating new lines of input until you type the word “stop” and press return. pretty cool, but I’m not sure why it works like it does lol
How do you grep search all the files in a directory? (recursively)
grep -r
how do you copy a directory of stuff?
cp -r
show a calendar
cal
show current date
date
show disk usage in human readable format
df -h
f for filesystem? heh
show disk usage of a file/folder but not the folders inside it
du -sh
u for underneath filesystem? heh
show disk usage of a file/folder and the folders inside it
du -h
how do you download a file with curl?
curl –output
how do you download a file with wget and name it what you want
wget -o
how do you download full page with wget
wget
print process id of the current shell
echo $$
print process id of the most recently invoked background job
echo $!
display exit status of last command
echo $?
read a string from input and assign it to a variable you could echo $variable out
read