manual, sysadmins, computer basics

This commit is contained in:
Mik-TF 2024-05-14 13:02:02 -04:00
parent c54a6ab037
commit 8f74e1e9bf
3 changed files with 98 additions and 92 deletions

View File

@ -70,16 +70,16 @@ sudo sh get-docker.sh
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
@ -93,11 +93,11 @@ You can also use the command **whereis docker** to see if any Docker folders and
### List containers
* List only running containers
* ```
```
docker ps
```
* List all containers (running + stopped)
* ```
```
docker ps -a
```
@ -108,15 +108,15 @@ You can also use the command **whereis docker** to see if any Docker folders and
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
```
@ -127,15 +127,15 @@ To pull an image from [Docker Hub](https://hub.docker.com/):
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
```
@ -144,11 +144,11 @@ To pull an image to [Docker Hub](https://hub.docker.com/):
### 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>
```
@ -174,20 +174,20 @@ To install Skopeo, read [this documentation](install.md).
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
```
@ -206,15 +206,15 @@ docker images
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>
```
@ -229,7 +229,7 @@ You can also specify the shell, e.g. **docker run -it <image_name> /bin/bash**
To run a new command in an existing container, use **docker exec**.
* Execute interactive shell on the container
* ```
```
docker exec -it <container_name> sh
```
@ -238,11 +238,11 @@ To run a new command in an existing container, use **docker exec**.
### 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
```
@ -300,22 +300,22 @@ 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)
```
@ -324,7 +324,7 @@ docker cp <container_id>:<file_path> <file_path_destination>
### Kill all the Docker processes
* To kill all processes:
* ```
```
killall Docker && open /Applications/Docker.app
```
@ -353,11 +353,11 @@ docker ps -s
### Examine disks usage
* Basic mode
* ```
```
docker system df
```
* Verbose mode
* ```
```
docker system df -v
```

View File

@ -33,14 +33,14 @@ Deploying on the TFGrid with tools such as the Playground and Terraform is easy
### 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
@ -56,11 +56,11 @@ For IPv6, it is similar to IPv4 but you need to add `-6` after scp and add `\[`
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
```
@ -77,16 +77,16 @@ Here is short description of the parameters used:
[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
```
@ -95,18 +95,18 @@ Here is short description of the parameters used:
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
@ -115,11 +115,11 @@ We show how to automate file transfers between two computers using rsync.
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
```
@ -128,11 +128,11 @@ We show how to automate file transfers between two computers using 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
```
@ -141,11 +141,11 @@ Depending on your situation, the parameters **--checksum** or **--ignore-times**
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
```

View File

@ -16,6 +16,12 @@
- [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)
- [Count the differences between two branches](#count-the-differences-between-two-branches)
- [See the default branch](#see-the-default-branch)
- [Force a push](#force-a-push)
- [Merge a branch to a different branch](#merge-a-branch-to-a-different-branch)
- [Clone completely one branch to another branch locally then push the changes to Github](#clone-completely-one-branch-to-another-branch-locally-then-push-the-changes-to-github)
- [The 3 levels of the command reset](#the-3-levels-of-the-command-reset)
- [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)
@ -50,11 +56,11 @@ You can install git on MAC, Windows and Linux. You can consult Git's documentati
### 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
@ -62,7 +68,7 @@ You can install git on MAC, Windows and Linux. You can consult Git's documentati
### Install on MAC
* With Homebrew
* ```
```
brew install git
```
@ -125,11 +131,11 @@ 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>
```
@ -139,13 +145,13 @@ git checkout <branch_name>
To push changes to Github, you can use the following commands:
* ```
```
git add .
```
* ```
```
git commit -m "write your changes here in comment"
```
* ```
```
git push
```
@ -178,15 +184,15 @@ 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
```
@ -197,19 +203,19 @@ git push --force
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
```
@ -217,17 +223,17 @@ For this example, we copy **branchB** into **branchA**.
### 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
@ -252,7 +258,7 @@ git checkout <filename>
### Download binaries from Github
* Template:
* ```
```
wget -O <file_name> https://raw.githubusercontent.com/<user_name>/<repository>/<path_to_file>/<file_name>
```
@ -263,29 +269,29 @@ git checkout <filename>
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
```
@ -294,11 +300,11 @@ We show how to resolve conflicts in a development branch (e.g. **branch_dev**) a
### 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
@ -309,15 +315,15 @@ We show how to resolve conflicts in a development branch (e.g. **branch_dev**) a
### 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
```
@ -334,11 +340,11 @@ 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>
```
@ -363,19 +369,19 @@ Note that this will not work for untracked and new files. See below for untracke
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
```
@ -388,27 +394,27 @@ Then, to delete the stash, you can use **git stash drop**.
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
```
@ -431,15 +437,15 @@ To download VS-Code, visit their website and follow the given instructions.
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
```