diff --git a/.github/README.md b/.github/README.md index efd77982..ac54e35c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,6 +1,6 @@ cheatsheets =========== -This repository contains community-sourced cheatsheets to be used with +This repository is fork of [cheatsheets][] cause the old repo has no update for long time. It contains community-sourced cheatsheets to be used with [cheat][] and similar applications. ### Format ### @@ -27,6 +27,9 @@ parameter placeholders. In edge-cases where that syntax may cause confusion, it is permissible to use placeholder values (`foo.txt`, `example.com`, etc.) as necessary. +### TODO ### +See [here](../TODO.md) + ### License ### Cheatsheets are licensed under [Creative Commons CC0 1.0][cc0]. See [LICENSE.txt][] for the full license text. @@ -36,3 +39,4 @@ Cheatsheets are licensed under [Creative Commons CC0 1.0][cc0]. See [cc0]: https://creativecommons.org/publicdomain/zero/1.0/legalcode [cheat]: https://github.com/cheat/cheat [docopt]: http://docopt.org +[cheatsheets]: https://github.com/cheat/cheatsheets \ No newline at end of file diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000..cd07bf28 --- /dev/null +++ b/TODO.md @@ -0,0 +1,7 @@ +# TODO: + +- fallocate +- ftp, lftp +- hostname +- htop +- locate \ No newline at end of file diff --git a/alias b/alias index 76eb813b..c5604619 100644 --- a/alias +++ b/alias @@ -6,3 +6,8 @@ alias ll='ls -l' # To remove alias: unalias ll + +# Add permanent aliasses +# bash: ~/.bashrc +# fish: ~/.config/fish/config.fish +# zsh: ~/.zshrc \ No newline at end of file diff --git a/aptss b/aptss new file mode 100644 index 00000000..1a90dc74 --- /dev/null +++ b/aptss @@ -0,0 +1,42 @@ +--- +tags: [ packaging ] +--- +# To find packages matching : +aptss search + +# To show information on a package: +aptss show + +# To fetch package list: +aptss update + +# To download and install the updates and (UNLIKE aptss-get) install new necessary packages: +aptss upgrade + +# To download and install the updates AND install new necessary packages +# AND remove packages that stand in the way of the upgrade - use with caution: +aptss dist-upgrade + +# To perform a full system upgrade: +aptss update && aptss upgrade + +# To install package(s): +aptss install ... + +# To uninstall package(s): +aptss remove ... + +# To remove automatically all unused packages: +aptss autoremove + +# To list dependencies of a package: +aptss depends ... + +# To remove packages and delete their config files: +aptss purge ... + +# To list all packages installed: +aptss list --installed + +--- +aptss is a wrapper of apt-fast and apt in order to accelerate package installation and download for spark app store and linuxdeepin \ No newline at end of file diff --git a/bash b/bash index 5097eac0..2284f9eb 100644 --- a/bash +++ b/bash @@ -1,6 +1,6 @@ # To implement a for loop: for file in *; -do +do echo $file found; done diff --git a/chmod b/chmod index 3af8ad6a..48fe5de6 100644 --- a/chmod +++ b/chmod @@ -2,7 +2,7 @@ chmod a+x myscript.sh # Set user to read/write/execute, group/global to read only (myscript.sh), symbolic mode -chmod u=rwx, go=r myscript.sh +chmod u=rwx, go=r myscript.sh # Remove write from user/group/global (myscript.sh), symbolic mode chmod a-w myscript.sh diff --git a/conda b/conda index a525a12a..135dd080 100644 --- a/conda +++ b/conda @@ -7,7 +7,7 @@ conda env list # To initialise an environment conda create --name -# To initialise an environment with python3.10 +# To initialise an environment with python3.10 conda create --name python=3.10 # To install from a file diff --git a/curl b/curl index 772de7f1..2c6e32f9 100644 --- a/curl +++ b/curl @@ -35,7 +35,7 @@ curl http://ifconfig.me/all.json curl --limit-rate 1000B -O # To get your global IP: -curl httpbin.org/ip +curl httpbin.org/ip # To get only the HTTP status code: curl -o /dev/null -w '%{http_code}\n' -s -I URL diff --git a/docker b/docker index 178262f3..7433343b 100644 --- a/docker +++ b/docker @@ -4,6 +4,9 @@ docker -d # To build a docker image: docker build -t +# To build a docker image with specific dockerfile name: +docker build -t -f + # To start a container with an interactive shell: docker run -ti /bin/bash @@ -13,6 +16,9 @@ docker run -d # To "shell" into a running container (docker-1.3+): docker exec -ti bash +# To exec some command inside container: +docker exec ping 8.8.8.8 + # To inspect a running container: docker inspect (or ) @@ -22,8 +28,11 @@ docker inspect --format {{.State.Pid}} # To list (and pretty-print) the current mounted volumes for a container: docker inspect --format='{{json .Volumes}}' | python -mjson.tool -# To copy files/folders between a container and your host: -docker cp foo.txt mycontainer:/foo.txt +# To copy a file from the running container to host mechine: +docker cp : + +# To copy a file from host mechine to the running container: +docker cp : # To list currently running containers: docker ps @@ -31,6 +40,9 @@ docker ps # To list all containers: docker ps -a +# To list all container in format: Name, Image, Status, Port +docker container ls -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" + # To remove all stopped containers: docker container prune @@ -46,6 +58,9 @@ docker image ls -q # To remove all untagged images: docker rmi $(docker images | grep "^" | awk '{print $3}') +# To remove all images: +for image in $(docker image ls --format "table {{.Repository}}:{{.Tag}}"); do docker image rm -f $image ; done + # To remove all volumes not used by at least one container: docker volume prune @@ -97,8 +112,5 @@ docker run -v : # To link current folder between host and container for development: docker run -v $(pwd): -# To copy a file from the running container to host mechine: -docker cp : - -# To copy a file from host mechine to the running container: -docker cp : +# To clean-up docker environment (remove all images, unused containers, volumes, networks) +docker system prune -af \ No newline at end of file diff --git a/du b/du index d391127f..51bbdba7 100644 --- a/du +++ b/du @@ -12,7 +12,7 @@ du -shL du -h --apparent-size # To sort directories/files by size (human-readable): -du -sh * | sort -rh +du -sh * | sort -rh # To list the 20 largest files and folders under the current working directory: du -ma | sort -nr | head -n 20 diff --git a/dwm b/dwm index ec89bb5d..eaf6560b 100644 --- a/dwm +++ b/dwm @@ -2,78 +2,78 @@ Basic ===== # launch terminal. [Shift]+[Mod]+[Enter] - + # show/hide bar. -[Mod]+[b] +[Mod]+[b] # dmenu for running programs like the x#www#browser. -[Mod]+[p] +[Mod]+[p] # push acive window from stack to master, or pulls last used window from stack onto master. -[Mod]+[Enter] +[Mod]+[Enter] # focus on next/previous window in current tag. -[Mod] + [j / k] +[Mod] + [j / k] # increases / decreases master size. -[Mod] + [h / l] +[Mod] + [h / l] Navigation ========== # moves your focus to tag 2. -[Mod]+[2] +[Mod]+[2] # move active window to the 2 tag. -[Shift]+[Mod]+[2] +[Shift]+[Mod]+[2] # increases / decreases number of windows on master -[Mod] + [i / d] +[Mod] + [i / d] # move focus between screens (multi monitor setup) -[Mod] + [, / .] +[Mod] + [, / .] # move active window to different screen. -[Shift]+[Mod]+[, / .] +[Shift]+[Mod]+[, / .] # view all windows on screen. -[Mod]+[0] +[Mod]+[0] # make focused window appear on all tags. -[Shift]+[Mod]+[0] +[Shift]+[Mod]+[0] # kill active window. -[Shift]+[Mod]+[c] +[Shift]+[Mod]+[c] # quit dwm cleanly. -[Shift]+[Mod]+[q] +[Shift]+[Mod]+[q] Layout ====== # tiled mode. []= -[Mod]+[t] +[Mod]+[t] # floating mode. ><> -[Mod]+[f] +[Mod]+[f] # monocle mode. [M] (single window fullscreen) -[Mod]+[m] +[Mod]+[m] Floating ======== # to resize the floating window. -[Mod]+[R M B] +[Mod]+[R M B] # to move the floating window around. -[Mod]+[L M B] +[Mod]+[L M B] # toggles to the previous layout mode. -[Mod]+[Space] +[Mod]+[Space] # to make an individual window float. -[Mod]+[Shift]+[Space] +[Mod]+[Shift]+[Space] # to make an individual window un#float. -[Mod]+[M M B] +[Mod]+[M M B] diff --git a/ed b/ed index a4635b82..ef8c3c9b 100644 --- a/ed +++ b/ed @@ -8,11 +8,11 @@ tags: [ ed ] :q quit :Q quit without saving changes :f {name} change buffer name -:w write to file using current buffer name +:w write to file using current buffer name :w {file} write buffer to new file :wq write buffer to existing file and exit -# Line-oriented addressing and movement +# Line-oriented addressing and movement # `ed' uses line addresses to move around and operate within a buffer # Move to or operate on single lines by entering the line number # Move to or operate on ranges of lines using comma-separated values @@ -53,12 +53,12 @@ r !{command} read output of {command} into buffer after current line e test.txt edit file "test.txt" 45 `ed' returns character count as confirmation 1,3n display lines 1 through 3 with line numbers -1 This is line 1 +1 This is line 1 2 This is line 2 3 This is line 3 2c change line 2 I am typing a new line 2 -. end active edit +. end active edit 1,3n display lines 1 thorugh 3 with line numbers 1 This is line 1 2 I am typing a new line 2 @@ -71,7 +71,7 @@ wq write file "test.txt" and exit g/foo/ search all lines for `foo' and display matching lines g/foo/n search all lines for `foo'; display with line numbers -4,9/foo/ search lines 1 through 5 for `foo' and display matches +4,9/foo/ search lines 1 through 5 for `foo' and display matches 4,9/foo/n search lines 1 through 5 for `foo'; display with line numbers # Replace diff --git a/emacs b/emacs index 88f3f6ee..32a02ba0 100644 --- a/emacs +++ b/emacs @@ -36,7 +36,7 @@ Run command in the scratch buffer C-x C-e # Navigation ( backward / forward ) - + Character-wise C-b , C-f Word-wise M-b , M-f Line-wise C-p , C-n diff --git a/ethtool b/ethtool index 355e5c2c..a3439f29 100644 --- a/ethtool +++ b/ethtool @@ -1,6 +1,6 @@ --- syntax: bash -tags: [networking] +tags: [networking] --- # To show statistics for the selected interface: ethtool -S diff --git a/ffmpeg b/ffmpeg index 60d10ac9..c58fe1d5 100644 --- a/ffmpeg +++ b/ffmpeg @@ -39,5 +39,8 @@ cat mylist.txt file '/path/to/file1' file '/path/to/file2' file '/path/to/file3' - + ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4 + +# To change INPUT's FPS to 30 and save as OUTPUT (https://trac.ffmpeg.org/wiki/ChangingFrameRate) +ffmpeg -i -filter:v fps=fps=30 \ No newline at end of file diff --git a/find b/find index a02b1aa7..2a05cf5d 100644 --- a/find +++ b/find @@ -32,6 +32,7 @@ find ./path/ -name '*.txt' -exec cat '{}' \; # To find files with extension '.txt' and look for a string into them: find ./path/ -name '*.txt' | xargs grep 'string' +find ./path/ -name '*.txt' -exec grep -nrH 'string' {} \; # To find files with size bigger than 5 Mebibyte and sort them by size: find . -size +5M -type f -print0 | xargs -0 ls -Ssh | sort -z @@ -61,10 +62,7 @@ find . -type f -samefile MY_FILE_HERE 2>/dev/null find . -type f -exec chmod 644 {} \; # To find all files changed in last 2 days: -find . -type f -ctime -48h find . -type f -ctime -2 -# Or created in last 2 days: -find . -type f -Btime -2 # Or accessed in last 2 days: find . -type f -atime -2 diff --git a/for b/for index e9309eb7..fe362e51 100644 --- a/for +++ b/for @@ -1,38 +1,36 @@ # basic loop -for i in 1 2 3 4 5 6 7 8 9 10 -do +for i in 1 2 3 4 5 6 7 8 9 10; do echo $i done # loop ls command results -for var in `ls -alF` -do +for var in $(ls -alF); do echo $var done # loop over all the JPG files in the current directory -for jpg_file in *.jpg -do +for jpg_file in *.jpg; do echo $jpg_file done # loop specified number of times -for i in `seq 1 10` -do +for i in $(seq 1 10); do echo $i done # same as above, but as one-liner -for i in `seq 1 10`; do echo $i; done +for i in $(seq 1 10); do echo $i; done # loop specified number of times: the C/C++ style -for ((i=1;i<=10;++i)) -do +for ((i = 1; i <= 10; ++i)); do echo $i done # loop specified number of times: the brace expansion -for i in {1..10} -do +for i in {1..10}; do echo $i done + +# loop array of strings +string=("a" "b") +for char in "${string[@]}"; do echo "$char"; done diff --git a/fzf b/fzf index d872599d..7f5b5b28 100644 --- a/fzf +++ b/fzf @@ -19,7 +19,7 @@ fzf --preview "file {}" # Find files from find command and preview it with fzf find . -type f -name "*.txt" | fzf --preview "head {}" -# Display border around fzf output +# Display border around fzf output fzf --border sharp # Output only selected files and pipe it to a file diff --git a/git b/git index 15a88286..e59a3c58 100644 --- a/git +++ b/git @@ -14,6 +14,9 @@ git config --global color.ui true # To stage all changes for commit: git add --all +# To unstage some changes in file/folder (Undo `git add` command): +git reset file-name/folder-name + # To stash changes locally, this will keep the changes in a separate changelist # called stash and the working directory is cleaned. You can apply changes # from the stash anytime @@ -54,6 +57,9 @@ git filter-branch --env-filter \ # To remove staged and working directory changes: git reset --hard +# To go 1 commits back & keep staged changes: +git reset --soft HEAD~1 + # To go 2 commits back: git reset --hard HEAD~2 diff --git a/go b/go index fe9c14ee..3c8885ba 100644 --- a/go +++ b/go @@ -90,7 +90,7 @@ go test -v -run=^TestFooBar$/^Baz$ . go test -short ./... # Handy flag - don't run further tests after a failure. -go test -failfast ./... +go test -failfast ./... # Test all module dependencies. @@ -104,7 +104,7 @@ go test -run=^TestFooBar$ -count=500 . go fix ./... # Create a new Github issue for Go's standard library -go bug +go bug # Running and Comparing Benchmarks diff --git a/gpg b/gpg index 11de2323..d4821493 100644 --- a/gpg +++ b/gpg @@ -159,11 +159,11 @@ gpg -K Should show sec# instead of just sec. - + # High-quality options for gpg for symmetric (secret key) encryption - This is what knowledgable people consider a good set of options for + This is what knowledgable people consider a good set of options for symmetric encryption with gpg to give you a high-quality result. - + gpg \ --symmetric \ --cipher-algo aes256 \ @@ -179,7 +179,7 @@ --no-symkey-cache \ --output somefile.gpg \ somefile # to encrypt - + gpg \ --decrypt \ --pinentry-mode loopback \ diff --git a/gyb b/gyb index 2fe9f8ac..c5333f3d 100644 --- a/gyb +++ b/gyb @@ -1,7 +1,7 @@ # To estimate the number and the size of all mails on youremail@gmail.com gyb --email youremail@gmail.com --action estimate -# To backup from youremail@gmail.com to your local-folder +# To backup from youremail@gmail.com to your local-folder gyb --email youremail@gmail.com --action backup --local-folder "~/MyLocalFolder/" # To backup from youremail@gmail.com only important or starred emails to the @@ -9,4 +9,4 @@ gyb --email youremail@gmail.com --action backup --local-folder "~/MyLocalFolder/ gyb --email youremail@gmail.com --search "is:important OR is:starred" # To restore from your local-folder to youremail@gmail.com -gyb --email youremail@gmail.com --action restore --local-folder "~/MyLocalFolder/" +gyb --email youremail@gmail.com --action restore --local-folder "~/MyLocalFolder/" diff --git a/helix b/helix new file mode 100644 index 00000000..699a9409 --- /dev/null +++ b/helix @@ -0,0 +1,57 @@ +--- + +tags: + - helix + +--- + +# File management + +:reload reload file +:q quit +:q! quit without saving changes +:w write file +:w {file} write new file +:x write file and exit + +# Movement + + k + h l basic motion + j + +gg go to first line in file +G go to end of file + +# Text selection + +v enter selection mode +w to next word start +W to next whitespace +e to next word end +E to next whitespace-delimited word end +b to previous start of word +B to provious start of whitespace-delimited word +x whole line + +# Insertion + +a append after the cursor +A append at the end of the line +i insert before the cursor +I insert at the beginning of the line +o create a new line under the cursor +O create a new line above the cursor +R enter insert mode but replace instead of inserting chars +c enter insert mode, removing char under cursor + +# Editing + +u undo +xy yank (copy) a line +v{motion}y yank text that {motion} moves over +p paste after cursor +P paste before cursor +d delete a character +xd delete a line +v{motion}d delete text that {motion} moves over \ No newline at end of file diff --git a/ifconfig b/ifconfig index ed6c15f9..aa9e32bc 100644 --- a/ifconfig +++ b/ifconfig @@ -5,7 +5,7 @@ ifconfig ifconfig -a # To take down / up the wireless adapter: -ifconfig wlan0 {up|down} +ifconfig wlan0 {up|down} # To set a static IP and netmask: ifconfig eth0 192.168.1.100 netmask 255.255.255.0 diff --git a/iptables b/iptables index 2da02d8a..182afa8d 100644 --- a/iptables +++ b/iptables @@ -23,6 +23,8 @@ iptables -A INPUT -i eth0 -p tcp --dport 902 -j REJECT --reject-with icmp-port-u # To add a comment to a rule: iptables ... -m comment --comment "This rule is here for this reason" +# To only allow ssh on the server and block all other ports: +iptables --append --protocol tcp --dport 22 --jump # To remove or insert a rule: # 1) Show all rules diff --git a/java b/java index 403bd753..d87dfc79 100644 --- a/java +++ b/java @@ -25,7 +25,7 @@ OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, java -Xms256m -Xmx2g -Xss1m -jar # To use the classpath variable -# It overrides the CLASSPATH of Environment variable but only for that session. +# It overrides the CLASSPATH of Environment variable but only for that session. # If you restart the application you need to again set the classpath variable. # You can use either: -classpath, --classpath or -cp java -classpath -jar diff --git a/kitty b/kitty index d56906f3..99037c45 100644 --- a/kitty +++ b/kitty @@ -25,12 +25,12 @@ ctrl+shift+, - Move tab backward ctrl+shift+alt+t - Set tab title # Fonts and clipboard -ctrl+shift+c - Copy to clipboard +ctrl+shift+c - Copy to clipboard ctrl+shift+v - Paste from clipboard ctrl+shift+s - Paste from selection ctrl+shift+equal - Increase font size ctrl+shift+minus - Decrease font size -ctrl+shift+backspace - Restore font size +ctrl+shift+backspace - Restore font size # Windows ctrl+shift+enter - New window @@ -44,7 +44,7 @@ ctrl+shift+` - Move window to top ctrl+shift+f7 - Visually focus window ctrl+shift+f8 - Visually swap window # Focus specific window -ctrl+shift+1, ctrl+shift+2 … ctrl+shift+0 +ctrl+shift+1, ctrl+shift+2 … ctrl+shift+0 # Open/select ctrl+shift+e - Open URL diff --git a/losetup b/losetup new file mode 100644 index 00000000..d6a42766 --- /dev/null +++ b/losetup @@ -0,0 +1,12 @@ +--- +tags: [ mount loop ] +--- + +# Output available loop device +$ losetup -f + +# Attach an image file with partitioning table on available loop device +$ losetup "$(losetup -f)" path/to/file.img + +# Detatch loop device +$ losetup -d /dev/loopX \ No newline at end of file diff --git a/ls b/ls index a19fe448..3a703833 100644 --- a/ls +++ b/ls @@ -17,7 +17,7 @@ ls -d */ ls -d .*/ */ # To display all files sorted by changed date, most recent first: -ls -ltc +ls -ltc # To display files sorted by create time: ls -lt @@ -31,3 +31,6 @@ ls -1 # To show all the subtree files (Recursive Mode): ls -R + +# To .... +ls -lhta \ No newline at end of file diff --git a/markdown b/markdown index 53b0d1c3..44b17472 100644 --- a/markdown +++ b/markdown @@ -37,7 +37,7 @@ Sub-bullets can be done with 2+ spaces or 1 tab a. Lettered <-- there is mixed support for this format 4. Fourth i. using roman numerals <-- there is mixed support for this format - ii. more stuff + ii. more stuff ## check list There is limited support for rendering check lists: @@ -86,7 +86,7 @@ Assuming you have a heading called `# My First Heading` then link is the case-in Italic: *em* _em_ -Bold: +Bold: **strong** __strong__ ~~strikethrough~~ @@ -98,8 +98,8 @@ The alignment applies to the table data, not the header. Left-aligned Stuff | Right-aligned Stuff | Center-aligned Stuff | :--- | ---: | :---: -Some left stuff | Some right stuff | Some center stuff -Some left stuff | Some right stuff | Some center stuff +Some left stuff | Some right stuff | Some center stuff +Some left stuff | Some right stuff | Some center stuff ## Special Characters in Tables First Header | Second Header diff --git a/multipass b/multipass index 52f48733..9cd4b22e 100644 --- a/multipass +++ b/multipass @@ -1,5 +1,5 @@ # List all options -multipass +multipass # List existing VMs on your device multiplass list diff --git a/mutt b/mutt index 0c459459..3d5b7d23 100644 --- a/mutt +++ b/mutt @@ -1,6 +1,6 @@ # Create new mailbox in IMAP + When located in mailbox list (c) - shift + C + shift + C # Move multiple messages to folder (bulk operations) @@ -17,4 +17,4 @@ ~A 3. It should mark all for deletion! - 4. Conversely, you can do the same thing with UPPERCASE U to undelete multiple messages. + 4. Conversely, you can do the same thing with UPPERCASE U to undelete multiple messages. diff --git a/mv b/mv index 2ff826fe..278fee15 100644 --- a/mv +++ b/mv @@ -14,4 +14,4 @@ mv -i mv -n # To move listed file(s) to a directory -mv -t ... +mv -t diff --git a/openssl b/openssl index 2a1470f3..983d2b02 100644 --- a/openssl +++ b/openssl @@ -13,7 +13,7 @@ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt openssl req -text -noout -in server.csr # To show certificate information for generated certificate -openssl x509 -text -noout -in server.crt +openssl x509 -text -noout -in server.crt # To get the sha256 fingerprint of a certificate openssl x509 -in server.crt -noout -sha256 -fingerprint @@ -30,12 +30,12 @@ openssl dhparam -outform PEM -out dhparams.pem 2048 openssl s_client -connect 10.240.2.130:433 # High-quality options for openssl for symmetric (secret key) encryption - -This is what knowledgable people consider a good set of options for + +This is what knowledgable people consider a good set of options for symmetric encryption with openssl to give you a high-quality result. Also, always remember that the result is only as good as the password you use. You must use a strong password otherwise encryption is meaningless. - + openssl enc -e -aes-256-cbc \ -salt \ -pbkdf2 \ diff --git a/p4 b/p4 index d956f8ce..e6b55c71 100644 --- a/p4 +++ b/p4 @@ -1,7 +1,7 @@ tags: [ vcs ] # To print details related to client and server configuration: -p4 info +p4 info # To open a file and add it to depot: p4 add diff --git a/pandoc b/pandoc index 64356c53..de076386 100644 --- a/pandoc +++ b/pandoc @@ -1,5 +1,10 @@ -# Convert HTML file to Markdown -pandoc -f html -t markdown -i -o +--- +syntax: bash +tags: [converters, markdown] +--- -# Convert Markdown file to HTML -pandoc -f markdown -t html -i -o +# Convert HTML file to Markdown: +pandoc --from=html --to=markdown --output= + +# Convert Markdown file to HTML: +pandoc --from=markdown --to=html --output= \ No newline at end of file diff --git a/pdfgrep b/pdfgrep new file mode 100644 index 00000000..5ddf5cb4 --- /dev/null +++ b/pdfgrep @@ -0,0 +1,11 @@ +# search word in pdf file: +pdfgrep "keyword" file-name.pdf + +# search work in multiple pdf files on multiple folders: +pdfgrep -R "keyword" storage-folder/* + +# show page number & filename +pdfgrep -RHn "keyword" storage-folder/* + +# search words with regular expression +pdfgrep -RHnp "key...." storage-folder/* \ No newline at end of file diff --git a/port b/port index 79fdac66..75ecab8f 100644 --- a/port +++ b/port @@ -71,14 +71,14 @@ port rdependents # (Only works for currently installed ports.) port contents -# View a ports' notes, if any (these are usually displayed right after a port +# View a ports' notes, if any (these are usually displayed right after a port # is installed): port notes # Print the path to a port within the ports tree: port dir -# Print the path to the archive used to activate a given port: +# Print the path to the archive used to activate a given port: # (Only works for currently installed ports) port location diff --git a/prqlc b/prqlc new file mode 100644 index 00000000..3d701aa2 --- /dev/null +++ b/prqlc @@ -0,0 +1,16 @@ +# PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement. + +# Run the compiler interactively: +prqlc compile + +# Compile a .prql file standard output: +prqlc compile + +# Compile a .prql file to a .sql file: +prqlc compile + +# Compile a query: +echo "from employees | filter has_dog | select salary" | prqlc compile + +# Watch a directory and compile on file modification: +prqlc watch \ No newline at end of file diff --git a/pstree b/pstree new file mode 100644 index 00000000..173b906d --- /dev/null +++ b/pstree @@ -0,0 +1,14 @@ +# To show one tree, starting at pid 1: +pstree + +# To show descendents of : +pstree + +# To show parents and descendents of : +pstree -u + +# To use utf-8 'graphics' for trees when calling with [args]: +pstree -g 2 .. + +# To show tree for processes owned by : +pstree -u \ No newline at end of file diff --git a/r2 b/r2 index 402a9168..1eb5761f 100644 --- a/r2 +++ b/r2 @@ -53,22 +53,22 @@ # Basic Commands ; Command chaining: x 3;s+3;pi 3;s+3;pxo 4; - + | Pipe with shell commands: pd | less - + ! Run shell commands: !cat /etc/passwd - + !! Escapes to shell, run command and pass output to radare buffer Note: The double exclamation mark tells radare to skip the plugin list to find an IO plugin handling this command to launch it directly to the shell. A single one will walk through the io plugin list. ` Radare commands: wx `!ragg2 -i exec` - + ~ grep - + ~! grep -v - + ~[n] grep by columns afl~[0] ~:n grep by rows afl~:0 @@ -96,13 +96,13 @@ .. repeats last commands (same as enter \n) ( Used to define and run macros - + $ Used to define alias - + $$: Resolves to current address Offsets (@) are absolute, we can use $$ for relative ones @ $$+4 - + ? Evaluate expression +------------------------------------------------------------------- @@ -113,33 +113,33 @@ +------------------------------------------------------------------- ?$? Help for variables used in expressions - + $$: Here - + $s: File size - + $b: Block size - + $l: Opcode length - + $j: When $$ is at a jmp, $j is the address where we are going to jump to - + $f: Same for jmp fail address $m: Opcode memory reference (e.g. mov eax,[0x10] => 0x10) - + ??? Help for ? command - + ?i Takes input from stdin. Eg ?i username - + ?? Result from previous operations - + ?s from to [step]: Generates sequence from to every - + ?p: Get physical address for given virtual address - + ?P: Get virtual address for given physical one - + ?v Show hex value of math expr +------------------------------------------------------------------- @@ -150,7 +150,7 @@ +------------------------------------------------------------------- ?l str: Returns the length of string - + @@: Used for iteractions +------------------------------------------------------------------- @@ -307,7 +307,7 @@ wow 11223344 @102!10 write looped value from 102 to 102+10 0x00000066 1122 3344 1122 3344 1122 0000 0000 0000 - + wox 0x90 XOR the current block with 0x90. Equivalent to wox 0x90 $$!$b (write from current position, a whole block) @@ -646,7 +646,7 @@ -S: binary to hex (for files) - -N: pack an integer + -N: pack an integer rax2 -N 0x1234 # \x34\x12\x00\x00 # rahash2 - Entropy, hashes and checksums @@ -681,7 +681,7 @@ +------------------------------------------------------------------- # rasm2 - Assembly/Disasembly - + -L: Supported architectures -a arch instruction: Sets architecture @@ -844,7 +844,7 @@ https://github.com/jpenalbae/r2-scripts # Parsing ELF - !!! open with r2 -nn + !!! open with r2 -nn + Parse 9 program headers (elf_phdr) from curr. seek plus offset 0x40 with temporary block size 0x200 in less mode (~..) diff --git a/range b/range new file mode 100644 index 00000000..b3ea9878 --- /dev/null +++ b/range @@ -0,0 +1,95 @@ +--- +syntax: bash +tags: [file manager] +--- + +# Ranger Cheatsheet + +# A VIM-inspired filemanager for the console + +# https://github.com/ranger/ranger + +# General + +ranger start Ranger + +Q quit Ranger +R reload current directory +? Ranger Manpages / Shortcuts +: execute Range Command +! execute Shell Command +S run the terminal in your current ranger window (exit to go back to ranger) + +# Movement + +k up +j down +h parent directory +l subdirectory +gg go to top of list +G go t bottom of list +J half page down +K half page up +H history Back +L history Forward +~ switch the view + +# File Operations + + open file +r open file with +i read file +z open settings +zh set show_hidden_files +zp set preview_files +zz console filter :filter +zd set sort_directories_first +o change sort order + toggle show_hidden_files +cw rename file +a rename-append +I rename-overwrite +yy yank / copy +dd cut +pp paste +/ search for files :search +n next match +N prev match +.f filter stack on type 'file' +.d filter stack on type 'directory' +.l filter stack on type 'link' +.c clear filter + mark files +v mark files all=True toggle=True +dD delete + delete +Mp show file permissions +chmod nnn change file permissions +nnn= change file permissions +dc show cummulative size + +# Tabs + +gn tab_new +gc tab_close +gt tab_move 1 +gT tab_move -1 + +# File substituting + +%f substitute highlighted file +%d substitute current directory +%s substitute currently selected files +%t substitute currently tagged files + +# Example for substitution + +:bulkrename %s + +# Marker + +m+ create Marker +um+ delete Marker +'+ go to Marker +t tag a file with an \* +t" tag a file with your desired mark diff --git a/rmdir b/rmdir index a5dae1ed..8c63299b 100644 --- a/rmdir +++ b/rmdir @@ -1,5 +1,5 @@ # Command syntax: -rmdir [option] directory_name +rmdir [option] directory_name # Outputs a message that the directory is being removed: rmdir -v directory_name diff --git a/sar b/sar index 3d798931..226caadc 100644 --- a/sar +++ b/sar @@ -8,7 +8,7 @@ sar -u 2 5 # Report the CPU usage for a given core: sar -P 1 1 3 -# Reports the amount of memory used, amount of memory free, available cache, available buffers every 1 second, 3 times: +# Reports the amount of memory used, amount of memory free, available cache, available buffers every 1 second, 3 times: sar -r 1 3 # Reports statistics on swapping: diff --git a/sha256sum b/sha256sum index 11e40d43..42d30b7a 100644 --- a/sha256sum +++ b/sha256sum @@ -15,15 +15,15 @@ echo -n "Hello World" | sha256sum # To verify if a hash (checksum) is correct if a hash-file is provided: # sha256sum will go thru the files listed in . # For each file it will look if it exists. If not, it will print an error. -# If it does exist it will compute the checksum and compare it with the hash +# If it does exist it will compute the checksum and compare it with the hash # provided in the . If they match (good!) it -# will print "filename: OK". -# If they don't match (warning, you might have been hacked), it will +# will print "filename: OK". +# If they don't match (warning, you might have been hacked), it will # print "filename: FAILED". sha256sum --check # Same as above (but ignore missing files): -# This tells you if your file is an exact copy (OK) or has been +# This tells you if your file is an exact copy (OK) or has been # tampered with (FAILED) without bothering you with warnings about # missing files sha256sum --check --ignore-missing diff --git a/socat b/socat index 2d28600e..62fbbd18 100644 --- a/socat +++ b/socat @@ -12,9 +12,9 @@ socat -x tcp-listen:3180,fork - # practical examples: -# complete real working http-example: +# complete real working http-example: # (sleep is necessary to prevent socat closing socket before data received) -(echo -e "GET / HTTP/1.1\r\nHost: butzel.info\r\n\r" && sleep 1) \ +(echo -e "GET / HTTP/1.1\r\nHost: butzel.info\r\n\r" && sleep 1) \ | socat tcp4:butzel.info:80 - # http to httpS 'Proxy' (for an webserver without TLS-Support) diff --git a/ss b/ss index f4da8cc7..1bf57880 100644 --- a/ss +++ b/ss @@ -11,6 +11,9 @@ Args # show all listening tcp sockets including the corresponding process ss -tlp +# show all listening tcp sockets including the corresponding process, netid +ss -tulp + # show all sockets connecting to 192.168.2.1 on port 80 ss -t dst 192.168.2.1:80 diff --git a/su b/su index 286941ce..49dafe91 100644 --- a/su +++ b/su @@ -1,2 +1,5 @@ # To switch to another user account: su + +# To switch to another user - inherit that user's bash configuration +su - \ No newline at end of file diff --git a/systemctl b/systemctl index ae0b8b74..9313c459 100644 --- a/systemctl +++ b/systemctl @@ -55,7 +55,7 @@ journalctl -b -u foo.service # To list the dependencies of a service: # when no service name is specified, lists the dependencies of default.target # add -all to expand dependencies recursively -systemctl list-dependencies foo.service +systemctl list-dependencies foo.service # To see low level details of a service settings on the system: systemctl show foo.service diff --git a/terraform b/terraform index 15863a0a..6d6b69f9 100644 --- a/terraform +++ b/terraform @@ -21,10 +21,10 @@ terraform apply terraform destroy -# To upgrade your [Terraform providers](https://www.terraform.io/docs/providers/index.html), which are distributed separately from the Terraform binary. +# To upgrade your [Terraform providers](https://www.terraform.io/docs/providers/index.html), which are distributed separately from the Terraform binary. terraform init -upgrade -# To upgrade your [Terraform modules](https://www.terraform.io/docs/modules/index.html), which are distributed separately from the Terraform binary. +# To upgrade your [Terraform modules](https://www.terraform.io/docs/modules/index.html), which are distributed separately from the Terraform binary. terraform get -update diff --git a/tmux b/tmux index 80a90a33..b8cf9649 100644 --- a/tmux +++ b/tmux @@ -8,7 +8,7 @@ Ctrl-b d tmux attach # To detach an already attached session (great if you are moving devices with different screen resolutions): -tmux attach -d +tmux attach -d # To display session: tmux ls @@ -53,3 +53,9 @@ Ctrl-b " # To swap windows: Ctrl-b :swap-window -s [0-9] -t [0-9] + +# To copy/paste +1. Enter 'copy mode' by pressing CTRL+b, [. +2. Use the arrow keys to go to the position from where you want to start copying. Press CTRL+SPACE to start copying. +3. Use arrow keys to go to the end of text you want to copy. Press ALT+w or CTRL+w to copy into Tmux buffer. +4. Press CTRL+b, ] to paste in a possibly different Tmux pane/window. \ No newline at end of file diff --git a/top b/top index 022fa66e..6a8b9a76 100644 --- a/top +++ b/top @@ -4,23 +4,20 @@ top -i # To set the delay between updates to seconds: top -s -# To set event counting to accumulative mode: -top -a +# To set memory unit +top -E -# To set event counting to delta mode: -top -d - -# To set event counting to absolute mode: -top -e - -# To not calculate statistics on shared libraries, also known as frameworks: -top -F - -# To calculate statistics on shared libraries, also known as frameworks (default): -top -f +# To monitor specific process IDs (maximum is 20 process IDs) +top -pN1,N2,N3,...N20 # To print command line usage information and exit: top -h # To order the display by sorting on in descending order: top -o + +# Basic command use after enter `top` +- f: show/hide fields, sort fiend + - d: show/hide field + - s: select as sort field + - a/w: keep this custom field forever \ No newline at end of file diff --git a/tr b/tr index 13a9b80c..825c0ec1 100644 --- a/tr +++ b/tr @@ -1,22 +1,22 @@ # To replace : with a new line: echo $PATH | tr ":" "\n" -echo $PATH | tr -t ":" \n +echo $PATH | tr -t ":" \n # To remove all occurance of "ab": -echo aabbcc | tr -d "ab" # ouput: cc +echo aabbcc | tr -d "ab" # ouput: cc # To complement "aa": # ("Complement" means to keep "aa", and replace all others with "x") -echo aabbccd | tr -c "aa" x # output: aaxxxxx (no newline) +echo aabbccd | tr -c "aa" x # output: aaxxxxx (no newline) # To complement "ab\n": -echo aabbccd | tr -c "ab\n" x #output: aabbxxx (with newline) +echo aabbccd | tr -c "ab\n" x #output: aabbxxx (with newline) # To preserve all alpha(-c). ":-[:digit:] etc" will be translated to "\n". sequeeze mode: -echo $PATH | tr -cs "[:alpha:]" "\n" +echo $PATH | tr -cs "[:alpha:]" "\n" # To convert an ordered list to an unordered list: echo "1. /usr/bin\n2. /bin" | tr -cs " /[:alpha:]\n" "+" # To remove all NULLs: -tr < file-with-nulls -d '\000' > file-without-nulls +tr file-without-nulls diff --git a/udisksctl b/udisksctl index c4d5233f..176a2f18 100644 --- a/udisksctl +++ b/udisksctl @@ -8,4 +8,4 @@ udisksctl mount --block-device udisksctl unmount --block-device # To get help: -udisksctl help +udisksctl help diff --git a/ufw b/ufw new file mode 100644 index 00000000..2baa153b --- /dev/null +++ b/ufw @@ -0,0 +1,28 @@ +# To check the status of the firewall: +ufw status + +# To check the status with more details: +ufw status verbose + +# To allow a port on the firewall by its name: +ufw allow +ufw allow http +ufw allow https +ufw allow ssh +ufw allow ftp + +# To allow a port on the firewall by its number: +ufw allow +ufw allow 5432 + +# To delete an allowed port rule on the firewall: +ufw delete allow 5432 + +# To block a port on the firewall: +ufw deny 21 + +# To enable the firewall and activate the rules: +ufw enable + +# To disable the firewall and deactivate the rules: +ufw disable \ No newline at end of file diff --git a/vim-plugins/vim-surround b/vim-plugins/vim-surround new file mode 100644 index 00000000..3b4186e5 --- /dev/null +++ b/vim-plugins/vim-surround @@ -0,0 +1,44 @@ +--- +tags: [ vim,vim-plugins ] +--- + +# https://github.com/tpope/vim-surround + +# To surround with the specified character: +`ys{motion}{character}` +ex: ysiw) foo => (foo) + ysiw( foo => ( foo ) + ysiw] foo => [foo] + ysiw[ foo => [ foo ] + ysiw

foo =>

foo

+ yss} foo => {foo} # surround the whole line with {} (ignores leading whitespace) + ySS} foo => { + foo # indent the line and place it on a new line + } + +# To change the current surrounding character: +`cs{old}{new}` +ex: cs([ (foo) => [foo] + cs[( [foo] => (foo) + cs" "foo" => foo + +# To delete the current surrounding: +`ds{character}` # delete the surrounding character +`dst` # delete the surrounding HTML tag +ex: ds( (foo) => foo + ds[ [foo] => foo + dst

foo

=> foo + +# To surround with function: +`ysWf{function_name}` +ex: ysWfprint "foo" => print("foo") + ysWFprint "foo" => print( "foo" ) + +# Legend + +ys = "you surround" +b = () +B = {} +r = [] +a = <> +t = HTML tag \ No newline at end of file diff --git a/watch b/watch new file mode 100644 index 00000000..e9317087 --- /dev/null +++ b/watch @@ -0,0 +1,2 @@ +# To watch a command and update the output every 2 seconds: +watch \ No newline at end of file diff --git a/xargs b/xargs index b4a3ace6..10eaa42b 100644 --- a/xargs +++ b/xargs @@ -1,8 +1,16 @@ -# To Find all file name ending with .pdf and remove them -find -name *.pdf | xargs rm -rf +--- +syntax: bash +--- -# if file name contains spaces you should use this instead -find -name *.pdf | xargs -I{} rm -rf '{}' +# Find all files whose names end with .pdf and remove them: +find -type f -name '*.pdf' | xargs rm -f + +# If file names contain special characters, you should use this instead. +# Special characters include spaces, quotes, parenthesis, unicode, etc: +find -type f -name '*.pdf' -print0 | xargs --null rm -f + +# Run 4 `rm` commands in parallel +find -name '*.pdf' | xargs --max-procs=4 rm -f # Will show every .pdf like: # &toto.pdf= diff --git a/yaourt b/yaourt index 4d742f24..77037216 100644 --- a/yaourt +++ b/yaourt @@ -3,7 +3,7 @@ tags: [ packaging ] --- # All pacman commands are working the same way with yaourt. # Just check the pacman cheatsheet. -# For instance, to install a package: +# For instance, to install a package: pacman -S yaourt -S # The difference is that yaourt will also query the Arch User Repository, @@ -19,7 +19,7 @@ yaourt # svn, hg...) yaourt -Suya --devel -# For all of the above commands, if you want yaourt to stop asking constantly for confirmations, +# For all of the above commands, if you want yaourt to stop asking constantly for confirmations, use the option --noconfirm # To build from source: diff --git a/yum b/yum index b86ed33e..c0153491 100644 --- a/yum +++ b/yum @@ -27,7 +27,7 @@ yum repolist # List packages matching : yum list - + # To download the source RPM for a package: yumdownloader --source