tmux
New session
tmux new -s session_name
List sessions
tmux ls
Attach to session
tmux a -t session_name
Keys
All must be preceded by `ctrl+b` | Key | Function | | --- | -------- | | `d` | Detach | | `?` | Show Help |Select
[Source](https://www.rockyourcode.com/copy-and-paste-in-tmux/) Enter ‘copy mode’ by pressing `CTRL+b`, `[`. Use the arrow keys to go to the position from where you want to start copying. Press `CTRL+SPACE` to start copying. 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. Press `CTRL+b`, `]` to paste in a possibly different Tmux pane/window.emacs
Emacs no window
emacs -nw
emacs --no-window-system --color=never
GUI
emacs
Keys
`C-x` means `control` + `x` | Key | Function | | --- | -------- | | `C-x C-c` | Close |ddcutil
Detect monitors.
sudo ddcutil detect
Show capabilities for the monitor.
sudo ddcutil --display 1 capabilities
Get and set values
sudo ddcutil getvcp ALL
sudo ddcutil getvcp 10
sudo ddcutil setvcp 10 20
https://www.ddcutil.com/commands/
Examples
Manual startsudo modprobe i2c-dev
Start on boot
echo "i2c-dev" | sudo tee /etc/modules-load.d/i2c-dev.conf
Show monitor models:
sudo ddcutil detect | grep "Model:" | awk '{$1=""; print substr($0,2)}'
Get more information on the *Feature*.
sudo ddcutil -d 1 vcpinfo 10
---
VCP code 10: Brightness
Increase/decrease the brightness of the image.
MCCS versions: 2.0, 2.1, 3.0, 2.2
ddcutil feature subsets: PROFILE, COLOR
Attributes: Read Write, Continuous (normal)
Set a value for a *Feature*.
sudo ddcutil setvcp 10 20
sudo ddcutil setvcp 10 +5
sudo ddcutil setvcp 10 -- -20
Get the current value of a *Feature*.
sudo ddcutil getvcp 10
---
VCP code 0x10 (Brightness): current value = 18, max value = 100
weechat
Key | Function |
---|---|
^p |
Previous buffer |
^n |
Next buffer |
Command | Function |
---|---|
/fset * |
Show current configuration |
/set |
Set the configuration |
/list |
List all channels |
/list -re #arch* |
Search channels |
Examples
Add a server/server add liberachat irc.libera.chat/6697
Connect to a server
/connect liberachat
/connect irc.libera.chat 6697 yurialek:password
Identify
/msg NickServ IDENTIFY yurialek password
Set the nick
/set irc.server.liberachat.nicks "yurialek"
Show the current options for the server
/fset irc.server.liberachat.*
Search for a channel
/list *nixos*
/list -re #arch*
Join a channel
/join #archlinux
Show help
/help part
Part a channel
/part
nnn
Keys
`^R` means `Control` + `r` | Key | Function | | --- | -------- | | `q` | Close context / Close | | `Q` | Close | | `o` | Open with | | `.` | Toggle hidden | | `b` `^/` | Bookmark key | | `1-4` | Context 1-4 | | `/` | Filter (Search) | | `f` `^F` | File details | | `e` | Edit file | | `n` | New | | `d` | Toggle detail mode | | `Space` `^J` | (Un)select | | `p` `^P` | Copy selection here | | `v` `^V` | Move selection here | | `x` `^X` | Delete | | `^R` | Rename | | `!` `^]` | Shell | | `=` | Launch app | | `]` | Cmd prompt. `Ctrl+d` to exit |Configure bookmarks
export NNN_BMS="d:$HOME/Documents;u:/data/videos;D:$HOME/Downloads/"
w3m
N
Number in some cases.()
Optional.shift+n
Press shift andn
at the same time to getN
esc n
Pressesc
thenn
^
isctrl
Keys
| Key | Function | | --- | -------- | | `H` | Hot keys | | `o` | Show options | | `B` | Close this buffer and go to previous buffer "Back" | | `s` | Select buffer | | `/` | Search forwards | | `?` | Search backwards | | `n` | Next "search" item | | `N` | Previous "search" item | | `g` | Go to top | | `G` | Got to bottom | | `T` | New tab with the same link but not the same buffer | | `ctrl+t` | Open link in a new tab | | `esc t` | List of all tabs | | `^q` | Close tab | | `{}` | Previous/Next tab | | `tab` | Next link | | `shift+tab` | Previous link | | `a` | Save link to file | | `shift+u` | Go to url | | `[]` | First/Last link | | `L` | List all links | | `esc l` | List of links to go. Better `shift+l`| | `u` | Peek the URL of a link | | `c` | Peek current URL | | `M` | Browse current document using external browser | | `esc m` | List of links to show, not to go | | `esc shift m` | Browse current document using external browser | | `(N) esc shift m` | Browse current document using N external browser | | `^h` | Show history | | `i` | Peek image URL | | `I` | View image | | `esc I` | Save image | | `esc b` | Show bookmarks | | `esc a` | Add current URL to bookmarks | | `space` | Page down | | `b` | Page up | | `,.` | Shift screen one column left/right | | `<>` | Scroll left and right | | `=` | Display information about current document | | `ctrl+c` | Show current line number | | `ctrl+r` | Reload page |Paths
| Paths | Usage | | ----- | ----- | | `~/.w3m/bookmark.html` | Bookmarks | | `~/.w3m/config` | Config | | `~/.w3m/pre_form` | Pre-fill forms |Links: - http://w3m.rocks/
surfraw
Browse something.
surfraw musicbrainz rolling stones
BROWSER=qutebrowser sr urban tldr
/usr/lib/surfraw/imdb E.T. -browser=w3m
List of elvi
surfraw -elvi
ls -lA /usr/lib/surfraw
Create new elvi
with mkelvis
from https://github.com/Hoboneer/surfraw-tools
mkelvis yourelvisname --description='Search Example for bliks' example.com 'example.com/search?q='
Paths
| Path | Use | | ---- | --- | | `~/.config/surfraw/elvi/` | Per‐user elvi | | `~/.config/surfraw/conf` | Per‐user config file | | `~/.config/surfraw/bookmarks` | Per‐user bookmarks file | Table: surfraw pathsInstall `surfraw-tools`
apt-get install -y python3-venv pipx
pipx install surfraw-tools --force
/root/.local/pipx/venvs/surfraw-tools/bin/mkelvis rarbg rarbgmirror.org 'rarbgmirror.org/torrents.php?search='
LXD
lxc launch images:debian/10 -e elvi && lxc exec elvi -- /bin/bash
apt-get install -y python3-venv pipx
pipx install surfraw-tools --force
/root/.local/pipx/venvs/surfraw-tools/bin/mkelvis rarbg rarbgmirror.org 'rarbgmirror.org/torrents.php?search='
lxc file pull elvi/root/rarbg ~/.config/surfraw/elvi/
# Power Off container
BROWSER=qutebrowser sr rarbg Ubuntu
scrcpy
MOD
is left alt
or right super
.
Shortcut | Action |
---|---|
MOD+f |
Switch fullscreen mode |
MOD+r |
Rotate device screen |
MOD+o |
Turn device screen off (keep mirroring) |
MOD+s |
Click on APP_SWITCH |
MOD+h or Middle-click |
Click on HOME |
Right-click |
Back | Power on while screen is off |
MOD+p |
Click on POWER |
https://github.com/Genymobile/scrcpy#shortcuts
More
| Shortcut | Action | | ----- | ----- | | `MOD+←` (left) | Rotate display left | | `MOD+→` (right) | Rotate display right | | `MOD+g` | Resize window to 1:1 (pixel-perfect) | | `MOD+w` or Double-click | Resize window to remove black borders | | `MOD+b` or Right-click | Click on BACK | | `MOD+m` | Click on MENU (unlock screen) | | `MOD+↑` (up) | Click on VOLUME_UP | | `MOD+↓` (down) | Click on VOLUME_DOWN | | `MOD+Shift+o` | Turn device screen on | | `MOD+n` | Expand notification panel | | `MOD+Shift+n` | Collapse notification panel | | `MOD+c` | Copy to clipboard | | `MOD+x` | Cut to clipboard | | `MOD+v` | Synchronize clipboards and paste³ | | `MOD+Shift+v` | Inject computer clipboard text | | `MOD+i` | Enable/disable FPS counter (on stdout) | | `Ctrl+click-and-move` | Pinch-to-zoom |Anacron
Run anacron right now.
sudo anacron -d -n -f
Options
- `s` Serialize execution of jobs - `f` Force execution of jobs, even before their time - `n` Run jobs with no delay, implies -s - `d` Don't fork to the background - `q` Suppress stderr messages, only applicable with -d - `u` Update the timestamps without actually running anything - `V` Print version information - `h` Print this message - `t` Use alternative anacrontab - `T` Test an anacrontab - `S` Select a different spool directoryRun the scripts directly.
nice run-parts /etc/cron.daily
rsync
rsync -aPHAXv -- /path/to/source user@server:/path/to/destination/
rsync -aPHAXv -- /path/to/file user@server:/path/to/file
rsync -e 'ssh -i ~/.ssh/id_rsa -l user' -- /path/to/file user@server:/path/to/destination/
Options
- `r` recurse into directories - `l` copy symlinks as symlinks - `p` preserve permissions - `t` preserve modification times - `g` preserve group - `o` preserve owner (super-user only) - `D` preserve device and special files - `a` archive mode; equals -rlptgoD (no -H,-A,-X) - `H` preserve hard links - `A` preserve ACLs (implies --perms) - `X` preserve extended attributes - `partial` keep partially transferred files - `progress` - `P` same as `--partial` `--progress` - `v` Verbose, useful to know which file changes - `e` Specify the remote shell command to use - `z` compress - `n` dry run - `S` sparse - `q` quiet - `u` skip files that are newer on the receiver - `U` preserve access (use) times - `delete` delete extraneous files from dest dirs. Sync (match) source and destination. Needs `r` or `d`. - `r` `recursive` recurse into directories - `d` `dirs` transfer directories without recursing - `remove-source-files` sender removes synchronized files (non-dir). Move files.tcpdump
tcpdump -ennq \( arp or icmp \)
tcpdump -ennq arp
tcpdump -ennqti enp2s0 tcp port 443 and src 10.0.0.1
tcpdump -ennqti enp2s0 dst port 443
tcpdump 'tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)'
tcpdump net 192.168.1.0/24
tcpdump src 192.168.1.1 and dst 192.168.1.2 and dst port 80
tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply' ## Not ping
Options
- `e` Print the link-level header on each dump line. - `n` Don't convert addresses to names. - `q` Print less protocol information so output lines are shorter. - `t` Don't print a timestamp on each dump line. - `i` listen on interface - `I` Put the interface in "monitor mode" (WiFi) - `w` write to file - `A` print each packet in ASCII without the link-level header. Handy for capturing web pages. - `X` show the contents in Hex and Ascii - `XX` show the contents and headers in Hex and Ascii - `l` Make stdout line buffered. Useful if you want to see the data while capturing it. - `q` quiet - `t|tttt` human-readable timestamp output - `v|vvv` verbose - `c` get x number of packets and stop - `s` size of the capture in bytes. `s0` to capture everything. - `S` print absolute sequence numbers - `e` get the ethernet header - `dst|src|net` - `arp|icmp|tcp|udp|ip6` - `r` Read packets from fileTCP flags
RSTtcpdump 'tcp[13] & 4!=0'
tcpdump 'tcp[tcpflags] == tcp-rst'
SYN
tcpdump 'tcp[13] & 2!=0'
tcpdump 'tcp[tcpflags] == tcp-syn'
SYN and ACK
tcpdump 'tcp[13]=18'
SYN and RST
tcpdump 'tcp[13]=6'
URG
tcpdump 'tcp[13] & 32!=0'
tcpdump 'tcp[tcpflags] == tcp-urg'
ACK
tcpdump 'tcp[13] & 16!=0'
tcpdump 'tcp[tcpflags] == tcp-ack'
PSH
tcpdump 'tcp[13] & 8!=0'
tcpdump 'tcp[tcpflags] == tcp-push'
FIN
tcpdump 'tcp[13] & 1!=0'
tcpdump 'tcp[tcpflags] == tcp-fin'
pass
pass insert internet/gitlab
pass insert --multiline internet/gitlab
pass --clip internet/gitlab
pass show --clip internet/gitlab
pass generate internet/gitlab
pass edit internet/gitlab
pass otp append --echo internet/gitlab
pass rm internet/gitlab
TOTP from hex to B32
oathtool -v -d6 511fa83c3493a7009f1ab5d7502cc2
Initialize
Create a GPG key.gpg --full-generate-key
Get the key ID. In this case is `AA21250888469FBC`.
gpg --list-secret-keys --keyid-format LONG
------------------------------------------
sec rsa4096/AA21250888469FBC 2019-08-15 [SC]
69215DC44E8303C83090F2F1AA21250888469FBC
uid [ultimate] Yuri Alek (Example keys)
ssb rsa4096/118727056C98BE57 2019-08-15 [E]
Initialize the repo with the key.
pass init "AA21250888469FBC"
Initialize a git repo.
pass git init
Manually decrypt a file.
gpg --decrypt .password-store/internet/gitlab.gpg
Backup
Backup
Export the keys (public and private). The key id is in `~/.password-store/.gpg-id`.gpg --output gpg_sec.gpg --armor --export-secret-key AA21250888469FBC
gpg --output gpg_sec.gpg --armor --export-secret-key `cat ~/.password-store/.gpg-id`
Backup the folder `~/.password-store`
Restore
Import the keys.gpg --allow-secret-key-import --import gpg_sec.gpg
And trust the keys again to encrypt new passwords
gpg --edit-key AA21250888469FBC
gpg> trust
1 = I don't know or won't say
2 = I do NOT trust
3 = I trust marginally
4 = I trust fully
5 = I trust ultimately
m = back to the main menu
Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y
gpg> quit
More
- `passmenu`: dmenu. - `gpg-agent`: Will keep the password for your key. - `pinentry`: Will pop a window to introduce your password.Re-encrypt every password with another key
pass init "8271F30B83C51C44"
where `"8271F30B83C51C44"` is the GPG ID of the new key.
You have to input the password for the old key.
Custom pinentry program
In Arch Linux edit `/usr/bin/pinentry`.#!/bin/sh
test -e /usr/lib/libgtk-x11-2.0.so.0 &&
exec /usr/bin/pinentry-curses "$@"
#exec /usr/bin/pinentry-gtk-2 "$@"
Links
-aria2c
aria2c -c -i links.txt -j 2 -d /path/to/download/folder/
Options
- `d` Directory to store downloaded files - `o` File name of the downloaded file - `i` Download from file - `c` Continue partially downloaded content - `j` Max concurrent downloadsnetcat
listen
- BSD
nc -lvn 9001
- Linux
nc -lvnp 9001
- Send file
nc -lvnp 80 < file
- Receive file
nc -lvnp 9001 > file
The file can contain any protocol information like http.
connect
- BSD
nc -vnp 10.0.0.1 9001
- linux
nc -v 10.0.0.1 9001
wget
wget --continue --mirror --no-host-directories --no-parent --recursive --user-agent=firefox --reject -R ".DS_Store,Thumbs.db,thumbcache.db,desktop.ini,_macosx,index.html*" --limit-rate=200k --random-wait --no-check-certificate https://www.example.com
wget -O file.zip http://www.example.org/random_name_file
wget -R ".DS_Store,Thumbs.db,thumbcache.db,desktop.ini,_macosx,index.html*" -nH -nc --no-cache --no-check-certificate -e robots=off -c --report-speed=bits --unlink https://www.example.com
Download a Full Website Using wget –mirror $ wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL
Options
- `--continue` - `--mirror` - `--no-host-directories` - `--no-parent` - `--recursive` - `--user-agent` - `--reject` - `--limit-rate` - `--random-wait` - `--no-check-certificate` - `--tries` - `-A` - `--spider`mpv
Options
- Right click over the seek buttons - show chaptersreadline
Shortcuts for bash, ftp and some others like telnet.
https://man.archlinux.org/man/readline.3
Keys
Run `bindkey` in `zsh` to see all of them. `^[` is `Meta` and `^` is `Control`. Dump the keycodes with `sudo dumpkeys -C /dev/console`. The *kill ring*. When something is erased, in most cases, is placed in a *kill ring*. To get what is inside the *kill ring* use `C-y`. *Kill* means move it to the *kill ring*. | Key | command | Explanation | | --- | :-----: | :---------- | | `ESC` | prefix-meta | Metafy the next character typed. `ESC f` is equivalent to `Meta-f`. | | `C-x C-e` or `C-x-e` | edit-command-line | Edit the current line in $EDITOR | | `C-_` or `C-x C-u` | undo | Incremental undo, separately remembered for each line. | | `C-o` | operate-and-get-next | Accept the current line for return to the calling application as if a newline had been entered, and fetch the next line relative to the current line from the history for editing. A numeric argument, if supplied, specifies the history entry to use instead of the current line. | | `C-k` | kill-line | Kill the text from cursor to the end of the line. | | `C-x Rubout` or `C-x C-k` | backward-kill-line | Kill backward to the beginning of the line. `Rubout` is `Backspace`. `Rubout` does not work for me in zsh. | | `C-u` | unix-line-discard | Kill backward from point to the beginning of the line. The killed text is saved on the kill-ring. | | `M-.` or `M-_` | yank-last-arg | Insert the last argument to the previous command (the last word of the previous history entry). With a numeric argument, behave exactly like yank-nth-arg | | `C-d` | end-of-file (EOF) and delete-char | The character indicating end-of-file as set, for example, by "stty". Also deletes the current character. | | `M-t` | transpose-words | Drag the word before point past the word after point, moving point over that word as well. If point is at the end of the line, this transposes the last two words on the line. | | `M-n-Backspace` | ? | Kill `n` words backwards. The words can be printed again with `C-y` | | `M-Rubout` or `C-w` | backward-kill-word | Kill the word behind point. Word boundaries are the same as those used by backward-word. | zsh only: | Key | command | Explanation | | --- | :-----: | :---------- | | `M-s` | spell-word | Fix word in cursor. Does not seem to work for arguments. | | `M-q` or `C-q` | push-line | Push the current buffer onto the buffer stack and clear the buffer. Next time the editor starts up, the buffer will be popped off the top of the buffer stack and loaded into the editing buffer. | | `M-g` or `C-g` | get-line | Pop the top line off the buffer stack and insert it at the cursor position. | | `M-l` | ls | execute `ls` | | `M-'` | quote-line | Quote the current line; that is, put a `'` character at the beginning and the end, and convert all `'` characters to `'\''`. | More zshsysrq
Keyboard | Shortcut | Description |
---|---|---|
Alt+SysRq+r |
Unraw | Take control of keyboard back from X. |
Alt+SysRq+e |
Terminate | Send SIGTERM to all processes, allowing them to terminate gracefully. |
Alt+SysRq+f |
OOM killer | Needs Unraw. |
Alt+SysRq+j |
Thaw | Needs Unraw. Unfreeze processes that are in uninterruptible sleep because of filesystem issue. |
Alt+SysRq+i |
Kill | Send SIGKILL to all processes, forcing them to terminate immediately. |
Alt+SysRq+s |
Sync | Flush data to disk. |
Alt+SysRq+u |
Unmount | Unmount and remount all filesystems read-only. |
Alt+SysRq+b |
Reboot | Reboot |
patch
git diff origin/master docs/arch/fstab.md > ~/fstab.patch
patch -p1 < file.patch
-p
works
-pn
means Strip the smallest prefix containing n leading slashes from each file name found in the patch file.
If your patch contains
--- a/docs/arch/fstab.md
+++ b/docs/arch/fstab.md
patch
will merge a/docs/arch/fstab.md
with b/docs/arch/fstab.md
.
If you specify -p1
it will merge docs/arch/fstab.md
with docs/arch/fstab.md
.
With -p2
arch/fstab.md
with arch/fstab.md
.
And -p3
fstab.md
with fstab.md
.
Create patch.
git clone --depth 1 <repo>
cd <repo>
vim path/to/file.md
git diff origin/master path/to/file.md > ~/file.patch
Creates a diff with this headers. You have to strip a/
and b/
with -p1
in patch.
--- a/path/to/file.md
+++ b/path/to/file.md
Patch.
git clone --depth 1 <repo>
cd <repo>
patch -p1 < ~/file.patch
Mysql
- Show databases:
show databases;
- Change current database:
use database_name;
- Show tables:
show tables;
- Select rows:
select * from users;
- Select rows in vertical:
select * from users \G
mysql> help
\g go Send command to mysql server.
\G ego Send command to mysql server, display result vertically.
dd
ddrescue
ddrescue -f -r5 /dev/sda /dev/sdb /mnt/ssd-af-mapfile
lnav
Open all logs from today.
lnav /var/log/remote/*/$(date +'%Y-%m-%d').log
Recursively open all files in a folder.
lnav -r /var/log/remote
Shortcuts
TAB
- FiltersG
- Go to bottomg
- Go to top