flowchart LR A(Python) --> B[fname.py file] B --> C[python fname.py] C --> D{hello world} E(C) --> F[fname.c file] F --> G[gcc fname.c -o ename] G --> H[./ename] H --> I{hello world}
Week 0x1
Crypto
podman
vim
gcc
git
wsl --install -d ubuntu
command oncewsl
to… enter wsl.sudo apt update
oncesudo apt upgrade
oncesudo apt install podman
podman
commands within WSLpodman machine start
podman machine init
podman-machine-default-arm64.raw
podman run -it
is an image
run
instances.Command | Explanation |
---|---|
podman |
do something with containers |
run |
run a new container |
-d |
detach - we’ll cover this next |
-p |
This is port forward… |
8080:80 |
80 is where websites usually live |
8080 is where we went (:8080) | |
docker/... |
Name of an image |
8080:80
to 8083:80
-d
-d
flag, it:
podman
commands to:
vim
podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7d6af09131b5 docker.io/docker/welcome-to-docker:latest nginx -g daemon o... 2 minutes ago Up 2 minutes 0.0.0.0:8080->80/tcp, 80/tcp confident_darwin
2e1b9f844dcd docker.io/docker/welcome-to-docker:latest nginx -g daemon o... 2 minutes ago Up 2 minutes 0.0.0.0:8083->80/tcp, 80/tcp adoring_shamir
podman ps -a
to see old containers./bin/sh
bash
> sh
, but sometimes only sh
availablerun -it
podman ps
:
podman ps -a
podman start
by namevim
:vim
vim
, I implicitly exit the container.exit
, to mepodman
vim
gcc
git
apt
to manage packages, like gcc
and vim
apt install
to… install gcc
from apt
-y
as by default apt
asks us if we’re sure-y
, apt
will wait for us to type
-y
i
to enter “insert mode”vim
terminal emulator
:term
:
is meaningful in vim
gcc
w
to change “window”vim
movement key, like j
j
moves down one “thing”:w
to write the filew
+k
podman
ls
to list files, look for a.out./
prefix to use a.out
as an executablepodman
vim
gcc
git
python
is written in GCC Cclang
now but that’s newcat
, ls
, rm
python
or podman
or vim
, GCC is a command - gcc
gcc
takes at least one argument: a filename, usually of a C file./
prefix
python
which runs a script without creating a corresponding program.flowchart LR A(Python) --> B[fname.py file] B --> C[python fname.py] C --> D{hello world} E(C) --> F[fname.c file] F --> G[gcc fname.c -o ename] G --> H[./ename] H --> I{hello world}
gcc
has many options
-o
specifies the name of the output file-std
specifies the C version (there’s a few)-Wall -Wextra -Werror -Wpedantic
set warnings - I use all 4-w
stop all warnings.-O2
to compile more slowly to make faster code:term
and runvim
window was tiny and I didn’t want to resize itgcc samp.c --std=c89
user@DESKTOP-THMS2PJ:~/crypto/c89_99$ podman exec -it -l gcc samp.c --std=c89
samp.c: In function 'main':
samp.c:5:9: error: C++ style comments are not allowed in ISO C90
5 | // This is a C++ style comment
| ^
samp.c:5:9: note: (this will be reported only once per input file)
user@DESKTOP-THMS2PJ:~/crypto/c89_99$ podman exec -it -l gcc samp.c
samp.c: In function 'main':
samp.c:5:9: error: C++ style comments are not allowed in ISO C90
5 | // This is a C++ style comment
| ^
samp.c:5:9: note: (this will be reported only once per input file)
samp.c:3:14: error: unused parameter 'argc' [-Werror=unused-parameter]
3 | int main(int argc, char **argv) {
| ~~~~^~~~
samp.c:3:27: error: unused parameter 'argv' [-Werror=unused-parameter]
3 | int main(int argc, char **argv) {
| ~~~~~~~^~~~
cc1: all warnings being treated as errors
-Wall
for intro programming classes!int main(int argc, char **argv) {
int i;
/* if (argc < 1) {
return 1;
} */
for (i = 0 ; argv[1][i]; i++) {
argv[1][i] = cipher(argv[1][i], i);
}
printf("%s\n", argv[1]);
return 0;
}
int main(int argc, char **argv) {
int i;
for (i = 0 ; argv[1][i]; i++) {
argv[1][i] = cipher(argv[1][i], i);
int i++;
}
printf("%s\n", argv[1]);
return 0;
}
const
convention-Werror=char-subscripts
int main(int argc, char **argv) {
char i;
for (i = 0 ; argv[1][i]; i++) {
argv[1][i] = cipher(argv[1][i], i);
}
printf("%s\n", argv[1]);
return 0;
}
int main(int argc, char **argv) {
char i;
if (argc < 1) {
return 1;
}
char *input_string = argv[1];
for (i = 0 ; argv[1][i]; i++) {
argv[1][i] = cipher(argv[1][i], i);
}
printf("%s\n", argv[1]);
return 0;
}
int main(int argc, char **argv) {
char i;
if (argc < 1) {
return 1;
}
char *output_string;
for (i = 0 ; argv[1][i]; i++) {
output_string[i] = cipher(argv[1][i], i);
}
printf("%s\n", argv[1]);
return 0;
}
podman
vim
gcc
git
git
If you want a lot of control and flexibility, you can use the command line.
git
podman
vim
gcc
git
root@262ad65a08ba:/# vim build.sh
root@262ad65a08ba:/# ./build.sh
bash: ./build.sh: Permission denied
root@262ad65a08ba:/# chmod 777 build.sh
root@262ad65a08ba:/# ./build.sh
samp.c: In function 'main':
samp.c:5:9: error: C++ style comments are not allowed in ISO C90
5 | // This is a C++ style comment
| ^
samp.c:5:9: note: (this will be reported only once per input file)
samp.c:3:14: error: unused parameter 'argc' [-Werror=unused-parameter]
3 | int main(int argc, char **argv) {
| ~~~~^~~~
samp.c:3:27: error: unused parameter 'argv' [-Werror=unused-parameter]
3 | int main(int argc, char **argv) {
| ~~~~~~~^~~~
cc1: all warnings being treated as errors
root@262ad65a08ba:/# cat build.sh
#!/bin/sh
gcc samp.c --std=c89 -Wall -Wextra -Werror -Wpedantic -O2 -o samp
root@262ad65a08ba:/#