change linux process priority with nice and renice


2009-12-03 Digg! icurtain Delcious icurtain Technorati icurtain


Process priorities are set between 20 (lowest) and -19 (highest)

To launch a task with a priority of 5 try:
mike@mikebox:~$ sudo nice task 5

If you're laptop is overehating and kacpi_notify is stealing all your CPU power polling the CPU temperature you can use renice to change priority of a running process (pid 20) to priority 5
mike@mikebox:~$ sudo renice 5 -p 20

renice Usage:
renice [-n] priority [-p|--pid] pid [... pid]
renice [-n] priority -g|--pgrp pgrp [... pgrp]
renice [-n] priority -u|--user user [... user]
renice -h | --help
renice -v | --version


nice Usage: nice [OPTION] [COMMAND [ARG]...]
Run COMMAND with an adjusted niceness, which affects process scheduling.
With no COMMAND, print the current niceness. Nicenesses range from
-20 (most favourable scheduling) to 19 (least favourable).

-n, --adjustment=N add integer N to the niceness (default 10)
--help display this help and exit
--version output version information and exit


find java path in ubuntu


2008-12-08 Digg! icurtain Delcious icurtain Technorati icurtain


finding the java path in ubuntu is easy, just follow the links... most links live in /usr/bin so:

mike@mbox:/$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2008-12-07 22:16 /usr/bin/java -> /etc/alternatives/java

mike@mbox:/$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 40 2008-12-07 22:34 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk/jre/bin/java


mounting external discs


2008-11-10 Digg! icurtain Delcious icurtain Technorati icurtain


sudo fdisk -l
sudo mount -t ntfs-3g /dev/target /media/target

Install Nvidia Drivers on Ubuntu


2008-08-25 Digg! icurtain Delcious icurtain Technorati icurtain


First stop the X Server

This should be done by running sudo gdm stop but ubuntu keeps restarting them

chmod -x /etc/rc3.d/gdm

then drop into init level 3

you must pre-install

sudo apt-get install build-essential linux-headers-$(uname -r)

then sudo sh NVIDIA**.run


whois on linux


2008-06-19 Digg! icurtain Delcious icurtain Technorati icurtain


installing whois on a linux box

# sudo apt-get install jwhois

# yum install jwhois

or

browse to: http://packages.qa.debian.org/j/jwhois.html

find the latest version and

# wget http://ftp.debian.org/debian/pool/main/j/jwhois/jwhois_4.0.orig.tar.gz

tar xf jwhois_4.0.orig.tar.gz

# cd jwhois_4.0/

# ./configure

# make install

get your environment variables / path with:

# env
:: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

# cd /usr/local/bin

create a symbolic link so you can call whois url

# ln -s jwhois whois

then put the link in the path

# mv whois /usr/local/bin


search for DHCP servers on a network - dhclient


2008-06-16 Digg! icurtain Delcious icurtain Technorati icurtain


If you wish to search for DHCP servers on a network just type:
dhclient [interface]
and it will bring back information on all running DHCP servers on your subnet


compile kernel in gentoo


2008-06-10 Digg! icurtain Delcious icurtain Technorati icurtain


compile kernel in gentoo

cd /usr/src/linux/

make menuconfig

Linux Kernel v2.6.*-gentoo Configuration

make

make modules_install

cp arch/i386/boot/bzImage /boot/kernal-2.6.*-gentoo


Command Line Web Browser


2008-06-05 Digg! icurtain Delcious icurtain Technorati icurtain


If need to browse the world wide web and you are either running in an ssh window or you really hate the whole web 2 thing.. help is at hand

Centos
yum install lynx

Debian
apt-get intall lynx

run lynx then you can view this page like this...

icurtain - lights on the roundabout
[H] Blog IDAT205 IDAT204 IDAT203 IDAT201 AINT204 SOFT221 ISAD223 SOFT218 Linux JSF PHP Java[EE] Java[J2ME] SQL submit search for..________
Centos NFS Install

2008-06-04 11:41:15 digg this!

Download the Centos Boot image
Download the Centos DVD image and save it on an NFS enabled share on your lan

Install with Network boot CD

choose to boot: linux text

Choose Manual IPv4
192.168.1.* / 255.255.255.0
192.168.1.*
192.168.1.*

(NORMAL LINK) Use right-arrow or to activate.
Arrow keys: Up and Down to move. Right to follow a link; Left to go back.
H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list


Centos NFS Install


2008-06-04 Digg! icurtain Delcious icurtain Technorati icurtain


Download the Centos Boot image
Download the Centos DVD image and save it on an NFS enabled share on your lan

Install with Network boot CD

choose to boot: linux text

Choose Manual IPv4
192.168.1.* / 255.255.255.0
192.168.1.*
192.168.1.*

Choose NFS Install

Server: 192.168.1.29
Dir: /install/linux/centos/5.1

Auto install proceeds from here..


Ubuntu 7.10 with Beryl on ATI Mobility Radeon X700


2008-04-11 Digg! icurtain Delcious icurtain Technorati icurtain


It took a day of playing but it is possible to get Beryl running with the proprietary ATI X700 drivers at a reasonable speed under Ubuntu (on an Acer Aspire 1691wlmi)

The biggest problem is the fact that the X700 chipset along with a bunch of others are black listed by compiz in the config file and therefore the system won't even attempt to run 3d acceleration

In the compiz config file located here:

/usr/bin/compiz

you will find a whole list of black-listed hardware based on drivers and PCI ids.
remove the PCI id of your card, for the pci-e x700 it'd included on the line

T="$T 1002:3152 1002:3150 1002:5462 1002: 5653 # ati x300 x600,x600 x700"

just remove it by preceeding it with a #
after you have done that you can install the native drivers, play around with your xorg config and the card responds fairly well.

you might also consider installing the XGL server
#sudo apt-get install xserver-xgl

To disable Xgl autostart for this user, create a file named ~/.config/xserver-xgl/disable


how to rip a dvd to mpg in 7 lines of perl


2008-04-01 Digg! icurtain Delcious icurtain Technorati icurtain


#!/usr/bin/perl -w
# 531-byte qrpff-fast, Keith Winstein and Marc Horowitz
# MPEG 2 PS VOB file on stdin -> descrambled output on stdout
# arguments: title key bytes in least to most-significant order
$_='while(read+STDIN,$_,2048){$a=29;$b=73;$c=142;$t=255;@t=map{$_%16or$t^=$c^=(
$m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;$t^=(72,@z=(64,72,$a^=12*($_%16
-2?0:$m&17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271);if((@a=unx"C*",$_)[20]&48){$h
=5;$_=unxb24,join"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$
d=unxV,xb25,$_;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=$t&($d>>12^$d>>4^
$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*8^$q<<6))<<9,$_=$t[$_]^
(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;eval

Automatic Zimbra Backup


2008-03-10 Digg! icurtain Delcious icurtain Technorati icurtain


If you are backing up Zimbra to a remote NFS file system then you should probably mount it in the fstab r the init.d - bear in mind that if the remote box cannot be found on boot or shutdown the machine will hang for ages before it times out.

#mounts remote file system #init.d
mount remoteBox:/email/backup /mnt/emailbackup/
#fstab
remoteBox:/email/backup /mnt/emailbackup/ nfs rw,intr,bg 0 0

Zimbra's own script
#!/bin/bash
export time=`date +%Y-%m-%d_%H-%M-%S`
export backup_dir=/var/spool/zimbra/backup
export backup_file=$backup_dir/zimbra$time.tar.gz
export zimbra_dir=/opt/zimbra
mkdir -p $backup_dir
su zimbra --command="/opt/zimbra/bin/zmcontrol stop"
tar -czvf $backup_file $zimbra_dir
su zimbra --command="/opt/zimbra/bin/zmcontrol start"

Zimbra Backup Script

Put this in /etc/cron.daily

#!/bin/sh
#deletes all files from remot drive older than 7 days
find /mnt/emailbackup/ -maxdepth 1 -ctime +7 -daystart -exec rm "{}" \;

#run back up
/opt/zimbra/bin/zmfullbackup > /var/spool/zimbra/backup/backup.log

#move back up to remote drive
mv /var/spool/zimbra/backup/* /mnt/emailbackup


Gateway on Centos


2008-01-10 Digg! icurtain Delcious icurtain Technorati icurtain


How to change your gateway in Centos

temporary change:

route del default gw 192.168.1.1

route add default gw 192.168.0.1

pemanent change

cd /etc/sysconfig/

nano network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=centosBox
GATEWAY=192.168.0.1


Changing CVS file permissions with chown


2007-12-13 Digg! icurtain Delcious icurtain Technorati icurtain


If someone has added something to CVS with incorrect permissions (ie. their own username instead of cvs) then you can do the following


Set Date Linux


2007-12-12 Digg! icurtain Delcious icurtain Technorati icurtain


Setting the date in linux

# date 121210312007

in the format - DDMMhhmmYYYY

# date

returns: Wed Dec 12 10:31:00 GMT 2007

type to commit to the hardware clock

# hwclock --utc --systohc


Find Files Linux


2007-12-10 Digg! icurtain Delcious icurtain Technorati icurtain


find [dir] -name '[name]'

# find / -name '*'


Nvidia MCP61 noapic linux network card bug


2007-12-07 Digg! icurtain Delcious icurtain Technorati icurtain


When using any board that utilises the Nvidia NForce 6100 (MCP61) chipset with Linux you will probably have to add the boot option of noapic as due to all the funky energy saving features on the board the chipset speed is all screwed up and Linux can't interface with any of the board management features.. that fixes the not being able to boot bug but can lead to others - with some kernel releases Linux disables IRQ11 and doesn't initialise a whole load of drivers properly.

On an Asus M2N-MX board running Centos 5.0 (kernal 2.6.18-8.el5) this can affect the network card causing it to erase all of the static settings and boot with DHCP every time you reboot

NForce APIC FIX

Upgrade to Centos 5.1 (kernel 2.6.18-53.el5PAE) which will boot with noapic enabled and initiate the network card correctly keeping the static settings or... apparently you can go into your bios and turn off all the power saving settings and then set static values for the memory speeds etc which might just make Linux boot with APIC enabled - but sounds like way too much hassle

You can get your current linux version by typing either of the following:


Open Source Solutions


2007-12-05 Digg! icurtain Delcious icurtain Technorati icurtain


Open source alternatives for common desktop tasks in Windows and Linux

CD Burning Software
InfraRecorder
Archiving and Compression
7-Zip
Desktop Publishing
Scribus
FTP Client
Filezilla
Image Editing
Gimp
Image Editing
InkScape
Office
Open Office
PDF Printer
PDFCreator
Media Player
VLC Player
Text/Source Editor
Notepad ++
Linux - Windows RDP client
rdesktop
Everything for free..
Ubuntu Linux

Enable Auto-Start SSH Redhat


2007-12-04 Digg! icurtain Delcious icurtain Technorati icurtain


chkconfig --add sshd

chkconfig --level 35 sshd on

/etc/rc.d/init.d/sshd start (just to start it up now)


Linux Start Up


2007-12-03 Digg! icurtain Delcious icurtain Technorati icurtain


/etc/rc.* contains symbolic links to all start up scripts

RHEL (redhat) Install Manager


2007-11-26 Digg! icurtain Delcious icurtain Technorati icurtain


install package: yum -y install application_name

(gentoo/ubunto)get package: apt-get application_name


linux free drive-space command


2007-10-22 Digg! icurtain Delcious icurtain Technorati icurtain


df (disk free)

open ports in firewall etc


2007-09-25 Digg! icurtain Delcious icurtain Technorati icurtain


chown munin:munin /usr/share/munin/plugins*

chmod 0755 /usr/share/munin/plugins*

ln -s --target-directory=/etc/munin/plugins /usr/share/munin/plugins*

iptables -I RH-Firewall-1-INPUT -m state --state NEW -p tcp --destination-port 55 -j ACCEPT

iptables -nvL


Samba System Share


2007-09-20 Digg! icurtain Delcious icurtain Technorati icurtain


cd /etc/samba/
nano samba.conf

# Security mode. Defines in which mode Samba will operate. Possible
# values are share, user, server, domain and ads. Most people will want
# user level security. See the Samba-HOWTO-Collection for details.
security = SHARE

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The default is NO.
dns proxy = no
guest ok = yes
guest account = root

[filesystem]
path = /
guest ok = yes
writeable = yes
create mask = 0777


Message file sp1.msb not found - solution


2007-09-17 Digg! icurtain Delcious icurtain Technorati icurtain


export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/


SSH on Ubuntu


2007-09-17 Digg! icurtain Delcious icurtain Technorati icurtain


to install SSH on ubuntu type:
sudo apt-get install openssh-server


make mod_jk in Debian Sarge


2007-09-14 Digg! icurtain Delcious icurtain Technorati icurtain


under debian enter the following command to make sure your compiler environment is working

set up your environment with
apt-get install libtool autoconf gcc apache2-prefork-dev
great.. now we are ready to compile

copy the tomcat source native directory over to the server and from within native/ run the following

make sure the support dir is sitting at the same level

./configure --with-apxs=/usr/bin/apxs2
make
make install

then after all that

Libraries have been installed in:
/usr/lib/apache2/modules

Or download a precomiled binary from http://mirror.public-internet.co.uk/ftp/apache/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.26/i386/


Debian Java/Tomcat Configuration on Sarge


2007-09-14 Digg! icurtain Delcious icurtain Technorati icurtain


Following on from the previous article Java should now be located in

/usr/lib/j2re1.6-sun/bin

You will have to set up

JAVA_HOME and JRE_HOME

these can be set in

/etc/environment

add the lines

JAVA_HOME = "/usr/lib/j2re1.6-sun"
export JAVA_HOME

CATALINA_HOME= "/opt/Tomcat5.5/"
export CATALINA_HOME

or from the command line

export JAVA_HOME=/usr/lib/j2re1.6-sun/

etc.

first we have to build mod_jk for our environment

refer to my other article on building mod_jk

put mod_jk.so into /etc/apache2/mods-available or wherever else you want and then refer to it in the apache conf stick this in your httpd.conf # Load mod_jk module # Specify the filename of the mod_jk lib LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so then restart apache ./ /etc/init.d/apache2 restart

Debian Java Install on Sarge [fragment]


2007-09-14 Digg! icurtain Delcious icurtain Technorati icurtain


I dont have a clue what im doing with Debian so im sticking it all here in no particular order

for sarge:

add to etc/apt/sources.list

deb http://oss.oracle.com/debian unstable main non-free
deb http://ftp.sunet.se/pub/os/Linux/distributions/debian-multimedia sarge main
deb ftp://ftp.sunet.se/pub/os/Linux/distributions/debian-multimedia sarge main

then type apt-get update

installing java:

apt-get install java-package

gcc errors?
apt-get gcc install

download your JRE/JDK.bin to the director in which you are working then as a USER NOT ROOT (adduser blah - then follow prompts) type:

fakeroot make-jpkg jre-1_5_0_06-linux-i586.bin

or whatever ur bin is called.. if this bitches out with a module not found error your version of java-package is probably prior to 0.25 - you can check this by typing:

apt-cache policy java-package | head -2

at this stage you can try to find an up to date repository or you can just download a version of java-package higher than 0.24 and stick it in the directory then type:

dpkg -i java-package.deb

this might complain about unzip and soundlib.. to resolve this type:

apt-get -f install

this will resolve your dependency issues

now you should have a combiled JRE....deb sitting in your directory - if you dont then type

fakeroot make-jpkg jre-1_5_0_06-linux-i586.bin

ok.. so far

now we have the .deb file you should just be able to type

dpkg -i jre-1_5_0_06-linux-i586.deb

and Java will be installed

type

java -version

to varify this


mod_jk - exclude sub-dirs from tomcat with no-jk


2007-09-10 Digg! icurtain Delcious icurtain Technorati icurtain


excluding sub-directories from mod_jk and allowing apache to execute them natively can be done with with SetEnvIf no-jk. simply add the following code to either the httpd.conf or the mod-jk.conf


DocumentRoot /var/www/html/
SetEnvIf Request_URI "/munin/*" no-jk
JkMount /* ajp13

In this case we are running munin with jboss/tomcat and want to run the perl code in the apache httpd environment at the same time forwarding all other requests to the root /* to the jboss/tomcat server


autostart with chkconfig in linux


2007-09-07 Digg! icurtain Delcious icurtain Technorati icurtain


in order to allow chkconfig to run a file in etc/init.d or wherever as a start up service the file must have a descriptor header that tells chkconfig what its
run level - startup - shutdown
are - this is set in the following way

#!/bin/sh
#
# chkconfig: 3 87 20
# description: Description of executed protram

then type
chkconfig serviceName --add
chkconfig jboss on
this will then allow init.d to auto run the service next time you reboot linux


exit linux terminal and leave programs running


2007-09-05 Digg! icurtain Delcious icurtain Technorati icurtain


to exit it a terminal window and leave spawned process running
eg ./etc/prog/bin/run.sh &
type exit instead of logout

this causes the shell to exit with a status of n. if n is omitted the exit status is that of the last command executed. a trap on EXIT is executed before the shell terminates.


auto-run at startup in linux


2007-09-04 Digg! icurtain Delcious icurtain Technorati icurtain


for simple commands just put them inside:
etc/rc.local
for example
route add default gw 192.168.1.1


Redhat Linux Network Config


2007-09-04 Digg! icurtain Delcious icurtain Technorati icurtain


Linux Redhat - when the network comes up it will try to execute all of the ifcfg* files in ### etc/sysconfig/network-scripts so create a new file ifcfg-eth01 for arguments sake and add:

### /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
ONBOOT=yes

to add a virtual ip from the command line simply type:

ifconfig eth0:1 192.168.0.1 255.255.255.0

then add:
route add default gw 192.168.0.50 (GATEWAY)
to make make the machine publically visible to through the firewall

Gateway settings

reside in ### /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=myServerBox
GATEWAY=192.168.0.1

DNS settings

reside in /etc/resolv.conf
nameserver 192.168.1.1
nameserver 192.168.1.2

Firewall Settings (IPTables)

reside here:### etc/sysconfig/iptables
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 211.1.1.211 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

network config in ubuntu shell:

$ nano /etc/network/interfaces

iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
auto eth0

/etc/init.d/networking restart


Installing Java on Linux


2007-08-31 Digg! icurtain Delcious icurtain Technorati icurtain


Install:

chmod +x jdk-6u2-linux-i586-rpm.bin

./jdk-6u2-linux-i586-rpm.bin

Follow prompts [yes]/[no] etc

If it gives the error message

error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

Then you have to download

compat-libstdc++-33-3.2.3-47.fc4.i386.rpm

which can be found

ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/

or by googling it

rpm -i compat-libstdc++-33-3.2.3-47.fc4.i386.rpm
or # yum install libstdc++.so.5

The SDK installed in /usr/java/jdk/

add path to $HOME/.bash_profile

PATH=/usr/java/jdk/bin:$PATH:$HOME/bin:./

export PATH

export JAVA_HOME=/usr/java/jdk

export CLASSPATH=/usr/java/jdk/lib/tools.jar:/usr/java/jdk/jre/lib/rt.jar:./

Possible Issues

When installing Jboss 4.2.1.GA it throws a fit if you have anything less than Java 1.6 JRE and the 1.5 JDK installed - Centos installs it's own version of Java 1.4 to fulfil install dependencies and this seems to conflict with the Sun versions - make sure you uninstall GNU Java 1.4 from the package manager or any other way you fancy and then install first the 1.6 JRE followed by the 1.5 JDK. After that you can just drag a copy of Jboss onto the linux box and start it with /bin/./run.sh & (to spawn a process)


Linux IP address Configuration - ifconfig


2007-08-31 Digg! icurtain Delcious icurtain Technorati icurtain


ifconfig is the linux equivilent of ipconfig and will give you your ipaddress and network details :)

to edit it in red hat go into /etc/sysconfig/network-scripts/ifcfg-eth0 (where 0 is the interface u want to change) and append as desired. then from the command line:

service network [start,stop,restart]

In Ubuntu (Debian)

nano /etc/network/interfaces

Contents should be:

iface eth0 inet static
address 192.168.1.55
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

For DHCP it should read

auto eth0
iface eth0 inet dhcp

To restart your network interface and update settings

sudo /etc/init.d/networking restart