Achim's LINUX Tips from Thu Apr 4 22:03:54 CEST 2002
Oneliners
Print size of needed libraries:
ldd $1 | awk '{print $3}'|xargs ls -lL |awk '{s+=$5}END{print s}'
Oneliners:
netstat -a #will allow you to see all the tcp and udp ports your system has open.
x9: route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
To get the size of all directories in the current directory:
find . -maxdepth 1 -type d -print | xargs du -sk | sort -rn
---
ls -l aeg.sh; ls -lut aeg.sh ;ls -lcT 19 aeg.sh
mount -t tmpfs /dev/total_egal /mnt
dpkg-repack
find . -ctime ... # inode changed
tune2fs -c0 -i0 /dev/hdaX # do not do fsck wheen booting
hdparm -d 1 /dev/hda # DMA ein
hdparm -Y /dev/hda # sleep
#======================================================0
Remote X-Display
Besser ist das Tool xauth, das exakt einem User gezielt den Desktop freigibt.
Hierbei extrahiert der User einen Schlüssel aus seiner automatisch angelegten
.Xauthority-Datei, übergibt ihn dem Remote-User, der ihn seiner .Xauthority hinzufügt.
Anschließend muss jener seinen Anwendungen über
die Variable DISPLAY noch mitteilen, auf welchem Desktop die Ausgabe erfolgen soll:
jo@planet ~> xauth extract schluesseldatei $DISPLAY
jo@planet ~> su -
root@planet:~> xauth merge /home/jo/schluesseldatei
root@planet:~> DISPLAY=:0.0; export DISPLAY
or direct :~> xauth merge /home/jo/.Xauthority
ssh: X11-forwarding.
It is disabled by default now for security reasons. You need to
explicitly enable by the parameter -X, if you want to use it.
You may also enable it by default by changing it globally (or
selectively for certain hosts) by setting "ForwardX11 yes" in
/etc/ssh/ssh_config.
Users may do it individually by putting this statement in their
~/.ssh/config.
There is in the default configuration disabled the use of ipv6.
The ipv6 is fully functional, to enable it you have to comment
out line 'ListenAddress 0.0.0.0' in the file '/etc/ssh/sshd_config'.
gepiepe abstellen
in X11: xset b 0
in vt100: setterm -blength 0
Blank Screen
setterm -blank 0
xset s blank/noblank
Start von serieller console zum Installieren
/etc/lilo.conf:
console=ttyS0
serial=0,9600n8 (>SuSE 8.0)
ohne VGA-Card ist das default!
configure wget
.wgetrc:
login="USERNAME"
passwd="xxxx"
wget ftp:~//xx.yy.zz/dir/* -O $HOME/download
Login f. root erlauben
/etc/securettys
FTP-DIR
/etc/pam.d/ftpd:
auth sufficient /lib/security/pam-ftp.so
ln -s /user /usr/local/pub/NTSRV-BACKUP
Mehrere PDF's auf ein File
gs -dBATCH -DNOPAUSE -sDEVICE=pdfwrite -q -dSAFER -sOutputFile=out.pdf file1.pdf file2.pdf ...
Postscript Tools
fixps, fixpspps, psbb, psselect, extractrees, pstops
fixwfwps<WORD.ps>out.ps Korigiert M$-Word PS-output
fixdlsrps
M$-Word Converters
wvAbw, wvHtml, wvLatex, wvCleanLatex, wvPS,
wvDVI, wvPDF, wvRTF, wvText, wvWml,
wvMime,catdoc, word2x, antiword
EXCEL xlhtml
HP-UX
Installation (CDROM PRI Jumper off)
search
boot pri isl
isl> hp-ux -is # Booten single user modes
awk -F":" '{gsub(passwd\/",""); print $0}' etc/passwd
Booten von CD
boot scsi.2.0
/sbin/set-parms add-network
Appliing an patch
gzip -cd < ../linux-9.9.9-ea-0.0.0.patch.gz | patch -p1
patch -p1 < linux-9.9.9-ea-0.0.0.patch
Encyption w. pgp
ONCE: pgp -kg
pgp -e filename
pgp -d filename.pgp
Perl CR-LF- conversion
perl -npe 's/\r$//' < infile > outfile
Update MBR
sfdisk -d /dev/hda > hda.out
sfdisk /dev/hda < hda.out
sfdisk -R /dev/hda # update kernel w. partition table
SAMBA
samba: strict locking = off
Oneliners
wget -r(ecursive) -c(ontinue) http://x.y.z/dir
On some brain-dead systems (actually, IRIX and HP-UX), Ctrl-C
and other control keys do not work correctly. Fix it with:
stty intr "^C" erase "^H" eof "^D" susp "^Z" kill "^U"
## Attach some files with your message
email -s "files attached" Dean,Jeff --attach stuff.tar.gz,readme.doc#
DEBIAN-SELECTION:
env COLUMNS=180 dpkg -l | grep ^ii > $(uname -nr| tr " " "-").knoppix-.$(mount | grep " / " | awk -F "/" '{print $3}' | awk '{print $1}').list
ps auxww | awk '/in\.tftpd/{if(!/awk/){print $2}}'
#
BASH
X=$(($X+1)); echo $X
X=0 ;while [ "$X" -lt 255 ]; do X=$(($X+1)); echo -n "$X "; done
xterm -e bash -c 'X=0 ;while [ "$X" -lt 9 ]; do X=$(($X+1)); xhost 192.168.1."$X "; done'
CONFIG_NETFILTER=y # 2.4.20+ if dhcp is not working
tar zcvf /dev/fd0 $( find TODO/ bin -maxdepth 1 -type f -a ! -name "*~" )
(X :1 &);sleep 6 ;(xterm -display :1 -e icewm &);xterm -display :1
cd /usr/src/linux ; patch -p1 < ../xfs-2.4.21.patch
# Up to which date files can be safed on a 97 MB tape
tar cvvf /dev/null /user | sort -k 4 | awk '{s+=$3; if ( s < 97*1024*1024) {DATE=$4};printf "%12.3f %s %s %s %s %s %s %s %s %s %s %s %s\n",s/1024/1024,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15}END {print DATE}'
#--
Check HD w. badblocks
1) badblocks -w -c 1024 -vv -o /root/badblocks.list /dev/hda1
2) mke2fs -l /dir/file /dev/hda1
1)u.2) mke2fs -cc /dev/hda1
Perl: replace strings in multiple files
#!/usr/bin/perl -w
while() {
chomp;
if(-x and ($null,$null,$mode)=stat and $mode & 040000) {
next;
}
$file=$_;
system("/bin/cp -p $file $file.tmp$$");
open(F1,"$file");
open(F2,">$file.tmp$$");
while () {
s/$ARGV[0]/$ARGV[1]/;
print F2;
}
close(F2);
close(F1);
system("/bin/mv $file.tmp$$ $file");
}
To use this, pipe in the file names you want replaced, and use argument one and
two on the command line for your search phrase, and your replace phrase. Exampl
e, assuming that you
made this an executable named replace:
find /home/httpd/html | replace 'speling' 'spelling'
---
Oneliners:
One nice way to copy an entire tree of files and still retainsymbolic links, is:
tar cvf - . | (cd /new/dir; tar zxvf -)
#tar -C /old/dir -cvf - . | tar -C /new/dir -xvf -
netstat -a #will allow you to see all the tcp and udp ports your system has open.
x9: route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
tail -f /var/log/messages > /dev/tty12
To get the size of all directories in the current directory:
find . -maxdepth 1 -type d -print | xargs du -sk | sort -rn
---
ls -l aeg.sh; ls -lut aeg.sh ;ls -lcT 19 aeg.sh
mount -t tmpfs /dev/total_egal /mnt
tar zcvf - /das/dir ssh userATcompi "cat > /bla/bla/x.tar.gz"
dpkg-repack
find . -ctime ... # inode changed
tune2fs -c0 -i0 /dev/hdaX # do not do fsck wheen booting
hdparm -d 1 /dev/hda # DMA ein
hdparm -Y /dev/hda # sleep
CONFIG debian:
/etc/networks/*
/etc/default.keytab
Edit the file /etc/init.d/keymap.sh and change the line: loadkeys /usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz
Die /etc/network/interfaces und das "up"-Kommando verwenden:
iface eth0 inet static
address a.b.c.d
netmask 255.255.255.0
network a.b.c.0
broadcast a.b.c.255
gateway a.b.c.1
# hier kommts:
up route add -net w.x.y.0 netmask 255.255.255.128 gw a.b.c.2
Wenn eth0 up gesetzt wird, gibts zusaetzlich die angegebene Route
hinter dem "up"-Schluesselwort.
DHCP:
auto eth0
iface eth0 inet dhcp
Passwordchange in batch
chpasswd<<EOF
root:xxxx
EOF
Zeitsyncronisation
rdate ,ntpdate,netdate,xntpd,ntpd
telnet p133-10 13
server ntp.conf:
server 192.168.118.200
fudge 192.168.118.200 stratum 10
client:
server 192.168.118.200
crontab:
* * * * * root ntpdate -B
Set Date
date -u -s ` telnet 131.107.1.10 13 |grep UTC |cut -b16-23 `
KEYBORD:
Create the good ~/.Xmodmap :
Dump the actual mapping :
xmodmap -pke > ~/.Xmodmap
Modify it like this :
keycode 115 =
keycode 116 = Multi_key
add Mod4 = Multi_key
keycode 117 =
Use this .xinitrc :
xmodmap ~/.Xmodmap
Windows
CYGWIN:
/cygdrive/c/shutdown.exe /C /L /Y /R /T:00\r
mount -b //./a: /dev/fd0
If you want to use raw devices with cygwin you have to mount them.
Some examples:
mount -f -b -s //./F: /dev/hdb2 # partition
mount -f -b -s //./physicaldrive0 /dev/hda # hard disk
mount -f -b -s //./tape0 /dev/st0 # rewind tape
mount -f -b -s //./tape0 /dev/nst0 # same as norewind
In further commands you have to use the mountpoints for correct
results:
dd if=/dev/hdb2 of=/dev/null bs=1024k
zero | dd of=/dev/hdb2 bs=1024k