8 Jan 2010

Linux Shtuff Posts

Author: admin | Filed under: General Info

Hi,

When I started this blog, I started it for my own benefit so I could remember those little tweaks or fixes which escape memory at crucial times when a needed repair or a new issue arose that I had never dealt with before. When I would research these issues, I would come across great posts and information I wanted to remember and posted that information here. I did not give credit where credit was due regarding those posts and if you find something that was posted by you, please let me know and I will credit the post to you. I cannot remember where I pulled all of the information from so, if you see something that is yours, do not fret, I am not stealing your shtuff, I am posting it so all can read and learn from the mistakes and information I have gathered. Most of the posts are mine, but not all. Thank you all for your patience and information you have shared to better improve the linux experience.

Oh and by the way, if you see a post that has outdated or incorrect information, please, please, pretty please let me know so I can update it. Believe it or not, I use this site also and I want my information to be up to date as well. Thanks again for visiting.

Comments Off
24 Jan 2012

clearing the arp cache in linux

Author: admin | Filed under: General Info

You can clear the arp cache using following commands

Current arp cache

root@server [~]# arp -n<br />
Address      HWtype  HWaddress           Flags Mask  Iface<br />
70.167.140.1 ether   00:00:0C:9F:F0:04   C           eth0<br />

Clearing arp cache with verbose

root@server [~]# ip -s -s neigh flush all<br />
70.167.140.1 dev eth0 lladdr 00:00:0c:9f:f0:04 ref 42 used 17/0/65 REACHABLE

*** Round 1, deleting 1 entries ***
70.167.140.1 dev eth0 ref 42 used 0/0/0 INCOMPLETE

*** Round 2, deleting 1 entries ***
*** Flush is complete after 2 rounds ***

current entries

root@server [~]# arp -n<br />
Address      HWtype  HWaddress           Flags Mask  Iface<br />
69.167.140.1 ether   00:00:0C:9F:F0:04   C           eth0<br />

You can also delete specific arp entries using the two following command

root@server [~]# arp -d 192.168.1.1<br />
root@server [~]# arp -d 192.168.1.2<br />

<br />
Add a static arp entry<br />
root@server [~]# arp -s 192.168.1.10 00:00:93:12:04:57

tested on CentOS release 5.7 (Final)

Comments Off
16 Jan 2012

Villustrator

Author: admin | Filed under: General Info

From bilalquadri.com

Here is a nice little addition to vi or vim. You can create a custom theme for vi/vim and download it to use locally. Nice!

From their FAQ:

Where do I put the colorscheme I just downloaded?
The colorscheme should be put in “~/.vim/colors”. If those directories don’t already exist, you will need to create them.

I’m using Vim in the terminal. How can I use my colorscheme outside of gvim?
There are few things to note here:
• Make sure you tell Vim how many colors your terminal supports. Just add this line to your .vimrc file in your home directory:
let &t_Co=256

Use 88 instead of 256 if that’s what your terminal supports.
• Download and unzip this plugin into the ~/.vim directory. After that, you should be set.

How do I change my colorscheme?
Just type “:colorscheme ” in Vim without the quotes. Tochange the default colorscheme, just add that line to your .vimrc file in your home directory.

From bilalquadri.com

Comments Off
10 Jan 2012

Reset visual and editor to use Vim

Author: admin | Filed under: General Info

Hi,

I ran across a small issue where the client wanted to use vim as the default editor for crontab as opposed to pico. I was able to modify this by using the following commands;

EDITOR=vim;
export EDITOR
VISUAL=vim;
export VISUAL=vim

and done…

Now, when editing crontab, it uses vim. Simple.

Comments Off
3 Jan 2012

Install Mongodb

Author: admin | Filed under: General Info

From mongodb.org
From if-not-true-then-false.com
From php.net

To install mongodb, add the appropriate repo information below for your distribution version (x86_64 or i686) to /etc/yum.repos.d/10gen.repo:

vim /etc/yum.repos.d/10gen.repo

add

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0

or

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0

then run

yum update && yum install mongo-10gen mongo-10gen-server

Check the basic mongodb configuration settings before starting MongoDB (default settings are usually good)

vim /etc/mongod.conf

logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo

Start the service

service mongod start

Start the service on boot

chkconfig --levels 235 mongod on

Now, lets test the server. Start it with the ‘mongo’ command

mongo

Save, Update and Find Some Test Data on MongoDB

> use test
  switched to db test
> db.foo.find()
> db.foo.save({a: 1})
> db.foo.find()
 { "_id" : ObjectId("4b8ed53c4f450867bb35a1a9"), "a" : 1 }
> db.foo.update( {a: 1}, {a: 5})
> db.foo.find()
 { "_id" : ObjectId("4b8ed53c4f450867bb35a1a9"), "a" : 5 }

Now, let’s oOpen MongoDB Port (27017) in Iptables

iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT
service iptables save
service iptables  restart

Let’s also add the port to csf in /etc/csf/csf.conf

# Allow incoming TCP ports
TCP_IN = 27017

To install the php extension:

pecl install mongo

Then add the following line to your php.ini file:

extension=mongo.so

Now, verify that the mongo port is open and listening

lsof -i |grep 27017

That’s it!

Comments Off
20 Dec 2011

Edit cPanel nameserver IP’s

Author: admin | Filed under: General Info

As of WHM 11.30, the nameservers’ IP assignments are now read from the Zonefiles and actual DNS queries after recent updates. If you are not seeing the needed IPs in /etc/nameserverips please do not attempt to edit that file, as it is now overwritten by cPanel.

Check under WHM: Main >> DNS Functions >> Nameserver IPs for current nameserverips

(Solutions may depend on the cPanel version)

Problem
The updated A entries and/or NS entries are not retained:
Solution(s)
Add the needed nameservers to the /etc/hosts file

vim /etc/hosts

Add (append) a new line, one per IP, onto the existing hosts file such as:

123.456.789.012     ns1.domain.com

OR

123.456.789.012     ns1.domain.com ns2.domain.com

Then run the updatenameserverips script:

/scripts/updatenameserverips

Check under WHM: Main >> DNS Functions >> Nameserver IPs again to see if it worked, if not continue

Delete the nameserverips.cache file

rm  /var/cpanel/nameserverips.cache

Then modify /var/cpanel/nameserverips.yaml to suite

vim /var/cpanel/nameserverips.yaml

Then run the updatenameserverips script again

Comments Off
4 Dec 2011

IO wait Load Tracking

Author: admin | Filed under: General Info

From http://balajitheone.blogspot.com

IO wait load tracking to a process.

How to identify what processes are generating IO wait load.
————————————————————-

An easy way to identify what process is generating your IO Wait load is to enable block I/O debugging. This is done by setting /proc/sys/vm/block_dump to a non zero value like:

echo 1 > /proc/sys/vm/block_dump

This will cause messages like the following to start appearing in dmesg:

bash(6856): dirtied inode 19446664 (ld-2.5.so) on md1

Using the following one-liner will produce a summary output of the dmesg entries:

dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head
    354 md
    324 export
    288 kjournald
     53 irqbalance
     45 pdflush
     14 portmap
     14 bash
     10 egrep
     10 crond
      8 ncftpput

Once you are finished you should disable block I/O debugging by setting /proc/sys/vm/block_dump to a zero value like:

echo 0 > /proc/sys/vm/block_dump

Nice…

From http://balajitheone.blogspot.com

Comments Off
15 Nov 2011

Installing the H264 Streaming Module for Apache

Author: admin | Filed under: General Info

Installing the streaming module can be a problem sometimes. This is a simple install guide which worked fine in a standard Cent5/cpanel server:

cd /usr/src
wget http://h264.code-shop.com/download/apache_mod_h264_streaming-2.2.7.tar.gz
tar -xzvf apache_mod_h264_streaming-2.2.7.tar.gz
cd mod_h264_streaming-2.2.7
./configure --with-apxs='which apxs'
make && make install

add the following entries via vim /usr/local/apache/conf/httpd.conf
add

 AddHandler h264-streaming.extensions .mp4
 LoadModule h264_streaming_module /usr/local/apache/modules/mod_h264_streaming.so

then…

service httpd restart

then, cd to a public_html which is resolving correctly and run

cd /home/user/public_html
wget -O test.mp4 "http://h264-demo.code-shop.com/demo/apache/trailer2.mp4"

to test:

http://your-servers-ip/test.mp4

http://your-servers-ip/test.mp4?start=55.5

You will see the opening preview credits in the first link and in the second, it should have the first 55.5 seconds removed from the original video file.

Comments Off
31 Oct 2011

Define

Author: admin | Filed under: General Info

Just a quick script for looking up the definition of a word via the commandline…

touch define
vim define

add the following code then :wq to save

#! /bin/bash
# display definition of a word
#
curl --stderr /dev/null dict://dict.org/d:$1 | sed '/^[.,0-9].*$/d'

then,

chmod +x define
mv define /usr/bin/define

Usage

# define linux
Linux
     n : an open-source version of the UNIX operating system
Comments Off
31 Oct 2011

Monitor file changes live

Author: admin | Filed under: General Info

Here’s a quick one for ya…

watch -d -n 2 "df; ls -FlAt;"

This brings up a top like interface which every 2 seconds shows files which are being written to.

Enjoy :)

Comments Off
26 Oct 2011

Mikogo

Author: admin | Filed under: General Info

Looking to host an online meeting without paying through the teeth? Look no further. Mikogo is a free desktop sharing tool full of features to assist you in conducting the perfect online meeting or web conference.

Take advantage of the opportunity to share any screen content or application over the Internet in true color quality with up to 10 participants simultaneously, while still sitting at your desk.

Mikogo can be employed for a range of professional, academic, or personal uses, including:

online meetings
web conferences
product demonstrations
web presentations
remote support
webinars
and more!

Provide online technical support for your customers. Conduct product demonstrations for business customers. Use Mikogo to discuss and edit a current team project. The ideal tool for free online group collaboration.

Download it today and broadcast your screen between your guests with just 2 mouse-clicks
From mikogo.com

Comments Off
25 Oct 2011

Install YUI Compressor

Author: admin | Filed under: General Info

Install YUI Compressor

wget http://yuilibrary.com/downloads/yuicompressor/yuicompressor-2.4.2.zip
unzip yuicompressor-2.4.2.zip
mv yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar /opt/fileconveyor/code/processors/yuicompressor.jar

or

Install YUI Compressor via apt:

sudo apt-get install yui-compressor

Compress the script:

java -jar /usr/share/yui-compressor/yui-compressor.jar --type js -v
myscript.js -o myscript.min.js

RPM available here from http://rpm.pbone.net

Comments Off
16 Oct 2011

Secure-Delete

Author: admin | Filed under: General Info

From ubuntugeek.com

The Secure-Delete tools are a particularly useful set of programs that use advanced techniques to permanently delete files. To install the Secure-Delete tools in Ubuntu, run the following command

sudo aptitude install secure-delete

The Secure-Delete package comes with the following commands

srm(Secure remove) – used for deleting files or directories currently on your hard disk.
smem(Secure memory wiper) – used to wipe traces of data from your computer’s memory (RAM).
sfill(Secure free space wiper) – used to wipe all traces of data from the free space on your disk.
sswap(Secure swap wiper) – used to wipe all traces of data from your swap partition.
srm – Secure remove

srm removes each specified file by overwriting, renaming, and truncat-ing it before unlinking. This prevents other people from undeleting or recovering any information about the file from the command line.

srm, like every program that uses the getopt function to parse its arguments, lets you use the — option to indicate that all arguments are non-options. To remove a file called ‘-f’ in the current directory, you could type either “srm — -f” or “srm ./-f”.

srm Syntax

srm [OPTION]… FILE…

Available Options

-d, –directory – ignored (for compatibility with rm)
-f, –force – ignore nonexistent files, never prompt
-i, –interactive – prompt before any removal
-r, -R, –recursive – remove the contents of directories recursively
-s, –simple – only overwrite with a single pass of random data
-m, –medium – overwrite the file with 7 US DoD compliant passes (0xF6,0×00,0xFF,random,0×00,0xFF,random)
-z, –zero – after overwriting, zero blocks used by file
-n, –nounlink – overwrite file, but do not rename or unlink it
-v, –verbose – explain what is being done
–help display this help and exit
–version – output version information and exit

srm Examples

Delete a file using srm

srm myfile.txt

Delete a directory using srm

srm -r myfiles

smem – Secure memory wiper

smem is designed to delete data which may lie still in your memory (RAM) in a secure manner which can not be recovered by thiefs, law enforcement or other threats. Note that with the new SDRAMs, data will not wither away but will be kept static – it is easy to extract the necessary information! The wipe algorythm is based on the paper “Secure Deletion of Data from Magnetic and Solid-State Memory” presented at the 6th Usenix Security Symposium by Peter Gutmann, one of the leading civilian cryptographers.

smem Syntax

smem [-f] [-l] [-l] [-v]

Available Options

-f – fast (and insecure mode): no /dev/urandom.
-l – lessens the security. Only two passes are written: the first with 0×00 and a final random one.
-l -l for a second time lessons the security even more: only one pass with 0×00 is written.
-v – verbose mode

sfill – secure free space wipe

sfill is designed to delete data which lies on available diskspace on mediums in a secure manner which can not be recovered by thiefs, law enforcement or other threats. The wipe algorythm is based on the paper “Secure Deletion of Data from Magnetic and Solid-State Memory” presented at the 6th Usenix Security Symposium by Peter Gutmann, one of the leading civilian cryptographers.

sfill Syntax

sfill [-f] [-i] [-I] [-l] [-l] [-v] [-z] directory/mountpoint

Available Option

-f – fast (and insecure mode): no /dev/urandom, no synchronize mode.
-i – wipe only free inode space, not free disk space
-I -wipe only free disk space, not free inode space
-l -lessens the security. Only two passes are written: one mode with 0xff and a final mode with random values.
-l -l for a second time lessons the security even more: only one random pass is written.
-v – verbose mode
-z – wipes the last write with zeros instead of random data

directory/mountpoint this is the location of the file created in your filesystem. It should lie on the partition you want to write.

sswap – Secure swap wiper

sswap is designed to delete data which may lie still on your swapspace in a secure manner which can not be recovered by thiefs, law enforce?ment or other threats.The wipe algorythm is based on the paper “Secure Deletion of Data from Magnetic and Solid-State Memory” pre?sented at the 6th Usenix Security Symposium by Peter Gutmann, one of the leading civilian cryptographers.

sswap Syntax

sswap [-f] [-l] [-l] [-v] [-z] swapdevice

Available Option

-f – fast (and insecure mode): no /dev/urandom, no synchronize mode.
-l – lessens the security. Only two passes are written: one mode with 0xff and a final mode with random values.
-l -l for a second time lessons the security even more: only one pass with random values is written.
-v – verbose mode
-z – wipes the last write with zeros instead of random data

sswap Examples

Before you start using sswap you must disable your swap partition.You can determine your mounted swap devices using the following command

cat /proc/swaps

Disable swap using the following command

sudo swapoff /dev/sda3

/dev/sda3 – This is my swap device

Once your swap device is disabled, you can wipe it with sswipe using the following command

sudo sswap /dev/sda3

After completing the above command you need to re-enable swap using the following command

sudo swapon /dev/sda3

From ubuntugeek.com

Comments Off
14 Oct 2011

Ubuntu 11.10 add applets to top panel

Author: admin | Filed under: General Info

Just a quick note; I upgraded to ubunutu 11.10 and really missed my applet links in the top panel (yup, using Gnome classic)

I could not find out how to add them back in. After a little tinkering, I found the using
“ALT + Right Click” on the top panel will open the old ‘add to panel’ and ‘properties’ to customize it.