Linux tips

  • 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) = ...
enddo
enddo

if (n>m)

do j = 1,n
do i = 1,p
x = ...
enddo
enddo
  • 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 lover0.ps
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

  • svnserver

ssh -g -L 107xx:localhost:107xx user@astro.ulb.ac.be
svn checkout --username user --password xxx svn://localhost:12345/home/user/svn_repos/

  • 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
network={
ssid="eduroam"
key_mgmt=WPA-EAP
group=TKIP
eap=TTLS TLS
identity="YourHomeNetID Login"
password="YourHomeNetID Password"
phase2="auth=MSCHAPV2"
}
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

tutorial

  • at - command to schedule actions

at now + 1 minutes < .cmd

  • emacs - tricky replacements

ALT % Ctrl Q ^J new_partern

  • sshfs syntax

sshfs machine.ulb.ac.be:/home/user/dir ~/dir2

  • ssh tunnel firefox

ssh -D 9999 -C me@ipaddress.com

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

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

  • ssh and known_hosts

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

# Add entry for host
ssh-keyscan -H astro.ulb.ac.be > /path/to/known_hosts

# Scan known hosts
ssh-keygen -f /path/to/known_hosts -H -F astro.ulb.ac.be

# Count matches for host
ssh-keygen -f /path/to/known_hosts -H -F astro.ulb.ac.be | wc -l

# Remove entry for host
ssh-keygen -f /path/to/known_hosts -R astro.ulb.ac.be

  • keyborad : change repeat rate

xset r

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'

  • wps fix

export WPS_NO_KDE_NATIVE_DIALOG=1

  • virtualbox patch

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

oggdec -o recording.wav recording.ogg