Linux Tips Tricks

From MukeWiki



user config

wget https://raw.github.com/musinsky/config/master/Git/gitconfig -O ~/.gitconfig
wget https://raw.github.com/musinsky/config/master/Emacs/emacs -O ~/.emacs
wget https://raw.github.com/musinsky/config/master/astyle/astylerc -O ~/.astylerc

yum

dnf upgrade --refresh
dnf download --source astyle
dnf --enablerepo=rawhide download --source astyle
dnf download --source --enablerepo=rawhide astyle
dnf --enablerepo=updates-testing update firefox
dnf --releasever=30 update firefox
dnf --releasever=31 update rclone   # update on F29
dnf deplist astyle
dnf builddep astyle.spec   # unzip spec from downloaded source file
dnf search all "GTK+ lib" # search in packages description
dnf provides \*bin\*clang-format
dnf provides \*eclipse.ini
dnf list installed \*.i\?86
dnf remove \*.i\?86
dnf list installed | grep @commandline
dnf install tito --setopt=install_weak_deps=False

dnf config-manager --dump

dnf download astyle --resolve

dnf repoquery --requires --resolve poppler
dnf repoquery --alldeps --whatrequires poppler
dnf repoquery --installed --whatrequires poppler

dnf repoquery --list root-hist | grep so

rpm -ql gcc | grep so                # only if installed
dnf repoquery --list gcc | grep so   # in repo(s)
dnf install sqlite   # need for tab completion of package names in DNF
dnf repolist
dnf repository-packages rpmfusion-nonfree remove
dnf repository-packages rpmfusion-nonfree list
https://kojipkgs.fedoraproject.org/packages/emacs/
https://kojipkgs.fedoraproject.org/packages/cernlib/
https://kojipkgs.fedoraproject.org/packages/cmake/
rpmpeek efitools-1.9.2-4.fc34.x86_64.rpm cp ./usr/share/efitools/efi/HelloWorld.efi $HOME/
# rpmpeek from rpmdevtools package
rpm2cpio efitools-1.9.2-4.fc34.x86_64.rpm | cpio -iv --to-stdout ./usr/share/efitools/efi/HelloWorld.efi > $HOME/HelloWorld2.efi
$ yum list \*spell\*
$ yum search all zenity
$ yum provides /etc/httpd\*
$ yum provides \*/libpng12.so.0
$ yum provides /*isoinfo
$ yum --enablerepo=rawhide update firefox
$ yum history list
$ yum history packages-list firefox
 
$ yumdownloader phpMyAdmin mc.x86_64
$ yumdownloader --source --enablerepo=rawhide emacs

$ yum-builddep emacs

Ak je potrebne aby sa v niektorej repository pracovalo len s (reps. bez) konkretneho balika, mozeme pouzit includepkgs (resp. exclude) options; nepouzivat znak ' \ ' ako v pripade prikazu yum

[russianfedora-fixes]
enabled=1
includepkgs=fontconfig* freetype*

V priapde viacerych repositories pre balik(y) sa odporuca pouzit priority options v kombinacii s yum-plugin-priorities utility

  • Nezapinat Russian Fedora fixes repository, inak po update sa Fedora premeni na RFRemix distribuciu (vratane mena, loga a pod.)
  • /etc/yum.conf
clean_requirements_on_remove=1
$ yum install --nogpgcheck http://mirror.yandex.ru/fedora/russianfedora/russianfedora/free/fedora/russianfedora-free-release-stable.noarch.rpm         # mediainfo
$ yum install --nogpgcheck http://mirror.yandex.ru/fedora/russianfedora/russianfedora/nonfree/fedora/russianfedora-nonfree-release-stable.noarch.rpm   # flash-plugin, skype
2024-10, Fedora41, dnf5

In Fedora 41 added fedora-repoquery(1)rpm tool for querying Fedora repos for packages.

# fedora-repoquery 39 41 gcc
gcc-13.2.1-3.fc39.x86_64 (f39)
gcc-13.3.1-3.fc39.x86_64 (f39-updates)
gcc-14.2.1-3.fc41.x86_64 (f41)
gcc-14.2.1-3.fc41.x86_64 (f41-updates-testing)

disable xdg-user-dirs

/etc/xdg/user-dirs.conf

enabled=False

alebo jednoducho vymazat cely package (yum remove xdg-user-dir\*)

add application

Program (aplikaciu) pridame do systemoveho menu vytvorenim suboru /usr/{,local/}share/applications/program-name.desktop, ikona subor program-name.png pre danu aplikaciu sa default hlada v /usr/{,local/}share/icons/ a moze zavisiet od pouzitej temy, prostredia.

[Desktop Entry]
Name=PrograName
Comment=Example program
Exec=program-name           # Exec=/path/to/exec/program-name
Type=Application
Icon=program-name           # Icon=/path/to/icons/program-name.png
StartupNotify=true
Categories=GNOME;Application;Development;

manpath

  • man manpath

manpath urcuje (precita configuration file /etc/man_db.conf), kde vsade sa budu hladat manualove stranky. Ak je napr. zadefinovana cesta PATH=/cern/root/bin/ tak sa automaticky budu hladat manualove stranky aj v /cern/root/man/, avsak len dovtedy pokial nie zadefinovana premenna MANPATH

$ manpath
manpath: warning: $MANPATH set, ignoring /etc/man_db.conf
/cern/root/man/man1:/cern/root/man:/usr/share/man
$ unset MANPATH
$ manpath
/cern/root/man:/usr/share/man
man -Lru man
man -Lcs socket
man -Lru 2 open
alias man='man --locale=cs'
man 2 intro      > 2014-02-20
man -Lru 2 intro > 2010-11-11
man -Lcs 2 intro > 18.ledna 1997 (very OLD)
$ man --html=firefox bash
$ yelp man:bash
$ yelp info:bash
# 2022-09
$ man -wK GROFF_NO_SGR
/usr/share/man/man1/grotty.1.gz

.bash_profile vs .bashrc

  • ~/.bash_profile is executed for login shells (personal initialization file), while ~/.bashrc is executed for interactive non-login shells (individual per-interactive-shell startup file)
  • ~/.bash_profile is executed when login via console or remotely via ssh. ~/.bash_profile load ~/.bashrc (in Fedora)
  • ~/.bashrc is executed when open a new terminal window or when start a new bash instance by typing /bin/bash in a terminal

multiple commands in one line in shell

To summarize (non-exhaustively) bash's command operators/separators

| pipes (pipelines) the standard output (stdout) of one command into the standard input of another one. Note that stderr still goes into its default destination, whatever that happen to be
; executes the right-hand command of ; always regardless whether the previous command succeeded or failed. Unless set -e was previously invoked, which causes bash to fail on an error
&& executes the right-hand command of && only if the previous one succeeded
|| executes the right-hand command of || only it the previous one failed
|& pipes both stdout and stderr of one command into the standard input of another one. Very useful, available in bash version 4 and above

NOTE double semicolon ;; is only used in case ... esac constructor.

call one shell script from another shell script

sh1

#!/bin/bash
x=5
echo "script 1, x=$x"
## caseA                  ## caseB
sh sh2                    source ./sh2   # must be path ('./')

sh2

#!/bin/bash
echo "script 2, x=$x"
## caseA                 ## caseB
$ sh sh1                 $ sh sh1
script 1, x=5            script 1, x=5
script 2, x=             script 2, x=5
  • caseA: spustili sme script sh2 vo vnutri skriptu sh1. Skript sh2 sa spusti ako dalsi proces, takze premenne a funkcie v druhom skripte nebudu pristupne.
  • caseB: prikaz source funguje tak, ako keby sme skopirovali obsah zo sh2 do sh1 a az potom sa spusti prikaz $ sh sh1. Skript sh2 sa vykona v procese prveho skriptu, takze premene a funkcie z volajuceho skriptu su pristupne.

NOTE source (Bash and some other shells) je synonymum pre prikaz . (POSIX standard).

More info: [1]

bash vs zsh

Bash uses backslash escapes. Zsh uses percentage escapes.

bash command substitution

Command substitution allows the output of a command to replace the command itself.

  • new-style $(command) interprets everything in between ( ) as a command.
  • old-style `command` (backquote or backtick "version") do treat backslashes \ and nesting a bit different.
$ echo $(uname | $(echo cat))
Linux
$ echo `uname | `echo cat``
bash: command substitution: line 2: syntax error: unexpected end of file
echo cat
$ echo `uname | \`echo cat\``
Linux
  • unlike the old-style `command`, the new-style $(command) form can be nested. So you can use command substitution inside another substitution.
  • prefer the $(command) form, more tips [2] or [3].
2023-05 double quotes using
my_input="$(some-command)"
unique_lines_in_file="$(sort -u "$my_file" | wc -l)"
DIRNAME="$(dirname "$FILE")"

https://unix.stackexchange.com/questions/118433/quoting-within-command-substitution-in-bash

bash builtin commands

2024-11-29

Najzakladnejsie, resp. najpouzivanejsie prikazy v shell prostredi su vacsinou priamo bash builtin (builtins(1)) commands shell prostredia GNU bash, ale popri tom zaroven existuju (vacsina z nich) ako standalone prikazy v ramci GNU Core Utilities. Je efektivnejsie pracovat s "core prikazmi" priamo ako s bash-om (pamat pre bash sa alokuje len raz a podobne). Standalone prikazy, resp. programy zostali v Linux skor uz len historicky (napr. volanie programu priamo aj s cestou /usr/bin/echo), pripadne pre nejake specialne prilezitosti. Typicky predstavitel bash builtin commands je cd, ktory ani nema standalone prikaz (/usr/bin/cd je len wrapper builtin cd "$@"). Vacsina bash builtin commands vsak ma aj svoj standalone prikaz, resp. program.

$ type cd echo printf emacs     # indicate how each name would be interpreted if used as a command name (or to same with command -V)
cd is a shell builtin
echo is a shell builtin
printf is a shell builtin
emacs is /usr/bin/emacs

$ type -a cd echo printf emacs
cd is a shell builtin
cd is /usr/bin/cd               # only as wrapper builtin cd "$@"
echo is a shell builtin
echo is /usr/bin/echo           # standalone echo from coreutils
printf is a shell builtin
printf is /usr/bin/printf       # standalone printf from coreutils
emacs is /usr/bin/emacs         # standalone only example program

Existuju nejake drobne rozdiely medzi builtin vs. standalone command. Vo vacsine je to dosledok toho, ze standalone commands sa uz nevyvijaju (kedze sa uz takmer nepouzivaju), na rozdiel od ich builtin verzii. Napr. standalone echo nepodporuje vypis v Unicode formate, na rozdiel od builtin verzie. Ako dosledok toho, by sme mali zobrazovat man stranky pre builtins commands, a nie pre standalone echo, printf a podobne, ktore v skutocnosti ani nepouzivame. Prikaz help(1) je urceny specialne len pre bash builtin commands.

$ echo -e '\u03B2'            # man builtins OR help echo
β
$ /usr/bin/echo -e '\u03B2'   # man echo
\u03B2
man(1) traditional system reference manuals, man pages
help(1) information for bash builtin commands only
info(1) alternative for man pages, provided mainly for GNU programs/commands

process substitution

$ paste <(echo 1; echo 2; echo 3) <(echo a; echo b; echo c)             # be careful with   (space char), don't try paste < (echo ...
$ paste <(echo 1; echo 2; echo 3) /dev/null <(echo a; echo b; echo c)   # /dev/null add one more tab
$ paste <(echo 12345678; echo 1234567; echo 123456) <(echo a; echo b; echo c) |  column -s $'\t' -t

When we pass the tab to column -s option, we may notice that we used a special format $'\t'. If we pass the string \t, the column command won’t treat it as a tab. Instead, it’ll use the t character as the separator. That is, the ANSI C standard backslash-escaped characters won’t be expanded.

POZOR pravdepodobne funkcne len pre bash v5+

# CentOS Stream 8, GNU bash version 4.4.20
$ /usr/bin/bash -c 'paste <(echo 1; echo 2; echo 3) <(echo a; echo b; echo c)'
1	a
2	b
3	c
$ /usr/bin/sh -c 'paste <(echo 1; echo 2; echo 3) <(echo a; echo b; echo c)'
/usr/bin/sh: -c: line 0: syntax error near unexpected token `('
/usr/bin/sh: -c: line 0: `paste <(echo 1; echo 2; echo 3) <(echo a; echo b; echo c)'

# CentOS Stream 9, GNU bash version 5.1.8, all OK

bash note 2024-09

$ var="\tabulator + \x5ctab"   # \x5c is hex code of '\'
$ printf "%s\n" "$var"
\tabulator + \x5ctab
$ printf "\tabulator + \x5ctab\n"
	abulator + \tab
$ printf "%b\n" "$var"
	abulator + \tab
 BS_direct="\\\\"     # or "\x5c", not "\" or "\\\" (error)
 BS_argument_s="\\"   # or '\'   # with %s FORMAT control
 BS_argument_b="\x5c"            # with %b FORMAT control
 printf "direct: ${BS_direct}tab, argument(as %%s): %s, argument(as %%b): %b\n" \
        "${BS_argument_s}tab_s" "${BS_argument_b}tab_b"

direct: \tab, argument(as %s): \tab_s, argument(as %b): \tab_b


# ${#parameter} => length in chars of the expanded value of parameter is substituted
# ${parameter//pattern/string} => all matches of 'pattern' are replaced with 'string'
# ${parameter/pattern/string}  => only the first match is replaced

bash ToDo

https://mywiki.wooledge.org/BashFAQ/031

https://learnbyexample.github.io/cli-computing/shell-features.html

$ echo "You enter "$HOSTNAME". You can smell the wumpus." >> /etc/issue # problematic
$ echo "You enter $HOSTNAME. You can smell the wumpus." >> /etc/issue   # correct
$ TEST="abc"
$ echo -n "TEST "; echo -n "$TEST "; echo -n "\$TEST "; echo -n '$TEST '; echo
TEST abc $TEST $TEST
  1. https://stackoverflow.com/questions/10822790/can-i-call-a-function-of-a-shell-script-from-another-shell-script
  2. https://stackoverflow.com/questions/8742783/returning-value-from-called-function-in-a-shell-script
  3. https://stackoverflow.com/questions/4419952/difference-between-return-and-exit-in-bash-functions
  1. https://stackoverflow.com/questions/10551981/how-to-perform-a-for-loop-on-each-character-in-a-string-in-bash
  2. https://unix.stackexchange.com/questions/656963/how-to-loop-over-every-character-of-a-filename

numfmt

numfmt reads numbers in various representations and reformats them as requested. Include in coreutils-8.21 (2013-02-14).

From coreutils-8.24 (2015-07-03) numfmt(1) can process multiple fields with --field range specifications similar to cut(1) and supports setting the output precision with the --format option.

$ ls -l | numfmt --debug --header=1 --field=5 --to=iec-i --suffix=B
$ ls -l | numfmt --debug --header=1 --field=5 --to=iec-i --suffix=B --format="%10.2f"
$ ls -s -l | numfmt --debug --header=1 --field=1,6 --to=none --suffix="###"
$ numfmt --from=si 1G
1000000000
$ numfmt --from=iec 1G
1073741824
$ echo 1Gi | numfmt --from=iec-i
1073741824
$ printf '1G \n 1Gi \n' | numfmt --from=auto
1000000000
1073741824
$ echo '1T 1Ti' | numfmt --from=auto --field=1,2
1000000000000 1099511627776
FSIZE_NUM="$(stat --format '%s' file.name)"
FSIZE_CHAR="$(numfmt "$FSIZE_NUM" --to=iec-i --suffix='B' --format='%8f  ')"   # opt1
FSIZE_CHAR="$(numfmt "$FSIZE_NUM" --to=iec-i --suffix='  B' --format='%10f')"  # opt2
FSIZE_CHAR="$(echo "$FSIZE_CHAR" | sed -E 's/([A-Z])/ \1/')"
printf "size = %s  %'15.0f\n" "$FSIZE_CHAR" "$FSIZE_NUM"

locale

# GNOME settings: Language => 'en_US.UTF-8' and Formats => 'en_GB.UTF-8'
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_GB.UTF-8
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

$ locale -ck LC_PAPER
LC_PAPER
height=297
width=210
paper-codeset="UTF-8"

$ export LC_PAPER=en_US.UTF-8
$ locale -ck LC_PAPER
LC_PAPER
height=279
width=216
paper-codeset="UTF-8"
  • v praxi ma asi zmysel menit len LC_PAPER (tlac na A4) a LC_TIME (D/M/Y, tyzden zacina pondelkom)
  • pozor zmena napr. LC_CTYPE moze pozmenit pravidla pre triedenie, LC_NUMERIC napr. zamiena desatinu ciarku a bodku v zavislosti od konkretneho jazyka
  • hodnoty locale ovpyvnuju LibreOffice len velmi malo, LC_CTYPE determines the general locale data setting, LC_MESSAGES determines the UI language, LC_PAPER determines the paper configuration (if libpaper is not available)

$HOME/.bashrc

export LC_PAPER='en_GB.UTF-8'
export LC_TIME='en_GB.UTF-8'
2023-06
# https://www.gnu.org/software/libc/manual/html_node/Standard-Locales.html
$ LC_ALL=C locale -k LC_COLLATE   # POSIX locale currently is an alias for the standard C locale
collate-nrules=0
collate-rulesets=""
collate-symb-hash-sizemb=0
collate-codeset="ANSI_X3.4-1968"
$ LC_ALL= locale -k LC_COLLATE    # empty name says to select a locale based on environment variables
collate-nrules=4
collate-rulesets=""
collate-symb-hash-sizemb=1303
collate-codeset="UTF-8"
# https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/locales/sk_SK;hb=HEAD
# https://www.gnu.org/software/libc/manual/html_node/Locales.html
# https://www.gnu.org/software/libc/manual/html_node/Locale-Categories.html
# https://www.gnu.org/software/libc/manual/html_node/Standard-Locales.html
# LANG=en_US.UTF-8   # current locale
# LC_ALL=            # locale based on environment variable (i.e. en_US.UTF-8)
export LC_PAPER='sk_SK.UTF-8'
export LC_MEASUREMENT='sk_SK.UTF-8'

# LC_COLLATE: filename sorting (case sensitive, dot files first, etc.)
# don't use recommended LC_ALL=C (overrides any other LC_ variable, see bellow)
if locale -a | grep -i -x -q C.UTF8; then
    # glibc 2.35 (2022-02) support C.UTF-8 locale
    alias ls='LC_COLLATE=C.UTF8 ls --color=auto --group-directories-first'
else
    alias ls='LC_COLLATE=C ls --color=auto --group-directories-first'
fi
# LC_NUMERIC: number formatting (thousands separator)
# $ LC_NUMERIC= locale -k LC_NUMERIC   # (i.e. en_US.UTF-8)
# thousands_sep="," (de_DE.UTF8 => ".", sk_SK.utf8 => " ", C => "")
# https://www.gnu.org/software/coreutils/manual/html_node/Block-size.html
alias lls="ls -l --block-size=\"'1\""     # or global BLOCK_SIZE env
#alias lls="LC_NUMERIC=de_DE.UTF8 ls -l --block-size=\"'1\"" # with "."
# LC_TIME: data and time formatting (full time format)
# https://www.gnu.org/software/coreutils/manual/html_node/Formatting-file-timestamps.html
# format strings separated by a newline are used for non-recent and recent files
#tsf_newline=$'\n'   # bash ANSI-C Quoting
#alias llt='ls -l --time-style="+%F %H:%M:%S $tsf_newline%F %H:%M:%S^"'
#unset tf_newline
alias llt='ls -l --time-style="+%F %T"'   # or global TIME_STYLE env
alias llt-utc='TZ=UTC llt'
# all in one
alias lll="LC_NUMERIC= ls -l --block-size=\"'1\" --time-style=\"+%F %T\""


$ locale decimal_point
.
$ locale thousands_sep
,

$ locale -ck thousands_sep
LC_NUMERIC
thousands_sep=","
char ' separate the digits into groups as specified by the locale specified for the LC_NUMERIC
$ printf "%'.2f\n" 123456789.54321
123,456,789.54
$ LC_NUMERIC=de_DE.UTF8 printf "%'.2f\n" 123456789,54321
123.456.789,54
$ printf "%10s=%'.2f\n" "size" 123456789.54321
      size=123,456,789.54
$ printf "%-10s=%'.2f\n" "size" 123456789.54321
size      =123,456,789.54


localectl set-locale C.UTF8  POZOR prepise /etc/locale.conf (aj ako user, nielen ako root)

vacsina (ale nie vsetky) LC_* (vratane LANG) su BASH VARIABLE

autofs

yum install autofs
systemctl enable autofs.service
systemctl start autofs.service

/etc/sysconfig/autofs

cd /net
cd strela-stor.jinr.ru
cd strela205

dd

dd if=/path/to/iso/file.iso of=/dev/sdX

dd if=/dev/sdX of=/path/to/iso/file.iso
dd if=/home/musinsky/Fedora-Everything-netinst-x86_64-33-1.2.iso of=/dev/sdX bs=8M status=progress oflag=direct

data recovery

  • Obnova dat z USB flashky, ktora je uz HW poskodena ("zomiera"), t.j. nepokusam sa zachranit samotnu USB flashku, ale len data, ktore su na nej ulozene.
  • Kedze USB flashka uz "zomiera", tak je uzitocne a vhodne vytvorit najprv z nej nejaky "raw image", s ktorym budem dalej pracovat uz "v klude" na pocitaci. S kazdou dalsou manipulaciou moze nastat jej uplna "smrt".
  • Kopirovat cely raw obsah USB flashky na pocitac (vratane chyb, vadnych sektorov a pod.), pomocou dd, ddrescue (pripadne nadstavba DDRescue-GUI), dd_rescue alebo TestDisk. Programy su distribuovane standardne v Fedora repositories (# dnf install ddrescue dd_rescue testdisk).TestDisk dokonca korektne funguje aj pod Windows.
  • Samotne kopirovanie obsahu USB flashky na pocitac v "raw image" je najvacsi problem. Zavisi od roznych faktorov, kedze USB flashka uz "zomiera". Potrebne skusat rozne metody, rozne USB porty, ale aj rozne programy. Najvacsi uspech (v jednom konkretnom pripade) som mal s testdisk, ktory dokazal zapisat, resp. prekopirovat dost velky obsah "umierajucej" USB flashky do image suboru. Samozrejme tento image obsahuje rozne chyby, inak by sa dal jednoducho priamo na-mount-ovat. Pri takomto kopirovani obsahu je podstatne, aby program ignoroval, resp. preskocil rozne chyby, vadne sektory a pokracoval v kopirovani.
  • Z takto ulozeneho (na disku pocitaca) recovered image suboru usbimage.img sa mozeme najprv este pokusit obnovit filesystem. V pripade uspechu by malo byt mozne na-mount-ovat image. Filesystem pravdepodobne nebude mozno obnovit (mala pravdepodobnost, kedze USB flashka je uz HW poskodena) a preto bude potrebne vyextrahovat jednotlive subory.
  • Na extrahovanie jednotlivych suborov existuje mnozstvo roznych recovery programov. Vacsina z nich funguje na principe hladania hlavicky (headers), paty (footers) suborov a signatury (hex numbers) jednotlivych formatov suborov. Z toho vyplyva, ze mozeme obnovit "len" konkretne, specificke formaty suborov. Takto obnovene subory nebudu mat povodny nazov_subora (filesystem bol poskodeny), ale konkretny recovery program ich pomenuje podla nejakej zakonitosti, struktury.
  • Recovery programy PhotoRec, foremost, recoverjpeg su v Fedora repositories (# dnf install foremost recoverjpeg). Uz skor spomenuty a nainstalovany balik testdisk.rpm obsahuje dva programy, samotny testdisk, ale aj program na obnovu suborov photorec. Prave s touto kombinaciou TestDisk & PhotoRec som mal najviac uspechov (navyse moznost pracovat aj pod Windows).
  • Cely princip je samozrejme mozno pouzit aj na obnovu zmazanych suborov, t.j. recovery deleted or lost files.

exit status

$ touch ~/test.file
$ echo $?
0
$ touch /root/test.file
touch: cannot touch '/root/test.file': Permission denied
$ echo $?
1

Tor Browser

$ dnf install torbrowser-launcher.noarch   # len script, ktory stiahne a nainstaluje tor browser

Stiahnut a nainstalovat (rozbalit) Tor Browser do lubovolnej user dir.

$ ./start-tor-browser.desktop --register-app   # --unregister-app
$ ./start-tor-browser.desktop --help

create ISO image from a source CD or DVD

Testing on Fedora 40 (2024-09) with external USB CD/DVD ROM.

CD-R Mitsubishi 74min / 650 MB (CD napalene na cca 95% kapacity, DST 1m HBC)
# GNOME Disks (gnome-disks): Create Disk Image... => file zakaz.iso
$ stat --format="%s" zakaz.iso
604286976   # 604286976/512 = 1180248; 604286976/2048 = 295062
$ sha256sum zakaz.iso
d69d91804f75b2f7844e3e9f168607d9418fa0839af82ee074236758db997e78  zakaz.iso
$ sha256sum /dev/sr0
d69d91804f75b2f7844e3e9f168607d9418fa0839af82ee074236758db997e78  /dev/sr0
$ df --block-size=1 /dev/sr0
Filesystem     1B-blocks      Used Available Use% Mounted on
/dev/sr0       603979776 603979776         0 100% /run/media/musinsky/zakaz
$ isosize /dev/sr0; isosize --sectors /dev/sr0
603979776
sector count: 294912, sector size: 2048
$ isoinfo -d -i /dev/sr0 | grep 'size'
Volume set size is: 1
Logical block size is: 2048
Volume size is: 294912
$ dd if=/dev/sr0 of=DST.1m.HBC.CD1997_01.iso bs=2048 count=294912   # 2048*294912 = 603979776
294912+0 records in
294912+0 records out
603979776 bytes (604 MB, 576 MiB) copied, 233.376 s, 2.6 MB/s
$ sha256sum DST.1m.HBC.CD1997_01.iso
6778831b8e546036e227dd621c2775c3091f907a467d56607cea945c8efac402  DST.1m.HBC.CD1997_01.iso
USE THIS METHOD
$ dd if=/dev/sr0 of=DST.1m.HBC.CD1997_02.iso                        # 512*1180248 = 604286976
1180248+0 records in
1180248+0 records out
604286976 bytes (604 MB, 576 MiB) copied, 230.554 s, 2.6 MB/s
$ sha256sum DST.1m.HBC.CD1997_02.iso
d69d91804f75b2f7844e3e9f168607d9418fa0839af82ee074236758db997e78  DST.1m.HBC.CD1997_02.iso

CD-R pravdepodobne obsahuje to, co sa nazyva extra padding at the end of the media. Subor DST.1m.HBC.CD1997_02.iso je o 307200 bytes vacsi ako subor DST.1m.HBC.CD1997_01.iso. Kedze tento "extra padding" sa nachadza na konci, nie je problem ziskat spatne ISO image bez tej "koncovky".

$ dd if=DST.1m.HBC.CD1997_02.iso of=image_01.iso bs=2048 count=294912
294912+0 records in
294912+0 records out
603979776 bytes (604 MB, 576 MiB) copied, 0.594742 s, 1.0 GB/s
$ sha256sum image_01.iso
6778831b8e546036e227dd621c2775c3091f907a467d56607cea945c8efac402  image_01.iso
DVD ASUS DVD MB Support (manufactured)
# GNOME Disks (gnome-disks): Create Disk Image... => file MB Support CD.iso
$ stat --format="%s" 'MB Support CD.iso'
3303585792   # 3303585792/512 = 6452316; 3303585792/2048 = 1613079
$ sha256sum 'MB Support CD.iso'
25cf86b27cc01a77d5de20d7d800b125485bdd121ec32c44c4c65fd2e38ecd2d  MB Support CD.iso
$ sha256sum /dev/sr0
25cf86b27cc01a77d5de20d7d800b125485bdd121ec32c44c4c65fd2e38ecd2d  /dev/sr0
$ df --block-size=1 /dev/sr0
Filesystem      1B-blocks       Used Available Use% Mounted on
/dev/sr0       3303585792 3303585792         0 100% /run/media/musinsky/MB Support CD
$ isosize /dev/sr0; isosize --sectors /dev/sr0
3303585792
sector count: 1613079, sector size: 2048
$ isoinfo -d -i /dev/sr0 | grep 'size'
Volume set size is: 1
Logical block size is: 2048
Volume size is: 1613079
$ dd if=/dev/sr0 of=dvd1.iso bs=2048 count=1613079   # 2048*1613079 = 3303585792
1613079+0 records in
1613079+0 records out
3303585792 bytes (3.3 GB, 3.1 GiB) copied, 911.939 s, 3.6 MB/s
$ sha256sum dvd1.iso
25cf86b27cc01a77d5de20d7d800b125485bdd121ec32c44c4c65fd2e38ecd2d  dvd1.iso
$ dd if=/dev/sr0 of=dvd2.iso                         # 512*6452316 =  3303585792
6452316+0 records in
6452316+0 records out
3303585792 bytes (3.3 GB, 3.1 GiB) copied, 459.9 s, 7.2 MB/s
$ sha256sum dvd2.iso
25cf86b27cc01a77d5de20d7d800b125485bdd121ec32c44c4c65fd2e38ecd2d  dvd2.iso

DVD neobsahuje ziaden "extra padding". Vsetky 3 subory (MB Support CD.iso, dvd1.iso and dvd2.iso) su identicke.

livecd-iso-to-disk


dnf install livecd-iso-to-mediums
livecd-iso-to-disk --format --reset-mbr /home/musinsky/boot.iso /dev/sdc     # This will DESTROY ALL DATA on: /dev/sdc
# fdisk -l
Disk /dev/sdc: 7.5 GiB, 8054112256 bytes, 15730688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5755f6cd

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdc1  *     8192 15726591 15718400  7.5G 83 Linux

# blkid
/dev/sdc1: LABEL="LIVE" UUID="e61cbf0c-2b7e-48ef-9b94-c3c2e5fb2f4a" TYPE="ext4" PARTUUID="5755f6cd-01"

nmap

nmap -sP 10.0.0.0/24
nmap -sn 10.0.0.0-199
nmap -sL 10.0.0.* | grep \(10

pgrep and pmap

[musinsky@alice ~]$ pgrep -l root
5006 root
5007 root.exe
[musinsky@alice ~]$ pmap 5007
5007:   /cern/root_v5.34.06/bin/root.exe -splash -l
0000000000400000      8K r-x--  /cern/root_v5.34.06/bin/root.exe
0000000000601000      4K r----  /cern/root_v5.34.06/bin/root.exe
0000000000602000      4K rw---  /cern/root_v5.34.06/bin/root.exe
0000000002144000   8536K rw---    [ anon ]
...
00007ff4fadbb000   7104K r-x--  /cern/root_v5.34.06/lib/libCore.so
00007ff4fb4ab000   2044K -----  /cern/root_v5.34.06/lib/libCore.so
00007ff4fb6aa000    168K r----  /cern/root_v5.34.06/lib/libCore.so
00007ff4fb6d4000     56K rw---  /cern/root_v5.34.06/lib/libCore.so
00007ff4fb6e2000    520K rw---    [ anon ]
00007fffbbcce000    244K rw---    [ stack ]
00007fffbbdfe000      8K r-x--    [ anon ]
ffffffffff600000      4K r-x--    [ anon ]
total            92108K

flush memory cache

sync; echo 3 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches && sync

./depcomp: No such file or directory

automake --add-missing

date in terminal

while sleep 1; do tput sc; tput cup 0 $(($(tput cols)-29)); date; tput rc; done &

GCC discovery options

2023-10

#pragma GCC diagnostic ignored "-Wuninitialized"

xclip

$ dnf install xclip   # xsel
$ man xclip

$ xclip file                      # copy to XA_PRIMARY (mouse middle click for paste)
$ xclip -selection primary file   # to same as above
$ xclip -sel p file               # to same as above (abbreviation)

$ xclip -selection clipboard file # copy to XA_CLIPBOARD (Ctrl-V for paste)
$ xclip -sel clip file            # to same as above (abbreviation)

$ xclip -o                        # print selection (default from primary)
$ xclip -o -sel p                 # to same as above
$ xclip -o -sel clip              # print selection (from clipboard)

$ echo "some text" | xclip
$ uname -a | xclip
$ xclip -o | xclip -sel clip      # copy primary to clipboard

ImageMagick

identify describe the format and characteristics of one or more image files.

By default, identify provides the following output

Filename[frame #] image-format widthxheight page-widthxpage-height+x-offset+y-offset colorspace user-time elapsed-time
$ identify IMG_20220930_085004.jpg
IMG_20220930_085004.jpg JPEG 3016x4032 3016x4032+0+0 8-bit sRGB 3017060B 0.000u 0:00.000
$ identify -format "%f %m resolution units=%U resolution (density)=%xx%y compression quality=%Q\n" IMG_20220930_085004.jpg
IMG_20220930_085004.jpg JPEG resolution units=PixelsPerInch resolution (density)=72x72 compression quality=87

# %G = %wx%h; %g = %Wx%H+%X+%Y; %O = %X+%Y
# %M %m %G %g %z-bit %r
# %[printsize.x] = %[width] / %[resolution.x] # -units PixelsPerCentimeter (by default) PixelsPerInch (1 inch = 2.54 centimeter)

$ identify -format "%[EXIF:*]" IMG_20220930_085004.jpg

ExifTool

$ dnf install perl-Image-ExifTool

$ exiftool image.jpg | grep -i date
File Modification Date/Time     : 2016:02:29 17:30:15+01:00
File Access Date/Time           : 2016:02:29 17:30:15+01:00
File Inode Change Date/Time     : 2016:05:09 14:09:39+02:00
Modify Date                     : 2016:02:29 17:30:15
Date/Time Original              : 2016:02:29 17:30:15
Create Date                     : 2016:02:29 17:30:15

$ exiftool image.jpg | grep -i name
File Name                       : 1.JPG
Camera Model Name               : NIKON D5100
ICC Profile Name                : sRGB IEC61966-2.1
$ exiftool -all= image.jpg   # remove all (Exif) metadata

Warning: ICC_Profile deleted. Image colors may be affected
$ exiftool -all= -TagsFromFile @ -ColorSpaceTags image.jpg   # https://photo.stackexchange.com/questions/56378/how-can-i-strip-tags-from-a-jpeg-without-removing-the-color-profile

$ exiftool -createdate .
$ exiftool -filename .
$ exiftool -filename -createdate -T .
# 2024-05
exiftool -listx -all -lang en | grep -i creationdate
exiftool '-FileModifyDate<CreateDate' .
exiftool '-FileModifyDate<DateTimeOriginal' -r *.jpg

See the -w option in the exiftool application documentation for details about special features available with these name format codes. Extra % necessary to escape the filename codes. %%c, %%d, %%f, %%e copy number (counter), directory, file name, extension of the original FILE. All format codes may be modified by l or u to specify lower or upper case respectively (ie. %%le for a lower case file extension). A special feature allows the copy number to be incremented for each processed file by using %%C (upper case) instead of %%c.

exiftool '-FileName<CreateDate' -d %Y-%m-%d_%%f.%%e file.pdf

exiftool '-FileName<CreateDate' -d BEFORE_%Y%m%d_AFTER.%%e image.jpg

exiftool '-FileName<CreateDate' -d BEFORE_%Y%m%d_AFTER_%%.5c.%%e .   # 5digit copy number start from 0 (%%.5c), if use (%%5c) first (0) copy number is not used
exiftool '-FileName<CreateDate' -d BEFORE_%Y%m%d_AFTER_%%.3nc.%%e .  # 3digit copy number start from 1

exiftool '-FileName<CreateDate' -d BEFORE_%%111.3C.%%e .             # 3digit copy number (each processed file) start from 111

exiftool '-FileName<CreateDate' -d BEFORE_%Y%m%d_XX_%%lf_YY_%H%M%S_AFTER.%%le .
mogrify -format jpg *.png
$ for f in *.JPG; do convert -resize 50% -quality 75 "$f" "RQ_$f"; done
$ for f in *.JPG; do convert -quality 75 "$f" "Q_$f"; done
$ exiftool '-FileModifyDate<CreateDate' .
d:\FOTO\exiftool.exe "-FileModifyDate<CreateDate" .

exiftool -TagsFromFile fromImage.jpg toImage.jpg   # copy EXIF from to

evince-dvi

$ dnf download evince-dvi   # neinstalovat priamo (instaluje komplet texlive z Fedora repository)
$ rpm -ivh evince-dvi-*.rpm --nodeps

$ tlmgr install gsftopk     # potrebne pre dvi (render a ghostscript font in TeX pk form)
  • Pri uzivatelskej, vlastnej instalacii TeX Live (/opt/texlive) vznika problem. evince pri zobrazovani file.dvi neustale dookola regeneruje chybajuce fonty (potrebne generovat iba 1x), co je znacne zdlhave. Tento problem je sposobeny pretoze evince nevie najst uzivatelsku, vlastnu cestu /opt/texlive/2020/texmf-dist/web2c/, kde sa nachadza konfiguracny subor texmf.cnf, viac info [4], [5] alebo [6].
$ evince file.dvi   # premena TEXMFCNF neobsahuje spravnu uzivatelsku cestu
warning: kpathsea: configuration file texmf.cnf not found in these directories: ...
$ kpsewhich texmf.cnf                  # nespravny subor
/opt/texlive/2020/texmf.cnf
$ kpsewhich -expand-path='$TEXMFCNF'   # TEXMFCNF multi-dir, kde vsade sa mozu nachadzat texmf.cnf
/opt/texlive/2020/bin/x86_64-linux:/opt/texlive/2020/bin:/opt/texlive/texmf-local/web2c:/opt/texlive/2020:/opt/texlive/2020/texmf-dist/web2c

$ kpsewhich -var-value=TEXMFDIST       # uzivatelsky subor texmf.cnf sa nachadza v tejto directory (ale bez web2c sub-dir)
/opt/texlive/2020/texmf-dist
$ TEXMFCNF=$(kpsewhich -var-value=TEXMFDIST)// kpsewhich texmf.cnf   # cela cesta aj s nazvom suboru ("//" na chvoste oznacuje, ze sa moze hladat aj vo vnorenych sub-dirs)
/opt/texlive/2020/texmf-dist/web2c/texmf.cnf
riesenie (ako uzivatel)
# bud priamo ako prikaz, alebo export TEXMFCNF do $HOME/.bashrc
TEXMFCNF=$(kpsewhich -expand-path='$TEXMFCNF') evince file.dvi   # cesta nenastavena na mult-dir, kde vsade sa moze nachadzat texmf.cnf, vratane dir, kde sa nachadza uzivatelsky texmf.cnf
# mozno nastavit cestu analogicky ako pre admin
# TEXMFCNF=$(kpsewhich -var-value=TEXMFDIST)// evince file.dvi   # cesta nastavena na jednu konkretnu directory (bez web2c sub-dir), kde sa nachadza uzivatelsky texmf.cnf
riesenie (ako admin)
mkdir -p /usr/share/texlive/texmf-dist/web2c/   # default pre texlive z Fedora repository
ln -s $(TEXMFCNF=$(kpsewhich -var-value=TEXMFDIST)// kpsewhich texmf.cnf)  /usr/share/texlive/texmf-dist/web2c/

PDF and PS

pdf2ps vs pdftops

ps2pdf will sometimes convert text to high-resolution bitmapped fonts rather than to embedded outline fonts. This will occur when the PostScript file uses Type 3, CIDFontType 1, or CIDFontType 4 fonts, or Type 0 fonts that reference any of these; it may also occur in some cases if the input file uses fonts with non-standard encodings, or in some other rare cases.


  • pdf2ps is Ghostscript PDF to PostScript translator (ghostscript-core.rpm)
  • pdftops tool comes with Xpdf or is successor Poppler (poppler-utils.rpm)
  • problem with pdf2ps: fonts are converted to bitmap fonts => prefer pdftops
  • apart from the pdftops tool, the poppler-utils package also provides some other interesting toosl: pdfinfo (PDF document information extractor), pdfimages (PDF image extractor), pdftohtml (PDF to HTML converter), pdftotext (PDF to text converter), and pdffonts (PDF font analyzer)


First, take note that the measurement unit for PDF is the same as for PostScript: it's called a point [pt].

72 points == 1 inch == 25.4 millimeters

Assuming you have a page size of A4. Then the media dimensions are:

595 points width  == 210 millimeters
842 points height == 297 millimeters

POSIX

ToDo

find

[11]

### sha256 checksum
# for ff in $(find DST_1m_HBC_CD1997/ -type f -name '*.dvo'); do echo "$ff"; done # SC2044
# find DST_1m_HBC_CD1997/ -type f -name '*.dvo' | xargs sha256sum            # SC2038 !!!
# find DST_1m_HBC_CD1997/ -type f -name '*.dvo' -print0 | xargs -0 sha256sum # OK     !!!
# https://unix.stackexchange.com/questions/156008/is-it-possible-to-use-find-exec-sh-c-safely
# https://superuser.com/questions/1526229/what-is-the-second-sh-in-sh-c-some-shell-code-sh
find DST_1m_HBC_CD1997/ -type f -name '*.dvo' -exec sh -c \
     'stat --format="# %n: %s bytes" "$1"; sha256sum "$1";' sh {} \; > dvo.files.sha256sum
sed -i 's/DST_1m_HBC_CD1997\///g' dvo.files.sha256sum


find /usr/include/ -type f -name '*posix*.h'   # -iname (case insensitive)

# GNU Linux: -not, -and, -or POSIX: !, -a, -o
# NOTE all tests and actions have -a implicitly
# NOTE -a has higher precedence than -o
find /usr/include/ -type f -name '*posix*.h' -or -name '*linux*'       # not correct logic, see also: [12]
# treated as: find /usr/include/ (-type f AND -name '*posix*.h') OR (-name '*linux*')
/usr/include/linux   # this is dir, not file
find /usr/include/ -type f \( -name '*posix*.h' -or -name '*linux*' \) # correct
# treated as: find /usr/include/ (-type f) AND (-name '*posix*.h' OR -name '*linux*')



find /usr/include/ -type f -name '*gcc*.h' -ls
 1183746      4 -rw-r--r--   1 root     root         3809 May 18 09:55 /usr/include/mysql/server/private/atomic/gcc_builtins.h
 1052387      4 -rw-r--r--   1 root     root         2226 Apr  1  2015 /usr/include/avahi-common/gccmacro.h
find /usr/include/ -type f -name '*gcc*.h' -mtime -90
/usr/include/mysql/server/private/atomic/gcc_builtins.h
find /usr/include/ -type f -name '*gcc*.h' \( -mtime -90 -or -size +2000c \)   # be careful, must be \( expr \) including those spaces
/usr/include/mysql/server/private/atomic/gcc_builtins.h
/usr/include/avahi-common/gccmacro.h

find /usr/include/ -type f -name '*gcc*.h' -printf '%s\t\t%TF %TT\t%p\n'
3809		2022-05-18 09:55:27.0000000000	/usr/include/mysql/server/private/atomic/gcc_builtins.h
2226		2015-04-01 06:58:14.0000000000	/usr/include/avahi-common/gccmacro.h
$ find /usr/include/ -type f -name '*posix*.h' -exec grep _POSIX_NAME_MAX {} \;
#define	_POSIX_NAME_MAX		14
$ find /usr/include/ -type f -name '*posix*.h' | xargs grep _POSIX_NAME_MAX
/usr/include/bits/posix1_lim.h:#define	_POSIX_NAME_MAX		14

$ time find /usr/include/ -type f -name '*.h' -exec grep -l _POSIX_NAME_MAX {} \; # slowly
/usr/include/bits/posix1_lim.h
real	0m6.627s
$ time find /usr/include/ -type f -name '*.h' | xargs grep -l _POSIX_NAME_MAX     # using xargs is much faster (PREFER THIS METHOD)
/usr/include/bits/posix1_lim.h
real	0m0.074s

POZOR, ak by nahodou nazov suboru obsahoval medzeru (whitespace) a nasledne sa pouzil napr. pipeline, tak nazov suboru nebude ako "celok".

$ find /path/to/dir -type f
/home/musinsky/test file with spaces.extension
$ find /path/to/dir -type f -printf '"%p"\n'     # or "'%p'\n"
"/home/musinsky/test file with spaces.extension"
$ find /path/to/dir -type f -printf '"%p"\n' | xargs ls -al
$ find /path/to/dir -type f -printf '"%p"\n' | xargs file --mime-encoding | grep --invert-match 'binary' # find non-binary files
regular expressions
find -name  pattern     # matches shell pattern (or -iname for match case insensitive)
find -regex pattern     # matches regular expression pattern (or -iregex for match case insensitive)
# The regular expressions understood by find are by default Emacs Regular Expressions (except that `.' matches newline), but this can be changed with the -regextype option.
find -regex pattern -regextype type
# Valid types are ‘findutils-default’, ‘ed’, ‘emacs’, ‘gnu-awk’, ‘grep’, ‘posix-awk’, ‘awk’, ‘posix-basic’, ‘posix-egrep’, ‘egrep’, ‘posix-extended’, ‘posix-minimal-basic’ and ‘sed’
# find don't support Perl compatible (PCRE) regexes.

find /path/to/dir -type f | grep pattern   # don't use with xargs
# grep pattern syntax
# -E, --extended-regexp => as extended regular expressions (EREs).
# -F, --fixed-strings   => as fixed strings, not regular expressions.
# -G, --basic-regexp    => as basic regular expressions (BREs). This is the default grep regexp.
# -P, --perl-regexp     => as Perl-compatible regular expressions (PCREs).
# Note that GNU find's default regexps are not BRE, but emacs REs (some sort of hybrid between BRE and ERE).
hidden files

Hidden paths (i.e. directories or files) are ignored using -not -path '*/\.*'. If only hidden files but no hidden directories are to be ignored, use -name '[!.]*' instead. More info [13].

find non-portable filename

linux pathnames and filenames

Vyborny clanok, ktory naozaj detailne vysvetluje ako je to s pathnames (aka dir) and filenames. V druhej kapitole tohoto clanku viac info hladom standardov. POSIX (aktualne POSIX.1-2017) definuje 3.282 Portable Filename Character Set, ale aj 3.280 Portable Character Set (detailne 6.1 Portable Character Set). Portable Filename Character Set obsahuje prave a len tieto znaky A-Z, a-z, 0-9, . (aka period or full point), _ (aka underscore) and - (aka hyphen-minus) = [A-Za-z0-9._-], plus portable filename nema zacinat znakom -.

pathchk

Program pathchk check whether file names are valid or portable. ALE problematicke pouzitie, kedze program, resp. POSIX vyzaduje _POSIX_NAME_MAX 14, co je dnes naozaj kratky nazov pre filename. Dnesne systemy (vratane Linux) maju vacsinou nastavenu hodnotu na 255.

$ find /path/to/dir -type f -printf '"%p"\n' | xargs pathchk --portability   # limitation _POSIX_NAME_MAX 14

Napriek tomu obmedzeniu, existuje moznost ako pouzit tento program. Nahliadnuc do coreutils/src/pathchk.c vidime, ze program najprv vola funkciu portable_chars_only a az potom preveruje _POSIX_NAME_MAX (a hlasi error, ktore obsahuje jedinecne slovo limit).

$ pathchk --portability 123456789012345
pathchk: limit 14 exceeded by length 15 of file name component ‘123456789012345’
$ pathchk --portability 123456789#12345
pathchk: nonportable character ‘#’ in file name '123456789#12345'
# since coreutils 9.4 (2023-08) 'nonportable' changed to 'non-portable'
pathchk: non-portable character ‘#’ in file name '123456789#12345'


$ find /path/to/dir -type f -printf '"%p"\n' | xargs pathchk --portability 2>&1 | grep --invert-match 'limit'
# Using 2>&1 redirects stderr (file descriptor 2) to stdout (file descriptor 1). Both stdout and stderr will be "captured". In bash 4+ (no POSIX) simple command-with-stderr |& grep 'bla'.

Samozrejme, tato moznost nie je univerzalna. Postacuje, aby nastala nejaka zmena v zdrojovy program pathchk (hoci v danom pripade asi malo pravdepodobne) a bude nutne zmenit podmienky, logiku vyhladavania.

find + grep
$ locale | grep LC_CTYPE
LC_CTYPE="en_US.UTF-8"

$ echo "ascii_slôvenčiná_русский_ελληνική" | grep '[[:alpha:]]'
ascii_slôvenčiná_русский_ελληνική
$ echo "ascii_slôvenčiná_русский_ελληνική" | LC_ALL=C grep '[[:alpha:]]'   # or LC_CTYPE=C
ascii_slôvenčiná_русский_ελληνική

$ echo "ascii_slôvenčiná_русский_ελληνική" | grep '[a-z]'            # !!!
ascii_slôvenčiná_русский_ελληνική
$ echo "ascii_slôvenčiná_русский_ελληνική" | LC_ALL=C grep '[a-z]'   # !!!
ascii_slôvenčiná_русский_ελληνική

$ echo "ascii_slôvenčiná_русский_ελληνική" | grep -P '[a-z]'         # perl-regexp, Perl ranges [a-z] works with English only (ASCII range alphabet), without affecting LC_LOCALE
ascii_slôvenčiná_русский_ελληνική
$ echo "ascii_slôvenčiná_русский_ελληνική" | grep -P '[\x61-\x7A]'   # perl-regexp, hex code in ASCII table (x61=a x7A=z)
ascii_slôvenčiná_русский_ελληνική


$ echo "ascii_slôvenčiná_русский_ελληνική" | grep '[^[:alpha:]]'
ascii_slôvenčiná_русский_ελληνική
$ echo "ascii_slôvenčiná_русский_ελληνική" | LC_ALL=C grep '[^[:alpha:]]'         # print multi-byte characters as question marks
ascii_sl??ven??in??_??????????????_????????????????
$ echo "ascii_slôvenčiná_русский_ελληνική" | LC_ALL=C grep '[^[:alpha:]]' | cat   # print correct, but without colors
ascii_slôvenčiná_русский_ελληνική
$ echo "ascii_slôvenčiná_русский_ελληνική" | LC_ALL=C grep --color=always '[^[:alpha:]]' | cat   # try cat -v or less -R
ascii_sl??ven??in??_??????????????_????????????????
$ find /path/to/dir -type f | LC_CTYPE=C grep '[^A-Za-z0-9/._-]'                         # added / char
$ find /path/to/dir -type f | grep -P '[^A-Za-z0-9/._-]'                                 # or to same with perl-regexp
$ find /path/to/dir -type f | grep -P '[^\x41-\x5A\x61-\x7A\x30-\x39\x2E\x5F\x2D\x2F]'   # or [A-Za-z0-9._-] in HEX [\x41-\x5A\x61-\x7A\x30-\x39\x2E\x5F\x2D] and slash / \x2F
only find
$ LC_ALL=C find /path/to/dir -name '*[^[:alnum:]._-]*' | cat
$ LC_ALL=C find /path/to/dir -name '*[^A-Za-z0-9._-]*' | cat

press any key

# echo; read -n 1 -s -r -p "Press any key to continue"
# echo; read -n 1 -r -s -p $'Press enter to continue...\n'
# echo "Press any key to continue"
# pause (read -s -n1 -t1   from wiki)
# read -p "Press enter to continue"

SMART Monitoring Tools

# smartctl --attributes /dev/sda | grep -i power
  9 Power_On_Hours          0x0032   097   097   000    Old_age   Always       -       2495   # Power On Hours [hours]
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       864    # Power On Count [count]
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       33

xargs

https://askubuntu.com/questions/833128/what-does-xargs-grep-do https://stackoverflow.com/questions/62334952/format-xargs-output-to-grep

$ find ROOT/lib/ -name *.so | xargs ldd
echo '1999-03-09' | date --date
date: option '--date' requires an argument
Try 'date --help' for more information.
$ echo '1999-03-09' | xargs date --date
Tue Mar  9 12:00:00 AM CET 1999

$ echo 2023-{01..12}-01 | xargs -n1 date +%B -d

SANE

Fedora packages sane-backends: sane-backends, sane-backends-drivers-cameras, sane-backends-drivers-scanners, sane-backends-libs and sane-airscan: sane-airscan, libsane-airscan.

$ airscan-discover   # temporary disable firewalld.service or correctly open port(s)

Brother DCP-7070DW na domacej sieti (otvorene porty 1025-65535) bez nastaveni a bez nainstalovaneho proprietarneho balika brscan4.

$ scanimage --list-devices
device `airscan:w0:Brother DCP-7070DW' is a WSD Brother DCP-7070DW ip=192.168.1.149

$ scanimage --formatted-device-list="device name: '%d', vendor name: '%v', model name: '%m',%n\
scanner type: '%t' and index number: '%i'%n"
device name: 'airscan:w0:Brother DCP-7070DW', vendor name: 'WSD', model name: 'Brother DCP-7070DW',
scanner type: 'ip=192.168.1.149' and index number: '0'



$ scanimage --list-devices                              # -L, --list-devices
device `brother4:net1;dev0' is a Brother Brother_MFC-T910DW MFC-T910DW
$ scanimage --help --device-name='brother4:net1;dev0'   # -d dev, --device-name=dev
$ scanimage --batch --format png -d 'brother4:net1;dev0' --mode 'Black & White' --resolution 150 --source 'FlatBed'
$ scanimage --format png -d 'brother4:net1;dev0' --resolution 300 > scan.image.png
$ scanimage --batch --format png -d 'brother4:net1;dev0' --mode 'Black & White' --resolution 150 --source 'FlatBed'
out1.png
$ scanimage --list-devices
device `airscan:w0:Brother DCP-7070DW' is a WSD Brother DCP-7070DW ip=192.168.1.149   # no brother drivers
$ scanimage --help --device-name='brother4:net1;dev0'
--format tiff --batch=$(date +%Y%m%d_%H%M%S)_p%04d.tiff

2024-01 zeby bez instalacie Brother nezmyslov ? https://github.com/GNOME/simple-scan/blob/69da888ceec5b95f9a050d308569adea40ca9014/src/simple-scan.vala#L147


Example from CVUT (many scanners)

$ scanimage --list-devices | grep 428
device `airscan:w10:HP LaserJet Pro M428f-M429f [6AA4BF]' is a WSD HP LaserJet Pro M428f-M429f [6AA4BF] ip=147.32.4.50   # once like this ?!
$ scanimage --list-devices | grep 428
device `airscan:wd:HP LaserJet Pro M428f-M429f [6AA4BF]' is a WSD HP LaserJet Pro M428f-M429f [6AA4BF] ip=147.32.4.50    # once like this ?!
$ scanimage --list-devices | grep 428
device `airscan:w9:HP LaserJet Pro M428f-M429f [6AA4BF]' is a WSD HP LaserJet Pro M428f-M429f [6AA4BF] ip=147.32.4.50    # once like this ?!

after install libsane-hpaio (libsane-airscan)

$ scanimage --list-devices | grep 428
device `hpaio:/net/HP_LaserJet_Pro_M428f-M429f?ip=147.32.4.50' is a Hewlett-Packard HP_LaserJet_Pro_M428f-M429f all-in-one
device `hpaio:/net/LaserJet_Pro_M428f-M429f?ip=147.32.4.50' is a Hewlett-Packard LaserJet_Pro_M428f-M429f all-in-one
device `airscan:w8:HP LaserJet Pro M428f-M429f [6AA4BF]' is a WSD HP LaserJet Pro M428f-M429f [6AA4BF] ip=147.32.4.50

problem with scanning (--device-name= any from list from above) pravdepodobne natavenie bezpecnosti adminom

scanimage: sane_start: Error during device I/O

scanimage

Graphviz

$ aliDeps O2Physics --outgraph graph.O2Physics.pdf --outdot graph.O2Physics.dot
pridat na zaciatok graph.O2Physics.dot
digraph {
size="28.00,15.75" ratio="fill";
"O2Physics" [shape=box, style="rounded,filled", fontname="helvetica", fillcolor=gold]
$ dot -Tsvg graph.O2Physics.dot > graph.O2Physics.dot.svg

2024-01 tar

Archivacny (a kompresny) program s velkym mnozstvom moznosti. Jeden z najstarsich nastrojov v Linux (Unix) svete.

# Option styles
tar -cvf etc.tar /etc   # tar -c -v -f       # short option style
tar --create --file etc.tar --verbose /etc   # long option style
tar cvf etc.tar /etc                         # old option style
# Compression
tar -czf etc.tar.gz /etc   # -z --gzip
tar -caf etc.tar.xz /etc   # -a --auto compress (compression program by the archive file name suffix)
tar -xf etc.tar.xz         # -x --extract (format recognition on file #1 signatures in header #2 name suffix)

tar -cf etc.tar.gz -I 'gzip --verbose' /etc
tar -cf - /etc | gzip --verbose > etc.tar.gz

Nastroj na porovnavanie roznych kompresnych programov, benchmark tool lzbench.

# Archive Format
--format=FORMAT   # create archive of the given format
  --format=gnu          # GNU tar 1.13.x format
  --format=oldgnu       # GNU format as per tar <= 1.12
  --format=posix, pax   # POSIX 1003.1-2001 (pax) format
  --format=ustar        # POSIX 1003.1-1988 (ustar) format
  --format=v7           # old V7 tar format (--old-archive, --portability)

$ tar --show-defaults # 2024-01, tar (GNU tar) 1.35
--format=gnu -f- -b20 --quoting-style=escape --rmt-command=/etc/rmt --rsh-command=/usr/bin/ssh

Aktualne je default format gnu, ale je planovana zamena v buducich verziach na posix format. Rozne odporucania (portability alebo reproducibility) vsak preferuju uz dnes pouzivat posix format. gnu format, among others, will drop nanoseconds data from the timestamp of file, unlike posix. Pri citani, extrahovani tar file vytvoreneho s pomocou --format=posix nie su potrebne ziadne specialne options.

2024-01 transfer files and timestamp precision

File modification time with or without nanoseconds precision:

$ touch test.file; stat --format %y test.file
2024-01-22 15:19:36.223697670 +0100
$ cp -p test.file test.file.cp; stat --format %y test.file.cp
2024-01-22 15:19:36.223697670 +0100
$ dos2unix -k test.file; stat --format %y test.file
2024-01-22 15:19:36.000000000 +0100
  • Programs that keeps nanoseconds data from the timestamp of file:
    mv, cp -p, scp -p (local->local), rsync -a, rclone (local->YandexDisc->remote), tar --format=posix
  • Programs that drops nanoseconds data from the timestamp of file:
    scp -p (local->remote), tar (default, non-posix format), dos2unix/unix2dos -k

Ignorovanie nanoseconds precision v principe nie je problem. Niektore "sync" programy mozu tuto zmenu v nanoseconds povazovat za zmenu v subore a synchronizovat timestamp.

miscellaneous commands

# checksum (as Fedora iso)
for f in *.DST; do stat --format='# %n: %s bytes' "$f"; sha256sum --tag "$f"; printf '\n'; done
sort IP addresses
$ sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 deny-ip-list.txt
$ sort -V deny-ip-list.txt   # -V, --version-sort   (GNU coreutils 7.0+, 2008)
apropos fopen

potrace is a tool to convert a pure black and white bitmap to vector graphics

$ rsync -av CLOUD_yandex musinsky@x.y.z.zz:/home/musinsky --dry-run # OK

locale -a | grep -E 'RU|ru'
export LC_ALL="ru_RU.utf8"
export LC_ALL="sk_SK.utf8"

ldd /usr/bin/skype | grep lib | awk '{print $3}' | xargs rpm -qf | sort | uniq
# http://gskinner.com/RegExr/
# http://www.regextester.com/

# https://mywiki.wooledge.org/BashGuide
# https://www.grymoire.com/Unix/index.html
# https://www.grymoire.com/Unix/Bourne.html
# https://www.grymoire.com/Unix/Quote.html
# https://www.grymoire.com/Unix/Sed.html
# https://www.gnu.org/software/sed/manual/sed.html  == $ info sed
$ echo blablabla | sed 's/b/B/'      # Blablabla
$ echo blablabla | sed 's/b/B/g'     # BlaBlaBla

sed -i 's/old-text/new-text/g' /path/to/file
sed -i 's/\x27-\x27/\x27+\x27/g' /path/to/file     # replace  '-'  by  '+' , hexa code for  '  is x27 
sed -i s/"'-'"/"'+'"/g /path/to/file               # replace  '-'  by  '+' 
tail -F logfile.txt
sed ':a;N;$!ba;s/\n/\\n/g' /path/to/file           # replace end of line by \n

sed -i '22,33s/old-text/new-text/g' /path/to/file        # replace from line 22 to line 33
sed -i '22,$s/old-text/new-text/g' /path/to/file         # replace from line 22 to end of file
sed -i '/regex/,+11s/old-text/new-text/g' /path/to/file  # replace from line with word 'regex' and next 11 lines

sed -i '/find_word/s/foo/bar/' /path/to/file   # replace foo by bar if line content a specific string such as find_word

replace from line with word 'regex' and next 11 lines

cat file | sed 's/[ \t]*$//'   # delete trailing whitespace (from mc macro)

# 2023-05
Use the following command to delete the lines lying between PATTERN-1 and PATTERN-2 ,excluding the lines containing these patterns
sed '/PATTERN-1/,/PATTERN-2/{//!d}' input.txt
Use the following command to delete the lines lying between PATTERN-1 and PATTERN-2 ,including the lines containing these patterns:
sed '/PATTERN-1/,/PATTERN-2/d' input.txt
To delete all the lines after PATTERN-2, use this
sed '/PATTERN-1/,$d' input.txt

# 2023-09
$ echo 'pred 11.08.72-28.08.72 potom' | sed -E 's,([0-9]{2}).([0-9]{2}).([0-9]{2}), 19\3-\2-\1 ,g'
$ echo 'today is DATE' | sed "s#DATE#$(date '+%d/%m/%Y')#g"   # use '#' as separator

# 2023-06
ff='/etc/default/grub'
# The simplest case is replacing an entire line by finding the line that starts ^ with the match
diff -y <(sed 's/^GRUB_TERMINAL_OUT.*/GRUB_TERMINAL_OUTPUT=\"bla\"/g' "$ff") <(cat "$ff")
# try .*, . or *
# Then we have the case where we need to insert a line after the match (append a text after)
diff -y <(sed '/^GRUB_TERMINAL_OUT.*/a line_after' "$ff") <(cat "$ff")
# .* is not necessary
# Then we have the case where we need to insert a line before the match (insert i text before line)
diff -y <(sed '/^GRUB_TERMINAL_OUT.*/i line_before' "$ff") <(cat "$ff")
# .* is not necessary
# If you want to insert multiple lines you can use \n
diff -y <(sed '/^GRUB_TERMINAL_OUT/i line1\nline2' "$ff") <(cat "$ff")
  
git clone --depth 1 git://git.savannah.gnu.org/emacs.git

find /etc -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r
$ file -i README.*     # doc files from PSCyr-0.4-beta9-tex.tar.gz (3 different russian encoding)
README.alt: text/plain; charset=unknown-8bit
README.koi: text/plain; charset=iso-8859-1
README.win: text/plain; charset=iso-8859-1
$ file -i *.cslatex    # doc files from cslatex.tar.gz (same czech encoding)
INSTALL.cslatex: text/plain; charset=iso-8859-1
README.cslatex:  text/plain; charset=iso-8859-1

$ enca -i -L russian README.*
README.alt: IBM866
README.koi: KOI8-R
README.win: CP1251
$ enca -i -L czech *.cslatex
INSTALL.cslatex: ISO-8859-2
README.cslatex: ISO-8859-2

$ uchardet README.*
README.alt: IBM866
README.koi: KOI8-R
README.win: WINDOWS-1251
$ uchardet *.cslatex
INSTALL.cslatex: ISO-8859-2
README.cslatex: WINDOWS-1250   # wrong

#############
iconv -f KOI8-R -t UTF8 < ru_RU.dic > ru_RU.dic.utf8
iconv -f encoding -t UTF8 < input.txt > output.txt
iconv -l | grep 1250

iconv -f UTF-8 -t ASCII//TRANSLIT text_s_diakritikou

Historically, the good old 7-bit ASCII code standard was expanded to the 8-bit IS0 8859-1 Latin alphabet code, which adds characters and punctuation marks from several European languages. UTF-8 is an encoding of all Unicode characters using variable numbers of 8-bit blocks, which is backwards compatible with ASCII. It is the dominant encoding for web-pages, although other systems remain in use.


# http://milan.kupcevic.net/ghostscript-ps-pdf/
pdfinfo -rawdates source_file.pdf
CreationDate:   D:20120229154202+01'00'
ModDate:        D:20120229154447+01'00'

file pdf_marks
[ /ModDate (D:20120229154447)
  /CreationDate (D:20120229154202)
  /DOCINFO pdfmark

gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite -sOutputFile=final_files.pdf input_file.pdf pdf_marks


gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite \
      -dFirstPage=12 -dLastPage=17 -sOutputFile=outfile_p12-p17.pdf inputfile.pdf
gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite \
      -sOutputFile=outfile_joined.pdf inputfile1.pdf inputfile2.pdf
gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -r100 -dUseCropBox \
      -sOutputFile=output.png input.pdf
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \
      -sOutputFile=output.png input.pdf
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -r400 -dTextAlphaBits=4 \
      -sOutputFile=output.png input.pdf
-colorspace Gray
gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfimage8 \                    # pdfimage8, pdfimage24, pdfimage32
      -dFirstPage=3 -dLastPage=3 -sOutputFile=p3.pdf inputfile.pdf   # render input to a bitmap, ideal for 2D histrogram (vector image with huge number of points) !!! render aj fonty na bitmap !!!

gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=jpeg -r150 -dJPEGQ=75 -dEPSCrop -sOutputFile=out.jpeg n_beam_375.eps
#
# https://www.ghostscript.com/doc/current/Devices.htm
# https://www.ghostscript.com/doc/current/VectorDevices.htm

# https://stackoverflow.com/questions/9607687/replacing-vector-images-in-a-pdf-with-raster-images
# https://www.linux.org.ru/forum/general/12660253
#
# replace vector image in pdf (or ps) file with raster, bitmap image
# objects of that type will not be rendered/output: FILTERIMAGE (raster, bitmap images), FILTERVECTOR (vector images), FILTERTEXT (text)
gs -dFirstPage=18 -dLastPage=18 -sDEVICE=pdfwrite -dFILTERIMAGE -dFILTERVECTOR -o p18_onlytext.pdf input_file.pdf
gs -dFirstPage=18 -dLastPage=18 -sDEVICE=pdfimage24 -dFILTERTEXT -o p18_onlyimages.pdf input_file.pdf   # gs direct convert to raster image (DEVICE=pdfimage24) or convert manually
pdftk p18_onlytext.pdf background p18_onlyimages.pdf output p18_new.pdf   # (or multibackground for more pages)
pdftk p18_onlyimages.pdf stamp p18_onlytext.pdf output p18_new.pdf        # same as previous (or multistamp for more pages)
# finally
pdftk A=input_file.pdf B=p18_new.pdf cat A1-17 B A19-23 output input_file_new.pdf

# pdftk under Fedora
dnf install snapd
# reboot PC
snap install pdftk

# QPDF
qpdf infile.pdf --pages . 1,3-5,8 -- outfile.pdf     # preserving all metadata (!!! try with --linearize !!!, i.a. can serious reduce size)
qpdf --empty --pages infile.pdf 1-5 -- outfile.pdf   # metadata to be dropped

qpdf --empty --pages infile1.pdf 1,6-8 --pages infile2.pdf 3,4,5 -- outfile.pdf
qpdf --empty --pages infile*.pdf -- output.pdf             # merge pdf files

qpdf infile.pdf outfile.pdf                          # repair, i.a. remove linearization

# linearization (optimization) or web optimized PDF or fast web view enabled PDF
qpdf --linearize infile.pdf outfile.pdf                       # --linearize disables QDF mode
qpdf --object-streams=disable -qdf infile.pdf outfile.pdf     # remove linearization (object streams) from PDF
     --object-streams=generate
# https://github.com/qpdf/qpdf/issues/113

qpdf in.pdf out.pdf --rotate=+90:2,4,6 --rotate=180:7-9

qpdf book.pdf --pages cover.pdf 1 book.pdf 1-z -- result.pdf  # merge two files, metadata from first
# zamena strany 2 v book.pdf stranou 3 z other.pdf
qpdf book.pdf --pages book.pdf 1 other.pdf 3 book.pdf 3-z -- book_corrected.pdf 

# merge files
qpdf --empty --pages $(for i in *.pdf; do echo $i 1-z; done) -- merged.pdf

# password (prestudovat 2021-03 https://github.com/qpdf/qpdf/issues/351)
# qpdf --encrypt user-password owner-password key-length flags --   # treba aj owner-password !!!
# qpdf --encrypt super_heslo super_heslo 256 -- unencrypted.pdf encrypted.pdf
# pdfinfo encrypted.pdf -upw super_heslo
# qpdf --password=super_heslo --decrypt encrypted.pdf decrypted.pdf
# https://cyberrunner.medium.com/removing-metadata-from-pdf-files-using-exiftool-and-qpdf-20090b75d7f0

a2ps --medium=a4 -r --columns=1 --font-size=11 -o magnet.ps magnet.txt
# https://github.com/lehner/gpdfx
pdfcrop --clip schema.pdf
pdfcrop --margins '5 10 5 5' --clip schema.pdf schema_crop.pdf
pdfcrop --margins '-120 -20 -120 -422' --clip out.pdf out_vycuc.pdf
# vyreze "clip" a prida "okraje" (vlavo, hore, vpravo, dole)
pdfcrop --margins '0 30 0 10' --clip cham_wires.pdf  # clip zvacseny o okraje zhora 30, zdola 10

pdfjam 1.pdf 2.pdf 3.pdf 4.pdf --nup 2x2 --landscape --outfile all_in_one.pdf   # --frame true --fitpaper true
pdfjam --outfile out_resize.pdf --papersize '{170mm,245mm}' input.pdf # resize pdf

# pridat okraje bielej farby zhora a zdola o velkosti 30 a zlava a sprava o velkosti 0, nasledne oreze o 0x0 ale zdola este o 20
convert drift_velocity.png -bordercolor white -border 0x30 -crop 0x0+0-20 final.png # obrazok zvacseny o okraje zhora 30, zdola 10
convert -transparent white strela_logo.png strela_logo_new.png
convert -transparent white -resize 32 -depth 2 output.eps alice_icon32.png

# vector to bitmap (raster) https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=26151
# convert -density 300 foo.pdf -resize 1000x foo.png
# optimal density ???
# identify -density 300 -format "%w %h" foo.pdf   # ale vraj, ze nie
# density = (bigger_dst_dim / (bigger_src_dim / 72.0)) + 5

# convert -density 150 logo_SASKE.pdf -resize 500x -background white -alpha remove -alpha off -bordercolor white -border 35x0 logo_SASKE.png

2023-01
$ convert -units PixelsPerInch input_image -density 300 output_image   # units is important
# eps
epstool --test-eps Four_Colors_Logo.eps   # File has   %%BoundingBox: 0 0 393 513     Correct is %%BoundingBox: 47 47 393 513
eps2eps Four_Colors_Logo.eps Four_Colors_Logo_OK.eps
epstool --copy --bbox Four_Colors_Logo_OK.eps Four_Colors_Logo_final.eps
convert -transparent white -resize x135 -depth 4 Four_Colors_Logo_OK.eps alice_logo_color.png
# order of options in convert command is important !!!
convert -auto-level -bordercolor white -border 70x70 -resize x135 -depth 4 -transparent white One_Color_Logo_OK.eps alice_logo_black.png # default depth is 16
convert -auto-level -bordercolor white -border 70x70 -resize x135 -transparent white -define png:format=png8 One_Color_Logo_OK.eps alice_logo_black.png
# value png8 reduces the number of colors to 256, only one of which may be fully transparent, if necessary (valid values are png8, png24, png32, png48, png64, and png00)
convert -bordercolor white -border 70x70 -resize x135 -transparent white -define png:format=png8 Four_Colors_Logo_OK.eps alice_logo_color.png
convert -auto-level -auto-gamma -bordercolor white -border 16x16 -resize 32x32 -transparent white -define png:format=png8 One_Color_Logo_final.eps alice_icon_black.png
convert -colorspace Gray -threshold 99% -resize x96 -depth 8 logo_CERN_final.eps logo_CERN.png
# reduce file size
convert -auto-level -background white -alpha remove -define png:format=png8 -define png:bit-depth=1 input.png output.png # don't resize
convert -auto-level -background white -alpha remove -resize 794 -define png:format=png8 input.png output.png # 794x1123 px = A4 96 dpi, 2480x3508 px = A4 300dpi
magick image.bmp PNG8:image.png   # -define png:format=png8
magick image.bmp -colors 256 PNG8:image.png   # best result
dnf install pngquant pngnq
# na prevod pdf -> png (alebo cokolvek ine) vyskusat aj: I generally get better results with poppler's pdftoppm, the anti-aliasing is way better. pdftoppm -png -r 600 out.pdf > out.png 

# https://github.com/davygravy/AirPrint-on-Entware/issues/6
Poppler is a PDF interpreter and QPDF is not. So you cannot render/rasterize PDF with QPDF and so you cannot generally replace Poppler by QPDF. QPDF is only a PDF manipulator, especially useful for generating valid PDF files.
But you can build cups-filters without Poppler now as it supports the three PDF interpreters Poppler, Ghostscript, and MuPDF.

convert double_page.png -crop 50%x100% +repage page_split_%02d.png
convert -resize 50% -depth 1 strela_2007-03.png strela_2007-03_OK.png
convert input.png -background white -alpha remove -alpha off output.png      # img2pdf (transparency which cannot be retained in PDF)
convert -colorspace Gray -depth 1 -background white -alpha remove -alpha off scan.png scanOK.png   # -resize 50%
# scan to pdf (scan to png and png reduce to -depth 1 = "8-bit Gray 2c")
for file in *; do  f=$(basename -s .png "$file")_OK.png; convert -colorspace Gray -depth 1 -background white -alpha remove -alpha off "$file" "$f"; done
convert -monochrome scan.image.jpg scan.image.png   # OK (ale "pomale")
    !!! -normalize !!!
img2pdf --pagesize A4 --auto-orient --fit fill --creationdate "2004-11-11 11:11:11" --moddate "2004-11-11 11:11:11" -o all_out.pdf *_OK.png   # time is UTC 

convert -brightness-contrast -25X25 scan.jpg -resize 1280 -quality 75 scan_p1.jpg

https://unix.stackexchange.com/questions/20026/convert-images-to-pdf-how-to-make-pdf-pages-same-size
dnf install python3-img2pdf python3-pillow
img2pdf --pagesize A4 -o all_out.pdf *.png # !!! NAJ !!! metoda png->pdf, bez stratova (ale OK aj pre jpg)
img2pdf --pagesize A4 --auto-orient --fit fill -o out.pdf *.jpg

$ pdfimages -list scanned.document.pdf
page   num  type   width height color comp bpc  enc interp  object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
   1     0 image    1530  2144  rgb     3   8  jpeg   no         3  0   300   301  348K 3.6%
$ pdfimages -j scanned.document.pdf scanned.image

# preskumat mutool, napr. mutool extract file.pdf     https://www.mupdf.com/docs/index.html

https://www.linux-magazine.com/Issues/2019/220/Purifying-Scanned-PDFs

# convert djvu to pdf
$ dnf install djvulibre
$
$ ddjvu -format=tiff -page=1-999 -eachpage scan_book.djvu page%03d.tiff     # format tiff produces file using lossless compression
$ for file in *; do  f=$(basename -s .tiff "$file")_OK.png; convert -monochrome "$file" "$f"; done
$ img2pdf -o scan_book_mono.pdf *_OK.png

# pdf2svg sam autor odporuca pouzivat modernejsie nastroje z poppler balika, prikaz pdftocairo.
# svg to pdf
$ inkscape --export-type=pdf,png MukeWiki.Inkscape.svg
$ inkscape --export-filename=MukeWiki.Inkscape.object.png -w 7000 MukeWiki.Inkscape.object.svg
Background RRGGBBAA: ffffff00
Area 0:0:700:500 exported to 7000 x 5000 pixels (960 dpi)
$ inkscape --export-id=tspan31679 --export-filename=export.text.png MukeWiki.Inkscape.object.svg
ackground RRGGBBAA: ffffff00
Area 148.82:400:551.195:457.354 exported to 402 x 57 pixels (96 dpi)
$ man inkscape

$ rsvg-convert --format pdf --output=MukeWiki.logo.pdf MukeWiki.logo.svg     # dnf install librsvg2-tools
$ rsvg-convert --width=7000 MukeWiki.logo.svg > MukeWiki.logo.png
# quickly create a large file
fallocate -l 13G big13GB.dat
truncate -s 15G big15GB.empty

# list open files for process
ls -l /proc/2982/fd
lsof -p 2982
lsof -p `pgrep root.exe`

# recursively fetch a directory with arbitrary files
wget -r -nH -np -R index.html* http://example.com/dir1/dir2/dir3

# https://www.guyrutenberg.com/2014/05/02/make-offline-mirror-of-a-site-using-wget/
# 2023-07
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://www.obliquity.com/computer/fortran/

watch -n 0.1 ls -al /var/log/

# find and replace space with underscore in file name
find . -maxdepth 1 -type f -name "* *"
find . -maxdepth 1 -type f -name "* *" | while read file; do mv -v "$file" ${file// /_}; done

for file in *; do mv -v "$file" "${file// /_}" ; done

# dnf install prename (Perl script to rename multiple files)
prename -vn 's/ABC/123/' *.txt   # ABC zameni na 123
prename -vn 's/^/OK_/' *         # "prefix" pred nazov subora OK_
prename -vn 's/\.cs\./.cze./' *  #  ".cs." -> ".cze."

# there's also the rename from util-linux.

miscellaneous commands 2

# wget multiple files at once from a web site [14]
this downloads all the *fc34*.rpm packages
wget -r -l1 --no-parent --no-check-certificate  -A*fc34*.rpm https://ecsft.cern.ch/dist/cvmfs/cvmfs-2.10.1/
wget -r -l1 --no-parent --no-check-certificate  -A*fc34*.rpm https://ecsft.cern.ch/dist/cvmfs/nightlies/cvmfs-git-3828/
rclone sync /home/musinsky/CLOUD_yandex/ remote_yandex: -v --dry-run
touch -md "2016-09-27 12:12:12" file.pdf

touch -r refer.ps file.pdf
FFF=projekt_Piskunov.pdf; touch -md "`exiftool -T -d "%Y-%m-%d %H:%M:%S" -createdate $FFF`" $FFF
touch -md "`exiftool -T -d "%Y-%m-%d %H:%M:%S" -modifydate Nik_alepto.pptx`" Nik_alepto.pdf          # dnf install perl-Archive-Any (Warning : Install Archive::Zip to decode compressed ZIP information)

$ FFF=Navod1mHBC.odt; exiftool '-FileModifyDate<Date' "$FFF"; mv "$FFF" $(exiftool -T -d "%Y-%m-%d_$FFF" -Date "$FFF")

POZOR Ak nemam nainstalovany "perl uznip" dnf install perl-Archive-Extract-zip-Archive-Zip tak napr. z *.odt nevie ziskat plnu informaciu, kedze *.odt je v principe zo-zip-ovany subor.

http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3523
$ exiftool -a -s -G1 -time:all aaa.pdf
[System]        FileModifyDate                  : 2012:09:20 05:58:54+04:00
[System]        FileAccessDate                  : 2019:03:19 17:28:59+03:00
[System]        FileInodeChangeDate             : 2019:03:19 17:28:31+03:00
[PDF]           CreateDate                      : 2019:03:19 14:14:02+00:00
[PDF]           ModifyDate                      : 2019:03:19 14:14:02Z
$ exiftool "-CreateDate<FileModifyDate" "-FileModifyDate<FileModifyDate" aaa.pdf
    1 image files updated
$ exiftool -a -s -G1 -time:all aaa.pdf
[System]        FileModifyDate                  : 2012:09:20 05:58:54+04:00
[System]        FileAccessDate                  : 2012:09:20 05:58:54+04:00
[System]        FileInodeChangeDate             : 2019:03:19 17:29:27+03:00
[XMP-xmp]       CreateDate                      : 2012:09:20 05:58:54+04:00
[PDF]           CreateDate                      : 2012:09:20 05:58:54+04:00
[PDF]           ModifyDate                      : 2019:03:19 14:14:02Z
$ pdfinfo aaa.pdf | grep -i date
CreationDate:   Thu Sep 20 05:58:54 2012 MSK
ModDate:        Tue Mar 19 17:14:02 2019 MSK
$ exiftool "-modifydate<filemodifydate"
$ exiftool "-filemodifydate<createdate" -r dir_name -ext pdf   # recursive all *.pdf in dir_name

$ exiftool -tagsFromFile source_file -ModifyDate -FileModifyDate target_file
$ exiftool -tagsFromFile source_file -time:all -FileModifyDate target_file

$ exiftool -overwrite_original -tagsFromFile src_file.pdf dest_file.pdf
$ exiftool -overwrite_original -tagsFromFile example.pdf example_compressed.pdf
# dalej na studium
exiftool -if "$DateTimeOriginal ne $CreateDate" -Title="Timestamp discrepancy" -r FileOrDir

1) A linearized PDF file is no longer linearized after the update, so it must be subsequently re-linearized if this is required.

2) All metadata edits are reversible. While this would normally be considered an advantage, it is a potential security problem because old information is never actually deleted from the file. (However, after running ExifTool the old information may be removed permanently using the "qpdf" utility with this command: "qpdf --linearize in.pdf out.pdf".)

$ hexdump -C cal_60_CH2right.pdf | grep -i date $ strings cal_60_CH2right_l.pdf | grep -i date

# FINAL
# vsetky *.pdf subory v current dir zameni System:FileModifyDate na PDF:CreateDate   !!! checkovat ci PDF:CreateDate alebo PDF:ModifyDate !!!
$ exiftool "-FileModifyDate<CreateDate" -r . -ext pdf

$ exiftool "-FileModifyDate<ModifyDate" -r . -ext doc   # !!! MS-DOC:ModifyDate !!!

# subor target_file.pdf ma zameneny System:FileModifyDate (ktory je zaroven zameneny na PDF:CreateDate zo source_file.pdf) a PDF:CreateDate hodnotami zo source_file.pdf
# !!! target_file.pdf sa meni (velkost), kedze sa menia MetaData !!!
$ exiftool -tagsFromFile source_file.pdf -CreateDate "-FileModifyDate<CreateDate" target_file.pdf

$ exiftool -tagsFromFile spin12_piskunov.ppt "-CreateDate<ModifyDate" "-FileModifyDate<ModifyDate" spin12_piskunov.pdf   # # !!! FlashPix:ModifyDate !!!
$ exiftool -tagsFromFile zmluva.docx "-ModifyDate<CreateDate" "-CreateDate<CreateDate" "-FileModifyDate<CreateDate" zmluva.pdf


# vsetky *.pdf subory v current dir zameni PDF:CreateDate na System:FileModifyDate a "zanecha" povodny System:FileModifyDate !!! checkovat ci PDF:CreateDate alebo PDF:ModifyDate !!!
# ak som predtym prerobil pdf subor (a teda v MetaData su nespravne datumy), ale subor ma aspon spravny System:FileModifyDate
$ exiftool "-CreateDate<FileModifyDate" "-FileModifyDate<FileModifyDate" -r . -ext pdf

# PDF:CreateDate a PDF:ModifyDate sa nastavi podla System:FileModifyDate a kedze sa menia metada (t.j. timestamp file sa meni) tak aj zachovava aj povodny timestamp 
$ exiftool "-CreateDate<FileModifyDate" "-ModifyDate<FileModifyDate" "-FileModifyDate<FileModifyDate" file.pdf
#!/bin/bash
# count number of characters in filename (filename length)
# https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits
# https://github.com/torvalds/linux/blob/master/include/uapi/linux/limits.h
for file in *; do echo -n "$file" | wc -m; done
# more elegant
for f in *; do echo ${#f}; done
# best
for file in *; do f=$(basename "$file"); printf "%s:%s\n" "$file" "${#f}"; done | column -s : -t


for f in *.eps; do epstopdf "$f" ; done


for file in *.np
do
    echo "processing file" $file
    iconv -f ISO_8859-1 -t UTF8 $file > $file.utf8
    mv $file.utf8 $file
done


$ for f in *.dat; do echo my_cmd -v "$f" "${f%%.*}"___"$(date -r "$f" +"%Y-%m-%d_%H-%M-%S")"."${f##*.}"; done
my_cmd -v a1.dat a1___2008-06-06_10-57-12.dat
my_cmd -v a2.dat a2___2008-06-06_10-57-27.dat

# https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
% FILE="example.tar.gz"
% echo "${FILE%%.*}"
example
% echo "${FILE%.*}"
example.tar
% echo "${FILE#*.}"
tar.gz
% echo "${FILE##*.}"
gz
# 2023-05 https://www.cyberciti.biz/faq/bash-get-basename-of-filename-or-directory-name/
PROGRAM=${FILE##*/} # Версия `basename` на bash

burn VOB files

/path/to/DVDFilm/ contains AUDIO_TS and VIDEO_TS folders

$ mkisofs -dvd-video -o image.img /path/to/DVDFilm/
$ growisofs -dvd-compat -speed=4 -Z /dev/dvd=image.img

GTK+ Color Selection Dialog

$ zenity --color-selection --show-palette

Firefox configuration

  • firefox.desktop[29462]: Failed to open VDPAU backend libvdpau_i965.so: cannot open shared object file: No such file or directory
yum install libva-intel-driver
  • disable auto creation ~/Desktop dir (under linux)

~/.config/user-dirs.dirs (and installed xdg-utils package)

XDG_DESKTOP_DIR="$HOME/"
XDG_DOWNLOAD_DIR="$HOME/"
XDG_DESKTOP_DIR="/home/musinsky/"
# dont use "~"
# "/" at the end of line is important
  • sharing personal dictionary (slovak ASCII) between Firefox (~/.mozilla/firefox/[uniqueID.default]/persdict.dat) and hunspell in emacs (~/.hunspell_sk-SK-ascii)
ln -s $HOME/.mozilla/firefox/*.default/persdict.dat $HOME/.hunspell_sk-SK-ascii

about:config

  • disable native PDF viewer
pdfjs.disabled                     true
  • disable scroll wheel zoom
mousewheel.with_control.action     0
  • acceleration scroll wheel
mousewheel.acceleration.factor     10
mousewheel.acceleration.start      1
  • click-to-play plugins
plugins.click_to_play              true

Default application

/usr/share/applications/mimeinfo.cache or /usr/share/applications/defaults.list

CERN Certification Authority

2020-10

Create new certificate
https://ca.cern.ch/ca/ => New Grid User Certificate => create new certificate (with password) and download, install in browser (Firefox)
Export public key
Backup my new certificate from Firefox (Preferences => Advanced => Certificates => View Certificates => Your Certificates) as file musinsky.p12
Convert to PEM Keypair
To use a Certificate with Globus, you need to convert it to PEM format Key pair, in 2 separate files, one for the key itself, and one for the certificate.
Extract certificate (which contains the public key)
openssl pkcs12 -in musinsky.p12 -clcerts -nokeys -out usercert.pem
Get the encrypted private key
openssl pkcs12 -in musinsky.p12 -nocerts -out userkey.pem
chmod 444 musinsky.p12 usercert.pem
chmod 400 userkey.pem   # must be read-only by the owner
mkdir ~/.globus
mv musinsky.p12 usercert.pem userkey.pem ~/.globus

  • [VOMS Admin] Request to sign VO alice acceptable usage policy (AUP).
    • VOMS Admin for VO alice [project-lcg-vo-alice-admin@cern.ch]
    • You are requested to sign the VO alice Acceptable Usage Policy (AUP) in order to continue to be part of the alice VO.
    • To sign the AUP, point your browser to the following URL: https://lcg-voms2.cern.ch:8443/voms/alice/sign-aup
    • Please ensure that you connect to the above URL with a valid certificate linked to your VO membership installed in the browser => musinsky.p12 in browser

Grid re-registering with a new certificate (alice VOMRS)
The certificate should have already been-loaded on your browser
https://lcg-voms.cern.ch:8443/vo/alice/vomrs (choose new certificate) => Member Info -> Re-sign Grid and VO AUPs



Po prihlaseni (s novym certifikatom) uz nie je potrebne robit nic dalej. Na "Certificate Info" vidno, ze uz expirujem s novym certifikatom, zasa o rok neskor.

test:

ssh lxplus.cern.ch
# copy "new" .globus dir
alienv enter VO_ALICE@AliPhysics::vAN-20160629-1
alien-token-init

Printing at CERN

Configure for example printer 13-R006-HP 13-R006-HPBW in building 13, printer model HP LaserJet 4300

Select Device -> Network Printer -> LPD/LPR Host or Printer -> Location of the LPD network printer
Host:    13-R006-HP.print.cern.ch
Queue: 13-R006-HP
Choose Driver: HP -> Models: LaserJet 4300 -> Drivers: HP LaserJet 4300 Series Postscript[en] (recommended)
Describe Printer
Printer Name: 13-R006-HP
Description:    HP LaserJet 4300
Location:         Building 13

Notes: for model HP LaserJet 4300 set Paper Source: Tray 2 (Tray 1 is for manual feed ?)

CERN Library Proxy Service

Automatic proxy configuration URL
https://library-proxy.web.cern.ch/proxy.pac

After configuring your browser you can use the page http://cern.ch/library-proxy/test to see if the connection via the proxy work

SASKE

Mail at SASKE

Webmail on saske: https://webmail.saske.sk (previous https://home.saske.sk)

ssh musinsky@imapx.saske.sk

Welcome on Central Mail, Slovak Academy of Sciences in Kosice (mail.saske.sk) Vasa posta je presmerovana na :blabla@bla.com

Sendmail on alice.saske.sk

/etc/mail/sendmail.mc

dnl # Uncomment and edit the following line if your outgoing mail needs to
dnl # be sent out through an external mail server:
dnl #
define(`SMART_HOST', `smtp.saske.sk')dnl
dnl #

and regenerate new /etc/mail/sendmail.cf config file with m4 command (must have installed sendmail-cf package)

$ m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
$ systemctl restart sendmail.service

Direct (simple) solution, edit /etc/mail/sendmail.cf file

# "Smart" relay host (may be null)
DSsmtp.saske.sk

Vidyo

yum install libXScrnSaver

VNC

VNC and Wayland 2024-03


TigerVNC server

$ dnf install tigervnc-server
[user]$ vncpasswd     # created /home/musinsky/.vnc/passwd
[user]$ vncserver     # created /home/musinsky/.vnc/config, /home/musinsky/.vnc/passwd and log files
$ firewall-cmd --permanent --zone=FedoraServer --add-service=vnc-server
$ firewall-cmd --reload
vnc-server as service

currently on Fedora 25 not working due to wayland issue

$ cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.service
# no need to include the display number in the file (systemd automatically creates the appropriately named instance in memory on demand)
# replacing <USER> by actual user name musinsky (from regex ExecStart to end of line)
$ sed -i '/Unit/,$s/<USER>/musinsky/g' /etc/systemd/system/vncserver@.service

[user]$ vncpasswd

$ systemctl daemon-reload
$ systemctl enable vncserver@:1.service
$ systemctl start vncserver@:1.service

# add vnc-server to firewall

VLC

VLC and BluRay menu in Fedora https://superuser.com/questions/1591003/vlc-gets-java-headless-error-on-blu-ray-discs

OK, F35, java-11-openjdk

BORDEL


Case Convert

  • vsetko na male pismenka (all to lower case)
# for i in $( ls | grep [A-Z] ); do mv -i $i `echo $i | tr 'A-Z' 'a-z'`; done

cstocs

# dos2unix *
#
# cstocs -i kam utf8 *.tex
# cstocs -i tex utf8 *.tex   # from file perl5/Cz/Cstocs/enc/tex.enc removed this line: ~<---->nobreakspace (~, \div, \times)
# cstocs -i tex utf8 *.pic

# recode KEYBCS2..UTF-8 *.tex

# cstocs kam utf8 < uvod.tex
# cstocs tex utf8 < uvodOK.tex

Bootable Windows 7 USB Drive in Linux

screen

screen -S example
# run any program   (no nohup program & necessary)
# press C-a d   (detach)
# program running in the background

# screen -r example

nfs

server

/etc/fstab

/dev/mapper/vg_he120_74-lv_home   /home   ext4   defaults   1 2

/home/data                        /data   none   defaults,bind   0 0

/etc/exports

/data *(ro)
client

/etc/fstab

strela205.jinr.ru:/data   /strela205-data   nfs   hard,intr,noac,actimeo=1,async,nosuid,nodev,sec=null,ro   0 0
192.168.0.100:/volume1/HD_video/   /mnt/HD_video   nfs   defaults,ro   0 0

vnc

VNCSERVERS="1:username"
VNCSERVERARGS[1]="-geometry 1280x1024 -nolisten tcp"

Google Chrome

PuTTY and VNC

PuTTY tunnels: L5901 127.0.0.1:5901 (Local IPv4)
vncviewer: localhost:1

port forwarding

input (WAN -> LAN)
iptables -t nat -A PREROUTING -i eth0 -p tcp -d x.x.x.x --dport 8080 -j DNAT --to 10.0.0.99:80
iptables -t nat -A PREROUTING -i eth0 -p tcp -d x.x.x.x --dport pop3 -j DNAT --to 10.0.0.123
output (LAN -> WAN)
iptables -t nat -A POSTROUTING -o eth0 -s 10.0.0.0/24 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -s 10.0.0.0/24 -j SNAT --to-source x.x.x.x

SSH tunel

$ ssh -C -L 5901:localhost:5901 musinsky@strela205.jinr.ru

$ vncviewer localhost:1

We have to create the ssh tunnels for the ports 5807 and 5907 to the host lxplus403.cern.ch (note that we have to bypass the generica alias lxplus)

$ ssh username@lxplus403.cern.ch -L5807:localhost:5807 -L5907:localhost:5907

The ssh tunnels will be active as long as the ssh connection is open, but you do not need to use this terminal until you want to kill the display

2024-06
# set up a SOCKS v5 proxy
# create a local socks proxy that a web browser (firefox, chrome, etc) can be configured to use
$ ssh -D 8080 lxtunnel.cern.ch   # ssh(1)   (or 8888 port)

In firefox Settings → General: Network Settings: select Manual proxy configuration SOCKS Host: localhost (SOCKS v5) Port: 8080

Midnight Commander

wget https://gist.githubusercontent.com/rb2/1f6b23ea5ea848c75a8c/raw/markdown.syntax -O /usr/share/mc/syntax/markdown.syntax
  • /usr/share/mc/syntax/Syntax
file ..\*\\.(md|markdown)$ Markdown
include markdown.syntax

file .\* unknown
include unknown.syntax
include/video
        Open=(vlc %f >/dev/null 2>&1 &)
        View=%view{ascii} mediainfo %f 2>/dev/null
regex/\.([aA][cC]3)$
        View=%view{ascii} mediainfo %f 2>/dev/null

Preview Markdown

grip preview GitHub README.md files locally before committing them. grip uses the GitHub markdown API to render a local README.md file. Edit any Markdown file.md with your editor and after save preview in web browser is automatically refreshing (without requiring a page refresh). POZOR kazde jedno save-nutie vyvolava refresh stranky a teda volanie GitHub API. Pre anonymous user je moznych len ?!60?! volani za jeden den, takze je potrebna authentication. Ale "Basic authentication using a password to the API is deprecated and will soon no longer work" tazke bude potrebne vytvorit token.

strela205

  • ak spustam vncserver cez "xorg.conf" tak sa obraz akoby klonoval, t.j. hybem myskou u seba a vidi to aj druhy na vncclient-e. Ak spustam cez service, tak su kvazi nezavisle obrazovky, a tu je problem s vmedaq, ludia mozu menit "configy" pre ten isty program, a on potom moze padat.
  • /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -s 159.93.117.0/24 -j ACCEPT                                                                                                                                                                                          
-A RH-Firewall-1-INPUT -s 159.93.112.0/24 -j ACCEPT

vsetkym s 159.93.117.* (okrem 0) povoleny pristup
vsetkym s 159.93.112.* (okrem 0) povoleny pristup

  • oficialne DNS servery dig -t ns jinr.ru

/etc/resolv.conf

search jinr.ru                                                                                                                                                                                                                       
nameserver 159.93.17.7                                                                                                                                                                                                                       
nameserver 159.93.14.7
dig -x 147.213.192.75
...
;; ANSWER SECTION:
75.192.213.147.in-addr.arpa. 86400 IN	PTR	alice.saske.sk.


[root@strela ~]# mount -t nfs strelads.jinr.ru:/volume1/data /mnt/strelads_data/ # OK
Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /usr/lib/systemd/system/rpc-statd.service.