Linux:Tips Tricks

From StrelaWiki
Jump to navigation Jump to search

user config

wget -O ~/.gitconfig
wget -O ~/.emacs
wget -O ~/.astylerc


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 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 sqlite   # need for tab completion of package names in DNF
dnf repolist
dnf repository-packages rpmfusion-nonfree remove
dnf repository-packages rpmfusion-nonfree list
$ yum list \*spell\*
$ yum search all zenity
$ yum provides /etc/httpd\*
$ yum provides \*/
$ 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

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
$ yum install --nogpgcheck         # mediainfo
$ yum install --nogpgcheck   # flash-plugin, skype

disable xdg-user-dirs



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]
Comment=Example program
Exec=program-name           # Exec=/path/to/exec/program-name
Icon=program-name           # Icon=/path/to/icons/program-name.png


  • 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
$ unset MANPATH
$ manpath
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

.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
|& pipes both stdout and stderr of one command into the standard input of another one. Very useful, available in bash version 4 and above
&& executes the right-hand command of && only if the previous one succeeded
|| executes the right-hand command of || only it the previous one failed
; 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


# GNOME settings: Language => 'en_US.UTF-8' and Formats => 'en_GB.UTF-8'
$ locale

$ locale -ck LC_PAPER

$ export LC_PAPER=en_US.UTF-8
$ locale -ck LC_PAPER
  • 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)


export LC_PAPER='en_GB.UTF-8'
export LC_TIME='en_GB.UTF-8'


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


cd /net
cd strela205


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

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


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 -sP
nmap -sn
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/
00007ff4fb4ab000   2044K -----  /cern/root_v5.34.06/lib/
00007ff4fb6aa000    168K r----  /cern/root_v5.34.06/lib/
00007ff4fb6d4000     56K rw---  /cern/root_v5.34.06/lib/
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

yum install libasan liblsan libtsan libubsan

-fsanitize=address -fno-omit-frame-pointer

$ g++ -Q --help=warnings > warnings_default
$ g++ -Wextra -Q --help=warnings > warnings_extra
$ g++ -Q --help=common | grep sanitize
$ g++ -Q --help=warnings | grep format
  -Wformat-contains-nul       		[disabled]
  -Wformat-extra-args         		[disabled]
  -Wformat-nonliteral         		[disabled]
  -Wformat-security           		[disabled]
  -Wformat-y2k                		[disabled]
  -Wformat-zero-length        		[disabled]
  -Wformat=                   		0
  -Wsuggest-attribute=format  		[disabled]
$ g++ -Wformat=2 -Q --help=warnings | grep format
  -Wformat-contains-nul       		[enabled]
  -Wformat-extra-args         		[enabled]
  -Wformat-nonliteral         		[enabled]
  -Wformat-security           		[enabled]
  -Wformat-y2k                		[enabled]
  -Wformat-zero-length        		[enabled]
  -Wformat=                   		0x2
  -Wsuggest-attribute=format  		[disabled]

expand standard include files

echo '#include <stdlib.h>' | cpp -I/usr/include > stdlib-expand.h
echo '#include <stdlib.h>' | cpp -I/usr/include | grep size_t

check compiler defined macros

$ gcc -E -dM - < /dev/null
# GCC 5 => The default mode for C is now -std=gnu11 instead of -std=gnu89
# gcc (GCC) 5.1.1 20150422 (Red Hat 5.1.1-1)
$ gcc -E -dM - < /dev/null | grep -i stdc_ver
#define __STDC_VERSION__ 201112L

# gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
$ gcc -E -dM - < /dev/null | grep -i stdc_ver
$ gcc -E -dM -std=gnu89 - < /dev/null | grep -i stdc_ver
$ gcc -E -dM -std=gnu99 - < /dev/null | grep -i stdc_ver
#define __STDC_VERSION__ 199901L

gfortran static

$ dnf install gcc-gfortran       # libgfortran libquadmath libquadmath-devel
$ dnf install libgfortran-static # libquadmath-static
$ dnf install glibc-static       # libxcrypt-static

$ gfortran -static tidy.for -o tidy_static.exe


$ 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 -createdate .
$ exiftool -filename .
$ exiftool -filename -createdate -T .
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 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 .
$ 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

PDF and PS

pdf2ps vs pdftops

  • 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)

miscellaneous commands

apropos fopen

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

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

tar cvfz archive_name.tar.gz dirname/
tar xvfz archive_name.tar.gz
tar cvfj archive_name.tar.bz2 dirname/
tar xvfj archive_name.tar.bz2

ldd /usr/bin/skype | grep lib | awk '{print $3}' | xargs rpm -qf | sort | uniq
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

git clone --depth 1 git://

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

find /etc -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r

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)

# 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

a2ps --medium=a4 -r --columns=1 --font-size=11 -o magnet.txt
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

# 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

# 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
dnf install pngquant pngnq

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%
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
img2pdf --pagesize A4 --auto-orient --fit fill --creationdate "2004-11-11 11:11:11" -o all_out.pdf *_OK.png   # time is UTC
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

# quickly create a large file
fallocate -l 13G big13GB.dat

# 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*

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."

miscellaneous commands 2

rclone sync /home/musinsky/CLOUD_yandex/ remote_yandex: -v --dry-run
touch -d "2016-09-27 12:12:12" file.pdf

touch -r file.pdf
FFF=projekt_Piskunov.pdf; touch -d "`exiftool -T -d "%Y-%m-%d %H:%M:%S" -createdate $FFF`" $FFF
touch -d "`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)
$ 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

# dalej na studium
exiftool -if "$DateTimeOriginal ne $CreateDate" -Title="Timestamp discrepancy" -r FileOrDir

# 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 !!!

# 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
# count number of characters in filename (filename length)
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
    echo "processing file" $file
    iconv -f ISO_8859-1 -t UTF8 $file > $file.utf8
    mv $file.utf8 $file

$ 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

% FILE="example.tar.gz"
% echo "${FILE%%.*}"
% echo "${FILE%.*}"
% echo "${FILE#*.}"
% echo "${FILE##*.}"

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 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)

# 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


  • 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

Create new certificate => 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 []
    • 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:
    • 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 (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.


# copy "new" .globus dir
alienv enter VO_ALICE@AliPhysics::vAN-20160629-1

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
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

After configuring your browser you can use the page to see if the connection via the proxy work

Printing at SASKE

Configure for example printer in room 328, printer model HP LaserJet 4200

  • Select Device -> Network Printer -> AppSocket/HP JetDirect -> Location of the network printer
Device URI: socket://
Port: 9100
  • Select Device -> Network Printer -> Internet Printing Protocol (ipp) -> Enter device URI
Choose Driver: HP -> Models: LaserJet 4200 -> Drivers: HP LaserJet 4200 Series Postscript[en] (recommended)

Mail at SASKE

Webmail on saske:


Welcome on Central Mail, Slovak Academy of Sciences in Kosice ( Vasa posta je presmerovana na

Sendmail on


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', `')dnl
dnl #

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

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

Direct (simple) solution, edit /etc/mail/ file

# "Smart" relay host (may be null)


yum install libXScrnSaver


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


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


# 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 -S example
# run any program   (no nohup program & necessary)
# press C-a d   (detach)
# program running in the background

# screen -r example




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

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


/data *(ro)

/etc/fstab   /strela205-data   nfs   hard,intr,noac,actimeo=1,async,nosuid,nodev,sec=null,ro   0 0   /mnt/HD_video   nfs   defaults,ro   0 0


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

Google Chrome


PuTTY tunnels: L5901 (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
iptables -t nat -A PREROUTING -i eth0 -p tcp -d x.x.x.x --dport pop3 -j DNAT --to
output (LAN -> WAN)
iptables -t nat -A POSTROUTING -o eth0 -s -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -s -j SNAT --to-source x.x.x.x

SSH tunel

$ ssh -C -L 5901:localhost:5901

$ vncviewer localhost:1

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

$ ssh -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

Midnight Commander

wget -O /usr/share/mc/syntax/markdown.syntax
  • /usr/share/mc/syntax/Syntax
file ..\*\\.(md|markdown)$ Markdown
include markdown.syntax

file .\* unknown
include unknown.syntax
  • Markdown viewer

V principe "mdv" alebo "pandoc" a potom v mc cez lynx resp. w3m

Ak nemusim do tyerminalu, tak

        Open=(vlc %f >/dev/null 2>&1 &)
        View=%view{ascii} mediainfo %f 2>/dev/null
        View=%view{ascii} mediainfo %f 2>/dev/null

route LANpolis


Xtreamer NFS


/mnt/sdb5		192.168.0.XXX(ro,async,no_subtree_check,all_squash)
# systemctl enable nfs-server.service
# systemctl start nfs-server.service
rpcbind.service ~ portmap
  • problem s firewall/port(s):
    • Mount Daemon Port: 1058
    • NFS Server Port: 2049

Audacious compiling

install audacious (default to /usr/local)
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
cd audacious-plugins-3.x/



  • 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 -j ACCEPT                                                                                                                                                                                          
-A RH-Firewall-1-INPUT -s -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


dig -x

building KDevelop

export KDEDIR=/home/mucha/KDE4

potrebny kdelibs-4.8.1.tar.bz2 a kate-4.8.1.tar.bz2
instalacia nejakych Fedora balikov yum install automoc phonon-devel strigi-devel attica-devel dbusmenu-qt-devel

mkdir build
cd build
cmake ../kdelibs-4.8.1/ -DCMAKE_INSTALL_PREFIX=$KDEDIR
make install
mkdir build
cd build
cmake ../kate-4.8.1/ -DCMAKE_INSTALL_PREFIX=$KDEDIR
make install

potrebny kdevplatform-1.3.0.tar.bz2 a samotny kdevelop-4.3.0.tar.bz2

mkdir build
cd build
cmake ../kdevplatform-1.3.0/ -DCMAKE_INSTALL_PREFIX=$KDEDIR
make install
mkdir build
cd build
cmake ../kdevelop-4.3.0/ -DCMAKE_INSTALL_PREFIX=$KDEDIR
make install
export KDEDIRS=/home/mucha/KDE:/$KDEDIRS