Lec 02
Linux Commands:
ssh: secure shell
pwd: print working directory (folder)
Is: list all the file in the directory. (-l long listing) (ls -lh human readable) (a flag - list all files, hidden file as well).
touch: creates a empty file. # touch example.txt
nano/vim/emacs: editor.
apt: install app # apt install emacs-nox
wget: download file to vm. (# wget url)
mv - move. can use to rename # mv oldname newname.
cp - copy. copy files.
scp: - copy between vm and local. # scp user@ip:~/source destination or switch dest and source
cat: read in the content and output it. (print content)
head/tail: - show the first 10 lines of file/show the last 10 lines of the file. (head -n lines - show number of line. tail -f - f means follow.
mkdir: make directory. (# mkdir data)
man: shows the manual of a command (# man ls) (# use / to search)
cd: change directory. (. is this direcotry) (.. - parent directory)
sudo/su: root. use as root user. /su - siwtch user, su root (default = root). (you can do sudo su - switch to root).
chmod: # chmod WHO+WHAT chmod o+r secret.txt (-r) took away read
python3: run python ptrogram.
which: - where is python3(or other) installed on computer.
echo: print things.
|: pipe - connect output of one process to input of the next.
>: redirection. A > output.txt - redirect of stdout to output.txt
>>: append to file if exists (not replace like >)
&>: standard error, and stdout both redirection.
wc: world count - how many world typed (ctrld to exit out) line, world,character
grep: - search # grep worldtosearch #-v inverse search case insensitive grep -i madison.
find: find looks at directory. dump everything in a directory.
&: Async. runs in background and get output immediagtely
ps: ps - list processes. # flags: ps a (all user on vm) ps ax (everything, not just shell).
kill: kill process. # kill PID . (can find pid using grep). (flg - kill -9 ( most strong), level 1-9).
pkill: #pkill Name - process name. Kill a program. e.g pkill python3
htop: show process running, resources (CPU, memory)
df: storage and capacity. #df - h human readable. #df -h . 25G disk.
du: information about how much space in different places. #du -hs summary. -hs ./*
Isof: # list open "files" . (use for networks) #sudo lsof -i tcp (tcp) -P ( port number)
Notes:
Shell - program with a loop, ask from prompt and run command.
ssh: secure shell
ctrl r - reverse search.
use sudo apt update before install.
ctrl+c kills a process
in ls -l . the first is - if the file is a file, if it is a d, then it is a directory.
The first colomn tells who owns the file. Second tells the group who own the file. 3 levels.
3 groups of 3 letters. rwx. # rwx = read write execute
Can use Pathlib (library) with reproducible path
First line on file - tells which program to use, how to execute.
(p1 - which bash) #! - top line
PATH variable. in bash, environment variable start with $. #$PATH.
Lec 03
pipe operate on stdin and stdout.
To connect two program, A | B. stdout of A -> stdin of B.

stderr -> for things like warning that shouldn't be chained. (straight to screen) (stack trace go to stderr).
Redirection: Process to file. A >output.txt. (can redirect from stdout or stderr)
Last updated