General
Utilities that can always be useful in different contexts.
Info Commands
Terminal
CTRL + ALT + T
Open terminal window
CTRL + SHIFT + T
New tabs
CTRL + SHIFT + W
Close tabs
ALT + <NUM_TAB>
Move between the tabs
Vim
:q!
Quit without saving
:wq
Save and quit
:w !sudo tee %
Save and quit when you forgot sudo
i
Insert mode before the cursor
a
Insert mode after the cursor
A
Insert mode at the end of the line
o
Add line above and Insert mode
O
Add line below and Insert mode
v
Visual mode
V
Select line and Visual mode
x
Delete character under cursor
dd
Delete line
r
Change one character under cursor
R
Change mode
u
Undo
CTRL + r
Redo
y
" <REG> y
Copy
Specific registers (+
or *
for outside of vim)
p
" <REG> p
Paste
Specific registers (+
or *
for outside of vim)
Tmux
tmux
New session
tmux ls
List sessions
tmux new -s <NAME>
New session <NAME>
tmux kill-ses -t <NAME>
Delete session <NAME>
tmux kill-session
Delete all session
CTRL + b
d
Detach from session
tmux a -t <NAME>
Attach to a session <NAME>
Search & Filter
Manipulation
<COMMAND> |
cut
-f <N> -d "<SEP>"
Split the output by single character <SEP> and return field <N>
<COMMAND> |
awk
-F “<SEP>” '{print $<N1>, $<N2>}'
Split the output by characters <SEP> and return field <N1> and <N2>
<COMMAND> |
tr
"X" ”Y”
Replaces certain characters X with others Y.
<COMMAND> |
sort
-u
Sort and Unique
<COMMAND> |
wc
-w -l -c
Word/Line/Char count
<COMMAND> |
rev
Reverse String
<COMMAND> |
tac
Print in Reverse, starting from the last lines
Regex
<START>
.+?
<END>
Between <START> and <END> including them
<START>
(
.+?
)
<END>
RBetween <START> and <END> excluding them
<START>
(
[^
<END>
]*
)
Between <START> and one of the characters in <END>
+
At least 1 character
*
Even without
Encoding
Extract
Cross-Compiling
TOR
Start service TOR
Set ProxyChains
Use command over TOR
GIT
Access by token
Create tokens in
Settings/Developer
> Settings/Personal
> access
> token
Insert token
git clone https://<USERNAME>:<TOKEN>@github.com/<USERNAME>/<REPOSITORY>
Or
git remote set-url origin https://<USERNAME>:<TOKEN>@github.com/<USERNAME>/<REPOSITORY>
Downloading GitHub repositories
git clone <LINK_REPOSITORY_GITHUB>
Download repository changes
git pull origin main
Loading repository changes
git commit -m "<DESCRIPTION>"
git push origin main
Docker
Manages single containere. dockerfile
docker build -t <name> .
docker --version
Docker version
docker search <STRING>
Search in the Docker Hub
docker login <DOMAIN>/<IMG_NAME>
It may require authentication if you are pulling unofficial images, so you need to authenticate for that domain and image first. See a domain's registry list at <DOMAIN>/v2/_catalog
.
docker pull <IMG_NAME>[:<VERSION>]
Download image from Docker Hub
docker inspect <IMG_NAME>
View information about the Docker image.
docker image
View possible commands for managing Docker images, such as ls
docker volume
View possible commands for managing Docker volumes, such as ls
docker volume create <VOLUME_NAME>
Create a volume and give it a name. They are used to store data persistently.
docker network
View possible commands for managing Docker network, such as ls
docker network create (…) <NETWORK_NAME>
Creating a network. It is important to specify:
--driver=bridge
: Specify the type of driver
--subnet=<ip/mask>
: Specify the subnet to be used by the container (ex. 172.18. 0.0/16
)
--gateway=<ip/mask>
: Specify the gateway to communicate outside the container (ex. typically 172.18. 0.1
)
docker run <IMG_NAME>
Runs a container from a specified Docker image.
--name=<NAME>
: Give a name to the container.
-d
: Run the container in the background.
-p <H_PORT>:<C_PORT>
: Perform port mapping. connect my H port to the C container port.
-v <VOLUME_NAME>:<C_PATH>
: Use a volume. Associate a created volume with a container PATH.
-v <H_PATH>:<C_PATH>
: Use a volume. Associate a PATH on the HOST system with a container PATH.
--network=<NETWORK_NAME>
: Start the container on a previously created network
-h <HOSTNAME>
: Specify hostname
docker run -it <IMG_NAME> bash
Start container but in interactive mode, connect to the container terminal.
CTRL+P
and CTRL+Q
: Exit from the container while leaving it running.
docker attach <ID>
Resume interaction with a container.
docker exec -it <ID_CONTAINER> bash
Runs a new interaction process with a container's terminal (also used to reconnect after exiting, like attach).
docker ps
Show running containers.
-a
: Also show stopped containers (if you want to remove them).
docker top <ID_CONTAINER>
View the processes running inside a container.
docker logs <ID_CONTAINER>
View logs of a container.
docker stat <ID_CONTAINER>
Provides real-time information about the resources used by a container.
docker stop <ID_CONTAINER>
Stops a running container.
docker start <ID_CONTAINER>
Run a stopped container.
docker rm <ID_CONTAINER>
Remove and delete a container.
docker container prune
Remove all stopped containers.
docker history <IMG_NAME>
View history of operations related to a Docker image.
docker system prune
Complete cleaning of everything, be careful! (does not delete images)
docker save -o <NAME>.tar <IMG_NAME>
Save a Docker image, including all its layers and metadata.
With ls -q
it prints only the IDs.
Last updated