Category: Linux

Linux Tips and tricks, either for desktop or internal system.

Linux

Problem: The ssh public key authentication doesn’t work

Try changing the permissions on .ssh/authorized_hosts to restrict READ AND WRITE to your user eg. chmod go-rw ~/.ssh/authorized_hosts SSH doesn’t like it when these files are world-readable Assuming that you wish to login to the machine called mystery from your current host with the id_rsa and id_rsa.pub files you’ve just generated you should run the …

Linux

Installing ZABBIX on Debian(Etch and Lenny)

ZABBIX ====== http://www.zabbix.com [^] This is an open source and seems quite good. It is available through Debian Repository as packages: zabbix-frontend-php (for central monitoring host) installed in monitoring server zabbix-server-mysql (for central monitoring host) installed in monitoring server zabbix-agent (for each monitored host) Installed in ALL 8 Hosts The mysql data: DB: zabbix user: …

Linux, XEN

Stop/Start a single XEN virtual machine

Assuming that the virtual machine is running, to stop the machine: – Make a list of the running virtual machines and note the ID of the one concerned. xl list Lets suppose the ID of the virtual machine concerned is 15 – Shutdown the machine. xl shutdown 15 – Make a few xm list commands …

Apache

Compile Apache 2 in Debian/Ubuntu/Mint/..

Introduction: Steps to compile Apache: – Installation of needed development packages – Prepare the directories needed – copy the config file and script below – Run the script below Installation of needed development packages Needed for Apache mod_deflate libzip-dev (sources) libzip1 (bin libs.) zlib1g-dev (sources) Needed for Mod_security libpcre3-dev libpcrecpp0 libxml2-dev Compiling script Configuration file …

Linux, MAC OS X

Using iTERM – The best terminal program for Linuxers

Configuration file: The full Config Plist is ~/Library/Preferences/com.googlecode.iterm2.plist it seem that it may be used to store the defaults values at startup, but the main one is the first one. Modifying/replacing the configuration file: Preferences are cached in 10.9. See http://hints.macworld.com/article.php?story=20130908042828630. If you edit a plist file directly or replace the plist of an application, …

Apache

Compiling a new standard Apache DSO module

# Build and install a distributed Apache module, say mod_foo.c, into its own DSO mod_foo.so: * Build and install via configure (preferred): $ ./configure –prefix=/path/to/install –enable-shared=foo $ make install * Build and install manually: – Edit src/Configuration: > SharedModule modules/xxxx/mod_foo.so $ make $ cp src/xxxx/mod_foo.so /path/to/install/libexec – Edit /path/to/install/etc/httpd.conf >> LoadModule foo_module /path/to/install/libexec/mod_foo.so # Build …

Apache

MOD GZIP Configuration in Apache 1.3.x

NOTE: The size of the zipped content(not header) is about 1/3 of original size. mod_gzip_command_version ‘/mod_gzip_status’ mod_gzip_temp_dir /tmp/mod_gzip_httpd mod_gzip_keep_workfiles No mod_gzip_minimum_file_size 1000 mod_gzip_maximum_file_size 100000 mod_gzip_maximum_inmem_size 60000 mod_gzip_min_http 1000 mod_gzip_handle_methods GET mod_gzip_item_include file \.html$ mod_gzip_item_include file \.jsp$ mod_gzip_item_include file \.do$ mod_gzip_item_include mime text/html mod_gzip_item_include mime text/plain mod_gzip_item_include mime application/x-javascript mod_gzip_item_include mime text/css mod_gzip_item_include mime text/xml mod_gzip_item_include …

Apache

Problem with openssl and Compiling Apache 2.2.11

Ursache ist, dass die Pfade richtig gesetzt werden müssen, damit ld den Parameter -lssl kennt. export LD_LIBRARY_PATH=”/www/hans/src/openssl-0.9.8j/” export LIBS=”-L/www/hans/src/openssl-0.9.8j” export CPPFLAGS=”-I/www/hans/src/openssl-0.9.8j/include/openssl” echo $LD_LIBRARY_PATH /www/jamba/src/openssl-0.9.8j/:/usr/lib/ echo $LIBS -L/www/jamba/src/openssl-0.9.8j echo $CPPFLAGS -I/www/jamba/src/openssl-0.9.8j/include/openssl

Apache

Issues on MaxClients Directive

WARNING: MaxClients of 3000 exceeds compile time limit of 2048 servers, lowering MaxClients to 2048. To increase, please see the HARD_SERVER_LIMIT define in src/include/httpd.h. Why increase MaxClients to 2048? Apache 1.x is non-threaded, so increasing MaxClients beyond 256 usually results in lower performance; often dramatically lower performance. At a prior job I worked with a …

Apache

GZIP Log Format

LogFormat “\”%h\” \”%{HOST}i\” \”%u\” \”%t\” \”%r\” \”%>s\” \”%b\” \”%{Referer}i\” \”%{User-Agent}i\” \”%{Connection}i\” \”%{Connection}o\” \”%{Content-Type}o\” \”%T\” \”PID:%P\” \”%{mod_gzip_result}n\” \”%{mod_gzip_input_size}n\” \”%{mod_gzip_output_size}n\” \”%{mod_gzip_compression_ration}n\”” JAMBA_BASIS_LOGFORMAT_GZIP

Apache

Using mod_cband to limit bandwidth per vhost

mod_cband (http://cband.linux.pl) can do this from 0.9.6.0 version! You should use CBandExceededSpeed directive to slow down pages when the bandwidth is exceeded 🙂 See: http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling http://www.icewalkers.com/Linux/Software/524590/mod_cband.html http://www.montanalinux.org/mod_cband.html http://www.uno-code.com/?q=node/64

Apache

MPM ‘worker’ configuration (Apache2)

Directive Description Default (worker.MPM) ===================== =============================================================================== ==================== ListenBackLog Maximum length of the queue of pending connections 511 . MaxClients Global maximum number of connections that will be processed simultaneously 400 MaxClients SHOULD NOT be lower than (ServerLimit) x (ThreadsPerChild). Normally they should be equal. . ServerLimit Upper limit on configurable number of processes (children) 16 …

Apache

Logging Apache Access logs through syslogd

Error logs can be logged very easyly to syslig using the following ErrorLog syslog:local1 Access logs must use a pipe-to-script trick as follows: In Apache config: CustomLog |/usr/local/apache/bin/apache_syslog combined As script in system: Content of /usr/local/apache/bin/apache_syslog ——————————————— logger -i -p local3.info -t TEST-APACHE ——————————————— chmod 755 /usr/local/apache/bin/apache_syslog

Apache

Running mod_gzip, mod_rewrite, and mod_proxy together in Apache 1.3.x

When using RewriteRule ….[P] with mod_gzip there are often problems To resolve this add the following directive to mod_gzip ———————————————– mod_gzip_item_include handler proxy-server ———————————————– mod_gzip_item_include mime “application/x-httpd-php.*” mod_gzip_item_include mime httpd/unix-directory mod_gzip_item_include handler ^server-status$ mod_gzip_item_exclude file \.css$ mod_gzip_item_exclude file \.js$ mod_gzip_item_exclude reqheader “Via:.*1\.0 PROXY” mod_gzip_item_exclude reqheader “Via:.*1\.0 lavoisier \(NetCache NetApp\/5\.0\.1R2\)”

Apache

Examples of mod_security diretives

SecFilterEngine On SecFilterScanPOST On SecFilterSelective “POST_PAYLOAD” “BoesesWort” “deny,log,status:412” # Ersetze BoesesWort durch das Wort, welches du sperren willst. # Speichere die Textdatei unter dem Namen .htaccess (den führenden Punkt nicht vergessen) SecFilterSelective “POST_PAYLOAD” “AnderesBoesesWort” “deny,log,status:412” # Alternative SecFilterSelective “POST_PAYLOAD” “BoesesWort” “deny,log,redirect:http.//www.deinedomain.de/seite.html”

Apache

MOD_JK configuration directives

see: http://tomcat.apache.org/connectors-doc/generic_howto/timeouts.html The following directives are normally inserted in workers.properties file connection_pool_minsize (default 0) defines, how many idle connections remain when the pool gets shrinked. By default this is half of the maximum pool size. connection_pool_size (default 0) We generally do not recommend to use this attribute in combination with Apache httpd. For Apache httpd …

Apache

Logging gzip compression factor of files

LogFormat “%h %l %u %t \”%r\” %>s %b mod_gzip:%{mod_gzip_result}n In:%{mod_gzip_input_size}nOut:%{mod_gzip_output_size}n:%{mod_gzip_compression_ratio}npct.” full_plus_gzip [17:29:14] CustomLog /var/log/httpd/mod_gzip.log full_plus_gzip Example of log entry: /reviews/cooling/HSR2_4.html HTTP/1.1″ 200 6289 mod_gzip: DECHUNK:OK In:23352 Out:6289:74pct.

MySQL

Tool to unstick MySQL Replicators.

# I’m managing an infrastructure with a number of databases who # (for codified reasons that I cannot influence) suffer from this situation often. # So, I’ve written a cron script to manage the situation. # Does anyone see any foreseeable issues with this logic (see below)? # —————————————– SCRIPT —————————————– #!/bin/bash ## Tool to …

MySQL

PROBLEM: Could not find target log during relay log initialization

SOLUTION: delete relay bin file in slave and try slave stop ; CHANGE MASTER TO master_log_file=’name_of_current_file_on_master’,master_log_pos=4; slave start; it will download play again the file IMPORTANT: Make sure the master log file is the one that was being read by the slave when the error occured, otherwise you loose data.

MySQL

FULL Manual rebuilding of SLAVE MySQL server mysql02 from Master mysql01

On mysql01 (MASTER): ——————– mysqldump -u root -p –single-transaction –flush-logs –master-data=2 –all-databases –delete-master-logs | gzip | ssh mysql02 ‘cat | gunzip >/var/lib/mysql_temp.sql’ echo “SHOW MASTER STATUS;” | mysql -p -u root Note the filename eg. mysql-bin.000299 we will use it later on mysql02 On mysql02 (SLAVE): ——————- – Changed the following config is in /etc/mysql/my.cnf …

MySQL

MySQL replication issues

Good links: =========== http://www.howtoforge.com/how-to-repair-mysql-replication MySQL recover from Backup .sql data ====================================== mysql -u root -p dbName backup-dbNameDump.sql ———– Very useful in slave ————————————————————– slave-skip-errors=126,1062 126 = the ambiguous ‘unknown error on master’ typically caused by tables in dis-repair on master. 1062 = duplicate entry (happens all the time on high capacity db in master-master setup)

Linux

Benchmarking and brute force testing of RAMs and CPU with STRESS

apt-get install stress $ stress –cpu 4 –vm 2 –vm-bytes 2G –timeout 60s $ stress –cpu 4 –vm 2 –vm-bytes 15G –timeout 1800s Belegt für 60s vier CPUs und 2 GB RAM. Funktioniert auch als normaler User, als root aber aggressiver, würde ich nach kurzem Test sagen. Hoffentlich lassen sich auch 16 GB belegen. Mit …

Linux

To install Skype on AMD64 Linux system

AS ROOT: – Download the sykpe static version from: http://www.skype.com/go/getskype-linux-static and unpack it in /usr/local/skype cp /usr/local/skype/skype /usr/bin mkdir /usr/share/skype cp -a /usr/local/skype/avatars /usr/local/skype/icons /usr/local/skype/lang /usr/local/skype/sounds /usr/share/skype/ apt-get install ia32-libs AS USER: – Create a launch icon on desktop that runs: linux32 skype

Linux

Logging all bash commands with user and timestamp

From: http://azio.org/2007/10/10/eternal-bash-history-super-duper-useful/ in /etc/profile and in /etc/bash.bashrc ———————————————————————– export HISTTIMEFORMAT=”(%d.%m.%Y) %H:%M ” export PROMPT_COMMAND=”${PROMPT_COMMAND:+$PROMPT_COMMAND ; }”‘echo “`date +’%d.%m.%y-%H:M:%S:’`” $USER “(“$ORIGINAL_USER”)” \ “COMMAND: ” “$(history 1 | cut -c8-)” >> /var/log/bash_eternal_history’ readonly PROMPT_COMMAND ———————————————————————– and then as root run the commands: touch /var/log/bash_eternal_history chmod 777 /var/log/bash_eternal_history chattr +a /var/log/bash_eternal_history

Linux

Preventing changes of variables through ssh session

– Make sure that the setting AcceptEnv is not set in /etc/ssh/sshd_config AcceptEnv Specifies what environment variables sent by the client will be copied into the session’s environ(7). See SendEnv in ssh_config(5) for how to configure the client. Note that environment passing is only supported for protocol 2. Variables are specified by name, which may …

Linux

Install WAP-Browser on Firefox

1. Install WML-Browser: https://addons.mozilla.org/en-US/firefox/addon/62 2. Install User Agent Switcher: https://addons.mozilla.org/en-US/firefox/addon/59 3. Install XHTML Mobile Profile: https://addons.mozilla.org/en-US/firefox/addon/1345 4. Restart Firefox 5. Download this file to your desktop: http://techpatterns.com/downloads/firefox/useragentswitcher.xml (Right mouse button “Save Link As”) or http://techpatterns.com/downloads/firefox/useragentswitcher.xml 6. Go to: Tools -> User Agent Switcher -> Options -> Options 7. Click on Import and select the *useragentswitcher.xml* …