--- tags: - Documentation - Bookstack - Notes --- # Cheat Sheets # Docker ## Running Containers
COMMANDDESCRIPTION
`docker run `Start a new container from an image
`docker run -it `Start a new container in interactive mode
`docker run --rm `Start a new container and remove it when it exits
`docker create `Create a new container
`docker start `Start a container
`docker stop `Graceful stop a container
`docker kill `Kill (SIGKILL) a container
`docker restart `Graceful stop and restart a container
`docker pause `Suspend a container
`docker unpause `Resume a container
`docker rm `Destroy a container
## Container Bulk Management
COMMANDDESCRIPTION
`docker stop $(docker ps -q)`To stop all the running containers
`docker stop $(docker ps -a -q)`To stop all the stopped and running containers
`docker kill $(docker ps -q)`To kill all the running containers
`docker kill $(docker ps -a -q)`To kill all the stopped and running containers
`docker restart $(docker ps -q)`To restart all running containers
`docker restart $(docker ps -a -q)`To restart all the stopped and running containers
`docker rm $(docker ps -q)`To destroy all running containers
`docker rm $(docker ps -a -q)`To destroy all the stopped and running containers
`docker pause $(docker ps -q)`To pause all running containers
`docker pause $(docker ps -a -q)`To pause all the stopped and running containers
`docker start $(docker ps -q)`To start all running containers
`docker start $(docker ps -a -q)`To start all the stopped and running containers
`docker rm -vf $(docker ps -a -q)`To delete all containers including its volumes use
`docker rmi -f $(docker images -a -q)`To delete all the images
`docker system prune`To delete all dangling and unused images, containers, cache and volumes
`docker system prune -a`To delete all used and unused images
`docker system prune --volumes`To delete all docker volumes
## Inspect Containers
COMMANDDESCRIPTION
`docker ps`List running containers
`docker ps --all`List all containers, including stopped
`docker logs `Show a container output
`docker logs -f `Follow a container output
`docker top `List the processes running in a container
`docker diff`Show the differences with the image (modified files)
`docker inspect`Show information of a container (json formatted)
## Executing Commands
COMMANDDESCRIPTION
`docker attach `Attach to a container
`docker cp : `Copy files from the container
`docker cp :`Copy files into the container
`docker export `Export the content of the container (tar archive)
`docker exec `Run a command inside a container
`docker exec -it /bin/bash`Open an interactive shell inside a container (there is no bash in some images, use /bin/sh)
`docker wait `Wait until the container terminates and return the exit code
## Images
COMMANDDESCRIPTION
`docker image ls`List all local images
`docker history `Show the image history
`docker inspect `Show information (json formatted)
`docker tag `Tag an image
`docker commit `Create an image (from a container)
`docker import `Create an image (from a tarball)
`docker rmi `Delete images
`docker pull /:`Pull an image from a registry
`docker push /:`Push and image to a registry
`docker search `Search an image on the official registry
`docker login`Login to a registry
`docker logout`Logout from a registry
`docker save /:`Export an image/repo as a tarball
`docker load`Load images from a tarball
## Volumes
COMMANDDESCRIPTION
`docker volume ls`List all vol1umes
`docker volume create `Create a volume
`docker volume inspect `Show information (json formatted)
`docker volume rm `Destroy a volume
`docker volume ls --filter="dangling=true"`List all dangling volumes (not referenced by any container)
`docker volume prune`Delete all volumes (not referenced by any container)
`docker run --rm --volumes-from -v $(pwd):/backup busybox tar cvfz /backup/backup.tar.gz `Backup a container
`docker run --rm --volumes-from -v $(pwd):/backup busybox sh -c "cd && tar xvfz /backup/backup.tar.gz --strip 1"`Restore a container from backup
# 256 Color Codes --- Colors 0-15 are Xterm system colors.
Xterm NumberXterm NameHEXRGBHSL
0Black (SYSTEM)`#000000`rgb(0,0,0)hsl(0,0%,0%)
1Maroon (SYSTEM)`#800000`rgb(128,0,0)hsl(0,100%,25%)
2Green (SYSTEM)`#008000`rgb(0,128,0)hsl(120,100%,25%)
3Olive (SYSTEM)`#808000`rgb(128,128,0)hsl(60,100%,25%)
4Navy (SYSTEM)`#000080`rgb(0,0,128)hsl(240,100%,25%)
5Purple (SYSTEM)`#800080`rgb(128,0,128)hsl(300,100%,25%)
6Teal (SYSTEM)`#008080`rgb(0,128,128)hsl(180,100%,25%)
7Silver (SYSTEM)`#c0c0c0`rgb(192,192,192)hsl(0,0%,75%)
8Grey (SYSTEM)`#808080`rgb(128,128,128)hsl(0,0%,50%)
9Red (SYSTEM)`#ff0000`rgb(255,0,0)hsl(0,100%,50%)
10Lime (SYSTEM)`#00ff00`rgb(0,255,0)hsl(120,100%,50%)
11Yellow (SYSTEM)`#ffff00`rgb(255,255,0)hsl(60,100%,50%)
12Blue (SYSTEM)`#0000ff`rgb(0,0,255)hsl(240,100%,50%)
13Fuchsia (SYSTEM)`#ff00ff`rgb(255,0,255)hsl(300,100%,50%)
14Aqua (SYSTEM)`#00ffff`rgb(0,255,255)hsl(180,100%,50%)
15White (SYSTEM)`#ffffff`rgb(255,255,255)hsl(0,0%,100%)
16Grey0`#000000`rgb(0,0,0)hsl(0,0%,0%)
17NavyBlue`#00005f`rgb(0,0,95)hsl(240,100%,18%)
18DarkBlue`#000087`rgb(0,0,135)hsl(240,100%,26%)
19Blue3`#0000af`rgb(0,0,175)hsl(240,100%,34%)
20Blue3`#0000d7`rgb(0,0,215)hsl(240,100%,42%)
21Blue1`#0000ff`rgb(0,0,255)hsl(240,100%,50%)
22DarkGreen`#005f00`rgb(0,95,0)hsl(120,100%,18%)
23DeepSkyBlue4`#005f5f`rgb(0,95,95)hsl(180,100%,18%)
24DeepSkyBlue4`#005f87`rgb(0,95,135)hsl(97,100%,26%)
25DeepSkyBlue4`#005faf`rgb(0,95,175)hsl(07,100%,34%)
26DodgerBlue3`#005fd7`rgb(0,95,215)hsl(13,100%,42%)
27DodgerBlue2`#005fff`rgb(0,95,255)hsl(17,100%,50%)
28Green4`#008700`rgb(0,135,0)hsl(120,100%,26%)
29SpringGreen4`#00875f`rgb(0,135,95)hsl(62,100%,26%)
30Turquoise4`#008787`rgb(0,135,135)hsl(180,100%,26%)
31DeepSkyBlue3`#0087af`rgb(0,135,175)hsl(93,100%,34%)
32DeepSkyBlue3`#0087d7`rgb(0,135,215)hsl(02,100%,42%)
33DodgerBlue1`#0087ff`rgb(0,135,255)hsl(08,100%,50%)
34Green3`#00af00`rgb(0,175,0)hsl(120,100%,34%)
35SpringGreen3`#00af5f`rgb(0,175,95)hsl(52,100%,34%)
36DarkCyan`#00af87`rgb(0,175,135)hsl(66,100%,34%)
37LightSeaGreen`#00afaf`rgb(0,175,175)hsl(180,100%,34%)
38DeepSkyBlue2`#00afd7`rgb(0,175,215)hsl(91,100%,42%)
39DeepSkyBlue1`#00afff`rgb(0,175,255)hsl(98,100%,50%)
40Green3`#00d700`rgb(0,215,0)hsl(120,100%,42%)
41SpringGreen3`#00d75f`rgb(0,215,95)hsl(46,100%,42%)
42SpringGreen2`#00d787`rgb(0,215,135)hsl(57,100%,42%)
43Cyan3`#00d7af`rgb(0,215,175)hsl(68,100%,42%)
44DarkTurquoise`#00d7d7`rgb(0,215,215)hsl(180,100%,42%)
45Turquoise2`#00d7ff`rgb(0,215,255)hsl(89,100%,50%)
46Green1`#00ff00`rgb(0,255,0)hsl(120,100%,50%)
47SpringGreen2`#00ff5f`rgb(0,255,95)hsl(42,100%,50%)
48SpringGreen1`#00ff87`rgb(0,255,135)hsl(51,100%,50%)
49MediumSpringGreen`#00ffaf`rgb(0,255,175)hsl(61,100%,50%)
50Cyan2`#00ffd7`rgb(0,255,215)hsl(70,100%,50%)
51Cyan1`#00ffff`rgb(0,255,255)hsl(180,100%,50%)
52DarkRed`#5f0000`rgb(95,0,0)hsl(0,100%,18%)
53DeepPink4`#5f005f`rgb(95,0,95)hsl(300,100%,18%)
54Purple4`#5f0087`rgb(95,0,135)hsl(82,100%,26%)
55Purple4`#5f00af`rgb(95,0,175)hsl(72,100%,34%)
56Purple3`#5f00d7`rgb(95,0,215)hsl(66,100%,42%)
57BlueViolet`#5f00ff`rgb(95,0,255)hsl(62,100%,50%)
58Orange4`#5f5f00`rgb(95,95,0)hsl(60,100%,18%)
59Grey37`#5f5f5f`rgb(95,95,95)hsl(0,0%,37%)
60MediumPurple4`#5f5f87`rgb(95,95,135)hsl(240,17%,45%)
61SlateBlue3`#5f5faf`rgb(95,95,175)hsl(240,33%,52%)
62SlateBlue3`#5f5fd7`rgb(95,95,215)hsl(240,60%,60%)
63RoyalBlue1`#5f5fff`rgb(95,95,255)hsl(240,100%,68%)
64Chartreuse4`#5f8700`rgb(95,135,0)hsl(7,100%,26%)
65DarkSeaGreen4`#5f875f`rgb(95,135,95)hsl(120,17%,45%)
66PaleTurquoise4`#5f8787`rgb(95,135,135)hsl(180,17%,45%)
67SteelBlue`#5f87af`rgb(95,135,175)hsl(210,33%,52%)
68SteelBlue3`#5f87d7`rgb(95,135,215)hsl(220,60%,60%)
69CornflowerBlue`#5f87ff`rgb(95,135,255)hsl(225,100%,68%)
70Chartreuse3`#5faf00`rgb(95,175,0)hsl(7,100%,34%)
71DarkSeaGreen4`#5faf5f`rgb(95,175,95)hsl(120,33%,52%)
72CadetBlue`#5faf87`rgb(95,175,135)hsl(150,33%,52%)
73CadetBlue`#5fafaf`rgb(95,175,175)hsl(180,33%,52%)
74SkyBlue3`#5fafd7`rgb(95,175,215)hsl(200,60%,60%)
75SteelBlue1`#5fafff`rgb(95,175,255)hsl(210,100%,68%)
76Chartreuse3`#5fd700`rgb(95,215,0)hsl(3,100%,42%)
77PaleGreen3`#5fd75f`rgb(95,215,95)hsl(120,60%,60%)
78SeaGreen3`#5fd787`rgb(95,215,135)hsl(140,60%,60%)
79Aquamarine3`#5fd7af`rgb(95,215,175)hsl(160,60%,60%)
80MediumTurquoise`#5fd7d7`rgb(95,215,215)hsl(180,60%,60%)
81SteelBlue1`#5fd7ff`rgb(95,215,255)hsl(195,100%,68%)
82Chartreuse2`#5fff00`rgb(95,255,0)hsl(7,100%,50%)
83SeaGreen2`#5fff5f`rgb(95,255,95)hsl(120,100%,68%)
84SeaGreen1`#5fff87`rgb(95,255,135)hsl(135,100%,68%)
85SeaGreen1`#5fffaf`rgb(95,255,175)hsl(150,100%,68%)
86Aquamarine1`#5fffd7`rgb(95,255,215)hsl(165,100%,68%)
87DarkSlateGray2`#5fffff`rgb(95,255,255)hsl(180,100%,68%)
88DarkRed`#870000`rgb(135,0,0)hsl(0,100%,26%)
89DeepPink4`#87005f`rgb(135,0,95)hsl(17,100%,26%)
90DarkMagenta`#870087`rgb(135,0,135)hsl(300,100%,26%)
91DarkMagenta`#8700af`rgb(135,0,175)hsl(86,100%,34%)
92DarkViolet`#8700d7`rgb(135,0,215)hsl(77,100%,42%)
93Purple`#8700ff`rgb(135,0,255)hsl(71,100%,50%)
94Orange4`#875f00`rgb(135,95,0)hsl(2,100%,26%)
95LightPink4`#875f5f`rgb(135,95,95)hsl(0,17%,45%)
96Plum4`#875f87`rgb(135,95,135)hsl(300,17%,45%)
97MediumPurple3`#875faf`rgb(135,95,175)hsl(270,33%,52%)
98MediumPurple3`#875fd7`rgb(135,95,215)hsl(260,60%,60%)
99SlateBlue1`#875fff`rgb(135,95,255)hsl(255,100%,68%)
100Yellow4`#878700`rgb(135,135,0)hsl(60,100%,26%)
101Wheat4`#87875f`rgb(135,135,95)hsl(60,17%,45%)
102Grey53`#878787`rgb(135,135,135)hsl(0,0%,52%)
103LightSlateGrey`#8787af`rgb(135,135,175)hsl(240,20%,60%)
104MediumPurple`#8787d7`rgb(135,135,215)hsl(240,50%,68%)
105LightSlateBlue`#8787ff`rgb(135,135,255)hsl(240,100%,76%)
106Yellow4`#87af00`rgb(135,175,0)hsl(3,100%,34%)
107DarkOliveGreen3`#87af5f`rgb(135,175,95)hsl(90,33%,52%)
108DarkSeaGreen`#87af87`rgb(135,175,135)hsl(120,20%,60%)
109LightSkyBlue3`#87afaf`rgb(135,175,175)hsl(180,20%,60%)
110LightSkyBlue3`#87afd7`rgb(135,175,215)hsl(210,50%,68%)
111SkyBlue2`#87afff`rgb(135,175,255)hsl(220,100%,76%)
112Chartreuse2`#87d700`rgb(135,215,0)hsl(2,100%,42%)
113DarkOliveGreen3`#87d75f`rgb(135,215,95)hsl(100,60%,60%)
114PaleGreen3`#87d787`rgb(135,215,135)hsl(120,50%,68%)
115DarkSeaGreen3`#87d7af`rgb(135,215,175)hsl(150,50%,68%)
116DarkSlateGray3`#87d7d7`rgb(135,215,215)hsl(180,50%,68%)
117SkyBlue1`#87d7ff`rgb(135,215,255)hsl(200,100%,76%)
118Chartreuse1`#87ff00`rgb(135,255,0)hsl(8,100%,50%)
119LightGreen`#87ff5f`rgb(135,255,95)hsl(105,100%,68%)
120LightGreen`#87ff87`rgb(135,255,135)hsl(120,100%,76%)
121PaleGreen1`#87ffaf`rgb(135,255,175)hsl(140,100%,76%)
122Aquamarine1`#87ffd7`rgb(135,255,215)hsl(160,100%,76%)
123DarkSlateGray1`#87ffff`rgb(135,255,255)hsl(180,100%,76%)
124Red3`#af0000`rgb(175,0,0)hsl(0,100%,34%)
125DeepPink4`#af005f`rgb(175,0,95)hsl(27,100%,34%)
126MediumVioletRed`#af0087`rgb(175,0,135)hsl(13,100%,34%)
127Magenta3`#af00af`rgb(175,0,175)hsl(300,100%,34%)
128DarkViolet`#af00d7`rgb(175,0,215)hsl(88,100%,42%)
129Purple`#af00ff`rgb(175,0,255)hsl(81,100%,50%)
130DarkOrange3`#af5f00`rgb(175,95,0)hsl(2,100%,34%)
131IndianRed`#af5f5f`rgb(175,95,95)hsl(0,33%,52%)
132HotPink3`#af5f87`rgb(175,95,135)hsl(330,33%,52%)
133MediumOrchid3`#af5faf`rgb(175,95,175)hsl(300,33%,52%)
134MediumOrchid`#af5fd7`rgb(175,95,215)hsl(280,60%,60%)
135MediumPurple2`#af5fff`rgb(175,95,255)hsl(270,100%,68%)
136DarkGoldenrod`#af8700`rgb(175,135,0)hsl(6,100%,34%)
137LightSalmon3`#af875f`rgb(175,135,95)hsl(30,33%,52%)
138RosyBrown`#af8787`rgb(175,135,135)hsl(0,20%,60%)
139Grey63`#af87af`rgb(175,135,175)hsl(300,20%,60%)
140MediumPurple2`#af87d7`rgb(175,135,215)hsl(270,50%,68%)
141MediumPurple1`#af87ff`rgb(175,135,255)hsl(260,100%,76%)
142Gold3`#afaf00`rgb(175,175,0)hsl(60,100%,34%)
143DarkKhaki`#afaf5f`rgb(175,175,95)hsl(60,33%,52%)
144NavajoWhite3`#afaf87`rgb(175,175,135)hsl(60,20%,60%)
145Grey69`#afafaf`rgb(175,175,175)hsl(0,0%,68%)
146LightSteelBlue3`#afafd7`rgb(175,175,215)hsl(240,33%,76%)
147LightSteelBlue`#afafff`rgb(175,175,255)hsl(240,100%,84%)
148Yellow3`#afd700`rgb(175,215,0)hsl(1,100%,42%)
149DarkOliveGreen3`#afd75f`rgb(175,215,95)hsl(80,60%,60%)
150DarkSeaGreen3`#afd787`rgb(175,215,135)hsl(90,50%,68%)
151DarkSeaGreen2`#afd7af`rgb(175,215,175)hsl(120,33%,76%)
152LightCyan3`#afd7d7`rgb(175,215,215)hsl(180,33%,76%)
153LightSkyBlue1`#afd7ff`rgb(175,215,255)hsl(210,100%,84%)
154GreenYellow`#afff00`rgb(175,255,0)hsl(8,100%,50%)
155DarkOliveGreen2`#afff5f`rgb(175,255,95)hsl(90,100%,68%)
156PaleGreen1`#afff87`rgb(175,255,135)hsl(100,100%,76%)
157DarkSeaGreen2`#afffaf`rgb(175,255,175)hsl(120,100%,84%)
158DarkSeaGreen1`#afffd7`rgb(175,255,215)hsl(150,100%,84%)
159PaleTurquoise1`#afffff`rgb(175,255,255)hsl(180,100%,84%)
160Red3`#d70000`rgb(215,0,0)hsl(0,100%,42%)
161DeepPink3`#d7005f`rgb(215,0,95)hsl(33,100%,42%)
162DeepPink3`#d70087`rgb(215,0,135)hsl(22,100%,42%)
163Magenta3`#d700af`rgb(215,0,175)hsl(11,100%,42%)
164Magenta3`#d700d7`rgb(215,0,215)hsl(300,100%,42%)
165Magenta2`#d700ff`rgb(215,0,255)hsl(90,100%,50%)
166DarkOrange3`#d75f00`rgb(215,95,0)hsl(6,100%,42%)
167IndianRed`#d75f5f`rgb(215,95,95)hsl(0,60%,60%)
168HotPink3`#d75f87`rgb(215,95,135)hsl(340,60%,60%)
169HotPink2`#d75faf`rgb(215,95,175)hsl(320,60%,60%)
170Orchid`#d75fd7`rgb(215,95,215)hsl(300,60%,60%)
171MediumOrchid1`#d75fff`rgb(215,95,255)hsl(285,100%,68%)
172Orange3`#d78700`rgb(215,135,0)hsl(7,100%,42%)
173LightSalmon3`#d7875f`rgb(215,135,95)hsl(20,60%,60%)
174LightPink3`#d78787`rgb(215,135,135)hsl(0,50%,68%)
175Pink3`#d787af`rgb(215,135,175)hsl(330,50%,68%)
176Plum3`#d787d7`rgb(215,135,215)hsl(300,50%,68%)
177Violet`#d787ff`rgb(215,135,255)hsl(280,100%,76%)
178Gold3`#d7af00`rgb(215,175,0)hsl(8,100%,42%)
179LightGoldenrod3`#d7af5f`rgb(215,175,95)hsl(40,60%,60%)
180Tan`#d7af87`rgb(215,175,135)hsl(30,50%,68%)
181MistyRose3`#d7afaf`rgb(215,175,175)hsl(0,33%,76%)
182Thistle3`#d7afd7`rgb(215,175,215)hsl(300,33%,76%)
183Plum2`#d7afff`rgb(215,175,255)hsl(270,100%,84%)
184Yellow3`#d7d700`rgb(215,215,0)hsl(60,100%,42%)
185Khaki3`#d7d75f`rgb(215,215,95)hsl(60,60%,60%)
186LightGoldenrod2`#d7d787`rgb(215,215,135)hsl(60,50%,68%)
187LightYellow3`#d7d7af`rgb(215,215,175)hsl(60,33%,76%)
188Grey84`#d7d7d7`rgb(215,215,215)hsl(0,0%,84%)
189LightSteelBlue1`#d7d7ff`rgb(215,215,255)hsl(240,100%,92%)
190Yellow2`#d7ff00`rgb(215,255,0)hsl(9,100%,50%)
191DarkOliveGreen1`#d7ff5f`rgb(215,255,95)hsl(75,100%,68%)
192DarkOliveGreen1`#d7ff87`rgb(215,255,135)hsl(80,100%,76%)
193DarkSeaGreen1`#d7ffaf`rgb(215,255,175)hsl(90,100%,84%)
194Honeydew2`#d7ffd7`rgb(215,255,215)hsl(120,100%,92%)
195LightCyan1`#d7ffff`rgb(215,255,255)hsl(180,100%,92%)
196Red1`#ff0000`rgb(255,0,0)hsl(0,100%,50%)
197DeepPink2`#ff005f`rgb(255,0,95)hsl(37,100%,50%)
198DeepPink1`#ff0087`rgb(255,0,135)hsl(28,100%,50%)
199DeepPink1`#ff00af`rgb(255,0,175)hsl(18,100%,50%)
200Magenta2`#ff00d7`rgb(255,0,215)hsl(09,100%,50%)
201Magenta1`#ff00ff`rgb(255,0,255)hsl(300,100%,50%)
202OrangeRed1`#ff5f00`rgb(255,95,0)hsl(2,100%,50%)
203IndianRed1`#ff5f5f`rgb(255,95,95)hsl(0,100%,68%)
204IndianRed1`#ff5f87`rgb(255,95,135)hsl(345,100%,68%)
205HotPink`#ff5faf`rgb(255,95,175)hsl(330,100%,68%)
206HotPink`#ff5fd7`rgb(255,95,215)hsl(315,100%,68%)
207MediumOrchid1`#ff5fff`rgb(255,95,255)hsl(300,100%,68%)
208DarkOrange`#ff8700`rgb(255,135,0)hsl(1,100%,50%)
209Salmon1`#ff875f`rgb(255,135,95)hsl(15,100%,68%)
210LightCoral`#ff8787`rgb(255,135,135)hsl(0,100%,76%)
211PaleVioletRed1`#ff87af`rgb(255,135,175)hsl(340,100%,76%)
212Orchid2`#ff87d7`rgb(255,135,215)hsl(320,100%,76%)
213Orchid1`#ff87ff`rgb(255,135,255)hsl(300,100%,76%)
214Orange1`#ffaf00`rgb(255,175,0)hsl(1,100%,50%)
215SandyBrown`#ffaf5f`rgb(255,175,95)hsl(30,100%,68%)
216LightSalmon1`#ffaf87`rgb(255,175,135)hsl(20,100%,76%)
217LightPink1`#ffafaf`rgb(255,175,175)hsl(0,100%,84%)
218Pink1`#ffafd7`rgb(255,175,215)hsl(330,100%,84%)
219Plum1`#ffafff`rgb(255,175,255)hsl(300,100%,84%)
220Gold1`#ffd700`rgb(255,215,0)hsl(0,100%,50%)
221LightGoldenrod2`#ffd75f`rgb(255,215,95)hsl(45,100%,68%)
222LightGoldenrod2`#ffd787`rgb(255,215,135)hsl(40,100%,76%)
223NavajoWhite1`#ffd7af`rgb(255,215,175)hsl(30,100%,84%)
224MistyRose1`#ffd7d7`rgb(255,215,215)hsl(0,100%,92%)
225Thistle1`#ffd7ff`rgb(255,215,255)hsl(300,100%,92%)
226Yellow1`#ffff00`rgb(255,255,0)hsl(60,100%,50%)
227LightGoldenrod1`#ffff5f`rgb(255,255,95)hsl(60,100%,68%)
228Khaki1`#ffff87`rgb(255,255,135)hsl(60,100%,76%)
229Wheat1`#ffffaf`rgb(255,255,175)hsl(60,100%,84%)
230Cornsilk1`#ffffd7`rgb(255,255,215)hsl(60,100%,92%)
231Grey100`#ffffff`rgb(255,255,255)hsl(0,0%,100%)
232Grey3`#080808`rgb(8,8,8)hsl(0,0%,3%)
233Grey7`#121212`rgb(18,18,18)hsl(0,0%,7%)
234Grey11`#1c1c1c`rgb(28,28,28)hsl(0,0%,10%)
235Grey15`#262626`rgb(38,38,38)hsl(0,0%,14%)
236Grey19`#303030`rgb(48,48,48)hsl(0,0%,18%)
237Grey23`#3a3a3a`rgb(58,58,58)hsl(0,0%,22%)
238Grey27`#444444`rgb(68,68,68)hsl(0,0%,26%)
239Grey30`#4e4e4e`rgb(78,78,78)hsl(0,0%,30%)
240Grey35`#585858`rgb(88,88,88)hsl(0,0%,34%)
241Grey39`#626262`rgb(98,98,98)hsl(0,0%,37%)
242Grey42`#6c6c6c`rgb(108,108,108)hsl(0,0%,40%)
243Grey46`#767676`rgb(118,118,118)hsl(0,0%,46%)
244Grey50`#808080`rgb(128,128,128)hsl(0,0%,50%)
245Grey54`#8a8a8a`rgb(138,138,138)hsl(0,0%,54%)
246Grey58`#949494`rgb(148,148,148)hsl(0,0%,58%)
247Grey62`#9e9e9e`rgb(158,158,158)hsl(0,0%,61%)
248Grey66`#a8a8a8`rgb(168,168,168)hsl(0,0%,65%)
249Grey70`#b2b2b2`rgb(178,178,178)hsl(0,0%,69%)
250Grey74`#bcbcbc`rgb(188,188,188)hsl(0,0%,73%)
251Grey78`#c6c6c6`rgb(198,198,198)hsl(0,0%,77%)
252Grey82`#d0d0d0`rgb(208,208,208)hsl(0,0%,81%)
253Grey85`#dadada`rgb(218,218,218)hsl(0,0%,85%)
254Grey89`#e4e4e4`rgb(228,228,228)hsl(0,0%,89%)
255Grey93`#eeeeee`rgb(238,238,238)hsl(0,0%,93%)
# ARP in Linux
CommandDescription
`arp`View the ARP table
`arp -a`View the ARP table
`arp -n`View the ARP table (don't resolve names)
`arp -d `Delete an entry from the ARP table
`arp -s `Add an entry to the ARP table
`arp -i -s `Add an entry to the ARP table for a specific interface
`arp -i -d `Delete an entry from the ARP table for a specific interface
`arp -i -n`View the ARP table for a specific interface
`arp -i -a`View the ARP table for a specific interface
`ip neigh show`View the ARP table
`ip neigh show `View the ARP table for a specific IP address
`ip neigh add lladdr dev `Add an entry to the ARP table
`ip neigh change lladdr dev `Change an entry in the ARP table
`ip neigh del dev `Delete an entry from the ARP table
`ip neigh flush dev `Flush the ARP table for a specific interface
`ip neigh flush all`Flush the ARP table
`ip -s neigh show`Show ARP statistics
`ip -s neigh flush all`Flush the ARP cache
# AWK
CommandDescription
`awk '/pattern/ {print $1}'`standard Unix shells
`awk '/pattern/ {print "$1"}'`compiled with DJGPP, Cygwin
`awk "/pattern/ {print \"$1\"}"`GnuWin32, UnxUtils, Mingw
`awk '1;{print ""}'`double space a file
`awk 'BEGIN{ORS="\n\n"};1'`double space a file
`awk 'NF{print $0 "\n"}'`double space a file which already has blank lines
`awk '1;{print "\n"}'`triple space a file
`awk '{print FNR "\t" $0}' files*`precede each line by its line number
`awk '{print NR "\t" $0}' files*`precede each line by its line number for all files together
`awk '{printf("%5d : %s\n", NR,$0)}'`number each line of a file
`awk 'NF{$0=++a " :" $0};1'`number each line of a file, but only print numbers if line is not blank
`awk 'END{print NR}'`count lines (emulates "wc -l")
`awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}'`print the sums of the fields of every line
`awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'`add all fields in all lines and print the sum
`awk '{for (i=1; i<=NF; i++) if ($i < 0) $i = -$i; print }'`print every line after replacing each field with its absolute value
`awk '{for (i=1; i<=NF; i++) $i = ($i < 0) ? -$i : $i; print }'`print every line after replacing each field with its absolute value
`awk '{ total = total + NF }; END {print total}' file`print the total number of fields ("words") in all lines
`awk '/Beth/{n++}; END {print n+0}' file`print the total number of lines that contain "Beth"
`awk '$1 > max {max=$1; maxline=$0}; END{ print max, maxline}'`print the largest first field and the line that contains it
`awk '{ print NF ":" $0 }'`print the number of fields in each line, followed by the line
`awk '{ print $NF }'`print the last field of each line
`awk '{ field = $NF }; END{ print field }'`print the last field of the last line
`awk 'NF > 4'`print every line with more than 4 fields
`awk '$NF > 4'`print every line where the value of the last field is > 4
# Certutil
CommandDescription
`certutil -store MY`List personal certificates
`certutil -store ROOT`List root certificates
`certutil -store CA`List intermediate certificates
`certutil -addstore -f "ROOT" new-root-certificate.crt`Add a root certificate
`certutil -delstore "ROOT" serial-number-hex`Remove a root certificate
`certutil -addstore -f "CA" new-intermediate-certificate.crt`Add an intermediate certificate
`certutil -delstore "CA" serial-number-hex`Remove an intermediate certificate
`certutil -addstore -f "MY" new-personal-certificate.pfx`Add a personal certificate
`certutil -delstore "MY" serial-number-hex`Remove a personal certificate
`certutil -dump certificate.crt`Display certificate information
`certutil -encode certificate.crt encoded-certificate.txt`Encode a certificate
`certutil -decode encoded-certificate.txt decoded-certificate.crt`Decode a certificate
`certutil -hashfile file.txt SHA256`Calculate the SHA256 hash of a file
# DNS ### Commonly used DNS Records
TypeDescription
**A**The record that holds the IP address of a domain.
**AAAA**The record that contains the IPv6 address for a domain (as opposed to A records, which list the IPv4 address).
**CNAME**Forwards one domain or subdomain to another domain, does NOT provide an IP address.
**MX**Directs mail to an email server.
**TXT**Lets an admin store text notes in the record. These records are often used for email security.
**NS**Stores the name server for a DNS entry.
**SOA**Stores admin information about a domain.
**SRV**Specifies a port for specific services.
**PTR**Provides a domain name in reverse-lookups.
### Less commonly used DNS Records
TypeDescription
**APL**The ‘address prefix list’ is an experiment record that specifies lists of address ranges.
**AFSDB**This record is used for clients of the Andrew File System (AFS) developed by Carnegie Melon. The AFSDB record functions to find other AFS cells.
**CAA**This is the ‘certification authority authorization’ record, it allows domain owners state which certificate authorities can issue certificates for that domain. If no CAA record exists, then anyone can issue a certificate for the domain. These records are also inherited by subdomains.
**DNSKEY**The ‘DNS Key Record’ contains a public key used to verify Domain Name System Security Extension (DNSSEC) signatures
**CDNSKEY**This is a child copy of the DNSKEY record, meant to be transferred to a parent.
**CERT**The ‘certificate record’ stores public key certificates.
**DCHID**The ‘DHCP Identifier’ stores info for the Dynamic Host Configuration Protocol (DHCP), a standardized network protocol used on IP networks.
**DNAME**The ‘delegation name’ record creates a domain alias, just like CNAME, but this alias will redirect all subdomains as well. For instance if the owner of ‘example.com’ bought the domain ‘website.net’ and gave it a DNAME record that points to ‘example.com’, then that pointer would also extend to ‘blog.website.net’ and any other subdomains.
**HIP**This record uses ‘Host identity protocol’, a way to separate the roles of an IP address; this record is used most often in mobile computing.
**IPSECKEY**The ‘IPSEC key’ record works with the Internet Protocol Security (IPSEC), an end-to-end security protocol framework and part of the Internet Protocol Suite (TCP/IP).
**LOC**The ‘location’ record contains geographical information for a domain in the form of longitude and latitude coordinates.
**NAPTR**The ‘name authority pointer’ record can be combined with an SRV record to dynamically create URI’s to point to based on a regular expression.
**NSEC**The ‘next secure record’ is part of DNSSEC, and it’s used to prove that a requested DNS resource record does not exist.
**RRSIG**The ‘resource record signature’ is a record to store digital signatures used to authenticate records in accordance with DNSSEC.
**RP**This is the ‘responsible person’ record and it stores the email address of the person responsible for the domain.
**SSHFP**This record stores the ‘SSH public key fingerprints’; SSH stands for Secure Shell and it’s a cryptographic networking protocol for secure communication over an unsecure network.
# Ethtool ## Displaying Information
CommandDescription
`ethtool `Display information about a specific network interface
`ethtool -i `Display driver information
`ethtool -a `Display all settings
`ethtool -k `Display offload settings
`ethtool -c `Display coalescing settings
`ethtool -g `Display ring buffer settings
`ethtool -l `Display large receive offload settings
`ethtool -S `Display statistics
`ethtool -t `Test the network interface for offloading capabilities
`ethtool -T `Display time stamping settings
`ethtool -x `Display channel settings
`ethtool -P `Display permanent MAC address
`ethtool -N `Display offload settings
`ethtool -u `Display bus information
`ethtool -d `Display register dump
`ethtool -g `Display ring buffer settings
## Setting Parameters
CommandDescription
`ethtool -G `Set ring buffer settings
`ethtool -L `Set large receive offload settings
`ethtool -A `Set pause parameters
`ethtool -C `Set coalescing settings
`ethtool -K `Set offload settings
`ethtool -N `Set offload settings
`ethtool -p `Blink the LED on the network interface
`ethtool -r `Reset the network interface
# GIT ## Repository Management
CommandDescription
`git init`Initialize a new Git repository
`git clone `Clone a remote repository
`git status`Show the working tree status
`git add `Add a file to the staging area
`git commit -m `Commit changes to the repository
`git push`Push changes to the remote repository
`git pull`Pull changes from the remote repository
`git fetch`Fetch changes from the remote repository
`git merge `Merge a branch into the current branch
`git branch`List all branches
`git branch `Create a new branch
`git checkout `Switch to a branch
`git checkout -b `Create and switch to a new branch
`git branch -d `Delete a branch
`git log`Show commit logs
`git diff`Show changes between commits
`git blame `Show who changed each line in a file
`git reflog`Show a log of changes to HEAD
`git reset --hard `Reset the repository to a commit
`git revert `Revert a commit
`git stash`Stash changes in the working directory
`git stash pop`Apply stashed changes to the working directory
`git tag `Create a tag for a commit
## Configuration
CommandDescription
`git config --global user.name `Set the user name for Git
`git config --global user.email `Set the user email for Git
`git config --global core.editor `Set the default text editor for Git
`git config --global color.ui auto`Enable colored output for Git
## Remote Repositories
CommandDescription
`git remote add `Add a remote repository
`git remote -v`List remote repositories
`git remote show `Show information about a remote repository
`git remote rename `Rename a remote repository
`git remote remove `Remove a remote repository
# HTTP Status Codes ## Categories
CodeDescription
**1XX**Informational Requests
**2XX**Successful Requests
**3XX**Redirects
**4XX**Client Errors
**5XX**Server Errors
## Complete List
CodeNameDescription
100ContinueEverything so far is OK and that the client should continue with the request or ignore it if it is already finished.
101Switching ProtocolsThe client has asked the server to change protocols and the server has agreed to do so.
102ProcessingThe server has received and is processing the request, but that it does not have a final response yet.
103Early HintsUsed to return some response headers before final HTTP message.
200OKSuccessful request.
201CreatedThe server acknowledged the created resource.
202AcceptedThe client's request has been received but the server is still processing it.
203Non-Authoritative InformationThe response that the server sent to the client is not the same as it was when the server sent it.
204No ContentThere is no content to send for this request
205Reset ContentTells the user agent to reset the document which sent this request.
206Partial ContentThis response code is used when the range-header is sent from the client to request only part of a resource.
207Multi-StatusConveys information about multiple resources, for situations where multiple status codes might be appropriate.
208Already ReportedThe members of a DAV binding have already been enumerated in a preceding part of the multi-status response.
226IM UsedIM is a specific extension of the HTTP protocol. The extension allows a HTTP server to send diffs (changes) of resources to clients.
300Multiple ChoicesThe request has more than one possible response. The user agent should choose one.
301Moved PermanentlyThe URL of the requested resource has been changed permanently. The new URL is given in the response.
302FoundThis response code means that the URI of requested resource has been changed temporarily
303See OtherThe server sent this response to direct the client to get the requested resource at another URI with a GET request.
304Not ModifiedIt tells the client that the response has not been modified, so the client can continue to use the same cached version of the response.
305Use ProxyDefined in a previous version of the HTTP specification to indicate that a requested response must be accessed by a proxy. (discontinued)
307Temporary RedirectThe server sends this response to direct the client to get the requested resource at another URI with same method that was used in the prior request.
308Permanent RedirectThis means that the resource is now permanently located at another URI, specified by the Location: HTTP Response header.
400Bad RequestThe server could not understand the request
401UnauthorizedThe client didn't authenticate himself.
402Payment RequiredThis response code is reserved for future use. The initial aim for creating this code was using it for digital payment systems, however this status code is used very rarely and no standard convention exists.
403ForbiddenThe client does not have access rights to the content
404Not FoundThe server can not find the requested resource
405Method Not AllowedThe request method is known by the server but is not supported by the target resource
406Not AcceptableThe reponse doens't conforms to the creteria given by the client
407Proxy Authentication RequiredThis is similar to 401 Unauthorized but authentication is needed to be done by a proxy.
408Request TimeoutThis response is sent on an idle connection by some servers, even without any previous request by the client.
409ConflictThis response is sent when a request conflicts with the current state of the server.
410GoneThis response is sent when the requested content has been permanently deleted from server, with no forwarding address.
411Length RequiredServer rejected the request because the Content-Length header field is not defined and the server requires it.
412Precondition FailedAccess to the target resource has been denied.
413Payload Too LargeRequest entity is larger than limits defined by server.
414Request-URI Too LongThe URI requested by the client is longer than the server is willing to interpret.
415Unsupported Media TypeThe media format is not supported by the server.
416Requested Range Not SatisfiableThe range specified by the Range header field in the request cannot be fulfilled.
417Expectation Failedthe expectation indicated by the Expect request header field cannot be met by the server.
418I'm a teapotThe server refuses the attempt to brew coffee with a teapot.
421Misdirected RequestThe request was directed at a server that is not able to produce a response.
422Unprocessable EntityThe request was well-formed but was unable to be followed due to semantic errors.
423LockedThe resource that is being accessed is locked.
424Failed DependencyThe request failed due to failure of a previous request.
426Upgrade RequiredThe server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
428Precondition Requiredhis response is intended to prevent the 'lost update' problem, where a client GETs a resource's state, modifies it and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict.
429Too Many RequestsThe user has sent too many requests in a given amount of time
431Request Header Fields Too LargeThe server is can't process the request because its header fields are too large.
444Connection Closed Without ResponseThe connection opened, but no data was written.
451Unavailable For Legal ReasonsThe user agent requested a resource that cannot legally be provided (such as a web page censored by a government)
499Client Closed RequestThe client closed the connection, despite the server was processing the request already.
500Internal Server ErrorThe server has encountered a situation it does not know how to handle.
501Not ImplementedThe request method is not supported by the server and cannot be handled.
502Bad GatewayThis error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response.
503Service UnavailableThe server is not ready to handle the request.
504Gateway TimeoutThis error response is given when the server is acting as a gateway and cannot get a response in time.
505HTTP Version Not SupportedThe HTTP version used in the request is not supported by the server.
506Variant Also Negotiatesthe chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
507Insufficient StorageThe method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
508Loop DetectedThe server detected an infinite loop while processing the request.
510Not ExtendedFurther extensions to the request are required for the server to fulfill it.
511Network Authentication RequiredIndicates that the client needs to authenticate to gain network access.
599Network Connect Timeout ErrorThe connection timed out due to a overloaded server, a hardware error or a infrastructure error.
# kubectl ## Contexts and Configuration
CommandDescription
`kubectl config view`Show the current kubeconfig file
`kubectl config get-contexts`List all contexts in the kubeconfig file
`kubectl config current-context`Show the current context
`kubectl config use-context `Change the current context
`kubectl config set-context --namespace=`Set the namespace for a context
`kubectl config set-context --cluster=`Set the cluster for a context
`kubectl config set-context --user=`Set the user for a context
`kubectl config set-context --namespace= --cluster= --user=`Set all context properties
## Cluster Management
CommandDescription
`kubectl cluster-info`Display addresses of the master and services
`kubectl get nodes`List all nodes in the cluster
`kubectl get pods`List all pods in the cluster
`kubectl get services`List all services in the cluster
`kubectl get deployments`List all deployments in the cluster
`kubectl get namespaces`List all namespaces in the cluster
`kubectl get events`List all events in the cluster
## Resource Management
CommandDescription
`kubectl apply -f `Apply a configuration file
`kubectl delete -f `Delete a configuration file
`kubectl get `List all resources of a type
`kubectl describe `Describe a resource
`kubectl edit `Edit a resource
`kubectl exec -it -- `Execute a command in a pod
## Pod Management
CommandDescription
`kubectl run --image=`Create a new pod
`kubectl delete pod `Delete a pod
`kubectl get pod `Get details of a pod
`kubectl describe pod `Describe a pod
`kubectl logs `Show logs of a pod
`kubectl exec -it -- /bin/bash`Execute a command in a pod
`kubectl cp : `Copy files from a pod
`kubectl top node`Show metrics for all nodes
`kubectl top pod`Show metrics for all pods
`kubectl top pod `Show metrics for a specific pod
## Service Management
CommandDescription
`kubectl expose pod --port=444 --target-port=555`Expose a pod as a service
`kubectl delete service `Delete a service
`kubectl get service `Get details of a service
`kubectl describe service `Describe a service
## Deployment Management
CommandDescription
`kubectl create deployment --image=`Create a new deployment
`kubectl delete deployment `Delete a deployment
`kubectl get deployment `Get details of a deployment
`kubectl describe deployment `Describe a deployment
`kubectl scale deployment --replicas=3`Scale a deployment to 3 replicas
`kubectl rollout status deployment/`Check the status of a deployment rollout
`kubectl rollout history deployment/`Show the history of a deployment rollout
`kubectl rollout undo deployment/`Rollback a deployment to the previous version
`kubectl rollout undo deployment/ --to-revision=1`Rollback a deployment to a specific revision
## Namespace Management
CommandDescription
`kubectl create namespace `Create a new namespace
`kubectl delete namespace `Delete a namespace
`kubectl get namespace `Get details of a namespace
`kubectl describe namespace `Describe a namespace
# OpenSSL ## Certificate Management
CommandDescription
`openssl req -new -key -out `Generate a new certificate signing request
`openssl req -x509 -key -in -out `Generate a self-signed certificate
`openssl x509 -in -text -noout`Display the details of a certificate
`openssl x509 -in -pubkey -noout`Extract the public key from a certificate
`openssl x509 -in -fingerprint -noout`Display the fingerprint of a certificate
## Key Management
CommandDescription
`openssl genrsa -out 2048`Generate a new RSA private key
`openssl rsa -in -pubout -out `Extract the public key from a private key
`openssl rsa -in -out `Convert a private key to a different format
`openssl rand -hex 16`Generate a random hex string
## Certificate Signing
CommandDescription
`openssl ca -in -out `Sign a certificate request
`openssl ca -config -in -out `Sign a certificate request with a custom configuration
`openssl verify -CAfile `Verify a certificate against a CA file
## Certificate Conversion
CommandDescription
`openssl pkcs12 -export -in -inkey -out `Convert a certificate and key to PKCS#12 format
`openssl pkcs12 -in -out -nodes`Extract a certificate and key from a PKCS#12 file
`openssl x509 -in -outform DER -out `Convert a certificate to DER format
`openssl x509 -in -outform PEM -out `Convert a certificate to PEM format
## Encryption and Decryption
CommandDescription
`openssl enc -aes-256-cbc -salt -in -out `Encrypt a file with AES-256-CBC
`openssl enc -d -aes-256-cbc -in -out `Decrypt a file encrypted with AES-256-CBC
`openssl dgst -sha256 FILE`Calculate the SHA-256 hash of a file
`openssl dgst -md5 FILE`Calculate the MD5 hash of a file
## Miscellaneous
CommandDescription
`openssl version`Display the OpenSSL version
`openssl s_client -connect :`Connect to a server using SSL/TLS
`openssl s_server -accept -cert -key `Start an SSL/TLS server
`openssl speed`Run benchmark tests on OpenSSL algorithms
`openssl ciphers -v`List all available ciphers
`openssl rand -base64 32`Generate a random base64 string
`openssl rand -base64 -out 32`Generate a random base64 string and save it to a file
`openssl rand -out 32`Generate a random binary string and save it to a file
`openssl rand -hex 32`Generate a random hex string
# PostgreSQL ## Connect to PostgreSQL
CommandDescription
`psql -U postgres`Connect to PostgreSQL as the `postgres` user
`psql -U -d `Connect to PostgreSQL as a specific user and database
`psql -U -d -h `Connect to PostgreSQL on a specific host
## PostreSQL CLI Commands
CommandDescription
`\c `Connect to a specific database
`\password `Change password for a specific user
`\l`List all databases
`\d+`Show detailed information about various database objects
`\dt`List all tables in the current database
`\du`List all users
`\df`List all functions
`\dv`List all views
`\dn`List all schemas
`\dp`List all permissions
`\di`List all indexes
`\ds`List all sequences
`\d+`Show detailed information about various database objects
`\q`Quit psql
`\x`Toggle expanded output
## Backup and Restore
CommandDescription
`pg_dump > backup.sql`Backup a database to a file
`psql < backup.sql`Restore a database from a file
# SQL ## Data Definition Language (DDL)
CommandDescription
`CREATE DATABASE `Create a new database
`DROP DATABASE `Delete a database
`CREATE TABLE ( , )`
Create a new table
`DROP TABLE `
Delete a table
`ALTER TABLE ADD COLUMN `
Add a new column to a table
`ALTER TABLE DROP COLUMN `
Remove a column from a table
`ALTER TABLE RENAME COLUMN TO `
Rename a column in a table
`ALTER TABLE RENAME TO `
Rename a table
`TRUNCATE TABLE `
Remove all rows from a table
`CREATE INDEX INDEXNAME ON ()`
Create an index on a table
`DROP INDEX INDEXNAME`Remove an index from a table
## Data Manipulation Language (DML)
CommandDescription
`INSERT INTO (, ) VALUES (, )`
Insert a new row into a table
`SELECT * FROM `
Retrieve all rows from a table
`UPDATE SET = WHERE = `
Update rows in a table
`DELETE FROM WHERE = `
Delete rows from a table
## Data Query Language (DQL)
CommandDescription
`SELECT , FROM `
Retrieve specific columns from a table
`SELECT * FROM WHERE = VALUE`
Retrieve rows that match a condition
`SELECT * FROM ORDER BY `
Retrieve rows sorted by a column
`SELECT * FROM LIMIT N`
Retrieve the first N rows from a table
`SELECT * FROM OFFSET N`
Retrieve rows starting from the Nth row
`SELECT * FROM JOIN ON . = .`
Retrieve rows from two tables that match a condition
`SELECT * FROM UNION SELECT * FROM `
Retrieve rows from two tables without duplicates
`SELECT * FROM GROUP BY `
Group rows that have the same value in a column
`SELECT * FROM HAVING COUNT() > N`
Filter grouped rows that have more than N rows
`SELECT * FROM WHERE IN (, )`
Retrieve rows where a column value matches any value in a list
`SELECT * FROM WHERE BETWEEN AND `
Retrieve rows where a column value is within a range
`SELECT * FROM WHERE LIKE '%'`
Retrieve rows where a column value matches a pattern
`SELECT * FROM WHERE IS NULL`
Retrieve rows where a column value is NULL
`SELECT * FROM WHERE IS NOT NULL`
Retrieve rows where a column value is not NULL
## Data Control Language (DCL)
CommandDescription
`GRANT PERMISSIONS ON TO `
Grant permissions to a user
`REVOKE PERMISSIONS ON FROM `
Revoke permissions from a user
## Transaction Control Language (TCL)
CommandDescription
`BEGIN TRANSACTION`Start a new transaction
`COMMIT`Save changes to the database
`ROLLBACK`Discard changes to the database
`SAVEPOINT `Create a savepoint in a transaction
`ROLLBACK TO SAVEPOINT `Rollback to a savepoint in a transaction
`RELEASE SAVEPOINT `Remove a savepoint in a transaction
## System Commands
CommandDescription
`SHOW DATABASES`List all databases
`SHOW TABLES`List all tables in the current database
`SHOW COLUMNS FROM `
List all columns in a table
`SHOW INDEXES FROM `
List all indexes in a table
`SHOW CREATE TABLE `
Show the SQL statement that creates a table
`DESCRIBE `
Show the structure of a table
`EXPLAIN SELECT * FROM `
Show the execution plan of a query
`SET autocommit = 0`Disable autocommit mode
`SET autocommit = 1`Enable autocommit mode
`SET FOREIGN_KEY_CHECKS = 0`Disable foreign key checks
## User Commands
CommandDescription
`CREATE ''@'' IDENTIFIED BY ''`Create a new user
`DROP ''@''`Delete a user
`ALTER ''@'' IDENTIFIED BY ''`Change password for a user
`GRANT ALL PRIVILEGES ON TO ''@''`Grant all privileges to a user
`REVOKE ALL PRIVILEGES ON FROM ''@''`Revoke all privileges from a user
`FLUSH PRIVILEGES`Reload privileges from the grant tables
# Terraform ## Format and Validate
CommandDescription
`terraform fmt`Reformat your configuration in the standard style
`terraform validate`Check whether the configuration is valid
## Initialize Working Directory
CommandDescription
`terraform init`Prepare your working directory for other commands
## Plan, Deploy and Cleanup
CommandDescription
`terraform apply --auto-approve`Create or update infrastructure without confirmation prompt
`terraform destroy --auto-approve`Destroy previously-created infrastructure without confirmation prompt
`terraform plan -out plan.out`Output the deployment plan to plan.out
`terraform apply plan.out`Use the plan.out to deploy infrastructure
`terraform plan -destroy`Outputs a destroy plan
`terraform apply -target=aws_instance.myinstance`Only apply/deploy changes to targeted resource
`terraform apply -var myregion=us-east-1`Pass a variable via CLI while applying a configuration
`terraform apply -lock=true`Lock the state file so it can't be modified
`terraform apply refresh=false`Do not reconcile state file with real-world resources
`terraform apply --parallelism=5`Number of simultaneous resource operations
`terraform refresh`Reconcile the state in Terraform state file with real-world resources
`terraform providers`Get informatino about providers used in the current configuration
## Workspaces
CommandDescription
`terraform workspace new `Create a new workspace
`terraform workspace select default`Change to a workspace
`terraform workspace list`List all workspaces
## State Manipulation
CommandDescription
`terraform state show aws_instance.myinstance`Show details stored in the Terraform state file
`terraform state pull > terraform.tfstate`Output Terraform state to a file
`terraform state mv aws_iam_role.my_ssm_role module.mymodule`Move a resource tracked via state to different module
`terraform state replace-provider hashicorp/aws registry.custom.com/aws`Replace an existing provider with another
`terraform state list`List all resources tracked in the Terraform state file
`terraform state rm aws_instance.myinstance`Unmanage a resource, delete it from the Terraform state file
## Import and Outputs
CommandDescription
`terraform import . `Import a Resource
`terraform output`List all outputs
`terraform output `List a specific output
`terraform output -json`List all outputs in JSON format
## Terraform Cloud
CommandDescription
`terraform login`Login to Terraform Cloud with an API token
`terraform logout`Logout from Terraform Cloud
# ZFS ## File System Management
CommandDescription
`zfs list`List ZFS file systems
`zfs create /`Create a ZFS file system
`zfs set = /`Set ZFS file system properties
`zfs get /`Get ZFS file system properties
`zfs destroy /`Destroy a ZFS file system
## Pool Management
CommandDescription
`zpool list`List ZFS pools
`zpool create `Create a ZFS pool
`zpool destroy `Destroy a ZFS pool
`zpool iostat`Display ZFS pool I/O statistics
`zpool status`Display ZFS pool status
`zpool history`Display ZFS pool history
`zpool events`Display ZFS pool events
`zpool scrub `Scrub a ZFS pool
`zpool clear `Clear ZFS pool errors
`zpool trim `Trim a ZFS pool
`zpool add `Add a device to a ZFS pool
`zpool remove `Remove a device from a ZFS pool
`zpool replace `Replace a device in a ZFS pool
`zpool offline `Offline a device in a ZFS pool
## Snapshots
CommandDescription
`zfs list -t snapshot`List ZFS snapshots
`zfs snapshot /@`Create a ZFS snapshot
`zfs rollback /@`Rollback a ZFS snapshot
`zfs diff /@ /@`Compare ZFS snapshots
`zfs send /@`Send ZFS snapshots
`zfs receive /`Receive ZFS snapshots
## Clones
CommandDescription
`zfs clone /@ /`Create a ZFS clone
`zfs promote /`Promote a ZFS clone
`zfs rollback /`Rollback a ZFS clone
`zfs destroy /`Destroy a ZFS clone