Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, June 5, 2012

Linux Ubuntu 12.04 - Ati / AMD discrete graphics

After searching "A LOT" on the web, forums, etc... i found a page that has a tip that works to change linux xserver to discrete graphics.

http://thealarmclocksixam.wordpress.com/2012/03/23/ubuntu-12-04-and-hybrid-graphics-on-sony-vaio-s/

I used this on my laptop HP dv6

Here are the steps;
1. edit /etc/modprobe.d/blacklist.conf
 
2. add these 2 lines to the end of the file 
# radeon
blacklist radeon
 
3. edit /etc/rc.local
modprobe radeon
chown -R $USER:$USER /sys/kernel/debug
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
 
4. reboot and it should be good
 
5. you can check if it worked
cat /sys/kernel/debug/vgaswitcheroo/switch
 
no more fan's noise, no more temperature...
Very nice hack
 
:D

Friday, March 16, 2012

apt-get gpg keys problem

W: GPG error: http://volatile.debian.org lenny/volatile Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DFD993306D849617

Use the key id that is complaining

root@bt:/etc/apt# gpg --keyserver wwwkeys.eu.pgp.net --recv-keys DFD993306D849617
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key 6D849617 from hkp server wwwkeys.eu.pgp.net
gpgkeys: HTTP fetch error 6: Couldn't resolve host 'wwwkeys.eu.pgp.net'
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

root@bt:/etc/apt# gpg --keyserver wwwkeys.uk.pgp.net --recv-keys DFD993306D849617
gpg: requesting key 6D849617 from hkp server wwwkeys.uk.pgp.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 6D849617: public key "Debian-Volatile Archive Automatic Signing Key (5.0/lenny)" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
root@bt:/etc/apt# gpg --armor --export DFD993306D849617 | apt-key add -
OK

Friday, December 30, 2011

WPS - BTA vulnerability - reaver

WPS - Wifi Protected Setup - PIN BTA vulnerability

link to read:
https://code.google.com/p/reaver-wps/wiki/README

"...Reaver targets the external registrar functionality mandated by the WiFi Protected Setup specification.
Access points will provide authenticated registrars with their current wireless configuration (including the WPA PSK), and also accept a new configuration from the registrar."

nice =)

http://dshield.org/diary.html?storyid=12292

Monday, July 18, 2011

Linux - Ubuntu - 2 Media tips

Two quick Linux media tips:

- Webcam - Viewer / recorder
To use my webcam i found this great peace of software:
"GUVCView"

To install it on ubuntu (simply):
# apt-get install guvcview

And that's it, you can launch it and view / record or take snapshots with your webcam.

- ffmpeg - great tool to encode and transform your videos, avi, mpeg, mov...etc.
# apt-get install ffmpeg
and use it:
$ ffmpeg -formats
$ ffmpeg -i yourfile.ext -vcodec wmv2 -sameq -acodec wmav2 -f avi outfile.avi

I run into some trouble with the xvid codecs, but found the solution here:
https://wiki.ubuntu.com/ffmpeg


That's it.

Thursday, May 19, 2011

Socat - nifty tool ;)

Here's some tips to test "socat"

: connect to port 80
> socat - tcp4-connect:192.168.1.1:80
-----------------------------------------------------------

: connect to port 80 + verbose
> socat -d -d - tcp4-connect:192.168.1.1:80
-----------------------------------------------------------

: listen to port 80
> socat -d -d - tcp4-listen:80
-----------------------------------------------------------

: Port forward : listen on port 443 -> send to 80 of the host
> socat -d -d tcp4-listen:443 tcp4:192.168.1.1:80
-----------------------------------------------------------

There's lot's more, try socat -h
.

examples:
http://technostuff.blogspot.com/2008/10/some-useful-socat-commands.html

Tuesday, March 29, 2011

Bash - simple "for loop"...

This may be usefull, it's a simple loop in BASH

#!/bin/bash
for hostname in $(cat text.txt); do
host $hostname
done

Just substitute the "text.txt" with a file containing the hosts.
.
.

Wednesday, August 11, 2010

Varnish - cache "invention" - Load balacing squid's

I tested load balacing squid proxys with HAproxy, and it was nice, then i had a crazy thought;
"what if i used varnish, and load-balance "and" cache at the same time...?"

Varnish its a great software for reverse-caching webservers... i'm not using it for what it was created, but i had this crazy idea...:P

Well, i took varnish and started "inventing" a way...

This is my setup to load-balance and cache, with varnish, 3 squid's :P (yep, crazy i know):

Request---> varnishd:8080 --> refered has "webfarm"
            /    |    \
           /     |     \
       proxy1  proxy2  proxy3

config file: default.vcl

 backend proxy1 {
     .host = "10.30.1.171";
     .port = "8080";
 }


 backend proxy2 {
     .host = "10.30.1.172";
     .port = "8080";
 }

 backend proxy3 {
     .host = "10.30.1.173";
     .port = "8080";
 }

 director webfarm round-robin {
 {
  .backend = proxy1;
 }
 {
  .backend = proxy2;
 }
 {
  .backend = proxy3;
 }
 }

 sub vcl_recv {
  if (client.ip == "10.1.5.10" )
   { set req.backend = webfarm; }
}.


Well it worked...but i'm not very sure about the perfomance...varnish was not created for this :P
.

HAproxy - LoadBalancer - balancing 3 squid's

Trying to loadbalance requests across 3 squid-cache proxys, very nice, i'm enjoiyng HAproxy a lot, great software.

Here it goes:

Client request <-----> HAproxy <---> squid1 \ 
                               <---> squid2  -- web
                               <---> squid3 /


Config file: haproxy.cfg

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #nbproc 2
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000



# reverse proxy-squid
listen  webfarm 0.0.0.0:8000
        mode http
        cookie  SERVERID insert indirect nocache
        balance roundrobin
        option httpclose
        option forwardfor header X-Client
        server  squid1 10.30.1.171:8080 check inter 2000 rise 2 fall 5
        server  squid2 10.30.1.172:8080 check inter 2000 rise 2 fall 5
        server  squid3 10.30.1.173:8080 check inter 2000 rise 2 fall 5


listen admin_stats 0.0.0.0:81
        mode http
        stats uri       /stats
        stats realm     Global\ statistics
        stats auth      username:password

        #errorloc       502     http://192.168.114.58/error502.html
        #errorfile      503     /etc/haproxy/errors/503.http
        errorfile       400     /etc/haproxy/errors/400.http
        errorfile       403     /etc/haproxy/errors/403.http
        errorfile       408     /etc/haproxy/errors/408.http
        errorfile       500     /etc/haproxy/errors/500.http
        errorfile       502     /etc/haproxy/errors/502.http
        errorfile       503     /etc/haproxy/errors/503.http
        errorfile       504     /etc/haproxy/errors/504.http

 
------------------------------ EOF ------------------------------------



.
To access the haproxy stats, use: (the "uri" defined)
http://webfarm:81/stats

Well it works, very nice, and it does backend servers check, and statistics NICE !
.

Tuesday, June 29, 2010

Linux - Tools to view disk activity

Here are some tools to find out what process is "eating" your resources:

  • iotop
  • vmstat
  • lsof
  • atop
  • strace -e trace=open "aplication"

.

Friday, June 25, 2010

HAproxy - LoadBalancer - Simple config

I'm testing HAproxy, here is my first simple configuration:
- 1 haproxy server -> Serving 2 backend webservers

Request ---> haproxy:80  ---refered as "webfarm"
                 |          
                / \
            moss1  moss2

Config file: haproxy.cfg

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #nbproc 2
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen  webfarm 0.0.0.0:80
        cookie  SERVERID insert indirect nocache
        balance roundrobin
        server  moss1 10.30.1.61:80 cookie check inter 2000 rise 2 fall 5
        server  moss2 10.30.1.62:80 cookie check inter 2000 rise 2 fall 5

listen admin_stats 0.0.0.0:81
        mode http
        stats uri       /my_stats
        stats realm     Global\ statistics
        stats auth      username:password

        #errorloc       502     http://192.168.114.58/error502.html
        #errorfile      503     /etc/haproxy/errors/503.http
        errorfile       400     /etc/haproxy/errors/400.http
        errorfile       403     /etc/haproxy/errors/403.http
        errorfile       408     /etc/haproxy/errors/408.http
        errorfile       500     /etc/haproxy/errors/500.http
        errorfile       502     /etc/haproxy/errors/502.http
        errorfile       503     /etc/haproxy/errors/503.http
        errorfile       504     /etc/haproxy/errors/504.http


To access haproxy stats:
http://webfarm:81/my_stats

It's working nice, i have to continue tests and try more configuration settings.

.

Wednesday, June 2, 2010

Ubuntu 10.04 - tips - boot in graphic mode

I'm trying Ubuntu (finaly...i wasn't a big fan...but it's growing :)

I installed Lucid Lynx, desktop version, but i'm using it as my second workstation, so i wanted to "tweak it" a little bit.

To boot in text mode, i did some search and found that Ubuntu desktop is configured to work in graphic mode in almost every runlevel

So we can config grub to boot in text mode:
edit /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

add "text"
to the options.

And i also stopped some services:
/etc/rc2.d/
# mv S70bluetooth K70bluetooth

I must confess that the package management of debian based systems is the best (in my humble opinion)

I'm very impressed with "apt-get" ;)
.

Tuesday, June 1, 2010

Logging in Apache - don't log favicon.ico

Apache logs a lot of info, but it can be configured.

Here is a brief description of what i've done to apache config, so that it would not log some hits, for example "favicon.ico", here it goes:

First i altered /etc/apache2/apache2.conf (other systems can be httpd.conf)

I don't want to log agents...
In these lines:
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined


I modified to look like this:
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O" vhost_combined

A lot less info about agent's ;)

Now for the sites, in the file /etc/apache2/sites-available/default i added this:
SetEnvIf Request_URI "^/favicon\.ico$" dontlog

then on the line that has the CustomLog entry:
CustomLog /var/log/apache2/access.log combined env=!dontlog

After this the favicon.ico continues to log in the error.log, so i created a zero size file in /var/www/
# cat /dev/null > favicon.ico

I know it's not the best for debugging but i like it better like this, i think it's better for reading ;)
.

Tuesday, March 2, 2010

Problem with Squid - signal 6

Squid-cache on a linux machine, was crashing repeatedly with the error:
$ exited due to signal 6

After lots of logs reading and net hunting i found out that this error was corrected on a newer version of squid.

The error was on the following version:
Squid Cache: Version 2.5.STABLE6

I upgraded to:
Squid Cache: Version 2.5.STABLE11
So i upgraded and .... no more crashes.

Some tips and commands that helped on troubleshooting:
Read squid logs:
 - /var/log/squid
     - cache.log


Verify squid cache directory:
- /var/spool/squid

Verify message logging:
 - /var/log/messages

Commands:
to rebuild cache:  squid -z

to start with debug: squid -d 3 -F -N -X
-d 3  --- more debug level
-F     --- don't service any request until cache is rebuild
-N    --- no daemon level
-X     --- force full debug 





Tuesday, October 13, 2009

Compile - NginX under Linux

== Tips for compiling NginX ==

After downloading nginx tarball you also need:
- zlib.tar.gz
- openssl.tar.gz


1 - make and install zlib
2 - uncompress openssl tarball
3 - Configure nginx script:
   - ./configure \
      --with-http_ssl_module --with-openssl=../openssl-uncompress-dir \
      --prefix=/srv/your-dir
4 - make
5 - make install



 That should give a working nginX server ;)


Thursday, September 10, 2009

Linux - diags commands, Get hard / soft Info

Here are some commands that we can use to obtain info from a Linux host:


# dmesg              -- show bootup messages / detected hardware

top                -- show cpu/mem/swap usage and running processes
# mii-tool           -- show nic infos
# du -xh | sort      -- show disk usage

# ps -exfcl          -- show processes running - list 
# rpm -qa            -- show packages.version installed - (redhat/fedora)
# cat /etc/fstab     -- show filesystem table

# cat /proc/cpuinfo  -- show cpu information
# cat /proc/devices  -- show devices ( /proc "filesystem" shows lots of info)
# cat /proc/meminfo  -- show memory


The list continues...i will add some more later

Thursday, August 20, 2009

Linux Basics - 1

== Linux basic commands ==

The kernel: Monolithic or Modular

A monolithic kernel is one which has support for all hardware, network, and filesystem compiled into a single image file.

A modular kernel is one which has some drivers compiled as object files, which the kernel can load and remove on demand. Loadable modules are kept in /lib/modules.

-------Commands that can help --------------------

# lsmod - list currently loaded modules
# rmmod - remove a single module
# insmod - insert a single module
# depmod - create the database of module dependencies modules.dep
# modprobe -insert a module and dependencies listed in modules.dep
# modinfo - list information about the author, license type and module parameters