Udemy Linux Flashcards
Open Terminal
Ctrl + Alt + D
Close Terminal
Ctrl + D
echo
Prints out what you give it
cal
Calendar
date
today’s date & time
clear
clear screen
history
all previous commands
to run command in history
! + line #
!!
run most recent command
history -c; history -w
clears history and makes changes permanent
exit
terminal closes
echo $PATH
current path
which
which folder a command is in
operand
input
man
man pages
man “-k” “which”
man page ; search ; for term “which” –> man (section number) “result title”
>
standard output; #1; also 1>; will truncate
> >
output; append file
tty
see path of terminal
<
standard INPUT
cut
cuts files and returns specific columns (“fields”); –delimiter –> give it what divides the columns; –fields –> how many to output
|
pipe data from standard input to next command for standard input
tee
causes data to flow in two directions; saves to file as directed; allows file to be saved to continue piping
xargs
(not all commands accept standard input, some only accept command line arguments) converts data from standard input and puts it into command line argument; can use command | xargs; command such as “echo”; command such as “cat” | xargs “rm”
rm
delete
.bash_aliases
file in home folder for aliases –> alias aliasName=”command1 -options args | command 2 -options args …” (make sure first command can be piped to, using xargs, if needed) –> restart terminal
pwd
print working directory; ~ –> home directory
absolute path
full path
ls -F
classiFy –> slash at the end is a directory (folder);
cd
change directory; ~(start at Home Directory)/; .=current directory; ..=parent folder or folder above
ls -a
show hidden files; hidden files start with .
touch
creates new empty files; touch // to create files inside directories / “folders”
create file with content inside
echo “” > ___fiel name_____.txt
mkdir
make directory; mkdir -p –> to create entire PATH; mkdir / –> will create folders inside folder
rm
remove file or directory
rm -r
delete recursively…delete the item and everything inside it; rm -ri (interactive, to have the r option ask for permission for each deletion)
rmdir
remove empty directory
cp
copy; cp -r –> copy the folder & everything inside (recursively)
locate
locate files; locate -i –> search in case insensitive way; locate –limit # –> limit to number of files; locate -S –> get information about database itself; locate -e –> check to see if files existed before reporting them / locate –existing; locate –follow / locate -L –> check links; (ONLY LISTS FILES)
updatedb
update database
find
DEFAULT BEHAVIOR: list every file & folder that is inside the current folder & lower down in the file system; always up-to-date (doesn’t use database); use “/” to list all files & folders in system; can be used to list all contents in folders by using file path; file -maxdepth # to control number of levels find command searches; find . (current directory) -type f (for type: file) d (for type: directory/ “folder”) –> can be combined with maxdepth option using maxdepth FIRST; find . -name “” –> place name in quotes; find . -maxdepth 10 -iname “?.TXT” –> ignore case in name search (case insensitive); sudo find / (starting at root directory, so use sudo command to avoid permission denied from getting access to files requiring administrative privileges) -type f -size +100k –> searches for files larger than 100 kilobytes in size; pipe output to | wc -l to count how many lines there are; chain together requirements -size +100k -size -5M (larger than 100 kilobytes but less than 5 megabytes, -o for the “or” option in-between sizes
-exec // -ok (OPTIONS)
execute OPTION; after command –> -exec __command to execute__ {} (every file) \; (to complete execution); using -ok will ask you each time if it is “ok” to do something
ctrl + L
clear the screen
cat
concatenate - “stick together”; or just read contents;
tac // rev (OPTIONS)
tac: reverse input; vertically – keeps lines intact across columns; rev: reverses lines horizontally – across the rows
less
paging program - page through large amounts of output
head
first # of lines; head -n #
sort
default: sort smallest first (a-z, 0-9); sort | tac (read backwards) OR sort -r (reverse) ; SORTING NUMBERS: sort using the value number give the “n” option –> sort -n (allows the sort command to sort numerically, instead of just by the digit); SORT FOR UNIQUE RESULTS: sort -q –> only get unique results; | sort -k (KEY DEFinition use for column) #column(+any other options, such as n, r, or u with no space…use h option to sort human-readable data – h can NOT be used with n); M for month
grep
search for specific text; grep ___text_to_search_for____ ; use -c option for number of lines withs specific text (grep -c __texttosearch____ ; -i option for the search to be case insensitive; -v option finds all the lines that do NOT have a certain letter/term…grep -v / –> finds all files (not directories with / in folder name) v= invert search (do the opposite)
ls
ls -lF –> gives slash around directories and nothing for files
tar
compress file; tar -c(create a new archive)v(verbose - don’t so this silently)f(accept files) ; tar -x(extract)vf; to create gzip file: tar -cvzf ; tar -cvjf; to extract gzip: tar -xvzf ; to extract bzip: tar -xvjf ;
gzip // bzip
gzip - faster but has less compression power; gzip (archive_name.tar) –> will see .gz file extension added; gunzip (“g unzip”) to undo gzip
bzip - can compress smaller but requires more time; bzip2 –> will see bz2 file extension added (best for really large files); to undo –> bunzip2 (“b unzip 2”)
zip
create zip file; zip .zip ; to undo unzip
bash script (Bourne-Again shell script)
nano .sh
#!(she-bang)/bin/bash(path to interpreter - to know words are commands) (verify with “which bash” at command prompt to retrieve interpreter’s file path)
python3 to run python script (“which python3”) /usr/bin/python3
bash to run bash script
add path to be found by running bash script in new directory
nano .bashrc
PATH=”$PATH:$HOME/bin” if bin is created to hold bash scripts
PATH=”$PATH:$HOME/”
new directory is now added to $PATH
*remember to make executable –> chmod +x *
cron utility
crontab -e –> open crontab editor (nano)
ls -a from ~ –> hidden file with selected editor (.selected_editor) or command “select-editor”