updated smaller collections for manual
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
<h1> Computer and IT Basics </h1>
|
||||
|
||||
Welcome to the *Computer and IT Basics* section of the ThreeFold Manual!
|
||||
|
||||
In this section, tailored specifically for system administrators, we'll delve into fundamental concepts and tools that form the backbone of managing and securing infrastructure. Whether you're a seasoned sysadmin or just starting your journey, these basics are essential for navigating the intricacies of the ThreeFold Grid.
|
||||
|
||||
<h2> Table of Contents </h2>
|
||||
|
||||
- [CLI and Scripts Basics](./cli_scripts_basics.md)
|
||||
- [Docker Basics](./docker_basics.md)
|
||||
- [Git and GitHub Basics](./git_github_basics.md)
|
||||
- [Firewall Basics](./firewall_basics/firewall_basics.md)
|
||||
- [UFW Basics](./firewall_basics/ufw_basics.md)
|
||||
- [Firewalld Basics](./firewall_basics/firewalld_basics.md)
|
||||
- [File Transfer](./file_transfer.md)
|
||||
- [Screenshots](./screenshots.md)
|
@@ -0,0 +1,458 @@
|
||||
<h1>Docker Basic Commands</h1>
|
||||
|
||||
<h2>Table of Contents</h2>
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Basic Commands](#basic-commands)
|
||||
- [Install Docker Desktop and Docker Engine](#install-docker-desktop-and-docker-engine)
|
||||
- [Remove completely Docker](#remove-completely-docker)
|
||||
- [List containers](#list-containers)
|
||||
- [Pull an image](#pull-an-image)
|
||||
- [Push an image](#push-an-image)
|
||||
- [Inspect and pull an image with GHCR](#inspect-and-pull-an-image-with-ghcr)
|
||||
- [See a docker image (no download)](#see-a-docker-image-no-download)
|
||||
- [Build a container](#build-a-container)
|
||||
- [List all available docker images](#list-all-available-docker-images)
|
||||
- [Run a container](#run-a-container)
|
||||
- [Run a new command in an existing container](#run-a-new-command-in-an-existing-container)
|
||||
- [Bash shell into container](#bash-shell-into-container)
|
||||
- [Pass arguments with a bash script and a Dockerfile](#pass-arguments-with-a-bash-script-and-a-dockerfile)
|
||||
- [Copy files from a container to the local computer](#copy-files-from-a-container-to-the-local-computer)
|
||||
- [Delete all the containers, images and volumes](#delete-all-the-containers-images-and-volumes)
|
||||
- [Kill all the Docker processes](#kill-all-the-docker-processes)
|
||||
- [Output full logs for all containers](#output-full-logs-for-all-containers)
|
||||
- [Resources Usage](#resources-usage)
|
||||
- [Examine containers with size](#examine-containers-with-size)
|
||||
- [Examine disks usage](#examine-disks-usage)
|
||||
- [Wasted Resources](#wasted-resources)
|
||||
- [Prune the Docker logs](#prune-the-docker-logs)
|
||||
- [Prune the Docker containers](#prune-the-docker-containers)
|
||||
- [Remove unused and untagged local container images](#remove-unused-and-untagged-local-container-images)
|
||||
- [Clean up and delete all unused container images](#clean-up-and-delete-all-unused-container-images)
|
||||
- [Clean up container images based on a given timeframe](#clean-up-container-images-based-on-a-given-timeframe)
|
||||
- [Command Combinations](#command-combinations)
|
||||
- [Kill all running containers](#kill-all-running-containers)
|
||||
- [Stop all running containers](#stop-all-running-containers)
|
||||
- [Delete all stopped containers](#delete-all-stopped-containers)
|
||||
- [Delete all images](#delete-all-images)
|
||||
- [Update and stop a container in a crash-loop](#update-and-stop-a-container-in-a-crash-loop)
|
||||
- [References](#references)
|
||||
|
||||
***
|
||||
|
||||
## Introduction
|
||||
|
||||
We present here a quick introduction to Docker. We cover basic commands, as well as command combinations. Understanding the following should give system administrators confidence when it comes to using Docker efficiently.
|
||||
|
||||
The following can serve as a quick reference guide when deploying workloads on the ThreeFold Grid and using Docker in general.
|
||||
|
||||
We invite the readers to consult the [official Docker documentation](https://docs.docker.com/) for more information.
|
||||
|
||||
|
||||
|
||||
## Basic Commands
|
||||
|
||||
### Install Docker Desktop and Docker Engine
|
||||
|
||||
You can install [Docker Desktop](https://docs.docker.com/get-docker/) and [Docker Engine](https://docs.docker.com/engine/install/) for Linux, MAC and Windows. Follow the official Docker documentation for the details.
|
||||
|
||||
Note that the quickest way to install Docker Engine is to use the convenience script:
|
||||
|
||||
```
|
||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
||||
sudo sh get-docker.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Remove completely Docker
|
||||
|
||||
To completely remove docker from your machine, you can follow these steps:
|
||||
|
||||
* List the docker packages
|
||||
* ```
|
||||
dpkg -l | grep -i docker
|
||||
```
|
||||
* Purge and autoremove docker
|
||||
* ```
|
||||
apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli docker-compose-plugin
|
||||
apt-get autoremove -y --purge docker-engine docker docker.io docker-ce docker-compose-plugin
|
||||
```
|
||||
* Remove the docker files and folders
|
||||
* ```
|
||||
rm -rf /var/lib/docker /etc/docker
|
||||
rm /etc/apparmor.d/docker
|
||||
groupdel docker
|
||||
rm -rf /var/run/docker.sock
|
||||
```
|
||||
|
||||
You can also use the command **whereis docker** to see if any Docker folders and files remain. If so, remove them with
|
||||
|
||||
|
||||
|
||||
### List containers
|
||||
|
||||
* List only running containers
|
||||
* ```
|
||||
docker ps
|
||||
```
|
||||
* List all containers (running + stopped)
|
||||
* ```
|
||||
docker ps -a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Pull an image
|
||||
|
||||
To pull an image from [Docker Hub](https://hub.docker.com/):
|
||||
|
||||
* Pull an image
|
||||
* ```
|
||||
docker pull <image_name>
|
||||
```
|
||||
* Pull an image with the tag
|
||||
* ```
|
||||
docker pull <image_name>:tag
|
||||
```
|
||||
* Pull all tags of an image
|
||||
* ```
|
||||
docker pull <image_name> -a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Push an image
|
||||
|
||||
To pull an image to [Docker Hub](https://hub.docker.com/):
|
||||
|
||||
* Push an image
|
||||
* ```
|
||||
docker push <image_name>
|
||||
```
|
||||
* Push an image with the tag
|
||||
* ```
|
||||
docker push <image_name>:tag
|
||||
```
|
||||
* Push all tags of an image
|
||||
* ```
|
||||
docker pull <image_name> -a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Inspect and pull an image with GHCR
|
||||
|
||||
* Inspect the docker image
|
||||
* ```
|
||||
docker inspect ghcr.io/<repository>/<image>:<tag>
|
||||
```
|
||||
* Pull the docker image
|
||||
* ```
|
||||
docker pull ghcr.io/<repository>/<image>:<tag>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### See a docker image (no download)
|
||||
|
||||
If you want to see a docker image without downloading the image itself, you can use Quay's [Skopeo tool](https://github.com/containers/skopeo), a command line utility that performs various operations on container images and image repositories.
|
||||
|
||||
```
|
||||
docker run --rm quay.io/skopeo/stable list-tags docker://ghcr.io/<repository>/<image>
|
||||
```
|
||||
|
||||
Make sure to write the proper information for the repository and the image.
|
||||
|
||||
To install Skopeo, read [this documentation](https://github.com/containers/skopeo/blob/main/install.md).
|
||||
|
||||
|
||||
|
||||
|
||||
### Build a container
|
||||
|
||||
Use **docker build** to build a container based on a Dockerfile
|
||||
|
||||
* Build a container based on current directory Dockerfile
|
||||
* ```
|
||||
docker build .
|
||||
```
|
||||
* Build a container and store the image with a given name
|
||||
* Template
|
||||
* ```
|
||||
docker build -t "<image_name>:<tag>"
|
||||
```
|
||||
* Example
|
||||
* ```
|
||||
docker build -t newimage:latest
|
||||
```
|
||||
* Build a docker container without using the cache
|
||||
* ```
|
||||
docker build --no-cache
|
||||
```
|
||||
|
||||
|
||||
|
||||
### List all available docker images
|
||||
|
||||
```
|
||||
docker images
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Run a container
|
||||
|
||||
To run a container based on an image, use the command **docker run**.
|
||||
|
||||
* Run an image
|
||||
* ```
|
||||
docker run <image_name>
|
||||
```
|
||||
* Run an image in the background (run and detach)
|
||||
* ```
|
||||
docker run -d <image_name>
|
||||
```
|
||||
* Run an image with CLI input
|
||||
* ```
|
||||
docker run -it <image_name>
|
||||
```
|
||||
|
||||
You can combine arguments, e.g. **docker run -itd**.
|
||||
|
||||
You can also specify the shell, e.g. **docker run -it <image_name> /bin/bash**
|
||||
|
||||
|
||||
|
||||
### Run a new command in an existing container
|
||||
|
||||
To run a new command in an existing container, use **docker exec**.
|
||||
|
||||
* Execute interactive shell on the container
|
||||
* ```
|
||||
docker exec -it <container_name> sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Bash shell into container
|
||||
|
||||
* Bash shell into a container
|
||||
* ```
|
||||
docker exec -i -t /bin/bash
|
||||
```
|
||||
* Bash shell into a container with root
|
||||
* ```
|
||||
docker exec -i -t -u root /bin/bash
|
||||
```
|
||||
|
||||
Note: if bash is not available, you can use `/bin/sh`
|
||||
|
||||
|
||||
|
||||
### Pass arguments with a bash script and a Dockerfile
|
||||
|
||||
You can do the following to pass arguments with a bash script and a Dockerfile.
|
||||
|
||||
```sh
|
||||
# script_example.sh
|
||||
#!/bin/sh
|
||||
|
||||
echo This is the domain: $env_domain
|
||||
echo This is the name: $env_name
|
||||
echo This is the password: $env_password
|
||||
|
||||
```
|
||||
* File `Dockerfile`
|
||||
|
||||
```Dockerfile
|
||||
FROM ubuntu:latest
|
||||
|
||||
ARG domain
|
||||
|
||||
ARG name
|
||||
|
||||
ARG password
|
||||
|
||||
ENV env_domain $domain
|
||||
|
||||
ENV env_name $name
|
||||
|
||||
ENV env_password $password
|
||||
|
||||
COPY script_example.sh .
|
||||
|
||||
RUN chmod +x /script_example.sh
|
||||
|
||||
CMD ["/script_example.sh"]
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Copy files from a container to the local computer
|
||||
|
||||
```
|
||||
docker cp <container_id>:<file_path> <file_path_destination>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Delete all the containers, images and volumes
|
||||
|
||||
* To delete all containers:
|
||||
* ```
|
||||
docker compose rm -f -s -v
|
||||
```
|
||||
|
||||
* To delete all images:
|
||||
* ```
|
||||
docker rmi -f $(docker images -aq)
|
||||
```
|
||||
|
||||
* To delete all volumes:
|
||||
* ```
|
||||
docker volume rm $(docker volume ls -qf dangling=true)
|
||||
```
|
||||
|
||||
* To delete all containers, images and volumes:
|
||||
* ```
|
||||
docker compose rm -f -s -v && docker rmi -f $(docker images -aq) && docker volume rm $(docker volume ls -qf dangling=true)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Kill all the Docker processes
|
||||
|
||||
* To kill all processes:
|
||||
* ```
|
||||
killall Docker && open /Applications/Docker.app
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Output full logs for all containers
|
||||
|
||||
The following command output the full logs for all containers in the file **containers.log**:
|
||||
|
||||
```
|
||||
docker compose logs > containers.log
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Resources Usage
|
||||
|
||||
### Examine containers with size
|
||||
|
||||
```
|
||||
docker ps -s
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Examine disks usage
|
||||
|
||||
* Basic mode
|
||||
* ```
|
||||
docker system df
|
||||
```
|
||||
* Verbose mode
|
||||
* ```
|
||||
docker system df -v
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Wasted Resources
|
||||
|
||||
### Prune the Docker logs
|
||||
|
||||
```
|
||||
docker system prune
|
||||
```
|
||||
|
||||
### Prune the Docker containers
|
||||
|
||||
You can use the prune function to delete all stopped containers:
|
||||
|
||||
```
|
||||
docker container prune
|
||||
```
|
||||
|
||||
### Remove unused and untagged local container images
|
||||
|
||||
The following is useful if you want to clean up local filesystem:
|
||||
|
||||
```
|
||||
docker image prune
|
||||
```
|
||||
|
||||
### Clean up and delete all unused container images
|
||||
|
||||
```
|
||||
docker image prune -a
|
||||
```
|
||||
|
||||
### Clean up container images based on a given timeframe
|
||||
|
||||
To clean up container images created X hours ago, you can use the following template (replace <X> with a number):
|
||||
|
||||
```
|
||||
docker image prune -a --force --filter "until=<X>h"
|
||||
```
|
||||
|
||||
To clean up container images created before a given date, you can use the following template (replace <date> with the complete date):
|
||||
|
||||
```
|
||||
docker image prune -a --force --filter "until=<date>"
|
||||
```
|
||||
|
||||
Note: An example of a complete date would be `2023-01-04T00:00:00`
|
||||
|
||||
|
||||
|
||||
## Command Combinations
|
||||
|
||||
### Kill all running containers
|
||||
|
||||
```
|
||||
docker kill $(docker ps -q)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Stop all running containers
|
||||
|
||||
```
|
||||
docker stop $(docker ps -a -q)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Delete all stopped containers
|
||||
|
||||
```
|
||||
docker rm $(docker ps -a -q)
|
||||
```
|
||||
|
||||
|
||||
### Delete all images
|
||||
|
||||
```
|
||||
docker rmi $(docker images -q)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Update and stop a container in a crash-loop
|
||||
|
||||
```
|
||||
docker update –restart=no && docker stop
|
||||
```
|
||||
|
||||
|
||||
|
||||
## References
|
||||
|
||||
* Docker Manual - https://docs.docker.com/
|
||||
* Code Notary - https://codenotary.com/blog/extremely-useful-docker-commands
|
@@ -0,0 +1,271 @@
|
||||
<h1>File Transfer</h1>
|
||||
|
||||
<h2>Table of Contents</h2>
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [SCP](#scp)
|
||||
- [File transfer with IPv4](#file-transfer-with-ipv4)
|
||||
- [File transfer with IPv6](#file-transfer-with-ipv6)
|
||||
- [Rsync](#rsync)
|
||||
- [File transfer](#file-transfer)
|
||||
- [Adjust reorganization of files and folders before running rsync](#adjust-reorganization-of-files-and-folders-before-running-rsync)
|
||||
- [Automate backup with rsync](#automate-backup-with-rsync)
|
||||
- [Parameters --checksum and --ignore-times with rsync](#parameters---checksum-and---ignore-times-with-rsync)
|
||||
- [Trailing slashes with rsync](#trailing-slashes-with-rsync)
|
||||
- [SFTP](#sftp)
|
||||
- [SFTP on the Terminal](#sftp-on-the-terminal)
|
||||
- [SFTP Basic Commands](#sftp-basic-commands)
|
||||
- [SFTP File Transfer](#sftp-file-transfer)
|
||||
- [SFTP with FileZilla](#sftp-with-filezilla)
|
||||
- [Install FileZilla](#install-filezilla)
|
||||
- [Add a Private Key](#add-a-private-key)
|
||||
- [FileZilla SFTP Connection](#filezilla-sftp-connection)
|
||||
- [Questions and Feedback](#questions-and-feedback)
|
||||
|
||||
***
|
||||
|
||||
## Introduction
|
||||
|
||||
Deploying on the TFGrid with tools such as the Playground and Terraform is easy and it's also possible to quickly transfer files between local machine and VMs deployed on 3Nodes on the TFGrid. In this section, we cover different ways to transfer files between local and remote machines.
|
||||
|
||||
## SCP
|
||||
|
||||
### File transfer with IPv4
|
||||
|
||||
* From local to remote, write the following on the local terminal:
|
||||
* ```
|
||||
scp <path_to_local_file>/<filename> <remote_username>@<remote_IPv4_address>:/<remote_username>/<path_to_remote_file>/<filename>
|
||||
```
|
||||
* From remote to local, you can write the following on the local terminal (more secure):
|
||||
* ```
|
||||
scp <remote_username>@<remote_IPv4_address>:/<remote_username>/<path_to_remote_file>/<filename> <path_to_local_file>/<file>
|
||||
* From remote to local, you can also write the following on the remote terminal:
|
||||
* ```
|
||||
scp <path_to_remote_file>/<file> <local_user>@<local_IPv4_address>:/<local_username>/<path_to_local_file>/<filename>
|
||||
|
||||
### File transfer with IPv6
|
||||
|
||||
For IPv6, it is similar to IPv4 but you need to add `-6` after scp and add `\[` before and `\]` after the IPv6 address.
|
||||
|
||||
## Rsync
|
||||
|
||||
### File transfer
|
||||
|
||||
[rsync](https://rsync.samba.org/) is a utility for efficiently transferring and synchronizing files between a computer and a storage drive and across networked computers by comparing the modification times and sizes of files.
|
||||
|
||||
We show here how to transfer files between two computers. Note that at least one of the two computers must be local. This will transfer the content of the source directory into the destination directory.
|
||||
|
||||
* From local to remote
|
||||
* ```
|
||||
rsync -avz --progress --delete /path/to/local/directory/ remote_user@<remote_host_or_ip>:/path/to/remote/directory
|
||||
```
|
||||
* From remote to local
|
||||
* ```
|
||||
rsync -avz --progress --delete remote_user@<remote_host_or_ip>:/path/to/remote/directory/ /path/to/local/directory
|
||||
```
|
||||
|
||||
Here is short description of the parameters used:
|
||||
|
||||
* **-a**: archive mode, preserving the attributes of the files and directories
|
||||
* **-v**: verbose mode, displaying the progress of the transfer
|
||||
* **-z**: compress mode, compressing the data before transferring
|
||||
* **--progress** tells rsync to print information showing the progress of the transfer
|
||||
* **--delete** tells rsync to delete files that aren't on the sending side
|
||||
|
||||
### Adjust reorganization of files and folders before running rsync
|
||||
|
||||
[rsync-sidekick](https://github.com/m-manu/rsync-sidekick) propagates changes from source directory to destination directory. You can run rsync-sidekick before running rsync. Make sure that [Go is installed](#install-go).
|
||||
|
||||
* Install rsync-sidekick
|
||||
* ```
|
||||
sudo go install github.com/m-manu/rsync-sidekick@latest
|
||||
```
|
||||
* Reorganize the files and folders with rsync-sidekick
|
||||
* ```
|
||||
rsync-sidekick /path/to/local/directory/ username@IP_Address:/path/to/remote/directory
|
||||
```
|
||||
|
||||
* Transfer and update files and folders with rsync
|
||||
* ```
|
||||
sudo rsync -avz --progress --delete --log-file=/path/to/local/directory/rsync_storage.log /path/to/local/directory/ username@IP_Address:/path/to/remote/directory
|
||||
```
|
||||
|
||||
### Automate backup with rsync
|
||||
|
||||
We show how to automate file transfers between two computers using rsync.
|
||||
|
||||
* Create the script file
|
||||
* ```
|
||||
nano rsync_backup.sh
|
||||
```
|
||||
* Write the following script with the proper paths. Here the log is saved in the same directory.
|
||||
* ```
|
||||
# filename: rsync_backup.sh
|
||||
#!/bin/bash
|
||||
|
||||
sudo rsync -avz --progress --delete --log-file=/path/to/local/directory/rsync_storage.log /path/to/local/directory/ username@IP_Address:/path/to/remote/directory
|
||||
```
|
||||
* Give permission
|
||||
* ```
|
||||
sudo chmod +x /path/to/script/rsync_backup.sh
|
||||
```
|
||||
* Set a cron job to run the script periodically
|
||||
* Copy your .sh file to **/root**:
|
||||
```
|
||||
sudo cp path/to/script/rsync_backup.sh /root
|
||||
```
|
||||
* Open the cron file
|
||||
* ```
|
||||
sudo crontab -e
|
||||
```
|
||||
* Add the following to run the script everyday. For this example, we set the time at 18:00PM
|
||||
* ```
|
||||
0 18 * * * /root/rsync_backup.sh
|
||||
```
|
||||
|
||||
### Parameters --checksum and --ignore-times with rsync
|
||||
|
||||
Depending on your situation, the parameters **--checksum** or **--ignore-times** can be quite useful. Note that adding either parameter will slow the transfer.
|
||||
|
||||
* With **--ignore time**, you ignore both the time and size of each file. This means that you transfer all files from source to destination.
|
||||
* ```
|
||||
rsync --ignore-time source_folder/ destination_folder
|
||||
```
|
||||
* With **--checksum**, you verify with a checksum that the files from source and destination are the same. This means that you transfer all files that have a different checksum compared source to destination.
|
||||
* ```
|
||||
rsync --checksum source_folder/ destination_folder
|
||||
```
|
||||
|
||||
### Trailing slashes with rsync
|
||||
|
||||
rsync does not act the same whether you use or not a slash ("\/") at the end of the source path.
|
||||
|
||||
* Copy content of **source_folder** into **destination_folder** to obtain the result: **destination_folder/source_folder_content**
|
||||
* ```
|
||||
rsync source_folder/ destination_folder
|
||||
```
|
||||
* Copy **source_folder** into **destination_folder** to obtain the result: **destination_folder/source_folder/source_folder_content**
|
||||
* ```
|
||||
rsync source_folder destination_folder
|
||||
```
|
||||
|
||||
|
||||
|
||||
## SFTP
|
||||
|
||||
### SFTP on the Terminal
|
||||
|
||||
Using SFTP for file transfer on the terminal is very quick since the SSH connection is already enabled by default when deploying workloads on the TFGrid.
|
||||
|
||||
If you can use the following command to connect to a VM on the TFGrid:
|
||||
|
||||
```
|
||||
ssh root@VM_IP
|
||||
```
|
||||
|
||||
Then, it means you can use SFTP to access the same VM:
|
||||
|
||||
```
|
||||
sftp root@VM_IP
|
||||
```
|
||||
|
||||
Once in the server via SFTP, you can use the command line to get all the commands with `help` or `?`:
|
||||
|
||||
```
|
||||
help
|
||||
```
|
||||
|
||||
### SFTP Basic Commands
|
||||
|
||||
Here are some common commands for SFTP.
|
||||
|
||||
| Command | Function |
|
||||
| --------------------------- | ----------------------------------- |
|
||||
| bye | Quit sftp |
|
||||
| cd path | Change remote directory to 'path' |
|
||||
| help | Display this help text |
|
||||
| pwd | Display remote working directory |
|
||||
| lpwd | Print local working directory |
|
||||
| ls [-1afhlnrSt] [path] | Display remote directory listing |
|
||||
| mkdir path | Create remote directory |
|
||||
| put [-afpR] local [remote] | Upload file |
|
||||
| get [-afpR] remote [local] | Download file |
|
||||
| quit | Quit sftp |
|
||||
| rm path | Delete remote file |
|
||||
| rmdir path | Remove remote directory |
|
||||
| version | Show SFTP version |
|
||||
| !command | Execute 'command' in local shell |
|
||||
|
||||
|
||||
### SFTP File Transfer
|
||||
|
||||
Using SFTP to transfer a file from the local machine to the remote VM is as simple as the following line:
|
||||
|
||||
```
|
||||
put /local/path/file
|
||||
```
|
||||
|
||||
This will transfer the file in the current user home directory of the remote VM.
|
||||
|
||||
To transfer the file in a given directory, use the following:
|
||||
|
||||
```
|
||||
put /local/path/file /remote/path/
|
||||
```
|
||||
|
||||
To transfer a file from the remote VM to the local machine, you can use the command `get`:
|
||||
|
||||
```
|
||||
get /remote/path/file /local/path
|
||||
```
|
||||
|
||||
To transfer (`get` or `put`) all the files within a directory, use the `-r` argument, as shown in the following example
|
||||
|
||||
```
|
||||
get -r /remote/path/to/directory /local/path
|
||||
```
|
||||
|
||||
## SFTP with FileZilla
|
||||
|
||||
[FileZilla](https://filezilla-project.org/) is a free and open-source, cross-platform FTP application, consisting of FileZilla Client and FileZilla Server.
|
||||
|
||||
It is possible to use FileZilla Client to transfer files between your local machine and a remote VM on the TFGrid.
|
||||
|
||||
Since SSH is set, the user basically only needs to add the private key in FileZilla and enter the VM credentials to connect using SFTP in FileZilla.
|
||||
|
||||
### Install FileZilla
|
||||
|
||||
FileZilla is available on Linux, MAC and Windows on the [FileZilla website](https://filezilla-project.org/download.php?type=client). Simply follow the steps to properly download and install FileZilla Client.
|
||||
|
||||
### Add a Private Key
|
||||
|
||||
To prepare a connection using FileZilla, you need to add the private key of the SSH key pair.
|
||||
|
||||
Simply add the file `id_rsa` in **SFTP**.
|
||||
|
||||
- Open FileZilla Client
|
||||
- Go to **Edit** -> **Settings** -> **Connection** -> **SFTP**
|
||||
- Then click on **Add key file...**
|
||||
- Search the `id.rsa` file usually located in `~/.ssh/id_rsa`
|
||||
- Click on **OK**
|
||||
|
||||
### FileZilla SFTP Connection
|
||||
|
||||
You can set a connection between your local machine and a remote 3Node with FileZilla by using **root** as **Username** and the VM IP address as **Host**.
|
||||
|
||||
- Enter the credentials
|
||||
- Host
|
||||
- `VM_IP_Address`
|
||||
- Username
|
||||
- `root`
|
||||
- Password
|
||||
- As set by the user. Can be empty.
|
||||
- Port
|
||||
- `22`
|
||||
- Click on **Quickconnect**
|
||||
|
||||
You can now transfer files between the local machine and the remote VM with FileZilla.
|
||||
|
||||
## Questions and Feedback
|
||||
|
||||
If you have any questions, you can ask the ThreeFold community for help on the [ThreeFold Forum](http://forum.threefold.io/) or on the [ThreeFold Grid Tester Community](https://t.me/threefoldtesting) on Telegram.
|
@@ -0,0 +1,8 @@
|
||||
<h1> Firewall Basics </h1>
|
||||
|
||||
In this section, we cover the basic information concerning Firewall uses on Linux, most notably, we give basic commands and information on UFW and Firewalld.
|
||||
|
||||
<h2> Table of Contents </h2>
|
||||
|
||||
- [UFW Basics](./ufw_basics.md)
|
||||
- [Firewalld Basics](./firewalld_basics.md)
|
@@ -0,0 +1,149 @@
|
||||
<h1>Firewalld Basic Commands</h1>
|
||||
|
||||
<h2>Table of Contents</h2>
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Firewalld Basic Commands](#firewalld-basic-commands)
|
||||
- [Install Firewalld](#install-firewalld)
|
||||
- [See the Status of Firewalld](#see-the-status-of-firewalld)
|
||||
- [Enable Firewalld](#enable-firewalld)
|
||||
- [Stop Firewalld](#stop-firewalld)
|
||||
- [Start Firewalld](#start-firewalld)
|
||||
- [Disable Firewalld](#disable-firewalld)
|
||||
- [Mask Firewalld](#mask-firewalld)
|
||||
- [Unmask Firewalld](#unmask-firewalld)
|
||||
- [Add a Service to Firewalld](#add-a-service-to-firewalld)
|
||||
- [Remove a Service to Firewalld](#remove-a-service-to-firewalld)
|
||||
- [Remove the Diles of a Service to Firewalld](#remove-the-diles-of-a-service-to-firewalld)
|
||||
- [See if a Service is Available](#see-if-a-service-is-available)
|
||||
- [Reload Firewalld](#reload-firewalld)
|
||||
- [Display the Services and the Open Ports for the Public Zone](#display-the-services-and-the-open-ports-for-the-public-zone)
|
||||
- [Display the Open Ports by Services and Port Numbers](#display-the-open-ports-by-services-and-port-numbers)
|
||||
- [Add a Port for tcp](#add-a-port-for-tcp)
|
||||
- [Add a Port for udp](#add-a-port-for-udp)
|
||||
- [Add a Port for tcp and udp](#add-a-port-for-tcp-and-udp)
|
||||
- [References](#references)
|
||||
|
||||
|
||||
## Introduction
|
||||
|
||||
We present a quick introduction to [firewalld](https://firewalld.org/), a free and open-source firewall management tool for Linux operating systems. This guide can be useful for users of the TFGrid deploying on full and micro VMs as well as other types of deployment.
|
||||
|
||||
## Firewalld Basic Commands
|
||||
|
||||
### Install Firewalld
|
||||
|
||||
* ```
|
||||
apt install firewalld -y
|
||||
```
|
||||
### See the Status of Firewalld
|
||||
|
||||
* ```
|
||||
firewall-cmd --state
|
||||
```
|
||||
### Enable Firewalld
|
||||
|
||||
* ```
|
||||
systemctl enablefirewalld
|
||||
```
|
||||
### Stop Firewalld
|
||||
|
||||
* ```
|
||||
systemctl stop firewalld
|
||||
```
|
||||
### Start Firewalld
|
||||
|
||||
* ```
|
||||
systemctl start firewalld
|
||||
```
|
||||
### Disable Firewalld
|
||||
|
||||
* ```
|
||||
systemctl disable firewalld
|
||||
```
|
||||
### Mask Firewalld
|
||||
|
||||
* ```
|
||||
systemctl mask --now firewalld
|
||||
```
|
||||
### Unmask Firewalld
|
||||
|
||||
* ```
|
||||
systemctl unmask --now firewalld
|
||||
```
|
||||
### Add a Service to Firewalld
|
||||
|
||||
* Temporary
|
||||
* ```
|
||||
firewall-cmd --add-service=<service_name>
|
||||
```
|
||||
* Permanent
|
||||
* ```
|
||||
firewall-cmd --add-service=<service_name> --permanent
|
||||
```
|
||||
|
||||
### Remove a Service to Firewalld
|
||||
|
||||
* Temporary
|
||||
* ```
|
||||
firewall-cmd --remove-service=<service_name>
|
||||
```
|
||||
* Permanent
|
||||
* ```
|
||||
firewall-cmd --remove-service=<service_name> --permanent
|
||||
```
|
||||
|
||||
### Remove the Diles of a Service to Firewalld
|
||||
|
||||
* ```
|
||||
rm -f /etc/firewalld/services/<service_name>.xml*
|
||||
```
|
||||
|
||||
### See if a Service is Available
|
||||
|
||||
* ```
|
||||
firewall-cmd --info-service=<service_name>
|
||||
```
|
||||
|
||||
### Reload Firewalld
|
||||
|
||||
* ```
|
||||
firewall-cmd --reload
|
||||
```
|
||||
|
||||
### Display the Services and the Open Ports for the Public Zone
|
||||
|
||||
* ```
|
||||
firewall-cmd --list-all --zone=public
|
||||
```
|
||||
|
||||
### Display the Open Ports by Services and Port Numbers
|
||||
|
||||
* By services
|
||||
* ```
|
||||
firewall-cmd --list-services
|
||||
```
|
||||
* By port numbers
|
||||
* ```
|
||||
firewall-cmd --list-ports
|
||||
```
|
||||
|
||||
### Add a Port for tcp
|
||||
|
||||
* ```
|
||||
firewall-cmd --zone=public --add-port=<port>/tcp
|
||||
```
|
||||
### Add a Port for udp
|
||||
|
||||
* ```
|
||||
firewall-cmd --zone=public --add-port=<port>/udp
|
||||
```
|
||||
### Add a Port for tcp and udp
|
||||
|
||||
* ```
|
||||
firewall-cmd --zone=public --add-port=<port>
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
ufw man pages - https://firewalld.org/documentation/man-pages/firewalld.html
|
@@ -0,0 +1,256 @@
|
||||
|
||||
<h1> Uncomplicated Firewall (ufw) Basic Commands</h1>
|
||||
|
||||
<h2>Table of Contents</h2>
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Basic Commands](#basic-commands)
|
||||
- [Install ufw](#install-ufw)
|
||||
- [Enable ufw](#enable-ufw)
|
||||
- [Disable ufw](#disable-ufw)
|
||||
- [Reset ufw](#reset-ufw)
|
||||
- [Reload ufw](#reload-ufw)
|
||||
- [Deny Incoming Connections](#deny-incoming-connections)
|
||||
- [Allow Outgoing Connections](#allow-outgoing-connections)
|
||||
- [Allow a Specific IP address](#allow-a-specific-ip-address)
|
||||
- [Allow a Specific IP Address to a Given Port](#allow-a-specific-ip-address-to-a-given-port)
|
||||
- [Allow a Port for tcp](#allow-a-port-for-tcp)
|
||||
- [Allow a Port for tcp and udp](#allow-a-port-for-tcp-and-udp)
|
||||
- [Allow a Subnet to a Given Port](#allow-a-subnet-to-a-given-port)
|
||||
- [Deny an IP Address](#deny-an-ip-address)
|
||||
- [Block Incoming Connections to a Network Interface](#block-incoming-connections-to-a-network-interface)
|
||||
- [Delete a Rule with Number](#delete-a-rule-with-number)
|
||||
- [Get App Info](#get-app-info)
|
||||
- [Allow a Specific App](#allow-a-specific-app)
|
||||
- [References](#references)
|
||||
|
||||
|
||||
## Introduction
|
||||
|
||||
We present a quick introduction to [Uncomplicated Firewall (ufw)](https://firewalld.org/), a free and open-source firewall management tool for Linux operating systems. This guide can be useful for users of the TFGrid deploying on full and micro VMs as well as other types of deployment.
|
||||
|
||||
## Basic Commands
|
||||
|
||||
We show here basic commands to set a firewall on Linux with Uncomplicated Firewall (ufw).
|
||||
|
||||
### Install ufw
|
||||
|
||||
* Update
|
||||
* ```
|
||||
apt update
|
||||
```
|
||||
* Install ufw
|
||||
* ```
|
||||
apt install ufw
|
||||
```
|
||||
|
||||
### Enable ufw
|
||||
|
||||
* ```
|
||||
ufw enable
|
||||
``````
|
||||
|
||||
### Disable ufw
|
||||
|
||||
* ```
|
||||
ufw disable
|
||||
```
|
||||
|
||||
### Reset ufw
|
||||
|
||||
* ```
|
||||
ufw reset
|
||||
```
|
||||
|
||||
### Reload ufw
|
||||
|
||||
* ```
|
||||
ufw reload
|
||||
```
|
||||
|
||||
### Deny Incoming Connections
|
||||
|
||||
* ```
|
||||
ufw default deny incoming
|
||||
```
|
||||
|
||||
### Allow Outgoing Connections
|
||||
|
||||
* ```
|
||||
ufw default allow outgoing
|
||||
```
|
||||
### Allow a Specific IP address
|
||||
|
||||
* ```
|
||||
ufw allow from <IP_Address>
|
||||
```
|
||||
|
||||
### Allow a Specific IP Address to a Given Port
|
||||
|
||||
* ```
|
||||
ufw allow from <IP_Address> to any port <port>
|
||||
```
|
||||
|
||||
### Allow a Port for tcp
|
||||
|
||||
* ```
|
||||
ufw allow <port>/tcp
|
||||
```
|
||||
### Allow a Port for udp
|
||||
|
||||
* ```
|
||||
ufw allow <port>/udp
|
||||
```
|
||||
### Allow a Port for tcp and udp
|
||||
|
||||
* ```
|
||||
ufw allow <port>
|
||||
```
|
||||
|
||||
### Allow Ports: Examples
|
||||
|
||||
Here are some typical examples of ports to allow with ufw:
|
||||
|
||||
* Allow SSH (port 22)
|
||||
* ```
|
||||
ufw allow ssh
|
||||
```
|
||||
* Allow HTTP (port 80)
|
||||
* ```
|
||||
ufw allow http
|
||||
```
|
||||
* Allow HTTPS (port 443)
|
||||
* ```
|
||||
ufw allow https
|
||||
```
|
||||
* Allow mysql (port 3306)
|
||||
* ```
|
||||
ufw allow 3306
|
||||
```
|
||||
|
||||
### Allow Port Ranges
|
||||
|
||||
* Template
|
||||
* ```
|
||||
ufw allow <port_range_floor>:<port_range_ceiling>
|
||||
```
|
||||
* Example
|
||||
* ```
|
||||
ufw allow 6000:6005
|
||||
```
|
||||
|
||||
### Allow a Subnet
|
||||
|
||||
* ```
|
||||
ufw allow from <subnet>
|
||||
```
|
||||
|
||||
### Allow a Subnet to a Given Port
|
||||
|
||||
* ```
|
||||
ufw allow from <subnet> to any port <port>
|
||||
```
|
||||
|
||||
### Deny a Port
|
||||
|
||||
* ```
|
||||
ufw deny <port>
|
||||
```
|
||||
|
||||
### Deny an IP Address
|
||||
|
||||
* ```
|
||||
ufw deny <IP_Address>
|
||||
```
|
||||
|
||||
### Deny a Subnet
|
||||
|
||||
* ```
|
||||
ufw deny from <subnet>
|
||||
```
|
||||
|
||||
### Block Incoming Connections to a Network Interface
|
||||
|
||||
* ```
|
||||
ufw deny in on <network_interface> from <IP_Address>
|
||||
```
|
||||
|
||||
### Check Rules
|
||||
|
||||
Use **status** to check the current firewall configurations. Add **verbose** for more details.
|
||||
|
||||
* ```
|
||||
ufw status
|
||||
```
|
||||
* ```
|
||||
ufw status verbose
|
||||
```
|
||||
|
||||
### Check Rules (Numbered)
|
||||
|
||||
It can be useful to see the numbering of the rules, to remove more easily a rule for example.
|
||||
|
||||
* ```
|
||||
ufw status numbered
|
||||
```
|
||||
|
||||
### Delete a Rule with Number
|
||||
|
||||
It can be useful to see the numbering of the rules, to remove more easily a rule for example.
|
||||
|
||||
* ```
|
||||
ufw delete <rule_number>
|
||||
```
|
||||
|
||||
### Delete a Rule with the Rule Name and Parameters
|
||||
|
||||
You can also delete a rule by writing directly the rule name you used to add the rule.
|
||||
|
||||
* Template
|
||||
* ```
|
||||
ufw delete <rule_name> <rule_parameters>
|
||||
```
|
||||
* Example
|
||||
* ```
|
||||
ufw delete allow ssh
|
||||
```
|
||||
* ```
|
||||
ufw delete allow 22
|
||||
```
|
||||
|
||||
You can always check the current rules with **ufw status** to see if the rules are properly removed.
|
||||
|
||||
### List the Available Profiles Available
|
||||
|
||||
* ```
|
||||
ufw app list
|
||||
```
|
||||
|
||||
This command will give you the names of the apps present on the server. You can then use **ufw app info** to get information on the app, or allow the app with **ufw allow**
|
||||
|
||||
### Get App Info
|
||||
|
||||
* ```
|
||||
ufw app info <app_name>
|
||||
```
|
||||
|
||||
### Set ufw in Verbose Mode
|
||||
|
||||
* ```
|
||||
ufw verbose
|
||||
```
|
||||
|
||||
### Allow a Specific App
|
||||
|
||||
* Template
|
||||
* ```
|
||||
ufw allow "<app_name>"
|
||||
```
|
||||
* Example
|
||||
* ```
|
||||
ufw allow "NGINX Full"
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
ufw man pages - https://manpages.ubuntu.com/manpages/trusty/man8/ufw.8.html
|
@@ -0,0 +1,450 @@
|
||||
<h1> Git and GitHub Basics </h1>
|
||||
|
||||
<h2>Table of Contents</h2>
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Install Git](#install-git)
|
||||
- [Install on Linux](#install-on-linux)
|
||||
- [Install on MAC](#install-on-mac)
|
||||
- [Install on Windows](#install-on-windows)
|
||||
- [Basic Commands](#basic-commands)
|
||||
- [Check Git version](#check-git-version)
|
||||
- [Clone a repository](#clone-a-repository)
|
||||
- [Clone a single branch](#clone-a-single-branch)
|
||||
- [Check all available branches](#check-all-available-branches)
|
||||
- [Check the current branch](#check-the-current-branch)
|
||||
- [Go to another branch](#go-to-another-branch)
|
||||
- [Add your changes to a local branch](#add-your-changes-to-a-local-branch)
|
||||
- [Push changes of a local branch to the remote Github branch](#push-changes-of-a-local-branch-to-the-remote-github-branch)
|
||||
- [Reverse modifications to a file where changes haven't been staged yet](#reverse-modifications-to-a-file-where-changes-havent-been-staged-yet)
|
||||
- [Download binaries from Github](#download-binaries-from-github)
|
||||
- [Resolve conflicts between branches](#resolve-conflicts-between-branches)
|
||||
- [Download all repositories of an organization](#download-all-repositories-of-an-organization)
|
||||
- [Revert a push commited with git](#revert-a-push-commited-with-git)
|
||||
- [Make a backup of a branch](#make-a-backup-of-a-branch)
|
||||
- [Revert to a backup branch](#revert-to-a-backup-branch)
|
||||
- [Start over local branch and pull remote branch](#start-over-local-branch-and-pull-remote-branch)
|
||||
- [Overwrite local files and pull remote branch](#overwrite-local-files-and-pull-remote-branch)
|
||||
- [Stash command and parameters](#stash-command-and-parameters)
|
||||
- [Code Editors](#code-editors)
|
||||
- [VS-Code](#vs-code)
|
||||
- [VS-Codium](#vs-codium)
|
||||
- [References](#references)
|
||||
|
||||
***
|
||||
|
||||
## Introduction
|
||||
|
||||
In this section, we cover basic commands and aspects of [GitHub](https://github.com/) and [Git](https://git-scm.com/).
|
||||
|
||||
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
|
||||
|
||||
GitHub is a platform and cloud-based service for software development and version control using Git, allowing developers to store and manage their code.
|
||||
|
||||
|
||||
|
||||
## Install Git
|
||||
|
||||
You can install git on MAC, Windows and Linux. You can consult Git's documentation learn how to [install git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
|
||||
|
||||
### Install on Linux
|
||||
|
||||
* Fedora distribution
|
||||
* ```
|
||||
dnf install git-all
|
||||
```
|
||||
* Debian-based distribution
|
||||
* ```
|
||||
apt install git-all
|
||||
```
|
||||
* Click [here](https://git-scm.com/download/linux) for other Linux distributions
|
||||
|
||||
### Install on MAC
|
||||
|
||||
* With Homebrew
|
||||
* ```
|
||||
brew install git
|
||||
```
|
||||
|
||||
### Install on Windows
|
||||
|
||||
You can download Git for Windows at [this link](https://git-scm.com/download/win).
|
||||
|
||||
|
||||
|
||||
## Basic Commands
|
||||
|
||||
### Check Git version
|
||||
|
||||
```
|
||||
git --version
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Clone a repository
|
||||
|
||||
```
|
||||
git clone <repository_url>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Clone a single branch
|
||||
|
||||
```
|
||||
git clone <repository_url> --branch <branch> --single-branch <folder>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Check all available branches
|
||||
|
||||
```
|
||||
git branch -r
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Check the current branch
|
||||
|
||||
```
|
||||
git branch
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Go to another branch
|
||||
|
||||
```
|
||||
git checkout <branch_name>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Add your changes to a local branch
|
||||
|
||||
* Add all changes
|
||||
* ```
|
||||
git add .
|
||||
```
|
||||
* Add changes of a specific file
|
||||
* ```
|
||||
git add <path_to_file>/<file_name>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Push changes of a local branch to the remote Github branch
|
||||
|
||||
To push changes to Github, you can use the following commands:
|
||||
|
||||
* ```
|
||||
git add .
|
||||
```
|
||||
* ```
|
||||
git commit -m "write your changes here in comment"
|
||||
```
|
||||
* ```
|
||||
git push
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Count the differences between two branches
|
||||
|
||||
Replace **branch1** and **branch2** with the appropriate branch names.
|
||||
|
||||
```
|
||||
git rev-list --count branch1..branch2
|
||||
```
|
||||
|
||||
### See the default branch
|
||||
|
||||
```
|
||||
git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Force a push
|
||||
|
||||
```
|
||||
git push --force
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Merge a branch to a different branch
|
||||
|
||||
* Checkout the branch you want to copy content TO
|
||||
* ```
|
||||
git checkout branch_name
|
||||
```
|
||||
* Merge the branch you want content FROM
|
||||
* ```
|
||||
git merge origin/dev_mermaid
|
||||
```
|
||||
* Push the changes
|
||||
* ```
|
||||
git push -u origin/head
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Clone completely one branch to another branch locally then push the changes to Github
|
||||
|
||||
For this example, we copy **branchB** into **branchA**.
|
||||
|
||||
* See available branches
|
||||
* ```
|
||||
git branch -r
|
||||
```
|
||||
* Go to **branchA**
|
||||
* ```
|
||||
git checkout branchA
|
||||
```
|
||||
* Copy **branchB** into **branchA**
|
||||
* ```
|
||||
git git reset --hard branchB
|
||||
```
|
||||
* Force the push
|
||||
* ```
|
||||
git push --force
|
||||
```
|
||||
|
||||
|
||||
|
||||
### The 3 levels of the command reset
|
||||
|
||||
* ```
|
||||
git reset --soft
|
||||
```
|
||||
* Bring the History to the Stage/Index
|
||||
* Discard last commit
|
||||
* ```
|
||||
git reset --mixed
|
||||
```
|
||||
* Bring the History to the Working Directory
|
||||
* Discard last commit and add
|
||||
* ```
|
||||
git reset --hard
|
||||
```
|
||||
* Bring the History to the Working Directory
|
||||
* Discard last commit, add and any changes you made on the codes
|
||||
|
||||
Note 1: If you're using **--hard**, make sure to run git status to verify that your directory is clean, otherwise you will lose your uncommitted changes.
|
||||
|
||||
Note 2: The argument **--mixed** is the default option, so **git reset** is equivalent to **git reset --mixed**.
|
||||
|
||||
|
||||
|
||||
### Reverse modifications to a file where changes haven't been staged yet
|
||||
|
||||
You can use the following to reverse the modifications of a file that hasn't been staged:
|
||||
|
||||
```
|
||||
git checkout <filename>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Download binaries from Github
|
||||
|
||||
* Template:
|
||||
* ```
|
||||
wget -O <file_name> https://raw.githubusercontent.com/<user_name>/<repository>/<path_to_file>/<file_name>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Resolve conflicts between branches
|
||||
|
||||
We show how to resolve conflicts in a development branch (e.g. **branch_dev**) and then merging the development branch into the main branch (e.g. **branch_main**).
|
||||
|
||||
* Clone the repo
|
||||
* ```
|
||||
git clone <repo_url>
|
||||
```
|
||||
* Pull changes and potential conflicts
|
||||
* ```
|
||||
git pull origin branch_main
|
||||
```
|
||||
* Checkout the development branch
|
||||
* ```
|
||||
git checkout branch_dev
|
||||
```
|
||||
* Resolve conflicts in a text editor
|
||||
* Save changes in the files
|
||||
* Add the changes
|
||||
* ```
|
||||
git add .
|
||||
```
|
||||
* Commit the changes
|
||||
* ```
|
||||
git commit -m "your message here"
|
||||
```
|
||||
* Push the changes
|
||||
* ```
|
||||
git push
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Download all repositories of an organization
|
||||
|
||||
* Log in to gh
|
||||
* ```
|
||||
gh auth login
|
||||
```
|
||||
* Clone all repositories. Replace <organization> with the organization in question.
|
||||
* ```
|
||||
gh repo list <organization> --limit 1000 | while read -r repo _; do
|
||||
gh repo clone "$repo" "$repo"
|
||||
done
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Revert a push commited with git
|
||||
|
||||
* Find the commit ID
|
||||
* ```
|
||||
git log -p
|
||||
```
|
||||
* Revert the commit
|
||||
* ```
|
||||
git revert <commit_ID>
|
||||
```
|
||||
* Push the changes
|
||||
* ```
|
||||
git push
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Make a backup of a branch
|
||||
|
||||
```
|
||||
git clone -b <branch_name> --single-branch /<path_to_repo>/<repo_name>.git
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Revert to a backup branch
|
||||
|
||||
* Checkout the branch you want to update (**branch**)
|
||||
* ```
|
||||
git checkout <branch>
|
||||
```
|
||||
* Do a reset of your current branch based on the backup branch
|
||||
* ```
|
||||
git reset --hard <backup_branch>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Start over local branch and pull remote branch
|
||||
|
||||
To start over your local branch and pull the remote branch to your working environment, thus ignoring local changes in the branch, you can do the following:
|
||||
|
||||
```
|
||||
git fetch
|
||||
git reset --hard
|
||||
git pull
|
||||
```
|
||||
|
||||
Note that this will not work for untracked and new files. See below for untracked and new files.
|
||||
|
||||
|
||||
|
||||
### Overwrite local files and pull remote branch
|
||||
|
||||
This method can be used to overwrite local files. This will work even if you have untracked and new files.
|
||||
|
||||
* Save local changes on a stash
|
||||
* ```
|
||||
git stash --include-untracked
|
||||
```
|
||||
* Discard local changes
|
||||
* ```
|
||||
git reset --hard
|
||||
```
|
||||
* Discard untracked and new files
|
||||
* ```
|
||||
git clean -fd
|
||||
```
|
||||
* Pull the remote branch
|
||||
* ```
|
||||
git pull
|
||||
```
|
||||
|
||||
Then, to delete the stash, you can use **git stash drop**.
|
||||
|
||||
|
||||
|
||||
### Stash command and parameters
|
||||
|
||||
The stash command is used to record the current state of the working directory.
|
||||
|
||||
* Stash a branch (equivalent to **git stash push**)
|
||||
* ```
|
||||
git stash
|
||||
```
|
||||
* List the changes in the stash
|
||||
* ```
|
||||
git stash list
|
||||
```
|
||||
* Inspect the changes in the stash
|
||||
* ```
|
||||
git stash show
|
||||
```
|
||||
* Remove a single stashed state from the stash list and apply it on top of the current working tree state
|
||||
* ```
|
||||
git stash pop
|
||||
```
|
||||
* Apply the stash on top of the current working tree state without removing the state from the stash list
|
||||
* ```
|
||||
git stash apply
|
||||
```
|
||||
* Drop a stash
|
||||
* ```
|
||||
git stash drop
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Code Editors
|
||||
|
||||
There are many code editors that can work well when working with git.
|
||||
|
||||
### VS-Code
|
||||
|
||||
[VS-Code](https://code.visualstudio.com/)is a source-code editor made by Microsoft with the Electron Framework, for Windows, Linux and macOS.
|
||||
|
||||
To download VS-Code, visit their website and follow the given instructions.
|
||||
|
||||
### VS-Codium
|
||||
|
||||
[VS-Codium ](https://vscodium.com/) is a community-driven, freely-licensed binary distribution of Microsoft’s editor VS Code.
|
||||
|
||||
There are many ways to install VS-Codium. Visit the [official website](https://vscodium.com/#install) for more information.
|
||||
|
||||
* Install on MAC
|
||||
* ```
|
||||
brew install --cask vscodium
|
||||
```
|
||||
* Install on Linux
|
||||
* ```
|
||||
snap install codium --classic
|
||||
```
|
||||
* Install on Windows
|
||||
* ```
|
||||
choco install vscodium
|
||||
```
|
||||
|
||||
|
||||
|
||||
## References
|
||||
|
||||
Git Documentation - https://git-scm.com/docs/user-manual
|
@@ -0,0 +1,75 @@
|
||||
<h1> Screenshots </h1>
|
||||
|
||||
<h2>Table of Contents</h2>
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Linux](#linux)
|
||||
- [MAC](#mac)
|
||||
- [Windows](#windows)
|
||||
|
||||
***
|
||||
|
||||
## Introduction
|
||||
|
||||
In this section, we show how to easily take screenshots on Linux, MAC and Windows.
|
||||
|
||||
## Linux
|
||||
|
||||
- Copy to the clipboard a full screenshot
|
||||
```
|
||||
PrintScreen
|
||||
```
|
||||
- Copy to the clipboard a screenshot of an active window
|
||||
```
|
||||
Alt + PrintScreen
|
||||
```
|
||||
- Copy to the clipboard a screenshot of an active app
|
||||
```
|
||||
Control + Alt + PrintScreen
|
||||
```
|
||||
- Copy to the clipboard a screenshot of a selected area
|
||||
```
|
||||
Shift + PrintScreen
|
||||
```
|
||||
|
||||
## MAC
|
||||
|
||||
- Save to the desktop a full screenshot
|
||||
```
|
||||
Shift + Command (⌘) + 3
|
||||
```
|
||||
- Save to the desktop a screenshot of an active window
|
||||
```
|
||||
Shift + Command (⌘) + 4 + Spacebar
|
||||
```
|
||||
- Copy to the clipboard a screenshot of an active window
|
||||
```
|
||||
Shift + Control + Command (⌘) + 3
|
||||
```
|
||||
- Save to the desktop a screenshot of a selected area
|
||||
```
|
||||
Shift + Command (⌘) + 4
|
||||
```
|
||||
- Copy to the clipboard a screenshot of a selected area
|
||||
```
|
||||
Shift + Control + Command (⌘) + 4
|
||||
```
|
||||
|
||||
## Windows
|
||||
|
||||
- Copy to the clipboard a full screenshot
|
||||
```
|
||||
PrintScreen
|
||||
```
|
||||
- Save to the pictures directory a full screenshot
|
||||
```
|
||||
Windows key + PrintScreen
|
||||
```
|
||||
- Copy to the clipboard a screenshot of an active window
|
||||
```
|
||||
Alt + PrintScreen
|
||||
```
|
||||
- Copy to the clipboard a selected area of the screen
|
||||
```
|
||||
Windows key + Shift + S
|
||||
```
|
Reference in New Issue
Block a user