Listing posts

Displaying posts 6 - 10 of 194 in total
GNU Screen | terminal multiplexer attachment
mouse 621 · person cloud · link
Last update
2019-05-10
2019
05-10
«terminal multiplexer»

Screen commands shortcuts:

Shortcut Descr
^a c create new terminal
^a # switch to # terminal (0-9)
^a " terminals list
^a A set the current terminal name/title
^a d detach session
^a S or ^a | split region horizontally or vertically
^a X close current region
^a Q close all regions but the current one
^a tab switch inputo to next region
^a ^a toggle between current and previous region
^a k terminate the current window/tab
^a \ terminate entire session
^a :number x changer current terminal number to x

Scrolling + copy&paste:

Press ^a esc then use PgUp/Dn or Up/Dn arrows to scroll, when finished hit return two times.

If you move the cursor after hitting return once, you will be selecting text to copy, and hitting return the second time will copy it. Then you can paste it with ^a ].

Command line how-to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
screen       # start a new session (default screen is 0)
screen -d -m # start a new detached session (useful in scrips)
screen -r    # reattach to a running session

screen -d|-D [pid.tty.host] # detaches the elsewhere running screen session

# reattaching options (in case of a "stale attached state"):
screen -d -r   # reattach a session and if necessary detach it first
screen -d -R   # reattach a session and if necessary detach or create it
screen -d -RR  # reattach to the first session and if necessary detach or create it

# or reattach trying even harder:
screen -D -r   # reattach a session, if necessary detach and logout remotely first
screen -D -R   # same as "-D -r" but also notify the user
screen -D -RR  # attach here and now. whatever that means, just do it

Share a session with another user

Same account

1
2
3
4
5
6
7
# user1 starts the session then attach to it
screen -d -m -S shared # start a new detached session called `shared`
screen -x shared # attach in multi display mode

# user2 only attach to it
screen -ls # show current sessions
screen -x shared # attach in multi display mode

Different accounts

1
2
3
4
5
6
7
8
# user1 starts the session then attach to it
screen -d -m -S shared # start a new detached session called `shared`
screen -r shared # attach to the named session
# press "Ctrl-a" and type ":multiuser on"
# press "Ctrl-a" and type ":acladd user2"

# user2 only attach to it
screen -x user1/shared

Note: the multiuser mode needs screen as suid root but this is a security issue... if you want to enable it then type as root:

1
2
3
chmod u+s `which screen`
chmod 755 /var/run/screen
rm -fr /var/run/screen/*

but you really should make a third shared account which both users can log into.

Customize session (see attachment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# ~/.screenrc - screen user config file

# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline '%{= kG}@%{G}%H%? %1`%?%{g}|%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}|%{y}%l%{g}|%{B}%Y-%m-%d %{W}%c%{g}'

# huge scrollback buffer
defscrollback 5000

# no welcome message
startup_message off

# 256 colors
term screen-256color
attrcolor b ".I"
#termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
#defbce on

# mouse tracking allows to switch region focus by clicking
#mousetrack on

shelltitle --
#shell /usr/bin/fish

# default windows
screen 1 bash
screen 2 bash
select 1
bind c screen 1 # window numbering starts at 1 not 0
bind 0 select 10

# get rid of silly xoff stuff
bind s split

# Ctrl+F2 puts Screen into resize mode. Resize regions using hjkl keys.
bindkey "^[O1;5Q" eval "command -c rsz" # enter resize mode
# use hjkl keys to resize regions
bind -c rsz h eval "resize -h -5" "command -c rsz"
bind -c rsz j eval "resize -h +5" "command -c rsz"
bind -c rsz k eval "resize -v -5" "command -c rsz"
bind -c rsz l eval "resize -v +5" "command -c rsz"

# switch windows with F1 (prev) and F2 (next)
bindkey "^[OP" prev
bindkey "^[OQ" next

Tips & tricks

  • Use this handy script to start your terminals the way you want:
1
2
3
4
5
6
7
8
#!/bin/bash
if [ -z "$1" ]; then
  echo "USAGE: bashto pwd [cmd arg1 arg2 ...]"
  exit
fi
cd "$1"                    # go to the specified folder
shift; [ -n "$1" ] && "$@" # execute an optional command
exec /bin/bash             # run shell

.screenrc example: screen -t www bashto /mnt/ramd elinks.

1
2
[ -n "$DISPLAY" ] && echo -n "$DISPLAY" > $HOME/.last_display
[ -z "$DISPLAY" ] && export DISPLAY=$(cat $HOME/.last_display)

Alternatives:


Source: GNU.org, ArchLinux tips, A killer GNU Screen Config gist, MC mouse support, Dev.to, Shared session


~~~ * ~~~

Setup VeraCrypt volume manager
mouse 566 · person cloud · link
Last update
2019-05-10
2019
05-10
« — »

Download and install VeraCrypt:

1
2
3
apt-get install libfuse2 libfuse-dev makeself libwxbase3.0-0
wget https://launchpad.net/veracrypt/trunk/1.21/+download/veracrypt-1.21-raspbian-setup.tar.bz2
# unarchive, run install script and extract the veracrypt binary

or compile it from source:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# save disk space by not installing all wxWidgets packages
apt install make gcc pkg-config libfuse-dev
wget https://launchpad.net/veracrypt/trunk/1.23/+download/VeraCrypt_1.23_Source.tar.bz2
wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.4/wxWidgets-3.0.4.7z
mkdir -p vc wx
cd wx && 7za x ../wxWidgets-*.7z & cd ..
cd vc && tar -xjf ../VeraCrypt_*_Source.tar.bz2
cd vc/src
make NOGUI=1 WXSTATIC=1 WX_ROOT=/path/to/wx wxbuild
make NOGUI=1 WXSTATIC=1

# or alternatively install wxWidgets packages
apt install make gcc pkg-config libfuse-dev libwxgtk3.0
wget https://launchpad.net/veracrypt/trunk/1.23/+download/VeraCrypt_1.23_Source.tar.bz2
# unarchive, run make

cp Main/veracrypt /usr/local/bin/

and apply my optional vc-mounter -headless systemd service (on the raspberry it seems that the shutdown does NOT cleanly unmount the volumes, see the UPS post for a solution).

Note: Remember to use a kernel supported cypher grep name /proc/crypto or you will get a Error allocating crypto tfm on dmesg preventing the mount.
Alternatively you can use the option -m nokernelcrypto with degraded performance.
You can test disk speed with these commands:

1
2
dd if=/dev/zero of=/dev/mapper/xxx bs=1G count=1 oflag=dsync # throughput
dd if=/dev/zero of=/dev/mapper/xxx bs=512 count=1000 oflag=dsync # latency

this seems to make sense... but after some tests on the raspberry pi 3 I found that -m nokernelcrypto is 3x faster than using kernel crypto services! :-O

For the sake of speed always remember to use a filesystem block size compatible with the device one1 (refer to man mkfs.xxxx), for example:

1
2
cat /sys/block/sdX/queue/physical_block_size # => 4096
mkfs.extX -E nodiscard -b 4096 /dev/sdaX

Notes for SSD drives:

  • Remember to disable TRIM2 operation via -m nokernelcrypto switch (vc-mounter already does it) and use the nodiscard mount option3.

  • You can use WDE/FDE (whole/full disk encryption) on an SSD drive because it does NOT require space overprovisioning unless you have a demanding workload (especially one with many random writes). Note that if you still want to leave some unallocated space (to further reduce write amplification4) then it must be trimmed5 if it has been written to before, otherwise it will have no benefit as the drive will see that space as occupied.

  • Comment any eventual fstrim usage in /etc/cron.* (find it with grep -rin fstrim /etc).

  • The util-linux package provides fstrim.service and fstrim.timer systemd unit files: eventually disable enable them.


Source: VeraCrypt setup and homepage, wiki.archlinux, raspbian forum


~~~ * ~~~

Esercizi per stretching/allungamento muscolo piriforme contro la sciatica attachment
mouse 15 · person cloud · link
Last update
2019-04-30
2019
04-30
«dolori nervo sciatico»

~~~ * ~~~

Create a booklet or a multipage PDF from a single page one
mouse 182 · person cloud · link
Last update
2019-04-30
2019
04-30
« — »
1
2
3
4
5
6
7
8
9
10
11
12
13
# install pdftk, pdfjam & scripts
apt install pdftk texlive-extra-utils

# --- input is an A4 portrait PDF ---
pdfnup  --a4paper --scale 0.95 --nup 2x1 in.pdf # multipage
pdfbook --a4paper --short-edge           in.pdf # booklet

# --- input is an A4 landscape PDF ---
pdfnup  --a4paper --scale 0.95 --nup 1x2 --no-landscape in.pdf # multipage
pdfbook --a4paper --short-edge in.pdf # simple booklet
# better booklet (minimize blank space)
pdf90 in.pdf # or pdftk in.pdf cat 1-endwest output in-rotated90.pdf
pdfbook --a4paper --short-edge in-rotated90.pdf

In case of need you can create a blank page via convert xc:none -page A4 blank.pdf.


~~~ * ~~~

Cheesecake al salmone affumicato
mouse 33 · person cloud · link
Last update
2019-04-24
2019
04-24
« — »
Cover original

Ingredienti per la base:

  • 150gr taralli (al pepe)
  • 60gr burro

Ingredienti per la crema:

  • 100gr salmone affumicato
  • 200gr philadelphia
  • 200gr ricotta
  • sale e pepe q.b.

Ingredienti per la decorazione:

  • 100gr salmone affumicato
  • prezzemolo q.b

Procedimento:

  1. Base: amalgamere i taralli polverizzati col burro fuso tiepido, stendere il composto su una teglia incartata e mettere in frigo per 30 minuti.

  2. Crema: mescolare ricotta, philadelphia, sale, pepe e salmone a pezzetti.

  3. Spalmare la crema sulla base e guarnire con salmone e prezzemolo.

Conservare max 2gg in frigo avvolta nella pellicola.


Fonte: cucina.fidelityhouse.eu