diff --git a/knowledge base/1password-cli.md b/knowledge base/1password-cli.md index 3ca4a41..833583d 100644 --- a/knowledge base/1password-cli.md +++ b/knowledge base/1password-cli.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # installation brew cask install 1password-cli @@ -23,7 +23,7 @@ op list items - After you have signed in the first time, you can sign in again using your account shorthand, which is your sign-in address subdomain (in this example, _company_); `op signin` will prompt you for your password and output a command that can save your session token to an environment variable: - ```shell + ```sh op signin company ``` diff --git a/knowledge base/README.md b/knowledge base/README.md new file mode 100644 index 0000000..8acf8e0 --- /dev/null +++ b/knowledge base/README.md @@ -0,0 +1,15 @@ +# Knwoledge base + +This is the collection of all notes, reminders and whatnot I gathered during the years. + +## Conventions + +- Use `sh` as document language instead of `shell` when writing shell snippets in code blocks: + + ```diff + - ```shell + + ```sh + #!/usr/bin/env zsh + ``` + + The local renderer just displays them better like this. diff --git a/knowledge base/access a jar file contents.md b/knowledge base/access a jar file contents.md index e73f829..98f21de 100644 --- a/knowledge base/access a jar file contents.md +++ b/knowledge base/access a jar file contents.md @@ -3,7 +3,7 @@ A `.jar` file is nothing more than an archive. You can find all the files it contains just unzipping it: -```shell +```sh $ unzip file.jar Archive: file.jar creating: META-INF/ diff --git a/knowledge base/acl.md b/knowledge base/acl.md index 75eaca7..e5dc190 100644 --- a/knowledge base/acl.md +++ b/knowledge base/acl.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # show acls of file test/declarations.h getfacl test/declarations.h diff --git a/knowledge base/ansible.md b/knowledge base/ansible.md index 2bbb25a..f60acc8 100644 --- a/knowledge base/ansible.md +++ b/knowledge base/ansible.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Install. pip3 install --user ansible && port install sshpass # darwin sudo pamac install ansible sshpass # manjaro linux @@ -161,7 +161,7 @@ ansible-galaxy remove namespace.role Roles can be either **created**: -```shell +```sh ansible-galaxy init role-name ``` @@ -174,7 +174,7 @@ collections: - community.docker ``` -```shell +```sh ansible-galaxy install mcereda.boinc_client ansible-galaxy install --roles-path ~/ansible-roles namespace.role ansible-galaxy install namespace.role,v1.0.0 @@ -203,7 +203,7 @@ dependencies: Change Ansible's output setting the stdout callback to `json` or `yaml`: -```shell +```sh ANSIBLE_STDOUT_CALLBACK=yaml ``` diff --git a/knowledge base/antigen.md b/knowledge base/antigen.md index 6233f64..72571d8 100644 --- a/knowledge base/antigen.md +++ b/knowledge base/antigen.md @@ -6,14 +6,14 @@ Example: -```shell +```sh tee: /Users/user/.antigen/bundles/robbyrussell/oh-my-zsh/cache//completions/_helm: No such file or directory /Users/user/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/helm/helm.plugin.zsh:source:9: no such file or directory: /Users/user/.antigen/bundles/robbyrussell/oh-my-zsh/cache//completions/_helm ``` The issue is due of the `$ZSH_CACHE_DIR/completions` being missing and `tee` not creating it on Mac OS X. Create the missing `completions` directory and re-run antigen: -```shell +```sh mkdir -p $ZSH_CACHE_DIR/completions antigen apply ``` diff --git a/knowledge base/apk.md b/knowledge base/apk.md index c9135aa..6720766 100644 --- a/knowledge base/apk.md +++ b/knowledge base/apk.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Update the package lists. apk update diff --git a/knowledge base/apt.md b/knowledge base/apt.md index 9d589bf..942d7f4 100644 --- a/knowledge base/apt.md +++ b/knowledge base/apt.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # mark all packages as non-explicitly installed apt-mark auto $(sudo apt-mark showmanual) diff --git a/knowledge base/asdf.md b/knowledge base/asdf.md index 4661d81..c4cac17 100644 --- a/knowledge base/asdf.md +++ b/knowledge base/asdf.md @@ -4,7 +4,7 @@ ## TL;DR -```shell +```sh # list installed plugins asdf plugin list @@ -46,7 +46,7 @@ asdf current helm ## Installation -```shell +```sh # install the program brew install asdf @@ -57,7 +57,7 @@ brew install asdf ## Plugins management -```shell +```sh # list installed plugins asdf plugin list asdf plugin list --urls @@ -80,7 +80,7 @@ asdf plugin remove $PLUGIN_NAME ## Versions management -```shell +```sh # list installed versions for a plugin # asdf list $PLUGIN_NAME asdf list elixir diff --git a/knowledge base/authenticate without using sudo.md b/knowledge base/authenticate without using sudo.md index 880d096..2fe3546 100644 --- a/knowledge base/authenticate without using sudo.md +++ b/knowledge base/authenticate without using sudo.md @@ -7,7 +7,7 @@ Requires [polkit] to be: - installed - configured to authorize and authenticate the users -```shell +```sh pkexec COMMAND ``` diff --git a/knowledge base/aws.md b/knowledge base/aws.md index 04dfa4a..62a2260 100644 --- a/knowledge base/aws.md +++ b/knowledge base/aws.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Install the CLI. brew install awscli @@ -16,7 +16,7 @@ export AWS_PROFILE="work" ## Profiles -```shell +```sh # Initialize the default profile. # Not specifying a profile means to configure the default profile. $ aws configure diff --git a/knowledge base/az.md b/knowledge base/az.md index 2c0138b..2aa025b 100644 --- a/knowledge base/az.md +++ b/knowledge base/az.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # login az login diff --git a/knowledge base/bash.md b/knowledge base/bash.md index 9b4543e..2f6f54f 100644 --- a/knowledge base/bash.md +++ b/knowledge base/bash.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Run a command or function on exit, kill or error. trap "rm -f $tempfile" EXIT SIGTERM ERR trap function-name EXIT SIGTERM ERR diff --git a/knowledge base/boinccmd.md b/knowledge base/boinccmd.md index 0a15d6f..3bcdc89 100644 --- a/knowledge base/boinccmd.md +++ b/knowledge base/boinccmd.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # use a project manager boinccmd --acct_mgr attach http://bam.boincstats.com myAwesomeUsername myAwesomePassword boinccmd --acct_mgr info diff --git a/knowledge base/btrfs.md b/knowledge base/btrfs.md index c90b7c4..eb8811f 100644 --- a/knowledge base/btrfs.md +++ b/knowledge base/btrfs.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # create a volume with single metadata and double data blocks (useless but good example) sudo mkfs.btrfs --metadata single --data dup /dev/sdb @@ -44,7 +44,7 @@ sudo compsize /mnt/btrfs-volume See also [snapper]. -```shell +```sh sudo btrfs send --no-data -p /old/snapshot /new/snapshot | sudo btrfs receive --dump # requires you to be using snapper for your snapshots diff --git a/knowledge base/cheat.sh.md b/knowledge base/cheat.sh.md index 87bcf6d..080d5c0 100644 --- a/knowledge base/cheat.sh.md +++ b/knowledge base/cheat.sh.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # using the exact name of the command curl cheat.sh/tar curl cht.sh/curl diff --git a/knowledge base/check a pod can connect to an external db.md b/knowledge base/check a pod can connect to an external db.md index b87a0bf..0e0f5a7 100644 --- a/knowledge base/check a pod can connect to an external db.md +++ b/knowledge base/check a pod can connect to an external db.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # access a test container kubectl run --generator=run-pod/v1 --limits 'cpu=200m,memory=512Mi' --requests 'cpu=200m,memory=512Mi' --image alpine ${USER}-mysql-test -it -- sh diff --git a/knowledge base/chezmoi.md b/knowledge base/chezmoi.md index cffb895..f64a4cf 100644 --- a/knowledge base/chezmoi.md +++ b/knowledge base/chezmoi.md @@ -4,7 +4,7 @@ A multi-machine dotfile manager, written in Go. ## TL;DR -```shell +```sh # initialize chezmoi chezmoi init chezmoi init https://github.com/username/dotfiles.git @@ -50,7 +50,7 @@ chezmoi update ## Save the current data to a remote repository -```shell +```sh $ chezmoi cd chezmoi $> git remote add origin https://github.com/username/dotfiles.git chezmoi $> git push -u origin main diff --git a/knowledge base/clamav.md b/knowledge base/clamav.md index edf2d6b..1bd1a04 100644 --- a/knowledge base/clamav.md +++ b/knowledge base/clamav.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # manually update the virus definitions # do it once **before** starting a scan or the daemon # the definitions updater deamon must be stopped to avoid complaints from it @@ -39,7 +39,7 @@ nice -n 15 clamscan && clamscan --bell -i -r /home - The `--fdpass` option of `clamdscan` (notice the _d_ in the command) sends a file descriptor to clamd rather than a path name, avoiding the need for the `clamav` user to be able to read everyone's files - `clamscan` is designed to be single-threaded, so when scanning a file or directory from the command line only a single CPU thread is used; use `xargs` or another executor to run a scan in parallel: - ```shell + ```sh find . -type f -printf "'%p' " | xargs -P $(nproc) -n 1 clamscan find . -type f | parallel --group --jobs 0 -d '\n' clamscan {} ``` diff --git a/knowledge base/compare two pdf files.md b/knowledge base/compare two pdf files.md index e55b348..4a2621b 100644 --- a/knowledge base/compare two pdf files.md +++ b/knowledge base/compare two pdf files.md @@ -2,13 +2,13 @@ Install and use `diffpdf` (preferred) or `diff-pdf`: -```shell +```sh sudo zypper install diff-pdf ``` As an alternative: -```shell +```sh # create a pdf with the diff as red pixels compare -verbose -debug coder $PDF_1 $PDF_2 -compose src /tmp/$OUT_FILE.tmp diff --git a/knowledge base/cpufreq.md b/knowledge base/cpufreq.md index 88ad2a5..89d40a3 100644 --- a/knowledge base/cpufreq.md +++ b/knowledge base/cpufreq.md @@ -4,7 +4,7 @@ Default governor is _ondemand_ for older CPUs and kernels and _schedutil_ for ne ## TL;DR -```shell +```sh # list the available governors cpupower frequency-info --governors diff --git a/knowledge base/curl.md b/knowledge base/curl.md index 3332e36..203da21 100644 --- a/knowledge base/curl.md +++ b/knowledge base/curl.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Send a single GET request and show its output on stdout. curl http://url.of/file diff --git a/knowledge base/diff-pdf.md b/knowledge base/diff-pdf.md index a1fac61..6546770 100644 --- a/knowledge base/diff-pdf.md +++ b/knowledge base/diff-pdf.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # just check diff-pdf --verbose file1.pdf file2.pdf diff --git a/knowledge base/docker.md b/knowledge base/docker.md index 67c9af0..4097565 100644 --- a/knowledge base/docker.md +++ b/knowledge base/docker.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Show locally available images. docker images -a @@ -101,7 +101,7 @@ The docker daemon is configured using the `/etc/docker/daemon.json` file: Docker mounts specific system files in all containers to forward its settings: -```shell +```sh 6a95fabde222$ mount … /dev/disk/by-uuid/1bb…eb5 on /etc/resolv.conf type btrfs (rw,…) @@ -116,7 +116,7 @@ Those files come from the volume the docker container is using for its root, and - Containers created with no specified name will be assigned one automatically: - ```shell + ```sh $ docker create hello-world 8eaaae8c0c720ac220abac763ad4b477d807be4522d58e334337b1b74a14d0bd @@ -131,7 +131,7 @@ Those files come from the volume the docker container is using for its root, and - When referring to a container or image using their ID, you just need to use as many characters you need to uniquely specify a single one of them: - ```shell + ```sh $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 63b1a0a3e557 alpine "/bin/sh" 34 seconds ago Created alpine diff --git a/knowledge base/dpkg.md b/knowledge base/dpkg.md index a117627..c0d0354 100644 --- a/knowledge base/dpkg.md +++ b/knowledge base/dpkg.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # add an extra architecture dpkg --add-architecture i386 diff --git a/knowledge base/envsubst.md b/knowledge base/envsubst.md index 74b5dc0..428357b 100644 --- a/knowledge base/envsubst.md +++ b/knowledge base/envsubst.md @@ -4,12 +4,12 @@ Substitutes environment variables in shell format strings. ## TL;DR -```shell +```sh envsubst < input.file envsubst < input.file > output.file ``` -```shell +```sh $ cat hello.file hello $NAME diff --git a/knowledge base/export all variables in a envfile.md b/knowledge base/export all variables in a envfile.md index 19bd4ff..3438093 100644 --- a/knowledge base/export all variables in a envfile.md +++ b/knowledge base/export all variables in a envfile.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh set -o allexport source envfile set +o allexport diff --git a/knowledge base/extract attachments from multipart emails.md b/knowledge base/extract attachments from multipart emails.md index 56cb899..cee51a6 100644 --- a/knowledge base/extract attachments from multipart emails.md +++ b/knowledge base/extract attachments from multipart emails.md @@ -18,7 +18,7 @@ In such cases the text file itself contains the multipart message body of the em You can use `munpack` to easily extract attachments out of such text files and write them into a proper named files. -```shell +```sh $ munpack -f plaintext.eml myawesomefile.tar.gz (application/x-gzip) ``` diff --git a/knowledge base/fedora linux.md b/knowledge base/fedora linux.md index 754dca9..1f62242 100644 --- a/knowledge base/fedora linux.md +++ b/knowledge base/fedora linux.md @@ -6,7 +6,7 @@ RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to These repositories are not available by default and need to be installed using a remote package: -```shell +```sh # All flavours but Silverblue-based ones. sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm @@ -16,7 +16,7 @@ sudo rpm-ostree install https://download1.rpmfusion.org/free/fedora/rpmfusion-fr After enabling the repositories, you can add their _tainted_ versions for closed or restricted packages: -```shell +```sh sudo dnf install rpmfusion-{free,nonfree}-release-tainted sudo rpm-ostree install rpmfusion-{free,nonfree}-release-tainted ``` diff --git a/knowledge base/fedora silverblue.md b/knowledge base/fedora silverblue.md index 89f9998..3823b11 100644 --- a/knowledge base/fedora silverblue.md +++ b/knowledge base/fedora silverblue.md @@ -4,7 +4,7 @@ Changes to the base layer are executed in a new bootable filesystem root. This means that the system must be rebooted after a package has been layered. -```shell +```sh # Check for available upgrades. rpm-ostree upgrade --check diff --git a/knowledge base/ffmpeg.md b/knowledge base/ffmpeg.md index 1dd62af..e6df2ef 100644 --- a/knowledge base/ffmpeg.md +++ b/knowledge base/ffmpeg.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Convert a webm file to GIF. ffmpeg -y -i rec.webm -vf palettegen palette.png \ && ffmpeg -y -i rec.webm -i palette.png \ @@ -13,7 +13,7 @@ ffmpeg -y -i rec.webm -vf palettegen palette.png \ ### Webm to GIF -```shell +```sh ffmpeg -y -i rec.webm -vf palettegen palette.png ffmpeg -y -i rec.webm -i palette.png -filter_complex paletteuse -r 10 out.gif ``` diff --git a/knowledge base/find.md b/knowledge base/find.md index d9a1b78..241ddf3 100644 --- a/knowledge base/find.md +++ b/knowledge base/find.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Change the permissions of all files and directories in the current directory, # recursively. find . -type d -exec chmod 755 {} + @@ -101,7 +101,7 @@ Any number of units may be combined in one `-Xtime` argument. with the `-newerXY file` form, `find` checks if `file` has a more recent last access time (X=a), inode creation time (X=B), change time (X=c), or modification time (X=m) than the last access time (Y=a), inode creation time (Y=B), change time (Y=c), or modification time (Y=m). If Y=t, `file` is interpreted as a direct date specification of the form understood by `cvs`. Also, `-newermm` is the same as `-newer`. -```shell +```sh # Find files last accessed exactly 5 minutes ago. find /dir -amin 5 find /dir -atime 300s @@ -143,14 +143,14 @@ find / -newer file.txt -user wnj -print - in GNU's `find` the path parameter defaults to the current directory and can be avoided - ```shell + ```sh # Delete all empty folders in the current directory only. find -maxdepth 1 -empty -delete ``` - GNU's `find` also understands fractional time specifications: - ```shell + ```sh # Find files modified in the last 1 hour and 30 minutes. find -mtime 1.5h ``` diff --git a/knowledge base/firewalld.md b/knowledge base/firewalld.md index 865116a..167a75f 100644 --- a/knowledge base/firewalld.md +++ b/knowledge base/firewalld.md @@ -9,7 +9,7 @@ It is the default firewall management tool for: ## TL;DR -```shell +```sh # Show which zone is currently selected as the default. firewall-cmd --get-default-zone diff --git a/knowledge base/flatpak.md b/knowledge base/flatpak.md index 0c286a8..3134c46 100644 --- a/knowledge base/flatpak.md +++ b/knowledge base/flatpak.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # List installed applications and runtimes. flatpak list flatpak list --app diff --git a/knowledge base/freebsd.md b/knowledge base/freebsd.md index 30268a5..1d62fa4 100644 --- a/knowledge base/freebsd.md +++ b/knowledge base/freebsd.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Initialize package managers. portsnap auto pkg bootstrap diff --git a/knowledge base/funtoo linux.md b/knowledge base/funtoo linux.md index e19fef0..91b3dcc 100644 --- a/knowledge base/funtoo linux.md +++ b/knowledge base/funtoo linux.md @@ -1,6 +1,6 @@ # Funtoo GNU/Linux -```shell +```sh # Portage update. sudo ego sync sudo emerge --sync diff --git a/knowledge base/fwupd.md b/knowledge base/fwupd.md index 8904cac..194bd61 100644 --- a/knowledge base/fwupd.md +++ b/knowledge base/fwupd.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Display all detected devices. fwupdmgr get-devices diff --git a/knowledge base/gcloud.md b/knowledge base/gcloud.md index 1dfed2a..d48ca21 100644 --- a/knowledge base/gcloud.md +++ b/knowledge base/gcloud.md @@ -6,7 +6,7 @@ ## TL;DR -```shell +```sh # Login. gcloud auth login gcloud auth login account diff --git a/knowledge base/get the environment of a process running in a container.md b/knowledge base/get the environment of a process running in a container.md index 3f920a7..610378b 100644 --- a/knowledge base/get the environment of a process running in a container.md +++ b/knowledge base/get the environment of a process running in a container.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh cat /proc/${PID}/environ # Container in kubernetes. diff --git a/knowledge base/git.md b/knowledge base/git.md index f7665ff..f370532 100644 --- a/knowledge base/git.md +++ b/knowledge base/git.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Set your identity. git config user.name 'User Name' git config --global user.email user@email.com @@ -291,7 +291,7 @@ git show :/cool ## Configuration -```shell +```sh # Required to be able to commit changes. git config --local user.email 'me@me.info' git config --local user.name 'Me' @@ -311,7 +311,7 @@ git config --global submodule.recurse true To show the current configuration use the `--list` option: -```shell +```sh git config --list git config --list --show-scope git config --list --global --show-origin @@ -320,7 +320,7 @@ git config --list --global --show-origin The configuration is shown in full for the requested scope (or all if not specified), but it might include the same setting multiple times if it shows up in multiple scopes. Render the current value of a setting using the `--get` option: -```shell +```sh # Get the current user.name value. git config --get user.name @@ -333,7 +333,7 @@ git config --list \ ## Manage changes -```shell +```sh # Show changes relative to the current index (not yet staged). git diff @@ -370,7 +370,7 @@ git diff --no-index path/to/file/A path/to/file/B Just save the output from `git diff` to get a patch file: -```shell +```sh # Just the current changes. # No staged nor committed files. git diff > file.patch @@ -382,7 +382,7 @@ git diff --output file.patch --cached The output from `git diff` just shows changes to **text** files by default, no metadata or other information about commits or branches. To get a whole commit with all its metadata and binary changes, use `git format-patch`: -```shell +```sh # Include 5 commits starting with 'commit' and going backwards. git format-patch -5 commit @@ -401,14 +401,14 @@ git add . && git commit -m 'uncommitted' \ Use `git apply` to apply a patch file to the current index: -```shell +```sh git apply file.patch ``` The changes from the patch are unstaged and no commits are created. To apply all commits from a patch, use `git am` on a patch created with `git format-patch`: -```shell +```sh git am file.patch ``` @@ -419,7 +419,7 @@ The commits are applied one after the other and registered in the repository's l The _stash_ is a changelist separated from the one in the current working directory. `git stash` will save the current changes there and cleans the working directory. You can (re-)apply changes from the stash at any time: -```shell +```sh # Stash changes locally. git stash @@ -442,7 +442,7 @@ git stash apply stash@{6} This creates a local branch tracking an existing remote branch. -```shell +```sh $ git checkout -b local-branch remote/existing-branch Branch 'local-branch' set up to track remote branch 'existing-branch' from 'remote'. Switched to a new branch 'local-branch' @@ -450,7 +450,7 @@ Switched to a new branch 'local-branch' ### Delete a branch -```shell +```sh # Delete local branches. git branch --delete local-branch git branch -D local-branch @@ -467,7 +467,7 @@ git branch --delete --remotes feat-branch Command source [here][prune local branches that do not exist on remote anymore]. -```shell +```sh # Branches merged on the remote are tagged as 'gone' in `git branch -vv`'s output. git fetch -p \ && awk '/origin/&&/gone/{print $1}' <(git branch -vv) | xargs git branch -d @@ -478,7 +478,7 @@ git branch --merged | grep -vE '(^\*|master|main|dev)' | xargs git branch -d ### Merge the master branch into a feature branch -```shell +```sh git stash pull git checkout master git pull @@ -488,7 +488,7 @@ git merge --no-ff master git stash pop ``` -```shell +```sh git checkout feature git pull origin master ``` @@ -498,7 +498,7 @@ git pull origin master `git rebase` takes the commits in a branch and appends them on top of the commits in a different branch. The commits to rebase are previously saved into a temporary area and then reapplied to the new branch, one by one, in order. -```shell +```sh # Rebase main on top of the current branch. git rebase main @@ -513,7 +513,7 @@ git pull --rebase=interactive origin master _Annotated_ tags are stored as full objects in git's database: -```shell +```sh # Create annotated tags. git tag --annotate v0.1.0 @@ -529,7 +529,7 @@ git push --follow-tags while _lightweight_ tags are stored as a pointer to a specific commit: -```shell +```sh # Create lightweight tags. git tag v0.1.1-rc0 git tag 1.12.1 HEAD @@ -537,7 +537,7 @@ git tag 1.12.1 HEAD Type-generic tag operations: -```shell +```sh # Push specific tags. git push origin v1.5 @@ -591,7 +591,7 @@ Those commands need to be wrapped into a one-line function definition: 1. Install the extension: - ```shell + ```sh apt install git-lfs brew install git-lfs dnf install git-lfs @@ -600,7 +600,7 @@ Those commands need to be wrapped into a one-line function definition: 1. If the package manager did not enable it system-wide, enable the extension for your user account: - ```shell + ```sh git lfs install ``` @@ -608,14 +608,14 @@ Those commands need to be wrapped into a one-line function definition: 1. Configure file tracking from inside the repository: - ```shell + ```sh git lfs track "*.exe" git lfs track "enormous_file.*" ``` 1. Add the `.gitattributes` file to the traced files: - ```shell + ```sh git add .gitattributes git commit -m "lfs configured" ``` @@ -624,7 +624,7 @@ Those commands need to be wrapped into a one-line function definition: See [Git Submodules: Adding, Using, Removing, Updating] for more information. -```shell +```sh # Add a submodule to an existing repository. git submodule add https://github.com/ohmyzsh/ohmyzsh lib/ohmyzsh @@ -640,7 +640,7 @@ To delete a submodule the procedure is more complicated: 1. De-init the submodule: - ```shell + ```sh git submodule deinit lib/ohmyzsh ``` @@ -648,7 +648,7 @@ To delete a submodule the procedure is more complicated: 1. Remove the submodule from the repository's index: - ```shell + ```sh git rm -rf lib/ohmyzsh ``` @@ -664,19 +664,19 @@ See [remove files from git commit]. 1. **Unstage** the file using `git reset`; specify HEAD as the source: - ```shell + ```sh git reset HEAD secret-file ``` 1. **Remove** the file from the repository's index: - ```shell + ```sh git rm --cached secret-file ``` 1. Check the file is no longer in the index: - ```shell + ```sh $ git ls-files | grep secret-file $ ``` @@ -684,13 +684,13 @@ See [remove files from git commit]. 1. Add the file to `.gitignore` or remove it from the working directory. 1. Amend the most recent commit from your repository: - ```shell + ```sh git commit --amend ``` ## Remotes -```shell +```sh # Add a remote. git remote add gitlab git@gitlab.com:user/my-awesome-repo.git @@ -705,7 +705,7 @@ git remote set-url origin git@github.com:user/new-repo-name.git To always push to `repo1`, `repo2`, and `repo3`, but always pull only from `repo1`, set up the remote 'origin' as follows: -```shell +```sh git remote add origin https://exampleuser@example.com/path/to/repo1 git remote set-url --push --add origin https://exampleuser@example.com/path/to/repo1 git remote set-url --push --add origin https://exampleuser@example.com/path/to/repo2 @@ -748,20 +748,20 @@ See . When everything else fails, enable tracing: -```shell +```sh export GIT_TRACE=1 ``` ### GPG cannot sign a commit -> ```shell +> ```sh > error: gpg failed to sign the data > fatal: failed to write commit object > ``` If gnupg2 and gpg-agent 2.x are used, be sure to set the environment variable GPG_TTY, specially zsh users with Powerlevel10k with Instant Prompt enabled. -```shell +```sh export GPG_TTY=$(tty) ``` @@ -769,7 +769,7 @@ export GPG_TTY=$(tty) Disable certificate verification: -```shell +```sh export GIT_SSL_NO_VERIFY=true git -c http.sslVerify=false … ``` diff --git a/knowledge base/gopass.md b/knowledge base/gopass.md index 99443d1..afe4c5b 100644 --- a/knowledge base/gopass.md +++ b/knowledge base/gopass.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh gopass init # multistore init @@ -14,7 +14,7 @@ gopass init --store work --path ~/.password-store.work ### Browserpass -```shell +```sh brew tap amar1729/formulae brew install browserpass for b in chromium chrome vivaldi brave firefox; do diff --git a/knowledge base/gpg.md b/knowledge base/gpg.md index 6d553af..b01cdf9 100644 --- a/knowledge base/gpg.md +++ b/knowledge base/gpg.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # List existing keys. gpg --list-keys gpg --list-keys --keyid-format short @@ -65,7 +65,7 @@ brew install gnupg ## Encryption -```shell +```sh # Single file. gpg --output $DB.key.gpg --encrypt --recipient $RECIPIENT $DB.key @@ -76,7 +76,7 @@ find . -type f -name secret.txt \ ## Decryption -```shell +```sh # Single file. gpg --output $DB.key --decrypt $DB.key.gpg @@ -90,7 +90,7 @@ The second command will create the decrypted version of all files in the same di As the original user, export all public keys to a base64-encoded text file and create an encrypted version of that file: -```shell +```sh gpg --armor --export > mypubkeys.asc gpg --armor --export email > mypubkeys-email.asc gpg --armor --symmetric --output mysecretatedpubkeys.sec.asc mypubkeys.asc @@ -98,14 +98,14 @@ gpg --armor --symmetric --output mysecretatedpubkeys.sec.asc mypubkeys.asc Export all encrypted private keys (which will also include corresponding public keys) to a text file and create an encrypted version of that file: -```shell +```sh gpg --armor --export-secret-keys > myprivatekeys.asc gpg --armor --symmetric --output mysecretatedprivatekeys.sec.asc myprivatekeys.asc ``` Optionally, export gpg's trustdb to a text file: -```shell +```sh gpg --export-ownertrust > otrust.txt ``` @@ -113,7 +113,7 @@ gpg --export-ownertrust > otrust.txt As the new user, execute `gpg --import` commands against the two `.asc` files, or the decrypted content of those files, and then check for the new keys with `gpg -k` and `gpg -K`, e.g.: -```shell +```sh gpg --output myprivatekeys.asc --decrypt mysecretatedprivatekeys.sec.asc gpg --import myprivatekeys.asc gpg --output mypubkeys.asc --decrypt mysecretatedpubkeys.sec.asc @@ -124,13 +124,13 @@ gpg --list-keys Optionally import the trustdb file as well: -```shell +```sh gpg --import-ownertrust otrust.txt ``` ## Key trust -```shell +```sh $ gpg --edit-key fingerprint gpg> trust gpg> quit @@ -140,7 +140,7 @@ gpg> quit > The non-interactive (--batch) option requires a settings file. -```shell +```sh # basic key with default values gpg --batch --generate-key < passwd gpg> quit @@ -193,7 +193,7 @@ You can create multiple subkeys as you would do for SSH keypairs. You should already have a GPG key. If you don't, read one of the many fine tutorials available on this topic. You will create the subkey by editing your existing key **in expert mode** to get access to the appropriate options: -```shell +```sh $ gpg2 --expert --edit-key fingerprint gpg> addkey Please select what kind of key you want: @@ -262,7 +262,7 @@ Save changes? (y/N) y When using SSH, `ssh-agent` is used to manage SSH keys. When using a GPG key, `gpg-agent` is used to manage GPG keys. To get `gpg-agent` to handle requests from SSH, you need to enable its SSH support: -```shell +```sh echo "enable-ssh-support" >> ~/.gnupg/gpg-agent.conf ``` @@ -270,7 +270,7 @@ You can avoid usinig `ssh-add` to load the keys pre-specifying which GPG keys to The entries in this file are keygrips—internal identifiers that `gpg-agent` uses to refer to the keys. A keygrip refers to both the public and private key. To find the keygrip use `gpg -K --with-keygrip`, then add that line to the `~/.gnupg/sshcontrol` file: -```shell +```sh $ gpg2 -K --with-keygrip /home/bexelbie/.gnupg/pubring.kbx ------------------------------ @@ -288,7 +288,7 @@ $ echo 7710BA0643CC022B92544181FF2EAC2A290CDC0E >> ~/.gnupg/sshcontrol Now tell SSH how to access `gpg-agent` by setting the value of the `SSH_AUTH_SOCK` environment variable. -```shell +```sh export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) gpgconf --launch gpg-agent ``` @@ -313,7 +313,7 @@ Run `ssh-add -L` to list your public keys and copy them over manually to the rem **Solution:** if `gnupg2` and `gpg-agent` 2.x are used, be sure to set the environment variable `GPG_TTY`: -```shell +```sh export GPG_TTY=$(tty) ``` diff --git a/knowledge base/grep the standard error stream.md b/knowledge base/grep the standard error stream.md index 4fd5cf3..9810e6e 100644 --- a/knowledge base/grep the standard error stream.md +++ b/knowledge base/grep the standard error stream.md @@ -2,13 +2,13 @@ If you're using `bash` or `zsh` you can employ anonymous pipes: -```shell +```sh ffmpeg -i 01-Daemon.mp3 2> >(grep -i Duration) ``` If you want the filtered redirected output on `stderr` again, add the `>&2` redirection to grep: -```shell +```sh command 2> >(grep something >&2) ``` @@ -19,7 +19,7 @@ Bash calls this _process substitution_: You can exclude `stdout` and grep `stderr` redirecting it to `null`: -```shell +```sh command 1>/dev/null 2> >(grep -oP "(.*)(?=pattern)") ``` diff --git a/knowledge base/grep.md b/knowledge base/grep.md index 97eaa5b..932019a 100644 --- a/knowledge base/grep.md +++ b/knowledge base/grep.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # base search grep 'pattern' path/to/search @@ -39,7 +39,7 @@ For simple searches, you might want to use [pdfgrep]. Should you need more advanced grep capabilities not incorporated by pdfgrep, you might want to convert the file to text and search there. You can to this using [pdftotext](pdfgrep.md) as shown in this example ([source][stackoverflow answer about how to search contents of multiple pdf files]): -```shell +```sh find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' ';' ``` @@ -48,7 +48,7 @@ find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename -- - Standard editions of `grep` run in a single thread; use another executor like `parallel` or `xargs` to parallelize grepping multiple files: - ```shell + ```sh find . -type f | parallel -j 100% grep 'pattern' find . -type f -print0 | xargs -0 -n 1 -P $(nproc) grep 'pattern' ``` diff --git a/knowledge base/gsutils.md b/knowledge base/gsutils.md index 37a2abd..5e41890 100644 --- a/knowledge base/gsutils.md +++ b/knowledge base/gsutils.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # delete a bucket and all its contents gsutil rm -r gs://${BUCKET_NAME} diff --git a/knowledge base/homebrew.md b/knowledge base/homebrew.md index 868e0d6..b101645 100644 --- a/knowledge base/homebrew.md +++ b/knowledge base/homebrew.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # install/uninstall on os x /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" @@ -21,7 +21,7 @@ brew bundle dump ## Configuration -```shell +```sh # require SHA check for casks # change cask installation dir to the Application folder in the user HOME export HOMEBREW_CASK_OPTS="--require-sha --appdir $HOME/Applications" diff --git a/knowledge base/imagemagick.md b/knowledge base/imagemagick.md index 7295d30..0eaa30c 100644 --- a/knowledge base/imagemagick.md +++ b/knowledge base/imagemagick.md @@ -6,7 +6,7 @@ Components: ## TL;DR -```shell +```sh # scale an image to 50% its original size convert IMG_20200117_135049.jpg -adaptive-resize 50% IMG_20200117_135049_resized.jpg diff --git a/knowledge base/iperf.md b/knowledge base/iperf.md index 52dab1c..19f767c 100644 --- a/knowledge base/iperf.md +++ b/knowledge base/iperf.md @@ -1,6 +1,6 @@ # Iperf -```shell +```sh # on the server iperf3 -s iperf3 -s -p 7575 diff --git a/knowledge base/iw.md b/knowledge base/iw.md index 2f9ea90..5d1d542 100644 --- a/knowledge base/iw.md +++ b/knowledge base/iw.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Scan for available wireless networks. iw dev wlp scan diff --git a/knowledge base/iwlist.md b/knowledge base/iwlist.md index 3054a12..49e2e92 100644 --- a/knowledge base/iwlist.md +++ b/knowledge base/iwlist.md @@ -4,7 +4,7 @@ ## TL;DR -```shell +```sh # Scan for networks. iwlist wlan0 scan ``` diff --git a/knowledge base/jdupes.md b/knowledge base/jdupes.md index 1ea1e82..44859bd 100644 --- a/knowledge base/jdupes.md +++ b/knowledge base/jdupes.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # prompt to delete all duplicate files jdupes -Zdr directory diff --git a/knowledge base/jira.md b/knowledge base/jira.md index b7ffee9..2313bba 100644 --- a/knowledge base/jira.md +++ b/knowledge base/jira.md @@ -1,6 +1,6 @@ # Jira -```shell +```sh # create a ticket curl https://${COMPANY}.atlassian.net/rest/api/2/issue \ -D - \ diff --git a/knowledge base/jq.md b/knowledge base/jq.md index a1b3cf4..4688481 100644 --- a/knowledge base/jq.md +++ b/knowledge base/jq.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # add a field jq --arg REGION ${AWS_REGION} '.spec.template.spec.containers[]?.env? += [{name: "AWS_REGION", value: $REGION}]' /tmp/service.kube.json diff --git a/knowledge base/jsonpath.md b/knowledge base/jsonpath.md index d0d2734..97c1a04 100644 --- a/knowledge base/jsonpath.md +++ b/knowledge base/jsonpath.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # filter elements # only works on arrays, not on maps kubectl get serviceaccounts \ diff --git a/knowledge base/kapp.md b/knowledge base/kapp.md index a393b22..77c4f3d 100644 --- a/knowledge base/kapp.md +++ b/knowledge base/kapp.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Configurations picked up from a directory $ kapp deploy -a my-app -f ./examples/simple-app-example/config-1.yml diff --git a/knowledge base/kde.md b/knowledge base/kde.md index c3d4125..659bded 100644 --- a/knowledge base/kde.md +++ b/knowledge base/kde.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Get from '~/.config/kinfocenterrc' the current value for the 'MenuBar' key in # the 'MainWindow' group. kreadconfig5 --file kinfocenterrc --group MainWindow --key MenuBar diff --git a/knowledge base/keda.md b/knowledge base/keda.md index 4c55fe3..3a7a463 100644 --- a/knowledge base/keda.md +++ b/knowledge base/keda.md @@ -51,7 +51,7 @@ KEDA offers a wide range of triggers (A.K.A. _scalers_) that can both detect if ### Helm chart -```shell +```sh # Installation. helm repo add kedacore https://kedacore.github.io/charts \ && helm repo update kedacore \ @@ -67,7 +67,7 @@ helm uninstall keda --namespace keda \ Use the YAML declaration (which includes the CRDs and all the other resources) available on the GitHub releases page: -```shell +```sh # Installation. kubectl apply -f https://github.com/kedacore/keda/releases/download/v2.0.0/keda-2.0.0.yaml @@ -77,7 +77,7 @@ kubectl delete -f https://github.com/kedacore/keda/releases/download/v2.0.0/keda One can also use the tools in the repository: -```shell +```sh git clone https://github.com/kedacore/keda cd keda VERSION=2.0.0 make deploy # installation @@ -270,7 +270,7 @@ For details and updated information see KEDA's [External Scalers] page. Use the logs for the keda operator or apiserver: -```shell +```sh kubectl logs --namespace keda keda-operator-8488964969-sqbxq kubectl logs --namespace keda keda-operator-metrics-apiserver-5b488bc7f6-8vbpl ``` @@ -286,7 +286,7 @@ There is at the moment of writing no way to control which of the replicas get te Just run the following: -```shell +```sh kubectl delete -f https://raw.githubusercontent.com/kedacore/keda/main/config/crd/bases/keda.sh_scaledobjects.yaml kubectl delete -f https://raw.githubusercontent.com/kedacore/keda/main/config/crd/bases/keda.sh_scaledjobs.yaml kubectl delete -f https://raw.githubusercontent.com/kedacore/keda/main/config/crd/bases/keda.sh_triggerauthentications.yaml diff --git a/knowledge base/keybase.md b/knowledge base/keybase.md index 301348f..231cae7 100644 --- a/knowledge base/keybase.md +++ b/knowledge base/keybase.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Start the services. run_keybase run_keybase -fg @@ -62,19 +62,19 @@ Use the import form in [Keybase launches encrypted git], or: 1. Create the remote repository: - ```shell + ```sh keybase git create dotfiles ``` 1. Copy the existing repository to a temporary directory: - ```shell + ```sh git clone --mirror https://github.com/user/dotfiles _tmp.git ``` 1. Push the contents of the old repository to the new one: - ```shell + ```sh git -C _tmp.git push --mirror keybase://private/user/dotfiles ``` @@ -89,7 +89,7 @@ Use `keybase oneshot` to establish a temporary device. The resulting process won `keybase oneshot` needs a username and a paperkey to work, either passed in via standard input, command-line flags, or environment variables: -```shell +```sh # Provide login information on the standard input. keybase oneshot diff --git a/knowledge base/keychron.md b/knowledge base/keychron.md index 551247e..60d92ec 100644 --- a/knowledge base/keychron.md +++ b/knowledge base/keychron.md @@ -6,7 +6,7 @@ 1. ensure the `hid_apple` module is loaded - ```shell + ```sh sudo modprobe hid_apple # load at boot @@ -15,7 +15,7 @@ 1. configure the keyboard's _fn mode_: - ```shell + ```sh echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode # load at boot diff --git a/knowledge base/kubeval.md b/knowledge base/kubeval.md index 319e761..8aae684 100644 --- a/knowledge base/kubeval.md +++ b/knowledge base/kubeval.md @@ -4,7 +4,7 @@ Validates one or more Kubernetes configuration files. ## TL;DR -```shell +```sh $ kubeval my-invalid-rc.yaml || echo "Validation failed" >&2 WARN - my-invalid-rc.yaml contains an invalid ReplicationController - spec.replicas: Invalid type. Expected: integer, given: string Validation failed diff --git a/knowledge base/less.md b/knowledge base/less.md index b34d642..4829a9e 100644 --- a/knowledge base/less.md +++ b/knowledge base/less.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Search words *forwards* in the current document. :/keyword diff --git a/knowledge base/lxc.md b/knowledge base/lxc.md index 37823ee..698a0f4 100644 --- a/knowledge base/lxc.md +++ b/knowledge base/lxc.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # install lxc apt-get install lxc snap install lxd @@ -44,7 +44,7 @@ man lxc.container.conf(5) ## Create new containers as unprivileged user -```shell +```sh # allow user vagrant to create up to 10 veth devices connected to the lxcbr0 bridge echo "vagrant veth lxcbr0 10" | sudo tee -a /etc/lxc/lxc-usernet ``` diff --git a/knowledge base/mac os x.md b/knowledge base/mac os x.md index 1d9b3f3..8a0416c 100644 --- a/knowledge base/mac os x.md +++ b/knowledge base/mac os x.md @@ -14,7 +14,7 @@ ## TL;DR -```shell +```sh # Install a .pkg file from CLI. # 'target' needs to be a device, not a path. installer -pkg /path/to/non-root-package.pkg -target CurrentUserHomeDirectory @@ -76,7 +76,7 @@ scutil --get ComputerName ## Xcode CLI tools -```shell +```sh xcode-select --install ``` @@ -84,7 +84,7 @@ The tools will be installed into `/Library/Developer/CommandLineTools` by defaul ### Headless installation -```shell +```sh # Force the `softwareupdate` utility to list the Command Line Tools. touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress @@ -102,7 +102,7 @@ CLI_TOOLS_LABEL="$(/usr/sbin/softwareupdate -l \ ### Removal -```shell +```sh sudo rm -rf $(xcode-select -p) sudo rm -rf /Library/Developer/CommandLineTools ``` @@ -111,7 +111,7 @@ sudo rm -rf /Library/Developer/CommandLineTools See [How to update Xcode from command line] for details. -```shell +```sh # Remove and reinstall. sudo rm -rf $(xcode-select -p) xcode-select --install @@ -121,7 +121,7 @@ xcode-select --install > **Note:** once set something, you'll probably need to restart the dock with `killall Dock` -```shell +```sh # Show hidden apps indicators in the dock. defaults write com.apple.dock showhidden -bool TRUE @@ -148,7 +148,7 @@ Note: * edits the input image * `-Z` retains ratio -```shell +```sh sips -Z 1000 Downloads/IMG_20190527_013903.jpg ``` @@ -176,7 +176,7 @@ Combination | Behaviour ## Update the OS from CLI -```shell +```sh # List all available updates. softwareupdate --list --all @@ -201,7 +201,7 @@ Save a password with the following settings: > The password's value needs to be given **last**. -```shell +```sh # Add the password to the default keychain. security add-generic-password -a johnny -s github -w 'b.good' # Also give it some optional data. diff --git a/knowledge base/macports.md b/knowledge base/macports.md index 8553c0c..caf18a3 100644 --- a/knowledge base/macports.md +++ b/knowledge base/macports.md @@ -6,7 +6,7 @@ Default ports install location is `/opt/local`. ## TL;DR -```shell +```sh # get help on a command port help install port help select diff --git a/knowledge base/magisk.md b/knowledge base/magisk.md index dd4057e..0873279 100644 --- a/knowledge base/magisk.md +++ b/knowledge base/magisk.md @@ -12,14 +12,14 @@ 1. select the boot image; the Magisk app will patch the image to `[Internal Storage]/Download/magisk_patched_.img` 1. copy the patched image to your computer using the file transfer mode or `adb`: - ```shell + ```sh adb pull /sdcard/Download/magisk_patched_.img ``` 1. reboot the device to the bootloader (fastboot) 1. flash the modified boot image: - ```shell + ```sh sudo fastboot flash boot path/to/modified/boot.img ``` diff --git a/knowledge base/manjaro linux.md b/knowledge base/manjaro linux.md index 6da06c9..d077a4b 100644 --- a/knowledge base/manjaro linux.md +++ b/knowledge base/manjaro linux.md @@ -12,7 +12,7 @@ One can use the [branch comparison] tool to check in what branch a package is av ## Printing -```shell +```sh pamac install manjaro-printer sudo gpasswd -a ${USER} sys sudo systemctl enable --now cups.service diff --git a/knowledge base/mdl.md b/knowledge base/mdl.md index 933a84e..004c97b 100644 --- a/knowledge base/mdl.md +++ b/knowledge base/mdl.md @@ -4,7 +4,7 @@ Tool to check markdown files and flag style issues. ## TL;DR -```shell +```sh # Install. gem install mdl diff --git a/knowledge base/microos.md b/knowledge base/microos.md index 11e99a2..b44b851 100644 --- a/knowledge base/microos.md +++ b/knowledge base/microos.md @@ -4,7 +4,7 @@ Every set of changes to the underlying system is executed on a new inactive snapshot, which will be the one the system will boot into on the next reboot. -```shell +```sh # Upgrade the system. sudo transactional-update dup pkcon update diff --git a/knowledge base/mktemp.md b/knowledge base/mktemp.md index f5cff5c..2e2ebc3 100644 --- a/knowledge base/mktemp.md +++ b/knowledge base/mktemp.md @@ -4,7 +4,7 @@ Creates a unique temporary file or directory and returns the absolute path to it ## TL;DR -```shell +```sh # create an empty temporary file mktemp diff --git a/knowledge base/mount samba shares from a unix client.md b/knowledge base/mount samba shares from a unix client.md index 8e2565b..8776be2 100644 --- a/knowledge base/mount samba shares from a unix client.md +++ b/knowledge base/mount samba shares from a unix client.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh sudo mount -t cifs -o user=my-user //nas.local/shared_folder local_folder ``` diff --git a/knowledge base/mount.md b/knowledge base/mount.md index efb1d86..00c4daa 100644 --- a/knowledge base/mount.md +++ b/knowledge base/mount.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # by label mount -L seagate_2tb_usb /media/usb diff --git a/knowledge base/mysql.md b/knowledge base/mysql.md index 41fce6c..5758e75 100644 --- a/knowledge base/mysql.md +++ b/knowledge base/mysql.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # connect with user "root" on the local default socket # don't ask password and do not select db mysql diff --git a/knowledge base/nc.md b/knowledge base/nc.md index 6076c7e..7988b79 100644 --- a/knowledge base/nc.md +++ b/knowledge base/nc.md @@ -12,7 +12,7 @@ ## TL;DR -```shell +```sh # Check port 22 on hosts. nc -Nnvz 192.168.0.81 22 parallel -j 0 "nc -Nnvz -w 2 192.168.0.{} 22 2>&1" ::: {2..254} | grep -v "timed out" diff --git a/knowledge base/needs-restarting.md b/knowledge base/needs-restarting.md index 4c3c906..a4a60c3 100644 --- a/knowledge base/needs-restarting.md +++ b/knowledge base/needs-restarting.md @@ -4,7 +4,7 @@ ## TL;DR -```shell +```sh # Install. sudo dnf install dnf-utils sudo yum install yum-utils diff --git a/knowledge base/nmap.md b/knowledge base/nmap.md index 6d82081..d4eaf51 100644 --- a/knowledge base/nmap.md +++ b/knowledge base/nmap.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # scan all 65535 ports on a host nmap -p- 192.168.1.1 diff --git a/knowledge base/opensuse linux.md b/knowledge base/opensuse linux.md index 62c7dbb..09126a3 100644 --- a/knowledge base/opensuse linux.md +++ b/knowledge base/opensuse linux.md @@ -20,7 +20,7 @@ Open port 22 on the firewall: - using [firewall-cmd][firewalld] on the command line: - ```shell + ```sh sudo firewall-cmd --add-port=22/tcp --permanent ``` @@ -29,7 +29,7 @@ Start the SSH daemon: - using Yast: open _Yast2_ > _System services_ and enable _SSHD_ - using [systemctl][systemd] on the command line: - ```shell + ```sh sudo systemctl enable --now sshd.service ``` @@ -39,7 +39,7 @@ Install the OS from another computer capable of reading and writing SD cards. Given `/dev/sdb` being a SD card, use the following: -```shell +```sh curl -C - -L -o opensuse.raw.xz http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-Tumbleweed-ARM-JeOS-raspberrypi.aarch64.raw.xz xzcat opensuse.raw.xz \ | sudo dd bs=4M of=/dev/sdb iflag=fullblock oflag=direct status=progress \ @@ -52,7 +52,7 @@ Connect using SSH and login using `root:linux`. ### Firmware update from a running system -```shell +```sh # Check for an updated firmware. sudo rpi-eeprom-update diff --git a/knowledge base/opkg.md b/knowledge base/opkg.md index c462273..5437466 100644 --- a/knowledge base/opkg.md +++ b/knowledge base/opkg.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # update the list of available packages opkg update diff --git a/knowledge base/pacman.md b/knowledge base/pacman.md index 0c38cc5..8b74f4a 100644 --- a/knowledge base/pacman.md +++ b/knowledge base/pacman.md @@ -9,7 +9,7 @@ Useful options: ## TL;DR -```shell +```sh # search an installed package pacman --query --search ddc diff --git a/knowledge base/pamac.md b/knowledge base/pamac.md index b36f7b0..7a57306 100644 --- a/knowledge base/pamac.md +++ b/knowledge base/pamac.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # check if updates are available (in aur too) pamac checkupdates --aur diff --git a/knowledge base/parallel.md b/knowledge base/parallel.md index 9d8018d..5c42ae7 100644 --- a/knowledge base/parallel.md +++ b/knowledge base/parallel.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # group output (--group) # fill up cpu threads (--jobs 100%) # use newline as delimiter for the arguments in input diff --git a/knowledge base/pdftk.md b/knowledge base/pdftk.md index d48d6b3..b668e27 100644 --- a/knowledge base/pdftk.md +++ b/knowledge base/pdftk.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # combine multiple files pdftk file1.pdf file2.pdf file3.pdf cat output newfile.pdf diff --git a/knowledge base/pi-hole.md b/knowledge base/pi-hole.md index 6cc1e63..72d6b69 100644 --- a/knowledge base/pi-hole.md +++ b/knowledge base/pi-hole.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # one-step automated install curl -sSL https://install.pi-hole.net | bash ``` diff --git a/knowledge base/pkexec.md b/knowledge base/pkexec.md index 9ac9444..2a9df9e 100644 --- a/knowledge base/pkexec.md +++ b/knowledge base/pkexec.md @@ -4,7 +4,7 @@ Allows an _authorized_ user to execute a command as another user. If a username ## TL;DR -```shell +```sh pkexec systemctl hibernate ``` diff --git a/knowledge base/pkgutil.md b/knowledge base/pkgutil.md index ec6d637..752a842 100644 --- a/knowledge base/pkgutil.md +++ b/knowledge base/pkgutil.md @@ -8,7 +8,7 @@ Options are processed first, and affect the operation of all commands. Multiple ## TL;DR -```shell +```sh # list the package id of all installed packages pkgutil --pkgs pkgutil --packages --volume / diff --git a/knowledge base/portage.md b/knowledge base/portage.md index 08eba2e..3446a26 100644 --- a/knowledge base/portage.md +++ b/knowledge base/portage.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # System update. sudo emerge --sync sudo emerge --depclean --ask diff --git a/knowledge base/postgresql.md b/knowledge base/postgresql.md index 8952712..87f3be5 100644 --- a/knowledge base/postgresql.md +++ b/knowledge base/postgresql.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # connect to a server psql --host "${HOSTNAME}" --port "${PORT:-5432}" "${DATABASENAME:-root}" "${USERNAME:-root}" ``` diff --git a/knowledge base/pre-commit.md b/knowledge base/pre-commit.md index 879914b..10c1eb3 100644 --- a/knowledge base/pre-commit.md +++ b/knowledge base/pre-commit.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # generate a very basic configuration pre-commit sample-config > .pre-commit-config.yaml diff --git a/knowledge base/python.md b/knowledge base/python.md index e2d2b03..7fcc314 100644 --- a/knowledge base/python.md +++ b/knowledge base/python.md @@ -59,14 +59,14 @@ if __name__ == "__main__": serve(app, host="0.0.0.0", port=8080) ``` -```shell +```sh pip install flask waitress python hello.py ``` ## Maintenance -```shell +```sh # generate a list of all outdated packages pip list --outdated diff --git a/knowledge base/raspberry pi os.md b/knowledge base/raspberry pi os.md index 260f93f..2de5c70 100644 --- a/knowledge base/raspberry pi os.md +++ b/knowledge base/raspberry pi os.md @@ -8,7 +8,7 @@ Enable containerization features in the kernel to be able to run containers as i Add the following properties at the end of the line in `/boot/cmdline.txt`: -```shell +```sh cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory ``` @@ -16,7 +16,7 @@ cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory Switch Debian firewall to legacy config: -```shell +```sh update-alternatives --set iptables /usr/sbin/iptables-legacy update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy ``` diff --git a/knowledge base/redis.md b/knowledge base/redis.md index 6237520..b95f382 100644 --- a/knowledge base/redis.md +++ b/knowledge base/redis.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # debug the server redis-cli -h "${HOST}" -p "${PORT}" --user "${USERNAME}" --askpass MONITOR diff --git a/knowledge base/reload a user's group assignments without logging out.md b/knowledge base/reload a user's group assignments without logging out.md index e696d18..631611c 100644 --- a/knowledge base/reload a user's group assignments without logging out.md +++ b/knowledge base/reload a user's group assignments without logging out.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh exec su -l $USER ``` diff --git a/knowledge base/retrieve disk information.md b/knowledge base/retrieve disk information.md index 0086e1c..2630d81 100644 --- a/knowledge base/retrieve disk information.md +++ b/knowledge base/retrieve disk information.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh lshw -class disk smartctl -i /dev/sda hdparm -i /dev/sda diff --git a/knowledge base/rpm.md b/knowledge base/rpm.md index d115b8e..9543e75 100644 --- a/knowledge base/rpm.md +++ b/knowledge base/rpm.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # list all installed packages rpm --query --all diff --git a/knowledge base/sddm.md b/knowledge base/sddm.md index 0cfef98..6d00b4f 100644 --- a/knowledge base/sddm.md +++ b/knowledge base/sddm.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # open a new window for every monitor you have connected and show a preview of the theme sddm-greeter --test-mode --theme /usr/share/sddm/themes/breeze ``` diff --git a/knowledge base/sed.md b/knowledge base/sed.md index 1ed21fa..84678e8 100644 --- a/knowledge base/sed.md +++ b/knowledge base/sed.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Delete lines matching "OAM" from a file. sed -e '/OAM/d' -i .bash_history diff --git a/knowledge base/send an email from cli.md b/knowledge base/send an email from cli.md index 9e3957e..8f37813 100644 --- a/knowledge base/send an email from cli.md +++ b/knowledge base/send an email from cli.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh mail -s "Subject" recipient@mail.server echo "" | mail -a attachment.file -s "Subject" recipient@mail.server diff --git a/knowledge base/set the ondemand cpu governor to not rise the frequencies for niced load.md b/knowledge base/set the ondemand cpu governor to not rise the frequencies for niced load.md index fc775ee..07ef7d2 100644 --- a/knowledge base/set the ondemand cpu governor to not rise the frequencies for niced load.md +++ b/knowledge base/set the ondemand cpu governor to not rise the frequencies for niced load.md @@ -2,7 +2,7 @@ ## TL:DR -```shell +```sh sudo cpupower frequency-set --governor ondemand echo 1 | sudo tee /sys/devices/system/cpu/cpufreq/ondemand/ignore_nice_load diff --git a/knowledge base/shellcheck.md b/knowledge base/shellcheck.md index 39f157b..cad5528 100644 --- a/knowledge base/shellcheck.md +++ b/knowledge base/shellcheck.md @@ -4,7 +4,7 @@ Gives warnings and suggestions about `bash`/`sh` shell scripts. ## TL;DR -```shell +```sh shellcheck /path/to/script.sh ``` diff --git a/knowledge base/shred.md b/knowledge base/shred.md index 6639fd7..2f4256b 100644 --- a/knowledge base/shred.md +++ b/knowledge base/shred.md @@ -2,6 +2,6 @@ ## TL;DR -```shell +```sh shred --force --remove --verbose --zero file other-file ``` diff --git a/knowledge base/shuf.md b/knowledge base/shuf.md index 655ae93..e1ff6b7 100644 --- a/knowledge base/shuf.md +++ b/knowledge base/shuf.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # randomize the order of lines in a file and output the result shuf filename diff --git a/knowledge base/snap.md b/knowledge base/snap.md index a755f5b..b2d4ad4 100644 --- a/knowledge base/snap.md +++ b/knowledge base/snap.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Find snaps. snap find chezmoi snap find --private boincstats-js @@ -81,7 +81,7 @@ snap get foo bar ## Manage revisions -```shell +```sh # List installed snaps with all their revisions. snap list --all diff --git a/knowledge base/snapper.md b/knowledge base/snapper.md index 37e443c..e0fa73f 100644 --- a/knowledge base/snapper.md +++ b/knowledge base/snapper.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # list existing configurations snapper list-config diff --git a/knowledge base/sort.md b/knowledge base/sort.md index cdc3cde..a9bc001 100644 --- a/knowledge base/sort.md +++ b/knowledge base/sort.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Sort given lines. sort path/to/file @@ -24,19 +24,19 @@ awk 'BEGIN {FS=","; OFS="|"} {print $NF,$0}' file.txt \ 1. copy the last field (column) of each line at the beginning of each of the lines with a different delimiter: - ```shell + ```sh awk 'BEGIN {FS=","; OFS="|"} {print $NF,$0}' file.txt ``` 1. sort on the 1st field specifing the delimiter to be the character above: - ```shell + ```sh awk 'BEGIN {FS=","; OFS="|"} {print $NF,$0}' file.txt | sort -n -t '|' ``` 1. discard the first field - ```shell + ```sh awk 'BEGIN {FS=","; OFS="|"} {print $NF,$0}' file.txt | sort -n -t '|' | awk -F '|' '{print $NF}' awk 'BEGIN {FS=","; OFS="|"} {print $NF,$0}' file.txt | sort -n -t '|' | awk -F '|' '{print $2}' awk 'BEGIN {FS=","; OFS="|"} {print $NF,$0}' file.txt | sort -n -t '|' | cut -d '|' -f 2 diff --git a/knowledge base/split.md b/knowledge base/split.md index 15610ed..3f0c4b9 100644 --- a/knowledge base/split.md +++ b/knowledge base/split.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Break the 'home.tar.bz2' archive file into small blocks. # Each block up to 10MB (10\*1000\*1000) in size. # Prefix each chunk with 'home.tar.bz2.part'. diff --git a/knowledge base/sponge.md b/knowledge base/sponge.md index d1a05f5..3678b34 100644 --- a/knowledge base/sponge.md +++ b/knowledge base/sponge.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # installation brew install sponge # or moreutils diff --git a/knowledge base/ssh.md b/knowledge base/ssh.md index a26e97b..c90a010 100644 --- a/knowledge base/ssh.md +++ b/knowledge base/ssh.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # load ssh keys from ~/.ssh and add them to the agent eval `ssh-agent` && ssh-add @@ -35,7 +35,7 @@ ssh-copy-id -i ~/.ssh/id_rsa.pub user@nas.lan Create a new key: -```shell +```sh ssh-keygen -t rsa -b 4096 ssh-keygen -t dsa ssh-keygen -t ecdsa -b 521 @@ -80,7 +80,7 @@ Original contents retained as /home/mek/.ssh/known_hosts.old Change password of a key file -```shell +```sh ssh-keygen -f ~/.ssh/id_rsa -p ``` @@ -96,13 +96,13 @@ Options: Usage: -```shell +```sh sshfs -o $OPTIONS_LIST $HOST:$REMOTE_PATH $LOCAL_PATH ``` Example: -```shell +```sh sshfs user@nas.lan:/mnt/data Data -o auto_cache,reconnect,defer_permissions,noappledouble,volname=Data ``` @@ -110,7 +110,7 @@ sshfs user@nas.lan:/mnt/data Data -o auto_cache,reconnect,defer_permissions,noap OSX (requires macports since brew does not offer sshfs anymore): -```shell +```sh sudo port install sshfs ``` diff --git a/knowledge base/stow.md b/knowledge base/stow.md index c449649..18f9f95 100644 --- a/knowledge base/stow.md +++ b/knowledge base/stow.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # Stow files from packages in the current directory. stow --dotfiles package1 packageN diff --git a/knowledge base/sudo.md b/knowledge base/sudo.md index 97ab130..4597dc6 100644 --- a/knowledge base/sudo.md +++ b/knowledge base/sudo.md @@ -4,7 +4,7 @@ ## TL;DR -```shell +```sh # Make changes to a sudoers file. visudo visudo -f path/to/file @@ -15,7 +15,7 @@ visudo -c path/to/file ## Drop privileges -```shell +```sh # Invalidate the user's cached credentials. sudo -k @@ -25,7 +25,7 @@ sudo -k ls ## Restrict permissions a little -```shell +```sh # file /etc/sudoers.d/user Cmnd_Alias UPGRADE_CMND = /usr/bin/apt update, /usr/bin/apt list --upgradable, /usr/bin/apt upgrade Cmnd_Alias SHUTDOWN_CMND = /sbin/shutdown @@ -34,7 +34,7 @@ user ALL=(ALL:ALL) NOPASSWD: SHUTDOWN_CMND, UPGRADE_CMND ## Avoid providing a password -```shell +```sh # file /etc/sudoers.d/user user ALL=(ALL:ALL) NOPASSWD: ALL ``` @@ -43,7 +43,7 @@ user ALL=(ALL:ALL) NOPASSWD: ALL Invoke a login shell using the `-i, --login` option. When one does not specify a command a login shell prompt is returned, otherwise the output of the command is returned: -```shell +```sh % whoami root % sudo -i -u user diff --git a/knowledge base/swap.md b/knowledge base/swap.md index e81571d..11e1076 100644 --- a/knowledge base/swap.md +++ b/knowledge base/swap.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # show the swap usage swapon --show free -h @@ -24,7 +24,7 @@ vmstat --wide 1 ## Swappiness -```shell +```sh # change the current value sudo sysctl vm.swappiness=10 sudo sysctl -w vm/swappiness=5 @@ -36,7 +36,7 @@ echo 'vm.swappiness = 5' | sudo tee -a /etc/sysctl.d/99-swappiness.conf ## Swapfile -```shell +```sh # add a swapfile sudo fallocate -l 1G /swapfile # or sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576 sudo chmod 600 /swapfile diff --git a/knowledge base/synology dsm.md b/knowledge base/synology dsm.md index d05b6c0..22e966d 100644 --- a/knowledge base/synology dsm.md +++ b/knowledge base/synology dsm.md @@ -12,7 +12,7 @@ Requirements: Examples: -```shell +```sh # From a shared folder on a NAS to a local one. rsync \ --archive --hard-links \ @@ -70,7 +70,7 @@ Gotchas: Examples: -```shell +```sh # small/medium dataset # 2 folders in a shared folder sudo docker run --privileged \ diff --git a/knowledge base/sysctl.md b/knowledge base/sysctl.md index 490e223..62a8dac 100644 --- a/knowledge base/sysctl.md +++ b/knowledge base/sysctl.md @@ -11,7 +11,7 @@ Default configuration files locations: ## TL;DR -```shell +```sh # see the value of a single setting sysctl kernel.ostype diff --git a/knowledge base/systemd.md b/knowledge base/systemd.md index dbda7c5..eeae7a1 100644 --- a/knowledge base/systemd.md +++ b/knowledge base/systemd.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # List all available units. systemctl list-unit-files @@ -122,7 +122,7 @@ hostnamectl set-hostname prettiky --pretty User's service files should be placed into `~/.config/systemd/user`: -```shell +```sh cat > "${HOME}/.config/systemd/user/davmail.service" <`, one must set the value of _Class_ in the `local.class` setting: -```shell +```sh yadm config local.class Work ``` @@ -75,7 +75,7 @@ Links are also created for directories named this way, as long as they have at l `yadm` will automatically create the links by default. This behaviour can be disabled using the `yadm.auto-alt` setting. Even if disabled, links can be manually created by running `yadm alt`: -```shell +```sh # force (re)creation of links based on alternate files yadm alt ``` diff --git a/knowledge base/yamllint.md b/knowledge base/yamllint.md index 671d11e..2de2af2 100644 --- a/knowledge base/yamllint.md +++ b/knowledge base/yamllint.md @@ -4,7 +4,7 @@ A linter for YAML files written in Python and compatible with Python 3 only. ## TL;DR -```shell +```sh # Use a specific configuration file. yamllint -c /path/to/config file.yaml @@ -18,7 +18,7 @@ yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" file.yaml To use a custom configuration file, use the `-c` option: -```shell +```sh yamllint -c /path/to/config file.yaml ``` diff --git a/knowledge base/youtube-dl.md b/knowledge base/youtube-dl.md index ae3a640..cd29852 100644 --- a/knowledge base/youtube-dl.md +++ b/knowledge base/youtube-dl.md @@ -4,7 +4,7 @@ ## TL;DR -```shell +```sh # Limit the bandwidth. youtube-dl --format 313 --limit-rate 2M video-url @@ -59,7 +59,7 @@ youtube-dl \ The preferred method is to just download it from the [project]: -```shell +```sh curl --location https://yt-dl.org/downloads/latest/youtube-dl --remote-name chown a+x youtube-dl python3 youtube-dl … diff --git a/knowledge base/yt-dlp.md b/knowledge base/yt-dlp.md index bcd824a..b264a27 100644 --- a/knowledge base/yt-dlp.md +++ b/knowledge base/yt-dlp.md @@ -4,7 +4,7 @@ > To be able to merge multiple formats into one, you will also need to install `ffmpeg`. -```shell +```sh # Install it. python3 -m pip install -U --user yt-dlp diff --git a/knowledge base/zfs.md b/knowledge base/zfs.md index af0b059..f374470 100644 --- a/knowledge base/zfs.md +++ b/knowledge base/zfs.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # create a single device pool zpool create pool_name device @@ -113,7 +113,7 @@ man zfs Manjaro has prebuilt modules for ZFS, which package is the kernel's package postfixed by `-zfs` (e.g. for `linux-515` it is `linux515-zfs`) -```shell +```sh # install the modules' packages for all installed kernels sudo pamac install $(mhwd-kernel --listinstalled | grep '*' | awk -F '* ' '{print $2}' | xargs -I {} echo {}-zfs) ``` @@ -142,7 +142,7 @@ Filesystem options (`-O option`): * [reference](http://open-zfs.org/wiki/Performance_tuning#Deduplication) * `xattr=sa` -```shell +```sh sudo zpool \ create \ -f \ diff --git a/knowledge base/zip.md b/knowledge base/zip.md index fe175d4..e1ab31e 100644 --- a/knowledge base/zip.md +++ b/knowledge base/zip.md @@ -2,7 +2,7 @@ ## TL;DR -```shell +```sh # recursively compress everything in the current directory to an archive named 'foo.zip' zip -r foo . diff --git a/knowledge base/zsh.md b/knowledge base/zsh.md index 46c9ef5..61259aa 100644 --- a/knowledge base/zsh.md +++ b/knowledge base/zsh.md @@ -12,7 +12,7 @@ Startup file sequence: Aliases are expanded when the function definition is parsed, not when the function is executed. Define aliases **before** functions to avoid problems. -```shell +```sh # Quoting. "$scalar" "${array[@]}" @@ -50,7 +50,7 @@ Parameter expansions can involve flags like `${(@kv)aliases}` and other operator If the parameter is a **scalar** then the value, if any, is substituted: -```shell +```sh $ scalar='hello' $ echo "$scalar" hello @@ -58,14 +58,14 @@ hello The braces are required if the expansion is to be followed by a letter, digit or underscore that is not to be interpreted as part of name: -```shell +```sh $ echo "${scalar}_world" hello_world ``` If the parameter is an **array**, then the value of each element is substituted, one element per word: -```shell +```sh $ typeset -a array=( 'hello' 'world' ) $ echo "${array[@]}" hello world @@ -73,7 +73,7 @@ hello world The two forms are equivalent: -```shell +```sh $ echo "${(@)array}" hello world ``` @@ -84,7 +84,7 @@ hello world If _name_ is set then its value is substituted by _1_, otherwise by _0_: -```shell +```sh $ typeset name='tralala' $ echo "${+name}" 1 @@ -102,7 +102,7 @@ $ echo "${+name}" If _name_ is set then substitute its value, otherwise substitute _word_: -```shell +```sh $ name='tralala' $ echo "${name-word}" tralala @@ -121,7 +121,7 @@ In the second form: - only substitute its value if _name_ is non-null, and - _name_ may be omitted, in which case _word_ is **always** substituted: -```shell +```sh $ name='tralala' $ echo "${name:-word}" tralala @@ -139,7 +139,7 @@ word If _name_ is set then substitute _word_, otherwise substitute nothing: -```shell +```sh $ name='tralala' $ echo "${name+word}" word @@ -155,7 +155,7 @@ $ echo "${name+word}" In the second form, only substitute its value if _name_ is non-null: -```shell +```sh $ name='tralala' $ echo "${name:+word}" word @@ -173,7 +173,7 @@ $ echo "${name:+word}" In the first form, if _name_ is unset then set it to _word_: -```shell +```sh $ name='tralala' # value: 'tralala' $ echo "${name=word}" tralala @@ -192,7 +192,7 @@ word In the second form, if _name_ is unset or null then set it to _word_: -```shell +```sh $ name='tralala' # value: 'tralala' $ echo "${name:=word}" tralala @@ -214,7 +214,7 @@ word In the third form, unconditionally set _name_ to _word_: -```shell +```sh $ name='tralala' # value: 'tralala' $ echo "${name::=word}" word @@ -241,7 +241,7 @@ word In the first form, if _name_ is set then substitute its value, otherwise print _word_ and exit from the shell. -```shell +```sh $ name='tralala' $ echo "${name?word}" tralala @@ -257,7 +257,7 @@ zsh: name: word In the second form, substitute its value only if _name_ is both set and non-null: -```shell +```sh $ name='tralala' $ echo "${name:?word}" tralala @@ -275,7 +275,7 @@ Interactive shells return to the prompt. If _word_ is omitted, a standard message is printed in its place: -```shell +```sh $ name='' $ echo "${name:?}" zsh: name: parameter not set @@ -289,7 +289,7 @@ FIXME ## Arrays -```shell +```sh # Get a slice of an array. # Negative numbers count backwards. echo "${ARRAY[2,-1]}" @@ -315,7 +315,7 @@ typeset -aU path ## Tests -```shell +```sh # Regex match. [[ "$OSTYPE" =~ "darwin" ]] [[ "$OSTYPE" -regex-match "darwin" ]] @@ -323,13 +323,13 @@ typeset -aU path ## Find broken symlinks in the current directory -```shell +```sh ls **/*(-@) ``` ## Key bindings -```shell +```sh # Show all active key bindings. bindkeys @@ -389,7 +389,7 @@ If `PATH` must be set in `~/.zshenv` to affect things like non-login ssh shells, ### History -```shell +```sh # The maximum number of events stored in the internal history list. # If you use the HIST_EXPIRE_DUPS_FIRST option, setting this value larger than # the SAVEHIST size will give you the difference as a cushion for saving @@ -406,7 +406,7 @@ SAVEHIST=1000 ### Completion -```shell +```sh # Enable completion. autoload -U compinit compinit @@ -417,7 +417,7 @@ zstyle ':completion::complete:*' use-cache true ### Prompt management -```shell +```sh # Enable prompt management. autoload -U promptinit promptinit; prompt theme-name @@ -425,7 +425,7 @@ promptinit; prompt theme-name ### Automatic source of files in a folder -```shell +```sh # Configuration modules. # All files in the configuration folder will be automatically loaded in # numeric order. The last file setting a value overrides the previous ones. @@ -468,7 +468,7 @@ What follows are some I always add to my setup: Some setting or plugin changed the key binding. Reassign them to obtain the expected behaviour: -```shell +```sh bindkey "^[[H" beginning-of-line bindkey "^[[F" end-of-line bindkey "^[[3~" delete-char @@ -480,7 +480,7 @@ bindkey "^[[3~" delete-char Compinit is complaining of some critical files being group writable. Running `compaudit` will list those files. Just use it to remove the group's write permission: -```shell +```sh compaudit | xargs chmod g-w ``` diff --git a/knowledge base/zypper.md b/knowledge base/zypper.md index b26d8c4..92c198b 100644 --- a/knowledge base/zypper.md +++ b/knowledge base/zypper.md @@ -4,7 +4,7 @@ SUSE and openSUSE GNU/Linux's package management utility. ## TL;DR -```shell +```sh # update the repositories zypper refresh @@ -19,7 +19,7 @@ zypper install parallel Zypper does not have for now a way to list the content of an installed package. Use [rpm] for this: -```shell +```sh sudo rpm --query --list ${PACKAGE_NAME} ```