Linux tips

Dieu a sagement agi en plaçant la naissance avant la mort ; sans cela, que saurait-on de la vie ?
Alphonse Allais

  • fortran

c write integer into character

character, (LEN=xx) :: char
write(char(1:1),'(i1)') intg

c write character into integer

integer :: intg
read(char(3:3),'(i1)') intg

c loops optimizations

do j = 1,n
do i = 1,p
a(i,j) = ...

if (n>m)

do j = 1,n
do i = 1,p
x = ...
  • f90

findent -ofree < source.f > \${source/.f/.f90}

gprof binstar.e | > prof.dat
xdot prof.dat

  • advanced batch command

for i in `ls *.ps` ; do mv \$i \${i/ps/eps} ; done

  • find

\find . -uid 104 -exec chmod o-r '{}' \;
\find . -name \*.hr.bz2 -exec sh -c "basename {} | sed s/\.hr\.bz2//" \;
\find . \( -name \*.v2 -o -name \*.v2.1 \) | grep -v bz2 | grep -v gz

  • advanced grep
Display all lines matching crz(arg) =grep crz'(\w*)\s\?=' *.f
Display any lines starting with a dot and digitgrep '^\.[0-9]'
Display any lines containing ,d[digit]grep ,d\[0-9\] *.f

  • a2ps

a2ps --medium=A4 --columns=1 --font-size=7 lover0.tpagb -o
pdftops -level3 b3.pdf - | psbook | psnup -2 -W5.5in -H8.5in | ps2pdf - booklet.pdf

  • merge pdf

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf

  • configure Apache server

in /etc/apache2/mods-enabled :
ln -s ../mods-available/userdir.conf
ln -s ../mods-available/userdir.load

  • svn

ssh -g -L 12345:localhost:12345
svn checkout --username user --password xxx svn://localhost:12345/home/user/svn_repos/
svn propset svn:executable ON file.exe
svn propedit svn:log --revprop -r NNNN --editor-cmd vim

svn propset svn:keywords "Date Rev Author" file.f90

  • vi settings

in .vim/scripts.vim, add the following lines
:set nowrap
:set noautoindent

  • setup eduroam connection

in wpa_supplicant.conf, add the following lines
identity="YourHomeNetID Login"
password="YourHomeNetID Password"
may need to get certificate from : GTE Cyber Trust Global Root

  • Patch

diff originalfile updatedfile > patchfile.patch
patch originalfile -i patchfile.patch -o updatedfile

Patching multiple files

diff -c originaldirectory/ updateddirectory/ > patchfile.patch
patch -i patchfile.patch

Reversing an applied patch

patch -p0 -R -i patchfile.patch


  • at - command to schedule actions

at now + 1 minutes < .cmd

  • sux - su with DISPLAY export

in /etc/pam.d/su add the following line:
session optional

  • emacs - tricky replacements

ALT % Ctrl Q ^J new_partern

  • sshfs syntax

from host, type: sshfs ~/dir2

to unmount fusermount -u ~/dir2

  • ssh tunnel firefox

ssh -D 9999 -C

Firefox> Edit> Preferences> Advanced tab> Network tab> Settings button.

Select Manual proxy configuration
SOCKS Host: localhost Port: 9999
No Proxy for: localhost,

  • ssh and known_hosts

Simply omit the -f flag to operate on ~/.ssh/known_hosts

# Add entry for host
ssh-keyscan -H > /path/to/known_hosts

# Scan known hosts
ssh-keygen -f /path/to/known_hosts -H -F

# Count matches for host
ssh-keygen -f /path/to/known_hosts -H -F | wc -l

# Remove entry for host
ssh-keygen -f /path/to/known_hosts -R

  • keyborad : change repeat rate

xset r rate 300 40

xset r rate 200 60

  • deborphan problem

egrep '^Status: |^Package: ' /var/lib/dpkg/status | egrep -B 1 'half-installed|half-configured|unpacked|triggers-awaited|triggers-pending'

deborphan --guess-data | xargs sudo apt-get -y remove --purge

  • wps fix


  • virtualbox patch

cd /usr/src/virtualbox-5.2.0 patch -p1 < linux-4.14-host.patch dpkg-reconfigure virtualbox-dkms modprobe vboxdrv

  • sddm

to set the keyboard in the login screen, add the following line to /usr/share/sddm/scripts/Xsetup

setxkbmap "be,us"

oggdec -o recording.wav recording.ogg