Tools

Unix Sed Tutorial: Advanced Sed Substitution Examples

Sed Substitution Delimiter As we discussed in our previous post, we can use the different delimiters such as @ % | ; : in sed substitute command. Let us first create path.txt file that will be used in all the Beispielen mentioned below. cat path.txt /usr/kbos/bin:/usr/local/bin:/usr/jbin:/usr/bin:/usr/sas/bin /usr/local/sbin:/sbin:/bin/:/usr/sbin:/usr/bin:/opt/omni/bin: /opt/omni/lbin:/opt/omni/sbin:/root/bin Beispiel 1 sed @ delimiter: Substitute /opt/omni/lbin to /opt/tools/bin When you substitute a path name which has ‘/’, you can use @ as a delimiter instead of ‘/’. In the sed Beispiel below, in the last line of the input file, /opt/omni/lbin was changed to /opt/tools/bin. sed 's@/opt/omni/lbin@/opt/tools/bin@g' path.txt /usr/kbos/bin:/usr/local/bin:/usr/jbin/:/usr/bin:/usr/sas/bin /usr/local/sbin:/sbin:/bin/:/usr/sbin:/usr/bin:/opt/omni/bin: /opt/tools/bin:/opt/omni/sbin:/root/bin Beispiel 2 sed / delimiter: Substitute /opt/omni/lbin to /opt/tools/bin When you should use ‘/’ in path name related substitution, you have to escape ‘/’ in the substitution data as shown below. In this sed Beispiel, the delimiter ‘/’ was escaped in the REGEXP and REPLACEMENT part. sed 's/\\/opt\\/omni\\/lbin/\\/opt\\/tools\\/bin/g' path.txt /usr/kbos/bin:/usr/local/bin:/usr/jbin/:/usr/bin:/usr/sas/bin /usr/local/sbin:/sbin:/bin/:/usr/sbin:/usr/bin:/opt/omni/bin: /opt/tools/bin:/opt/omni/sbin:/root/bin Sed ‘&’ Get Matched String The precise part of an input line on which the Regular Expression matches is represented by &, which can then be used in the replacement part. Beispiel 1 sed & Usage: Substitute /usr/bin/ to /usr/bin/local sed 's@/usr/bin@&/local@g' path.txt /usr/kbos/bin:/usr/local/bin:/usr/jbin/:/usr/bin/local:/usr/sas/bin /usr/local/sbin:/sbin:/bin/:/usr/sbin:/usr/bin/local:/opt/omni/bin: /opt/omni/lbin:/opt/omni/sbin:/root/bin In the above Beispiel ‘&’ in the replacement part will replace with /usr/bin which is matched pattern and add it with /local.

Continue reading

Installation MoBlock

Installation MoBlock Leider wird PeerGuardian für Linux nicht mehr weiterentwickelt. Deshalb hab ich nun MoBlock probiert: http://moblock.berlios.de/ http://moblock-deb.sourceforge.net/ Quelle und weitere Infos: http://doc.gwos.org/index.php/Moblock Eine .rpm Version gibt es unter: wget http://rpm.pbone.net/index.php3/stat/4/idpl/3499655/com/moblock-0.8-2mdv2007.1.i586.rpm.html Installation: rpm -Uhv moblock\*\*.rpm Beim Installieren kommt oft eine Fehlermeldung wie diese: Ausgabe: postinst called with unknown argument `1’ error: %post(moblock-ipq-0.8-16.i386) scriptlet failed, exit status 1 Die kann aber anscheinend ignoriert werden, da sich moblock auch so starten lässt: MoBlock start: moblock -d ipfilter/ipfilter\_full.dat Moblock bricht aber ab mit folgender Fehlermeldung: _Ausgabe:_ MoBlock: Failed to send netlink message: Connection refused Folgendes verschafft Abhilfe: modprobe ip\_queue Läuft MoBlock nun? ps aux | grep moblock _Ausgabe:_ root 15919 6.9 4. 95656 24832 pts/2 S 19:03 0:01 moblock -d ipfilter/ipfilter\_full.dat root 15912 0.0 0.1 3852 742 pts/1 R+ 19:03 0:00 grep moblock Die Ausgabe von moblock beim Starten ist: moblock -d ipfilter/ipfilter\_full.dat moblock.log _Ausgabe:_ Logging to moblock.log Ranges loaded: 222533 Using .dat file format Merged ranges: 0 Skipped useless ranges: 0 Im Logfile steht nach dem Starten das hier: cat moblock.log _Ausgabe:_ Duplicated range ( IANA - Multicast, Bog ) Duplicated range ( IANA - Multicast, B ) Duplicated range ( IANA - Multicast, ) Duplicated range ( ) Duplicated range ( ) Duplicated range ( ) Duplicated range ( ) Duplicated range ( ) Duplicated range ( ) Ranges loaded: 222533 Merged ranges: 0 Skipped useless ranges: 0 Testen ob Moblock läuft:

Continue reading

MJPG-Streamer

MJPG-Streamer Zum Verständnis dieses Artikels sind folgende Seiten hilfreich: Ein Terminal öffnen Programme kompilieren Ein Programm starten MJPG-Streamer ist ein Werkzeug für die Kommandozeile, mit dem sich Videodaten von einer Webcam oder einer anderen Videoquelle als Motion-JPEG (M-JPEG/MJPG) streamen lassen. Während moderne Netzwerkkameras einen solchen Stream automatisch erzeugen, kann mit Hilfe des Programms auch eine einfache Webcam mittels eines Rechners mit Internet-Zugang zu einer solchen umfunktioniert werden. Voraussetzungen Zum Betrieb eines Webstreams muss die Webcam zunächst korrekt eingerichtet sein. Bei einigen Modellen muss zunächst ein Treiber für Video 4 Linux 2 installiert werden. Wenn die Kamera aber unter anderen Programmen funktioniert, entfällt dieser Schritt. Installation MJPG-streamer ist nicht in den offiziellen Paketquellen enthalten und muss selber kompiliert werden, dafür werden folgende Pakete benötigt: build-essential libjpeg-dev imagemagick subversion libv4l-dev (optional) checkinstall (optional) Paketliste zum Kopieren: sudo apt-get install build-essential libjpeg-dev imagemagick subversion libv4l-dev checkinstall sudo aptitude install build-essential libjpeg-dev imagemagick subversion libv4l-dev checkinstall Der aktuelle Quelltext wird aus dem SVN-Projektarchiv heruntergeladen svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer Nun wechselt man in das erstellte Verzeichnis mjpg-streamer/mjpg-streamer. ​ cd mjpg-streamer/mjpg-streamer und kompiliert bzw. installiert das Programm entweder auf die klassische Weise ​ make sudo make install oder mit checkinstall (dann kann das Programm leicht wieder deinstalliert werden).

Continue reading

mod_rewrite aktivieren

Lösung oder Tipp zum aktivieren des Apache Moduls mod_rewrite unter SUSE Linux 10.3: Dieses Modul ist unter anderem wichtig, damit ein Apache Webserver die Fähigkeit erhält URL’s der Form php?=352354?abec=3453 in eine Suchmaschinen “freundliche” Form wie datei.html zu bringen. Getestet bei SUSE Linux 10.0 - 10.3 mit Plesk 8 - 8.3 (bei Strato) Es reicht nur ein Befehl reicht: root:/# a2enmod rewrite Danach Apache neustarten: root:/# rcapache restart Oder gleich den Server neustarten: root:/# reboot Natürlich kann man andere Apache Module auch so laden (ohne das “mod_” davor) und wieder entfernen mit dem Befehl: a2dismod .....

Continue reading

Webmin – A Web Based System Administration Control Panel for Linux

Webmin is an open source web based system configuration application for Linux system administration. With the help of this tool we can manage internal system configuration such as setting up user accounts, disk quotas, services configuration like Apache, DNS, PHP or MySQL, file sharing and much more. Webmin applications is based on Perl module and it uses TCP port 10000 with OpenSSL library for communicating via browser. Webmin team has released latest Webmin 1.740 version on 15th March, 2015, which contains lots of major fixes and changes, more consistent and themeable Web user. What’s New in Webmin 1.740 New awesome Authentic Theme by Ilia Rostovtsev has been added. Added more German translation updates. Editing support has been added for DMARC DNS records, which are specially encoded TXT records for determining the response to SPF and DKIM violations. SSL connection option added when Webmin sends mail to remote mail server like Gmail that doesn’t allow unencrypted SMTP connections. Module access control options added to minimize visible system status details on a user basis. A new button to reload Postfix mail configuration. This brief tutorial will explain you how to install latest Webmin in Linux systems. I assume that the following installation guidelines will work on all major Linux flavours like RHEL, CentOS, Fedora and Debian, Ubuntu, Linux Mint.

Continue reading