Http Configure options
./configure --enable-so --with-mpm=worker --prefix=/opt/httpd/http2.2/ --enable-rewrite --enable-alias --with-port=8080 --enable-cgi --enable-spelling | tee jjj.configure | tee jjj.configure
make | tee jjj.make
make install | tee jjj.make
mod_python Configure options
./configure --with-apxs=/opt/httpd/http2.2/bin/apxs --with-python=/opt/python2.6/bin/python
make
make install
http://cavedoni.com/2005/django-osx
Thursday, January 08, 2009
Tuesday, January 06, 2009
Change keyboard in X
http://ubuntu-tutorials.com/2008/01/31/changing-the-system-keyboard-mapping-on-ubuntu-dvorak-vs-qwerty/
http://xorg.freedesktop.org/archive/X11R7.0/doc/html/setxkbmap.1.html
http://xorg.freedesktop.org/archive/X11R7.0/doc/html/setxkbmap.1.html
Tuesday, December 16, 2008
Find Usage
"Grep" through each file in a directory:
ls xargs grep -i 'STRING'
List all directories and subdirectories in a directory
find . -type d
List all files in a directory no recursion
# workaround for "parameter list is too long".
find . \( ! -name . -prune \) -name 'STRING*' -print
find . -maxdepth 1 -name 'STRING*' -print # GNU find only
Remove all files in a directory no recursion
# workaround for "parameter list is too long".
find . \( ! -name . -prune \) -name 'STRING*' -print -exec rm {} \;
Find a file with a given inode and delete it
ls -lai # lists the inodes next to the files
find . -inum 12345 -exec rm {} \; # finds and removes by inode
http://www.faqs.org/qa/qa-1381.html
http://sial.org/howto/shell/
ls xargs grep -i 'STRING'
List all directories and subdirectories in a directory
find . -type d
List all files in a directory no recursion
# workaround for "parameter list is too long".
find . \( ! -name . -prune \) -name 'STRING*' -print
find . -maxdepth 1 -name 'STRING*' -print # GNU find only
Remove all files in a directory no recursion
# workaround for "parameter list is too long".
find . \( ! -name . -prune \) -name 'STRING*' -print -exec rm {} \;
Find a file with a given inode and delete it
ls -lai # lists the inodes next to the files
find . -inum 12345 -exec rm {} \; # finds and removes by inode
http://www.faqs.org/qa/qa-1381.html
http://sial.org/howto/shell/
Monday, October 13, 2008
Django Model Many-to-One
Define the models
from django.db import models
class Reporter(models.Model):
.. first_name = models.CharField(max_length=30)
.. last_name = models.CharField(max_length=30)
.. email = models.EmailField(blank=True, null=True)
def __unicode__(self):
.. return u"%s %s" % (self.first_name, self.last_name)
class Article(models.Model):
.. headline = models.CharField(max_length=100)
.. pub_date = models.DateField()
.. reporter = models.ForeignKey(Reporter, blank=True, null=True)
def __unicode__(self):
.. return self.headline
.. class Meta:
.... ordering = ('headline',)------------------------------------------------Add some objects
# import models from core.models
>>> from core.models import Reporter, Article
>>> from datetime import datetime # needed for inserting current time
# add some reporters
>>> r1 = Reporter(first_name="Joe", last_name="Jaz")
>>> r1.save()
>>> r2 = Reporter(first_name="Jane", last_name="Smith")
>>> r2.save()
# add some articles
>>> a1 = Article(headline="Article1", pub_date=datetime(2008,10,14))
>>> a1.reporter = r1 # can add separately
>>> a1.save()
>>> a2 = Article(headline="Article2", pub_date=datetime(2008,10,15), reporter=r2)
>>> a2.save()
# show an article's reporter
>>> a1.reporter
'Jane'
# create an article "under" a Reporter via the Reporter object
# the 'article_set' method is generated on model creation using the lower-case model name
# the create method automatically does a save()
>>> a3 = r1.article_set.create(headline="Article3", pub_date=datetime.now())
>>> a3.headline
'Article3'
>>> a3
<Article: Article1> # returns object with Article type
# create an article with no reporter and then add it to a particular reporters set of articles
# the add method automatically does a save()
>>> a4 = Article(headline="Article4", pub_date=datetime.now())
>>> r2.article_set.add(a4)
# show all of the given reporter's articles
>>> r2.article_set.all()
[<Article: Article2>, <Article: Article4>]
# count the number of articles that belong to a reporter
>>> r2.record_set.count()
2
>>> r1.record_set.count()
2
# associate article 4 with reporter 1 (instead of reporter 2)
>>> r1.article_set.add(a4)
# we can assign it back and use different syntax this time
>>> a4.reporter = r2
>>> a4.save()
# we can assign multiple articles to a reporter at a time
# this syntax calls save automatically
>>> r1.article_set = [a2, a4]
# we can create an article and assign it with a reporter_id instead of the reporter object
# the reporter_id field is generated with the model
>>> a5 = Article(headline="Article5",pub_date=datetime.now(),reporter_id=r1.id)
>>> a5.save()
# or reporter_id can be a string
>>> a6 = Article(headline="Article6",pub_date=datetime.now(), reporter_id="1")
>>> a6.save()
# Do a query to find reporters of article 1 and article 3
>>> Reporter.objects.filter(article__in=[a1,a3])
http://www.djangoproject.com/documentation/models/many_to_one/
Sunday, October 12, 2008
Django OneToMany & ManyToMany Recursive Models
Define the models in core.models.
from django.db import models
class Place(models.Model):
.. name = models.CharField(max_length=50);
.. parent = models.ForeignKey('self', null=True);
.. def __unicode__(self):
.... return "%s > %s" % (self.name,self.parent )
class Fan(models.Model):
.. name = models.CharField(max_length=8)
.. idol = models.ManyToManyField('self', null=True)
.. def __unicode__(self):
.... return self.name
----------------------------------------------------------
Interact with a Foreign Key (One to Many)
# import Place model
from core.models import Place
# add a Place and save
world = Place(name="Earth", parent=None)
world.save()
# add two Places with the world as a parent
country1 = Place(name="US", parent=world)
country1.save()
country2 = Place(name="UK", parent=world)
country2.save()
# add two Places with the US as a parent
city1 = Place(name="Chicago")
city1.parent = country1 # make the association through an update
city1.save()
city2 = Place(name="New York", parent=country1) # associate through insert
city2.save()
# select all the places
Place.objects.all()
------------------------------------------------------
Interact with a Many to Many model
from core.models import Fan
# Define 2 people
person1 = Fan(name="Joe")
person1.save()
person2 = Fan(name="Jane")
person2.save()
# associate the two people
person1.idol.add(person2)
------------------------------------------------------
from django.db import models
class Place(models.Model):
.. name = models.CharField(max_length=50);
.. parent = models.ForeignKey('self', null=True);
.. def __unicode__(self):
.... return "%s > %s" % (self.name,self.parent )
class Fan(models.Model):
.. name = models.CharField(max_length=8)
.. idol = models.ManyToManyField('self', null=True)
.. def __unicode__(self):
.... return self.name
----------------------------------------------------------
Interact with a Foreign Key (One to Many)
# import Place model
from core.models import Place
# add a Place and save
world = Place(name="Earth", parent=None)
world.save()
# add two Places with the world as a parent
country1 = Place(name="US", parent=world)
country1.save()
country2 = Place(name="UK", parent=world)
country2.save()
# add two Places with the US as a parent
city1 = Place(name="Chicago")
city1.parent = country1 # make the association through an update
city1.save()
city2 = Place(name="New York", parent=country1) # associate through insert
city2.save()
# select all the places
Place.objects.all()
------------------------------------------------------
Interact with a Many to Many model
from core.models import Fan
# Define 2 people
person1 = Fan(name="Joe")
person1.save()
person2 = Fan(name="Jane")
person2.save()
# associate the two people
person1.idol.add(person2)
------------------------------------------------------
Labels:
django,
manytomany,
onetoone,
python,
recursive
Monday, September 22, 2008
Java Jar Commands
Creating the File structure
# simple suggested structure
project_directory/
\
_ bin/ # binary files
\_ byte_file.class # compiled java bytecode
_src/ # source files (optional)
_META-INF/ # standard location for manifest file
\_MANIFEST.MF # manifest file containing jar variables
Editing the MANIFEST.MF
The manifest can contain variables such as the following:
Main-Class: class_name # name of a class with a "main" method that will run when jar is run.
Class-path: path/to/classes/in/package/ # path start at root of package
Create the Jar
jar -cvfm jar_name.jar path/to/manifest.mf dir/to/class/files/
jar -cvfm project.jar META-INF/MANIFEST.MF bin/
-c # compress into a jar
-v # verbose output
-f # compress to a file specified on the command line (versus to stdout)
-m # specify a path to a manifest file.
Execute the Jar
java -jar jar_name.jar
Extract a Jar file
jar -xvf jar_name.jar
# simple suggested structure
project_directory/
\
_ bin/ # binary files
\_ byte_file.class # compiled java bytecode
_src/ # source files (optional)
_META-INF/ # standard location for manifest file
\_MANIFEST.MF # manifest file containing jar variables
Editing the MANIFEST.MF
The manifest can contain variables such as the following:
Main-Class: class_name # name of a class with a "main" method that will run when jar is run.
Class-path: path/to/classes/in/package/ # path start at root of package
Create the Jar
jar -cvfm jar_name.jar path/to/manifest.mf dir/to/class/files/
jar -cvfm project.jar META-INF/MANIFEST.MF bin/
-c # compress into a jar
-v # verbose output
-f # compress to a file specified on the command line (versus to stdout)
-m # specify a path to a manifest file.
Execute the Jar
java -jar jar_name.jar
Extract a Jar file
jar -xvf jar_name.jar
Tuesday, August 19, 2008
SSH Client Persistance
Keep SSH connections from timing out
On your client, add this line to your /etc/ssh/ssh_config:
ServerAliveInterval 30
On your client, add this line to your /etc/ssh/ssh_config:
ServerAliveInterval 30
Labels:
client,
ServerAliveInterval,
ssh,
ssh_config,
timeout
Saturday, August 09, 2008
Sound Card Info
Check what ALSA soundcards are available on a Linux system:
cat /proc/asound/cards
Check what features each ALSA card has:
cat /proc/asound/devices
# note that the left number column corresponds to a soundcard in the above list
List sound cards detected
aplay -l
Set the default sound card:
# Enter this into /etc/asound.conf or .asoundrc
mplayer -ao oss:/dev/dsp *.mp3 # device 0
mplayer -ao alsa:device=hw=0.0 *.mp3 # device 0
mplayer -ao oss:/dev/dsp1 *.mp3 # device 1
mplayer -ao alsa:device=how=1.0 *.mp3 # device 1
http://seehuhn.de/pages/alsa
http://ubuntuforums.org/showthread.php?t=747054
cat /proc/asound/cards
Check what features each ALSA card has:
cat /proc/asound/devices
# note that the left number column corresponds to a soundcard in the above list
List sound cards detected
aplay -l
Set the default sound card:
# Enter this into /etc/asound.conf or .asoundrc
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}Using mplayer with a non-default sound device
Using alsamixer to select which sound card to affect:
alsamixer -c<sound_card_number_from_proc>
mplayer -ao oss:/dev/dsp *.mp3 # device 0
mplayer -ao alsa:device=hw=0.0 *.mp3 # device 0
mplayer -ao oss:/dev/dsp1 *.mp3 # device 1
mplayer -ao alsa:device=how=1.0 *.mp3 # device 1
http://seehuhn.de/pages/alsa
http://ubuntuforums.org/showthread.php?t=747054
Thursday, July 17, 2008
Sendmail/Postfix Info
Sendmail view mailq:
mailq
sendmail -bp
Sendmail view verbose info:
sendmail -v
Postfix flush mail queue:
sudo postfix flush
sudo postfix -f
Remove all mail in queue:
sudo postsuper -d ALL
Remove all mail in deferred queue:
sudo postsuper -d ALL deferred
Postfix Info
http://www.akadia.com/services/postfix_mta.html
http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html
http://www.unix.com.ua/orelly/networking/tcpip/ch10_08.htm
http://shinphp.blogspot.com/2011/09/ubuntu-clean-sendmail-queue.html
mailq
sendmail -bp
Sendmail view verbose info:
sendmail -v
Postfix flush mail queue:
sudo postfix flush
sudo postfix -f
Remove all mail in queue:
sudo postsuper -d ALL
Remove all mail in deferred queue:
sudo postsuper -d ALL deferred
Postfix Info
http://www.akadia.com/services/postfix_mta.html
http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html
http://www.unix.com.ua/orelly/networking/tcpip/ch10_08.htm
http://shinphp.blogspot.com/2011/09/ubuntu-clean-sendmail-queue.html
Wednesday, July 09, 2008
Join UNIX Command
Join takes two sorted text files and joins them together on common keys, similar to the Join SQL statements.
Basic join syntax:
join file1 file2
Specify a delimiter other than the default of whitespace (for input and output):
join -t: file1 file2 # sets the delimiter to be a colon
Join on specific columns in each file:
join -1 1 -2 1 file1 file2 # this will make file1's first column join with the file2's first column.
Join on a specific column and output specific columns:
join -11 -21 -o 1.1 1.2 2.1 2.2 file1 file2 # the -o options takes space-seperated arguments that take the form of file.column to specify only particular columns.
Specify filler text in a result column when two keys do not match between files:
join -e "none" file1 file2 -o 1.1 1.2 2.1 2.2 # the -e option needs to be used with -o
http://www.softpanorama.org/Tools/join.shtml
http://www.computerhope.com/unix/ujoin.htm
Basic join syntax:
join file1 file2
Specify a delimiter other than the default of whitespace (for input and output):
join -t: file1 file2 # sets the delimiter to be a colon
Join on specific columns in each file:
join -1 1 -2 1 file1 file2 # this will make file1's first column join with the file2's first column.
Join on a specific column and output specific columns:
join -11 -21 -o 1.1 1.2 2.1 2.2 file1 file2 # the -o options takes space-seperated arguments that take the form of file.column to specify only particular columns.
Specify filler text in a result column when two keys do not match between files:
join -e "none" file1 file2 -o 1.1 1.2 2.1 2.2 # the -e option needs to be used with -o
http://www.softpanorama.org/Tools/join.shtml
http://www.computerhope.com/unix/ujoin.htm
Monday, June 02, 2008
Compile Python 2.5 From Source
Download from Python web page
http://www.python.org/
UnTAR and enter the directory
tar -jxvf Python-2.5.2.tar.bz2
cd Python-2.5.2
Configure using an alternate install dir
(use ./configure -h for config options)
./configure --prefix=/opt/python/
Build and install the software
make | tee makelog
make test | tee maketestlog
make install | tee makeinstalllog
This will create a python binary. If you specified the prefix, it will put it in the bin/ directory under the prefix directory. However, this compiles the command line python version. To get it working with Apache, preform the following.
Download mod_python
http://www.modpython.org/
Untar and enter into the directory
tar -zxvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
Configure mod_python.
It needs to know where python binary to use, and the apache build tool apxs is located during the configure.
./configure \
--with-apxs=/usr/sbin/apxs \ # the apache build tool
--with-python=/opt/python25/bin/python2.5 \ # path to python binary
| tee output.config
make | tee output.make
make install | tee output.makeinstall
make install should place a binary module in /etc/httpd/modules
(or /usr/lib/httpd/modules)
The module will be called mod_python.so
Configure Apache
You will need to tell Apache to load the module by adding the following line in the Apache configuration file (httpd.conf)
Imaging Support
To be able to manipulate images with python, you need the PIL library. Download it from http://www.pythonware.com/products/pil/
After untaring and entering the directory, install by: python setup.py install
It will copy files into your default (`which python`) python install.
http://www.modpython.org/live/current/doc-html/inst-apacheconfig.html
http://www.python.org/
UnTAR and enter the directory
tar -jxvf Python-2.5.2.tar.bz2
cd Python-2.5.2
Configure using an alternate install dir
(use ./configure -h for config options)
./configure --prefix=/opt/python/
Build and install the software
make | tee makelog
make test | tee maketestlog
make install | tee makeinstalllog
This will create a python binary. If you specified the prefix, it will put it in the bin/ directory under the prefix directory. However, this compiles the command line python version. To get it working with Apache, preform the following.
Download mod_python
http://www.modpython.org/
Untar and enter into the directory
tar -zxvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
Configure mod_python.
It needs to know where python binary to use, and the apache build tool apxs is located during the configure.
./configure \
--with-apxs=/usr/sbin/apxs \ # the apache build tool
--with-python=/opt/python25/bin/python2.5 \ # path to python binary
| tee output.config
make | tee output.make
make install | tee output.makeinstall
make install should place a binary module in /etc/httpd/modules
(or /usr/lib/httpd/modules)
The module will be called mod_python.so
Configure Apache
You will need to tell Apache to load the module by adding the following line in the Apache configuration file (httpd.conf)
LoadModule python_module modules/mod_python.so
<Directory /path/to/somewhere >
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
</Directory>
Imaging Support
To be able to manipulate images with python, you need the PIL library. Download it from http://www.pythonware.com/products/pil/
After untaring and entering the directory, install by: python setup.py install
It will copy files into your default (`which python`) python install.
http://www.modpython.org/live/current/doc-html/inst-apacheconfig.html
Sunday, April 20, 2008
Basic apache .htaccess authentication
To restrict access to a specific directory
Create a .htaccess file in the directory that you want to restrict
AuthUserFile /path/to/.mypasswds
AuthGroupFile /dev/null
AuthName "Title for password box"
AuthType Basic
require user username
require user user2 # you can add more users by setting multiple require statements
# Require valid-user # you can allow any user listed in password files.
To generate an encrypted password
Execute this shell command which will create the file .mypasswds with a hashed password entry
htpasswd -c /path/to/.mypasswds username
New password: password
Re-type new password: password
Enable the configuration
The module mod_auth must be loaded in Apache2 config
LoadModule auth_module modules/mod_auth.so
Edit the Apache2 config files to set the AllowOverride for the directory you want to protect
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride AuthConfig
</Directory>
http://www.yolinux.com/TUTORIALS/LinuxTutorialApacheAddingLoginSiteProtection.html
http://engr.oregonstate.edu/computing/web/43
http://httpd.apache.org/docs/2.0/howto/auth.html
Thursday, April 17, 2008
Compile PHP 5 From Source
Before configuring, you must have development versions of the given packages installed. For example, for mcrypt support, you must install mcrypt-devel. In the list below, this applies to zlib-devel, libxml2-devel, mysql-devel, bzip2-devel, httpd-devel, and mhash-devel. Some configure options below didn't require a development version.
View configure options
./configure --help
Many configure options allow an optional =/path syntax to allow you to specify a non-default location for the development libraries.
Special configure notes
The --prefix config option allows you to specify a non-default location to install the php distribution (The root of the install, if you will)
The --exec-prefix directory allows you to specify an alternate location to install the compiled PHP binary files. In this example, they are set to the same location in the /opt directory.
Highly recommended to install --with-apxs (Apache 1.x) or --with-apxs2 (Apache 2.x). This creates the Apache module called libphp5.so that is normally installed in the Apache modules directory. This module is what Apache uses to run PHP web sites (and not the command line PHP program from the --prefix directory).
Configure command
./configure \
--prefix=/opt/php5/dist \
--exec-prefix=/opt/php5/dist \
--with-mysql \
--with-pdo-mysql \
--with-zlib \
--with-bz2 \
--enable-zip \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-ttf \
--with-apxs2 \
--enable-ftp \
--enable-exif \
--with-freetype-dir \
--enable-calendar \
--enable-soap \
--enable-mbstring \
--with-libxml-dir=/usr/lib
Brief explanation of given config options
--prefix=/opt/php5/dist # sets where the root of the install will be
--exec-prefix=/opt/php5/dist # sets where the root of the binary install will be
--with-mysql # add mysql support
--with-pdo-mysql # add support for php mysql database abstraction layer
--with-zlib # add support for compressing using zlib
--with-bz2 # adds support for bunzip2
--enable-zip # adds zip compression support
--with-openssl # adds openssl functionality
--with-mcrypt # adds support for mycrypt style functions (encryption)
--with-mhash # adds special hashing functions
--with-curl # adds support for cURL which
--with-gd # adds support for manipulating images with php
--with-jpeg-dir # adds support for manipulating jpegs with php
--with-png-dir # adds support for manipulating png files with php
--with-ttf # adds support for manipulating true type fonts
--with-apxs2 # adds support for apache2 module (important)
--enable-ftp # adds support for php ftp
--enable-exif # adds support for manipulating Image metadata
--with-freetype-dir # adds support for FreeType2
--enable-calendar # don't know
--enable-soap # adds support for SOAP XML stuff
--enable-mbstring # multi-byte string support
--with-libxml-dir=/usr/lib # adds XML support (required)
Compile and install PHP
make | tee output.make
make test | tee output.maketest
make install | tee output.makeinstall
Special notes about the compile
When using --with-apxs or --with-apxs2, the libphp5.so will be compiled in the "libs/" directory of the PHP source code. The make install will try to copy this automatically to your Apache modules directory. (In the case of the above example, make install placed the module in the /etc/httpd/modules directory - this is really a simlink to /usr/lib/httpd/modules/ in this case.)
The command line PHP binary will be located in the bin/ directory of the path specified by the --prefix option.
Install the mod_php shared library into apache
After a compile of php with the --with-apxs or --with-apxs2, and placement in the /etc/httpd/modules directory (as mentioned above), the module needs to be referenced in the httpd.conf
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
# Also, the following needs to be added to the httpd.conf
# Cause the PHP interpreter to handle files with a .php extension
AddHandler php5-script php
AddType text/html php
# PHP Syntax Coloring
AddType application/x-httpd-php-source phps
# Add index.php to the list of files that will be served as directory
DirectoryIndex index.php
http://dan.drydog.com/apache2php.html
http://us.php.net/manual/en/configure.php#configure.options.servers
View configure options
./configure --help
Many configure options allow an optional =/path syntax to allow you to specify a non-default location for the development libraries.
Special configure notes
The --prefix config option allows you to specify a non-default location to install the php distribution (The root of the install, if you will)
The --exec-prefix directory allows you to specify an alternate location to install the compiled PHP binary files. In this example, they are set to the same location in the /opt directory.
Highly recommended to install --with-apxs (Apache 1.x) or --with-apxs2 (Apache 2.x). This creates the Apache module called libphp5.so that is normally installed in the Apache modules directory. This module is what Apache uses to run PHP web sites (and not the command line PHP program from the --prefix directory).
Configure command
./configure \
--prefix=/opt/php5/dist \
--exec-prefix=/opt/php5/dist \
--with-mysql \
--with-pdo-mysql \
--with-zlib \
--with-bz2 \
--enable-zip \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-ttf \
--with-apxs2 \
--enable-ftp \
--enable-exif \
--with-freetype-dir \
--enable-calendar \
--enable-soap \
--enable-mbstring \
--with-libxml-dir=/usr/lib
Brief explanation of given config options
--prefix=/opt/php5/dist # sets where the root of the install will be
--exec-prefix=/opt/php5/dist # sets where the root of the binary install will be
--with-mysql # add mysql support
--with-pdo-mysql # add support for php mysql database abstraction layer
--with-zlib # add support for compressing using zlib
--with-bz2 # adds support for bunzip2
--enable-zip # adds zip compression support
--with-openssl # adds openssl functionality
--with-mcrypt # adds support for mycrypt style functions (encryption)
--with-mhash # adds special hashing functions
--with-curl # adds support for cURL which
--with-gd # adds support for manipulating images with php
--with-jpeg-dir # adds support for manipulating jpegs with php
--with-png-dir # adds support for manipulating png files with php
--with-ttf # adds support for manipulating true type fonts
--with-apxs2 # adds support for apache2 module (important)
--enable-ftp # adds support for php ftp
--enable-exif # adds support for manipulating Image metadata
--with-freetype-dir # adds support for FreeType2
--enable-calendar # don't know
--enable-soap # adds support for SOAP XML stuff
--enable-mbstring # multi-byte string support
--with-libxml-dir=/usr/lib # adds XML support (required)
Compile and install PHP
make | tee output.make
make test | tee output.maketest
make install | tee output.makeinstall
Special notes about the compile
When using --with-apxs or --with-apxs2, the libphp5.so will be compiled in the "libs/" directory of the PHP source code. The make install will try to copy this automatically to your Apache modules directory. (In the case of the above example, make install placed the module in the /etc/httpd/modules directory - this is really a simlink to /usr/lib/httpd/modules/ in this case.)
The command line PHP binary will be located in the bin/ directory of the path specified by the --prefix option.
Install the mod_php shared library into apache
After a compile of php with the --with-apxs or --with-apxs2, and placement in the /etc/httpd/modules directory (as mentioned above), the module needs to be referenced in the httpd.conf
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
# Also, the following needs to be added to the httpd.conf
# Cause the PHP interpreter to handle files with a .php extension
AddHandler php5-script php
AddType text/html php
# PHP Syntax Coloring
AddType application/x-httpd-php-source phps
# Add index.php to the list of files that will be served as directory
DirectoryIndex index.php
http://dan.drydog.com/apache2php.html
http://us.php.net/manual/en/configure.php#configure.options.servers
Thursday, February 07, 2008
Grub Config
Example of menu.lst booting a kernel
title Item Title Goes here
# this first root option selects which partition to set GRUB root
root (hd0,0) # name of the partition that grub should look for the kernel image
# the second root option in the kernel statement is the root partition that Linux will mount to
kernel (hd0,4)/boot/vmlinuz ro root=/dev/sda5 # location of read only image.
initrd (hd0,4)/boot/initrd.img # location of initrd image
boot # actually boots the system with the given commands
Example of menu.lst chainloading an OS
title Item Title Goes here
root (hd0,1)
chainloader +1
Installing grub into a boot sector (within the os)
sudo grub
> root (hd0,0)
> setup (hd0)
exit
title Item Title Goes here
# this first root option selects which partition to set GRUB root
root (hd0,0) # name of the partition that grub should look for the kernel image
# the second root option in the kernel statement is the root partition that Linux will mount to
kernel (hd0,4)/boot/vmlinuz ro root=/dev/sda5 # location of read only image.
initrd (hd0,4)/boot/initrd.img # location of initrd image
boot # actually boots the system with the given commands
Example of menu.lst chainloading an OS
title Item Title Goes here
root (hd0,1)
chainloader +1
Installing grub into a boot sector (within the os)
sudo grub
> root (hd0,0)
> setup (hd0)
exit
Thursday, November 22, 2007
Create MySQL User
To create a user in mysql, issue the following:
CREATE USER 'user'@'host' IDENTIFIED BY 'password';
To create a user in mysql and assign grants, issue the following:
grant privilege ondatabase.table to 'user'@'host' [with grant option] [identified by "password"]
Available privileges:
ALL [PRIVILEGES]
ALTER
CREATE
DELETE
DROP
FILE
INDEX
INSERT
PROCESS
USAGE
RELOAD
SELECT
SHUTDOWN
UPDATE
To revoke privileges:
revoke privilege on database.table from user
To revoke grant option:
revoke grant option on database.table from user
To change a password:
UPDATE mysql.user SET Password=PASSWORD('password')
WHERE User='someuser';
View current user:
select user();
Show user permissions:
show grants for 'username'@'localhost';
http://www.tech-faq.com/reset-mysql-password.shtml
CREATE USER 'user'@'host' IDENTIFIED BY 'password';
To create a user in mysql and assign grants, issue the following:
grant privilege on
Available privileges:
ALL [PRIVILEGES]
ALTER
CREATE
DELETE
DROP
FILE
INDEX
INSERT
PROCESS
USAGE
RELOAD
SELECT
SHUTDOWN
UPDATE
To revoke privileges:
revoke privilege on database.table from user
To revoke grant option:
revoke grant option on
To change a password:
UPDATE mysql.user SET Password=PASSWORD('password')
WHERE User='someuser';
View current user:
select user();
Show user permissions:
show grants for 'username'@'localhost';
http://www.tech-faq.com/reset-mysql-password.shtml
Reset MYSQL root password
Reset the mysql "root" password:
1) Log in as UNIX root
2) Stop the MySQL Deamon (may vary depending on OS)
/etc/rc.d/init.d/mysqld stop
3) Start mysql in safe mode
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables
4) Log into the mysql schema as root in safe mode
/usr/local/mysql/bin/mysql --user=root mysql
5) Run the update to change the password
UPDATE user SET Password=PASSWORD('YOUR_PASSWORD')
WHERE Host='localhost' AND User='root';
flush privileges;
6) Restart the MySQL server deamon
/etc/rc.d/init.d/mysqld start
Method set a root password
mysqladmin -u root password 'new-password'
http://help.hardhathosting.com/question.php/200
1) Log in as UNIX root
2) Stop the MySQL Deamon (may vary depending on OS)
/etc/rc.d/init.d/mysqld stop
3) Start mysql in safe mode
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables
4) Log into the mysql schema as root in safe mode
/usr/local/mysql/bin/mysql --user=root mysql
5) Run the update to change the password
UPDATE user SET Password=PASSWORD('YOUR_PASSWORD')
WHERE Host='localhost' AND User='root';
flush privileges;
6) Restart the MySQL server deamon
/etc/rc.d/init.d/mysqld start
Method set a root password
mysqladmin -u root password 'new-password'
http://help.hardhathosting.com/question.php/200
Friday, September 14, 2007
Terminal Information
The $TERM environment variable sets the terminal type. The terminal type environment variable should specify a terminal type definition file that is usually located in the /usr/share/lib/terminfo/ directory. This terminal type in the shell environment should match the terminal type setting in your terminal emulator program (xterm, putty, gterm, secureCRT, etc. ).
Set this environment variable to override default terminfo DB location
TERMINFO
Use this to query a terminfo DB in a nondefault location
infocmp -A /nonstandard/terminfo/DB/location/path
Terminfo default DB location
/usr/share/lib/terminfo
Show differences between terms
infocmp -d vt100 vt220
Show similarities between terms
infocmp -c vt100 vt220
Show term capabilities
infocmp # no args defaults to $TERM var
infocmp -I # no args defaults to $TERM var
infocmp term_name # term_name is a filename in the terminfo DB location
infocmp -1 # one item per line
Print ansi escape sequences for a given terminal capability
tput option # option listed in infocmp output
Compile a terminfo source file to be stored in the TERMINFO dir
tic filename
Create Windows style newline characters from the terminal
type: Ctrl-v Ctrl-m
printf '\r\n'
Display Windows style newline characters
cat -ve filename
Enable color in vim for terminals that support it (xterm, vt100, linux)
Add the following to the ~/.vimrc
set t_Co=8
set t_Sf=^[[3%p1%dm
set t_Sb=^[[4%p1%dm
syntax on
Replace the ^[ with a real key (type CTRL-V ESC)
http://vimdoc.sourceforge.net/htmldoc/syntax.html#xterm-color
http://vim.wikia.com/wiki/Color_highlighting_on_telnet
http://en.wikipedia.org/wiki/Newline
Set this environment variable to override default terminfo DB location
TERMINFO
Use this to query a terminfo DB in a nondefault location
infocmp -A /nonstandard/terminfo/DB/location/path
Terminfo default DB location
/usr/share/lib/terminfo
Show differences between terms
infocmp -d vt100 vt220
Show similarities between terms
infocmp -c vt100 vt220
Show term capabilities
infocmp # no args defaults to $TERM var
infocmp -I # no args defaults to $TERM var
infocmp term_name # term_name is a filename in the terminfo DB location
infocmp -1 # one item per line
Print ansi escape sequences for a given terminal capability
tput option # option listed in infocmp output
Compile a terminfo source file to be stored in the TERMINFO dir
tic filename
Create Windows style newline characters from the terminal
type: Ctrl-v Ctrl-m
printf '\r\n'
Display Windows style newline characters
cat -ve filename
Enable color in vim for terminals that support it (xterm, vt100, linux)
Add the following to the ~/.vimrc
set t_Co=8
set t_Sf=^[[3%p1%dm
set t_Sb=^[[4%p1%dm
syntax on
Replace the ^[ with a real
http://vimdoc.sourceforge.net/htmldoc/syntax.html#xterm-color
http://vim.wikia.com/wiki/Color_highlighting_on_telnet
http://en.wikipedia.org/wiki/Newline
Wednesday, August 22, 2007
Subversion
Setting up a repository:
svnadmin create /usr/local/svn/newrepos
Import files into repository:
svn import /import/dir file:///usr/local/svn/newrepos/projectname -m "comment"
List files in a repository tree:
svn list file:///usr/local/svn/newrepos/projectname
svn ls #while in sandbox
svn ls -v # verbose
Checkout a directory:
svn checkout "http://host:port/path"
svn co http://host:port/path
svn checkout file:///path/to/repos
svn checkout file:///localhost/path/to/repos
svn checkout svn+ssh://host/path/to/repos
Check a specific revision:
svn checkout -r revision_num
svn checkout -r {2006-02-17}
svn checkout -r {"2006-02-17 15:30"}
Checkin a file:
svn commit filename.txt -m "some comment here"
Update working copy with committed changes from other users:
svn update
Manage local copy (sandbox):
svn add filename
svn delete filename
svn move file1 file2
svn copy file1 file2
svn mkdir dirname
View files changed since last commit:
svn stat
svn stat filename
svn status -v # verbose view of all files in sandbox
svn status -v -u # contacts the repository to show more info
View changes since last commit:
svn diff # show diffs within files
Revert a file (working copy):
svn revert file
svn merge -r curr_version:prev_version working_file.txt
Show revision history:
svn log
svn log -r 5:19 # shows revisions 5 through 19
svn log -r 9 # shows revision 9
svn log filename # show revisions on a given file
svn log -r {2006-11-20}:{2006-11-22} # show versions between two dates
svn log --verbose # show all files in all revisions
svn log --verbose | grep "/path/to/file/" -B10 # grep history and show last 10 lines
Show file info:
svn info filename
Backup a repository:
svnadmin dump /path/to/repository > dumpfile
Restore a repository:
svnadmin load /path/to/repository/ < dumpfile.dump
Export a repository without all the metadata:
svn export file:///path/to/repository export_dir
Ignore files in the svn working copy:
create a file in home directory called .svnignore
While in working copy, run command
svn -R propset svn:ignore -F /path/to/home/.svnignore .
http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/
http://svnbook.red-bean.com/en/1.0/re10.html
http://svnbook.red-bean.com/en/1.0/re36.html
http://aralbalkan.com/1381
http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-3-sect-6.2.2
svnadmin create /usr/local/svn/newrepos
Import files into repository:
svn import /import/dir file:///usr/local/svn/newrepos/projectname -m "comment"
List files in a repository tree:
svn list file:///usr/local/svn/newrepos/projectname
svn ls #while in sandbox
svn ls -v # verbose
Checkout a directory:
svn checkout "http://host:port/path"
svn co http://host:port/path
svn checkout file:///path/to/repos
svn checkout file:///localhost/path/to/repos
svn checkout svn+ssh://host/path/to/repos
Check a specific revision:
svn checkout -r revision_num
svn checkout -r {2006-02-17}
svn checkout -r {"2006-02-17 15:30"}
Checkin a file:
svn commit filename.txt -m "some comment here"
Update working copy with committed changes from other users:
svn update
Manage local copy (sandbox):
svn add filename
svn delete filename
svn move file1 file2
svn copy file1 file2
svn mkdir dirname
View files changed since last commit:
svn stat
svn stat filename
svn status -v # verbose view of all files in sandbox
svn status -v -u # contacts the repository to show more info
View changes since last commit:
svn diff # show diffs within files
Revert a file (working copy):
svn revert file
Restore a previously committed file back to working copy:
Show revision history:
svn log
svn log -r 5:19 # shows revisions 5 through 19
svn log -r 9 # shows revision 9
svn log filename # show revisions on a given file
svn log -r {2006-11-20}:{2006-11-22} # show versions between two dates
svn log --verbose # show all files in all revisions
svn log --verbose | grep "/path/to/file/" -B10 # grep history and show last 10 lines
Show file info:
svn info filename
Backup a repository:
svnadmin dump /path/to/repository > dumpfile
Restore a repository:
svnadmin load /path/to/repository/ < dumpfile.dump
Export a repository without all the metadata:
svn export file:///path/to/repository export_dir
Ignore files in the svn working copy:
create a file in home directory called .svnignore
While in working copy, run command
svn -R propset svn:ignore -F /path/to/home/.svnignore .
http://svnbook.red-bean.com/en/1.0/re10.html
http://svnbook.red-bean.com/en/1.0/re36.html
http://aralbalkan.com/1381
http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-3-sect-6.2.2
Sunday, April 22, 2007
Serial to USB converter
Prerequisites
minicom
kernel configure options:
USB=m # USB subsystem
USB_SERIAL=m # USB serial port support
USB_SERIAL_GENERIC=m # USB serial port generic driver
USB_SERIAL_PL2303=m # USB serial port driver
menuconfig path:
- Device Drivers ->
-- USB Support ->
--- USB Serial Converter support ->
---- USB Generic Serial Driver
---- (hardware specific driver)
---- e.x. USB Prolific 2303 Single Port Serial Driver
lsmod Listing (modules loaded):
usbcore pl2303,usbserial,...
- usbserial pl2303
Minicom serial port settings:
Serial Device: /dev/ttyUSB0
Bps/Par/Bits: 9600 8N1
Hardware Flow Control: No
Software Flow Control: No
http://www.gentoo.org/doc/en/usb-guide.xml
minicom
kernel configure options:
USB=m # USB subsystem
USB_SERIAL=m # USB serial port support
USB_SERIAL_GENERIC=m # USB serial port generic driver
USB_SERIAL_PL2303=m # USB serial port driver
menuconfig path:
- Device Drivers ->
-- USB Support ->
--- USB Serial Converter support ->
---- USB Generic Serial Driver
---- (hardware specific driver)
---- e.x. USB Prolific 2303 Single Port Serial Driver
lsmod Listing (modules loaded):
usbcore pl2303,usbserial,...
- usbserial pl2303
Minicom serial port settings:
Serial Device: /dev/ttyUSB0
Bps/Par/Bits: 9600 8N1
Hardware Flow Control: No
Software Flow Control: No
http://www.gentoo.org/doc/en/usb-guide.xml
Saturday, April 14, 2007
iproute commands
Prerequisites
iproute2 package
kernel configure options:
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_IP_ROUTE_MULTIPATH=y
menuconfig path:
- Networking -->
-- Networking Support -->
--- Networking options -->
---- TCP/IP networking
----- IP: Advanced router
----- IP: policy routing
----- IP: equal cost multipath
Enable IP Forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
IP LINK (cmd subset)
Show hardware address
ip link
ip link [show|ls|list|sh]
Take an interface up/down
ip link set dev (device) up
ip link set (device) up
ip link set dev (device) down
ip link set (device) up
Change the MAC address of the interface
ip link set dev (device) address (arp address)
IP ADDRESS (cmd subset)
Show ip address
ip addr
ip addr [show|sh|list|ls]
ip addr show dev eth0 # show specific device
Show ip addresses (the old "ifconfig" way)
ifconfig -a
ifconfig
Assign IP address to interface
ip addr [add|a] (address)/(mask) dev (device)
ex: ip addr add 192.168.1.2/24 dev eth0
Assign IP address to interface (the old "ifconfig" way)
ifconfig eth0 192.168.1.2 netmask 255.255.255.0
Remove IP address from interface
ip addr [delete|del|d] (address)/(mask) dev (device)
ex: ip addr del 192.168.1.2/24 dev eth0
IP NEIGHBOR (cmd subset)
Show ip Layer 2 neighbors (arp table)
ip neigh
Show ip Layer 2 netighbors (the old "arp" way)
arp -a
Add new ARP mapping
ip neigh add 192.168.1.100 dev eth0 lladdr (mac address)
ip neigh add 192.168.1.100 dev eth0 lladdr (mac address) nud reachable
NUD Statuses
--permanent (perm) # administrative mapping
--noarp # neighbor valid but no attempt to rearp will be made
--reachable # neighbor entry valid until timeout
--stale # old arp entry
Remove ARP mapping
ip neigh del 192.168.1.100 dev eth0
Flush arp table
ip neigh flush
IP ROUTE (cmd subset)
Show ip routing tables
ip route
Show ip routing tabes (the old "route" way)
route
Add Static Route
ip route add (network)/(mask) via (ip to route through)
e.x. ip route add 10.0.0.0/24 via 192.244.7.65
ip route add (network)/(mask) src INTERFACE_IP dev (device)
ip route add (network)/(mask) dev (device) protocol static
Add Static Route (old "route" method)
route add -net 10.0.0.0 netmask 255.255.255.0 dev eth0
Add Default Route
ip route add default via GATEWAY_IP
Add Default Route (old "route" method)
route add default gw 192.168.1.1
Del Route
ip route del 10.0.0.0/24
Delete all routes on an interface
ip route flush dev eth0
http://www.policyrouting.org/iproute2.doc.html
http://gentoo-wiki.com/Dual_internet_connections
iproute2 package
kernel configure options:
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_IP_ROUTE_MULTIPATH=y
menuconfig path:
- Networking -->
-- Networking Support -->
--- Networking options -->
---- TCP/IP networking
----- IP: Advanced router
----- IP: policy routing
----- IP: equal cost multipath
Enable IP Forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
IP LINK (cmd subset)
Show hardware address
ip link
ip link [show|ls|list|sh]
Take an interface up/down
ip link set dev (device) up
ip link set (device) up
ip link set dev (device) down
ip link set (device) up
Change the MAC address of the interface
ip link set dev (device) address (arp address)
IP ADDRESS (cmd subset)
Show ip address
ip addr
ip addr [show|sh|list|ls]
ip addr show dev eth0 # show specific device
Show ip addresses (the old "ifconfig" way)
ifconfig -a
ifconfig
Assign IP address to interface
ip addr [add|a] (address)/(mask) dev (device)
ex: ip addr add 192.168.1.2/24 dev eth0
Assign IP address to interface (the old "ifconfig" way)
ifconfig eth0 192.168.1.2 netmask 255.255.255.0
Remove IP address from interface
ip addr [delete|del|d] (address)/(mask) dev (device)
ex: ip addr del 192.168.1.2/24 dev eth0
IP NEIGHBOR (cmd subset)
Show ip Layer 2 neighbors (arp table)
ip neigh
Show ip Layer 2 netighbors (the old "arp" way)
arp -a
Add new ARP mapping
ip neigh add 192.168.1.100 dev eth0 lladdr (mac address)
ip neigh add 192.168.1.100 dev eth0 lladdr (mac address) nud reachable
NUD Statuses
--permanent (perm) # administrative mapping
--noarp # neighbor valid but no attempt to rearp will be made
--reachable # neighbor entry valid until timeout
--stale # old arp entry
Remove ARP mapping
ip neigh del 192.168.1.100 dev eth0
Flush arp table
ip neigh flush
IP ROUTE (cmd subset)
Show ip routing tables
ip route
Show ip routing tabes (the old "route" way)
route
Add Static Route
ip route add (network)/(mask) via (ip to route through)
e.x. ip route add 10.0.0.0/24 via 192.244.7.65
ip route add (network)/(mask) src INTERFACE_IP dev (device)
ip route add (network)/(mask) dev (device) protocol static
Add Static Route (old "route" method)
route add -net 10.0.0.0 netmask 255.255.255.0 dev eth0
Add Default Route
ip route add default via GATEWAY_IP
Add Default Route (old "route" method)
route add default gw 192.168.1.1
Del Route
ip route del 10.0.0.0/24
Delete all routes on an interface
ip route flush dev eth0
http://www.policyrouting.org/iproute2.doc.html
http://gentoo-wiki.com/Dual_internet_connections
Saturday, April 07, 2007
Date Time Clocks
Setting the timezone:
ln -sf /usr/share/zoneinfo/your/zone /etc/localtime
Setting the timezone for a particular user:
export TZ=America/Chicago
Show time in a given timezone:
# relative to the /usr/share/zoneinfo/ directory
zdump Japan
zdump America/Chicago
zdump US/Central
# absolute path to zonefile
zdump /etc/localtime
zdump /usr/share/zoneinfo/America/Chicago
View date and time:
date
date --utc #universal time
Set the date and time:
date -s "16:15:00" # just the time
date -s "16:15:00 April 7, 2007" # date and time
date 040716552007.00 # the fields being MMDDhhmmCCYY.ss
Verify connectivity with NTP server:
ntpdate -q time.nist.gov
Several common time servers:
clock.redhat.com
clock2.redhat.com
ns1.tuxfamily.org
time.nist.gov
time.apple.com
Manually use NTP to set time:
ntpdate time.nist.gov
ntpdate -v time.nist.gov # verbose output
Use NTPd to automatically set date and time:
/etc/init.d/ntpd start #ntpd must be installed, of course
Monitor NTPd:
ntpdc -p
ntpdc -p -n
http://www.linuxsa.org.au/tips/time.html
http://www.vanemery.com/Linux/RH-Linux-Time.html
ln -sf /usr/share/zoneinfo/your/zone /etc/localtime
Setting the timezone for a particular user:
export TZ=America/Chicago
Show time in a given timezone:
# relative to the /usr/share/zoneinfo/ directory
zdump Japan
zdump America/Chicago
zdump US/Central
# absolute path to zonefile
zdump /etc/localtime
zdump /usr/share/zoneinfo/America/Chicago
View date and time:
date
date --utc #universal time
Set the date and time:
date -s "16:15:00" # just the time
date -s "16:15:00 April 7, 2007" # date and time
date 040716552007.00 # the fields being MMDDhhmmCCYY.ss
Verify connectivity with NTP server:
ntpdate -q time.nist.gov
Several common time servers:
clock.redhat.com
clock2.redhat.com
ns1.tuxfamily.org
time.nist.gov
time.apple.com
Manually use NTP to set time:
ntpdate time.nist.gov
ntpdate -v time.nist.gov # verbose output
Use NTPd to automatically set date and time:
/etc/init.d/ntpd start #ntpd must be installed, of course
Monitor NTPd:
ntpdc -p
ntpdc -p -n
http://www.linuxsa.org.au/tips/time.html
http://www.vanemery.com/Linux/RH-Linux-Time.html
Sunday, April 01, 2007
Fake RAID links
Wikipedia FakeRAID Def
http://en.wikipedia.org/wiki/Fakeraid
Not transparent to the OS like real RAID. Not controlled entirely by the operating system either like softRAID. However, it uses hardware and needs an OS driver.
LINUX FakeRAID drivers
http://linux-ata.org/driver-status.html
List of FaikRAID hardware devices/controllers
http://linuxmafia.com/faq/Hardware/sata.html
My MoBo
http://www.pcstats.com/articleview.cfm?articleid=1770&page=1
This Mobo uses the following kernel modules:
sata_nv: for the 4 nForce4 controllers
kernel configure option:
CONFIG_SATA_NV=y
menconfig path:
- Device Drivers -->
-- Serial ATA (prod) and ... -->
--- ATA device support -->
---- NVIDIA SATA support
----- sata_sil: for the 4 Sillicon Image 3314 controllers
kernel configure option:
CONFIG_SATA_SLI = y
menuconfig path:
- Device Drivers -->
-- Serial ATA (prod) and ... -->
--- ATA device support -->
---- Silicon Image SATA support
----- ahci: generic Open standard (I don't have this, but worth a mention)
kernel configure option:
CONFIG_SATA_AHCI=y
menuconfig path:
- Device Drivers -->
-- Serial ATA (prod) and ... -->
--- ATA device support -->
---- AHCI SATA support
Both of these modules depend on the module:
libata
Libata depends on the following module:
scsi_mod
kernel configure option:
CONFIG_SCSI=y
menuconfig path:
- Device Drivers -->
-- SCSI device support -->
--- SCSI device support
http://en.wikipedia.org/wiki/Fakeraid
Not transparent to the OS like real RAID. Not controlled entirely by the operating system either like softRAID. However, it uses hardware and needs an OS driver.
LINUX FakeRAID drivers
http://linux-ata.org/driver-status.html
List of FaikRAID hardware devices/controllers
http://linuxmafia.com/faq/Hardware/sata.html
My MoBo
http://www.pcstats.com/articleview.cfm?articleid=1770&page=1
This Mobo uses the following kernel modules:
sata_nv: for the 4 nForce4 controllers
kernel configure option:
CONFIG_SATA_NV=y
menconfig path:
- Device Drivers -->
-- Serial ATA (prod) and ... -->
--- ATA device support -->
---- NVIDIA SATA support
----- sata_sil: for the 4 Sillicon Image 3314 controllers
kernel configure option:
CONFIG_SATA_SLI = y
menuconfig path:
- Device Drivers -->
-- Serial ATA (prod) and ... -->
--- ATA device support -->
---- Silicon Image SATA support
----- ahci: generic Open standard (I don't have this, but worth a mention)
kernel configure option:
CONFIG_SATA_AHCI=y
menuconfig path:
- Device Drivers -->
-- Serial ATA (prod) and ... -->
--- ATA device support -->
---- AHCI SATA support
Both of these modules depend on the module:
libata
Libata depends on the following module:
scsi_mod
kernel configure option:
CONFIG_SCSI=y
menuconfig path:
- Device Drivers -->
-- SCSI device support -->
--- SCSI device support
Tuesday, March 20, 2007
mdadm software raid usage
Install
mdadm package needed (aptitude install mdadm)
http://neil.brown.name/blog/mdadm
Create array:
mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdc1
or
/etc/mdadm.conf
# optional, but used for easier interaction
DEVICE /dev/sdb1 /dev/sdc1
ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1
# produces output that you would put in the mdadm.conf
mdadm --detail --scan
Show device info:
mdadm -E /dev/sdc1
# shows info about the component disks
Start (assemble) Existing Array:
mdadm -As /dev/md0
# -A starts assemble mode to assemble existing array
# -s indicates the use of /etc/mdadm.conf
or
mdadm -A /dev/md0 /dev/sdb1 /dev/sdc1
# starts array without existing /etc/mdadm.conf
Assemble an existing array automatically:
mdadm --assemble --scan
or
mdadm -As
Stop the array:
mdadm -S /dev/md0
or
mdadm --stop /dev/md0
Add a disk:
mdadm /dev/md0 --add /dev/sdc1
Remove a disk:
mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1
# "fails" and removes a disk
fstab entry for the array:
# this assumes the array was formated with ext3
/dev/md0 /export/ ext3 suid,dev,defaults,exec 0 0
http://www.linuxdevcenter.com/pub/a/linux/2002/12/05/RAID.html
mdadm package needed (aptitude install mdadm)
http://neil.brown.name/blog/mdadm
Create array:
mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdc1
or
mdadm -Cv /dev/md0 -l0 -n2 -c128 /dev/sdb1 /dev/sdc1/etc/mdadm.conf
# optional, but used for easier interaction
DEVICE /dev/sdb1 /dev/sdc1
ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1
Show md info:# produces output that you would put in the mdadm.conf
mdadm --detail --scan
Show device info:
mdadm -E /dev/sdc1
# shows info about the component disks
Start (assemble) Existing Array:
mdadm -As /dev/md0
# -A starts assemble mode to assemble existing array
# -s indicates the use of /etc/mdadm.conf
or
mdadm -A /dev/md0 /dev/sdb1 /dev/sdc1
# starts array without existing /etc/mdadm.conf
Assemble an existing array automatically:
mdadm --assemble --scan
or
mdadm -As
Stop the array:
mdadm -S /dev/md0
or
mdadm --stop /dev/md0
Add a disk:
mdadm /dev/md0 --add /dev/sdc1
Remove a disk:
mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1
# "fails" and removes a disk
fstab entry for the array:
# this assumes the array was formated with ext3
/dev/md0 /export/ ext3 suid,dev,defaults,exec 0 0
http://www.linuxdevcenter.com/pub/a/linux/2002/12/05/RAID.html
Saturday, March 03, 2007
SUDO
<users_to_allow> <host> = (run_as_user) <command_to_run>
No password for users in admin group
%admin ALL= (ALL) NOPASSWD: ALL
No password for joeuser user
joeuser ALL=(ALL) NOPASSWD: ALL
Allow joeuser to run only certain privileged commands as root
joeuser ALL= /bin/kill, /usr/local/bin/
Allow joeuser to run certain commands as given users
joeuser ALL=(janeuser,johnuser) /bin/kill, /usr/local/bin
Run sudo command as another user using
sudo -u janeuser /bin/kill
http://aplawrence.com/Basics/sudo.html
Monday, February 26, 2007
Screen Command Usage
Create a new Screen session
screen # creates a default session
screen -S name # creates a session with a name
# Screen has two similar concepts: screens and window sessions.
# screens are seperate processes that show up when doing
# a "screen -ls" listing. Windows are "sub-screens" of a given
# screen process used for split screen modes and such.
Rename an already created window
CTRL-a A # then provide name
Rename a screen (interactively)
CTRL-a :sessionname newsessionname
Rename a screen (without attaching)
screen -X sessionname newsessionname
Detach from a screen session
screen -d # detach from a command prompt
Ctrl-a d # detach from anywhere in the session
List screen sessions
screen -ls
Reattach to a screen session
screen -r # attaches to default session
screen -r name # attaches to specific session (unique string in the name)
Toggle between several attached windows
Ctrl-a Ctrl-a
Attach to an already attached screen (mirror)
screen -x # attaches to default session
screen -x name # attaches to named session
Share a screen session
owner:
screen -S name # start and name the screen
Ctrl-a :multiuser on # add multiuser support
Ctrl-a :acladd userids # share the screen to userids (comma sep)
client:
screen -x username/session # attach to the screen (in mirror)
Change permissions on a shared session
owner:
Ctrl-a :aclchg userids [permbits] [list]
# permbits = rwx and prefixed by "-" or "+"
# list of commands - #(all windows), ?(all commands)
Remove user access
owner:
acldel userids
Lock a Screen
ctrl-a ctrl-x # requires user to enter password to unlock
Copy and Paste from the screen scrollback buffer
Ctrl-a [Esc] # enters scrollback editor (movement like vi)
[spacebar] # starts and stops a copy selection range
Ctrl-a :paste . # pastes the copy buffer to the term
Screenrc options:
/home/> vi .screenrc
#shell -bash
shell -ksh # Make Screenrc exe .profile file on login
# Set the scrollback buffer
defscrollback 5000
# Turn off the startup banner
startup_message off
# displays a status line at the bottom of the terminal window.
hardstatus alwayslastline "Screen: %w %c:%s %D, %M/%d/%Y "
# detach on hangup - if my dial-up session fails, screen will simply
# detach and let me re re-attach later
autodetach on
Split Screen
# Create two screens
screen # create first screen
CTRL-a c # create second screen session (1 screen instance, but 2 window sessions)
CTRL-a S # split the screen
CTRL-a TAB # move to the bottom part of the split
CTRL-a " # will prompt for a screen number. Choose 0 or 1 indicating the window session
CTRL-a Q # quit all splits except the current
Scrollback / Copy and Paste
CTRL-a [ or CTRL-a ESC # frees the cursor to move into scrollback buffer (Copy mode)
# ESC to exit copy mode without copying
# use arrow keys or h,j,k,l to navigate in copy mode
# use CTRL-F and CTRL-B to page up and down in copy mode
ENTER # indicates a start point for text copy
ENTER # (second) indicates an end point for text copy
CTRL-a ] # pastes copied text range
http://aperiodic.net/screen/quick_reference
http://news.softpedia.com/news/GNU-Screen-Tutorial-44274.shtml
screen # creates a default session
screen -S name # creates a session with a name
# Screen has two similar concepts: screens and window sessions.
# screens are seperate processes that show up when doing
# a "screen -ls" listing. Windows are "sub-screens" of a given
# screen process used for split screen modes and such.
Rename an already created window
CTRL-a A # then provide name
Rename a screen (interactively)
CTRL-a :sessionname newsessionname
Rename a screen (without attaching)
screen -X sessionname newsessionname
Detach from a screen session
screen -d # detach from a command prompt
Ctrl-a d # detach from anywhere in the session
List screen sessions
screen -ls
Reattach to a screen session
screen -r # attaches to default session
screen -r name # attaches to specific session (unique string in the name)
Toggle between several attached windows
Ctrl-a Ctrl-a
Attach to an already attached screen (mirror)
screen -x # attaches to default session
screen -x name # attaches to named session
Share a screen session
owner:
screen -S name # start and name the screen
Ctrl-a :multiuser on # add multiuser support
Ctrl-a :acladd userids # share the screen to userids (comma sep)
client:
screen -x username/session # attach to the screen (in mirror)
Change permissions on a shared session
owner:
Ctrl-a :aclchg userids [permbits] [list]
# permbits = rwx and prefixed by "-" or "+"
# list of commands - #(all windows), ?(all commands)
Remove user access
owner:
acldel userids
Lock a Screen
ctrl-a ctrl-x # requires user to enter password to unlock
Copy and Paste from the screen scrollback buffer
Ctrl-a [Esc] # enters scrollback editor (movement like vi)
[spacebar] # starts and stops a copy selection range
Ctrl-a :paste . # pastes the copy buffer to the term
Screenrc options:
/home/> vi .screenrc
#shell -bash
shell -ksh # Make Screenrc exe .profile file on login
# Set the scrollback buffer
defscrollback 5000
# Turn off the startup banner
startup_message off
# displays a status line at the bottom of the terminal window.
hardstatus alwayslastline "Screen: %w %c:%s %D, %M/%d/%Y "
# detach on hangup - if my dial-up session fails, screen will simply
# detach and let me re re-attach later
autodetach on
Split Screen
# Create two screens
screen # create first screen
CTRL-a c # create second screen session (1 screen instance, but 2 window sessions)
CTRL-a S # split the screen
CTRL-a TAB # move to the bottom part of the split
CTRL-a " # will prompt for a screen number. Choose 0 or 1 indicating the window session
CTRL-a Q # quit all splits except the current
Scrollback / Copy and Paste
CTRL-a [ or CTRL-a ESC # frees the cursor to move into scrollback buffer (Copy mode)
# ESC to exit copy mode without copying
# use arrow keys or h,j,k,l to navigate in copy mode
# use CTRL-F and CTRL-B to page up and down in copy mode
ENTER # indicates a start point for text copy
ENTER # (second) indicates an end point for text copy
CTRL-a ] # pastes copied text range
http://aperiodic.net/screen/quick_reference
http://news.softpedia.com/news/GNU-Screen-Tutorial-44274.shtml
Tuesday, February 20, 2007
SSH Port Forward
Allow port forwarding on the server
# Edit the /etc/ssh/sshd_config
AllowTcpForwarding yes
Local Forward
# create a tunnel to access an ssh server behind a firewall using a gateway
ssh -L 7777:192.168.1.160:22 gateway.example.com cat -
# access the ssh server via your local machine
ssh -p 7777 localhost
http://www.securityfocus.com/infocus/1816
# Edit the /etc/ssh/sshd_config
AllowTcpForwarding yes
Local Forward
# create a tunnel to access an ssh server behind a firewall using a gateway
ssh -L 7777:192.168.1.160:22 gateway.example.com cat -
# access the ssh server via your local machine
ssh -p 7777 localhost
http://www.securityfocus.com/infocus/1816
Tuesday, February 13, 2007
Find File Space Usage
Find space used on filesystem level:
du -ks # shows summary of space used on disk in Kb
du -ms # shows summary of space used on disk in Mb
du -gs # show summary of space used on disk in Gb
Find space used on a file level:
find . -type f -ls | awk '{print $7}' | while read size
do
((TSIZE=TSIZE + $size))
done
echo "$TSIZE"
Shows largest files in a directory:
Shows files using the most space on the filesystem:
du
# this space list will not include files or dirs that the current
# user has no read permissions on
ls /home/ | while read a
do
du -sm /home/$a
done 2> /dev/null | sort -k 1n | tail -10
du -ks # shows summary of space used on disk in Kb
du -ms # shows summary of space used on disk in Mb
du -gs # show summary of space used on disk in Gb
Find space used on a file level:
find . -type f -ls | awk '{print $7}' | while read size
do
((TSIZE=TSIZE + $size))
done
echo "$TSIZE"
Shows largest files in a directory:
ls -l | sort -k 5rn,5 -k 9fd,9
-k = search criteria
5 = sort column five
r = apply reverse sort
n = numeric sort
Shows files using the most space on the filesystem:
du
-ak | sort -k 1rn -k 2fd
Shows users using the most space:# this space list will not include files or dirs that the current
# user has no read permissions on
ls /home/ | while read a
do
du -sm /home/$a
done 2> /dev/null | sort -k 1n | tail -10
http://www.devdaily.com/unix/edu/examples/sort.shtml
http://www.cs.rit.edu/~vcss231/Labs/Tips/unix-w8.html
Friday, January 12, 2007
OpenLDAP Commands
Search ldap database:
view everything anonymously authenticated
ldapsearch -x -b 'dc=example,dc=com'
-x : unauthenticated
-b : baseDN
-h : host
-p : port (389 normal; 636 secure)
Same as above but more explicit
ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*)'
The test in the parens can be used to restrict the search and return only records for which that test is true. For example, the following will only return the record whose uid is set to joeuser.
ldapsearch -x -b 'dc=example,dc=com' '(uid=joeuser)'
view everything anonymously authenticated
ldapsearch -x -b 'dc=example,dc=com'
-x : unauthenticated
-b : baseDN
-h : host
-p : port (389 normal; 636 secure)
Same as above but more explicit
ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*)'
The test in the parens can be used to restrict the search and return only records for which that test is true. For example, the following will only return the record whose uid is set to joeuser.
ldapsearch -x -b 'dc=example,dc=com' '(uid=joeuser)'
Sunday, January 07, 2007
dm-crypt filesystem encryption
Dependencies needed:
Kernel Setup:
Device Drivers > Multi-device support (RAID and LVM) > Device Mapper Support (dm-mod)
Device Drivers > Multi-device support (RAID and LVM) > Crypt Target Support (dm-crypt)
Cryptographic Options > (Select cyphers .. ex. aes, twofish)
Userspace tools needed:
cryptsetup.sh
libdevmapper
cryptsetup.sh Syntax:
Create crypto physical device (sized by existing partition):
cryptsetup.sh -c aes -h plain -y -b `blockdev --getsize \
/dev/hdb2` create cryptvol1 /dev/hdb2
Copy over data:
http://www.linux.com/article.pl?sid=04/06/07/2036205
http://www.saout.de/misc/dm-crypt/
Kernel Setup:
Device Drivers > Multi-device support (RAID and LVM) > Device Mapper Support (dm-mod)
Device Drivers > Multi-device support (RAID and LVM) > Crypt Target Support (dm-crypt)
Cryptographic Options > (Select cyphers .. ex. aes, twofish)
Userspace tools needed:
cryptsetup.sh
libdevmapper
cryptsetup.sh Syntax:
Syntax: cryptsetup [<OPTIONS>] <action> <name> [<device>]
<OPTIONS>:
-c <cipher> (see /proc/crypto)
-h {plain/<hash>} (see hashalot)
-y (verifies the passphrase by asking for it twice)
-d <file> (read key from file
e.g. /dev/urandom; useful for swap devices.
If set, the parameters -h and -y will be ignored)
-s <keysize> (in bits) (WARNING: in bytes for cryptsetup.sh)
-b <size> (in sectors)
-o <offset> (in sectors)
-p <skipped> (in sectors)
<action> is one of:
create - create device
remove - remove device
reload - modify active device
resize - resize active device
status - show device status
<name> is the device to create under /dev/mapper/
<device> is the encrypted device
Create crypto physical device (sized by existing partition):
cryptsetup.sh -c aes -h plain -y -b `blockdev --getsize \
/dev/hdb2` create cryptvol1 /dev/hdb2
Copy over data:
dd if=/dev/hdb2 of=/dev/mapper/cryptvol1 bs=4khttp://www.linux.com/article.pl?sid=04/06/07/2036205
http://www.saout.de/misc/dm-crypt/
Saturday, January 06, 2007
rsync
Syntax:
-v: verbose
-r: recursive
-a: archive - maintain perms, ownership
-H: Maintain hard links
-x: no recursion into other filesystems
--progress: shows progress info
--numeric-ids: don't translate UID/GIDs; important for backups.
--delete: delete from backup files that no longer exist on server
--exclude-from=file.txt: specifies a file to exclude paths. One path per line.
--delete-excluded: delete files previous backup which are now within exclude list
username@: username on remote host
host:: name of host
/home/userdir: path to backup
Example of simple copy:
rsync -r -e ssh --delete /home/user/ user@host:/backups/
http://www.sanitarium.net/golug/rsync_backups.html
http://linuxgazette.net/104/odonovan.html
rsync -vaHx --progress --numeric-ids --delete \Common options:
--exclude-from=asylum_backup.excludes --delete-excluded \
username@host:/home/userdir/ /backupdir/
-v: verbose
-r: recursive
-a: archive - maintain perms, ownership
-H: Maintain hard links
-x: no recursion into other filesystems
--progress: shows progress info
--numeric-ids: don't translate UID/GIDs; important for backups.
--delete: delete from backup files that no longer exist on server
--exclude-from=file.txt: specifies a file to exclude paths. One path per line.
--delete-excluded: delete files previous backup which are now within exclude list
username@: username on remote host
host:: name of host
/home/userdir: path to backup
trailing slash: backup contents of dir/backupdir: location to backup files
no trailing slash: backup dir
Example of simple copy:
rsync -r -e ssh --delete /home/user/ user@host:/backups/
http://www.sanitarium.net/golug/rsync_backups.html
http://linuxgazette.net/104/odonovan.html
Sunday, December 31, 2006
LVM Basics
Dependencies needed:
Kernel module (version 2.6.9+):
Device Drivers > Multi-device support (RAID and LVM) > Device Mapper Support (CONFIG_BLK_DEV_DM)
Associated kernel module:
dm_mod
Package:
lvm2 - lvm tools
libdevmapper
Show LVM version:
lvm version
Create the physical disks:
pvcreate /dev/hda
pvcreate /dev/hdb
pvcreate /dev/hdc1
pvcreate /dev/hdc2
Show allocated Physical volumes:
pvscan
pvdisplay
lvm pvs
Setup a volume group:
vgcreate vg_name /dev/hda /dev/hdb /dev/hdc1 /dev/hdc2
Display a volume group:
vgdisplay
lvm vgs
Display a logical volume:
lvdisplay
lvm lvs
Create Logical Volume:
Sets the size to 1GB
lvcreate -L1G -n lv_name vg_name
Activate/deactivate a volume group:
vgchange -a y vg_name #Activates: needed after each reboot!!
# This makes it show up as an entry in /dev/
vgchange -a n vg_name #Deactivates
Create the file system (choose one):
mk2fs /dev/vg_name/lv_name # create ext2 fs
mkfs.ext3 /dev/VolGroupBAK/lv_BAK # create ext2 fs
mkfs.ext3 /dev/VolGroupBAK/lv_BAK # create ext3 fs
mkreiserfs /dev/VolGroupBAK/lv_BAK # create reiserfs (reiserfs utils needed)
mkfs.xfs /dev/VolGroupBAK/lv_BAK # create xfs (xfsprogs package needed)
jfs_mkfs /dev/VolGroupBAK/lv_BAK # create jfs (jfsutils package needed)
Mount the File System:
mount /dev/vg_name/lv_name /mnt/point
Add disks to volume groups:
Create the new physical volumes
pvcreate /dev/hdd1
pvcreate /dev/hdd2
Add physical volumes to volume group
vgextend vg_name /dev/hdd1
vgextend vg_name /dev/hdd2
Unmount logical volume to extend
unmount /dev/vg_name/lv_name
Grow lv by 1GB
lvextend -L+1G /dev/vg_name/lv_name
Resize the underlying filesystem to fit (choose one)
resize2fs /dev/vg_name/lv_name # grow ext2/3 to match
resize_reiserfs -f /dev/vg_name/lv_name # grow reiserfs online
resize_reiserfs /dev/vg_name/lv_name # grow reiserfs offline
xfs_growfs /mount_pt # grow xfs online (must be mounted to resize)
mount -o remount,resize /home # grow jfs online (must be mounted)
Remount logical volume
mount /dev/vg_name/lv_name # remount if unmounted
Remove a Logical Volume:
unmount /dev/vg_name/lv_name # unmount any mounted lv
lvremove /dev/vg_name/lv_name # remove any lv
Remove a volume Group:
All logical volumes in group must be removed first.
vgchange -a n vg_name # deactivate vg
vgremove vg_name # removes vg
http://tldp.org/HOWTO/LVM-HOWTO/index.html
http://sources.redhat.com/lvm2/
http://www.die.net/doc/linux/man/man8/jfs_mkfs.8.html
http://www.die.net/doc/linux/man/man8/mkfs.xfs.8.html
http://www.howtoforge.com/linux_lvm_p2
Kernel module (version 2.6.9+):
Device Drivers > Multi-device support (RAID and LVM) > Device Mapper Support (CONFIG_BLK_DEV_DM)
Associated kernel module:
dm_mod
Package:
lvm2 - lvm tools
libdevmapper
Show LVM version:
lvm version
Create the physical disks:
pvcreate /dev/hda
pvcreate /dev/hdb
pvcreate /dev/hdc1
pvcreate /dev/hdc2
Show allocated Physical volumes:
pvscan
pvdisplay
lvm pvs
Setup a volume group:
vgcreate vg_name /dev/hda /dev/hdb /dev/hdc1 /dev/hdc2
Display a volume group:
vgdisplay
lvm vgs
Display a logical volume:
lvdisplay
lvm lvs
Create Logical Volume:
Sets the size to 1GB
lvcreate -L1G -n lv_name vg_name
Activate/deactivate a volume group:
vgchange -a y vg_name #Activates: needed after each reboot!!
# This makes it show up as an entry in /dev/
vgchange -a n vg_name #Deactivates
Create the file system (choose one):
mk2fs /dev/vg_name/lv_name # create ext2 fs
mkfs.ext3 /dev/VolGroupBAK/lv_BAK # create ext2 fs
mkfs.ext3 /dev/VolGroupBAK/lv_BAK # create ext3 fs
mkreiserfs /dev/VolGroupBAK/lv_BAK # create reiserfs (reiserfs utils needed)
mkfs.xfs /dev/VolGroupBAK/lv_BAK # create xfs (xfsprogs package needed)
jfs_mkfs /dev/VolGroupBAK/lv_BAK # create jfs (jfsutils package needed)
Mount the File System:
mount /dev/vg_name/lv_name /mnt/point
Add disks to volume groups:
Create the new physical volumes
pvcreate /dev/hdd1
pvcreate /dev/hdd2
Add physical volumes to volume group
vgextend vg_name /dev/hdd1
vgextend vg_name /dev/hdd2
Unmount logical volume to extend
unmount /dev/vg_name/lv_name
Grow lv by 1GB
lvextend -L+1G /dev/vg_name/lv_name
Resize the underlying filesystem to fit (choose one)
resize2fs /dev/vg_name/lv_name # grow ext2/3 to match
resize_reiserfs -f /dev/vg_name/lv_name # grow reiserfs online
resize_reiserfs /dev/vg_name/lv_name # grow reiserfs offline
xfs_growfs /mount_pt # grow xfs online (must be mounted to resize)
mount -o remount,resize /home # grow jfs online (must be mounted)
Remount logical volume
mount /dev/vg_name/lv_name # remount if unmounted
Remove a Logical Volume:
unmount /dev/vg_name/lv_name # unmount any mounted lv
lvremove /dev/vg_name/lv_name # remove any lv
Remove a volume Group:
All logical volumes in group must be removed first.
vgchange -a n vg_name # deactivate vg
vgremove vg_name # removes vg
http://tldp.org/HOWTO/LVM-HOWTO/index.html
http://sources.redhat.com/lvm2/
http://www.die.net/doc/linux/man/man8/jfs_mkfs.8.html
http://www.die.net/doc/linux/man/man8/mkfs.xfs.8.html
http://www.howtoforge.com/linux_lvm_p2
httpd.conf Activate User Webspace
Load the User Directory module:
LoadModule userdir_module modules/mod_userdir.so
Add the following lines to activate user dirs:
<IfModule mod_userdir.c>
UserDir public_html #typical dir convention is public_html
</IfModule>
Set directory specific options (optional):
<Directory /export/home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny, allow
Deny from all
</LimitExcept>
</Directory>
Several Available Options:
All: all options except multiviews (default)
ExecCGI: Execution of CGI scripts is permitted
Indexes: if no DirectoryIndex (index.html) present in dir, display formated list
SymLinksIfOwnerMatch: follow sym links only if source and target owner match
Several Available AllowOverride directive settings:
This directive allows the use of .htaccess files to override
All: all options are allowed in .htaccess
AuthConfig: allow use of AuthName, AuthType, AuthUserFile, AuthGroupFile, Require, etc.
Indexes: allow use of DirectoryIndex and more
Limit: allow use of Allow, Deny and Order
Options: allow use of specific option settings (above)
http://httpd.apache.org/docs/1.3/mod/core.html#allowoverride
LoadModule userdir_module modules/mod_userdir.so
Add the following lines to activate user dirs:
<IfModule mod_userdir.c>
UserDir public_html #typical dir convention is public_html
</IfModule>
Set directory specific options (optional):
<Directory /export/home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny, allow
Deny from all
</LimitExcept>
</Directory>
Several Available Options:
All: all options except multiviews (default)
ExecCGI: Execution of CGI scripts is permitted
Indexes: if no DirectoryIndex (index.html) present in dir, display formated list
SymLinksIfOwnerMatch: follow sym links only if source and target owner match
Several Available AllowOverride directive settings:
This directive allows the use of .htaccess files to override
All: all options are allowed in .htaccess
AuthConfig: allow use of AuthName, AuthType, AuthUserFile, AuthGroupFile, Require, etc.
Indexes: allow use of DirectoryIndex and more
Limit: allow use of Allow, Deny and Order
Options: allow use of specific option settings (above)
http://httpd.apache.org/docs/1.3/mod/core.html#allowoverride
httpd.conf Basic Authentication.
Add these lines to a given directory section or .htaccess file:
AuthType Basic
AuthName "By Invitation Only"
AuthUserFile /etc/httpd/passwords
Require user admin1 admin2
Execute these commands to create / add users:
htpasswd -c /etc/httpd/passwords admin1 #create
htpasswd /etc/httpd/passwords rbowen admin2 #add
Or Create to stdout:
htpasswd -nbs user pass
To use a .htaccess file, the following is needed in a directory section:
AccessFileName .htaccess # ID .htaccess as override file (default)
AllowOverride AuthConfig # allows .htaccess to override authorization
http://httpd.apache.org/docs/1.3/howto/auth.html
http://httpd.apache.org/docs/1.3/mod/core.html#authname
AuthType Basic
AuthName "By Invitation Only"
AuthUserFile /etc/httpd/passwords
Require user admin1 admin2
Execute these commands to create / add users:
htpasswd -c /etc/httpd/passwords admin1 #create
htpasswd /etc/httpd/passwords rbowen admin2 #add
Or Create to stdout:
htpasswd -nbs user pass
To use a .htaccess file, the following is needed in a directory section:
AccessFileName .htaccess # ID .htaccess as override file (default)
AllowOverride AuthConfig # allows .htaccess to override authorization
http://httpd.apache.org/docs/1.3/howto/auth.html
http://httpd.apache.org/docs/1.3/mod/core.html#authname
Thursday, December 28, 2006
Job Control
View the currently running jobs:
jobs
Place running foreground process into background:
ctl-z #puts the job to sleep
bg %1
Bring a background job into the foreground:
fg %1
Kill a job:
kill %1
kill %1 -9
Find the PID of all jobs
jobs -p
jobs -pl
Bring a nohuped process to the foreground
# note: I think you can only do this from the same terminal session.
# It doesn't look like it is possible to nohup a process, close a terminal
# and then bring the process back to the foreground again. Use screen instead.
# If you do not close your terminal session and if you do something like
nohup sleep 100 &
# and want to bring this to the foreground
# find the process ID using
jobs -p
or
ps -ef
# then supply the PID as the argument to the fg command
fg 14389420
http://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html#Job-Control-Basics
http://www.uwyo.edu/askit/displaydoc.asp?askitdocid=262&parentid=1
http://linuxhelp.blogspot.com/2005/05/job-control-in-linux.html#axzz0gU42IqoP
jobs
Place running foreground process into background:
ctl-z #puts the job to sleep
bg %1
Bring a background job into the foreground:
fg %1
Kill a job:
kill %1
kill %1 -9
Find the PID of all jobs
jobs -p
jobs -pl
Bring a nohuped process to the foreground
# note: I think you can only do this from the same terminal session.
# It doesn't look like it is possible to nohup a process, close a terminal
# and then bring the process back to the foreground again. Use screen instead.
# If you do not close your terminal session and if you do something like
nohup sleep 100 &
# and want to bring this to the foreground
# find the process ID using
jobs -p
or
ps -ef
# then supply the PID as the argument to the fg command
fg 14389420
http://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html#Job-Control-Basics
http://www.uwyo.edu/askit/displaydoc.asp?askitdocid=262&parentid=1
http://linuxhelp.blogspot.com/2005/05/job-control-in-linux.html#axzz0gU42IqoP
Wednesday, December 27, 2006
Mencoder Usage
Listing available codecs:
mencoder -ovc help
mencoder -oac help
Basic encode syntax:
mencoder movie.wmv -o movie.avi -ovc lavc -oac lavc (mpeg4 default)
# -o = output file
# -ovc = output video codec
# -oac = output audio codec
One-pass FFmpeg (lavc) encoding:
mencoder file.avi -ovc lavc -oac lavc --ffourcc DX50 -o output.avi
mencoder file.avi -ovc lavc -oac lavc -lavaopts acodec=mp3 -o movie.avi
http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
mencoder -ovc help
mencoder -oac help
Basic encode syntax:
mencoder movie.wmv -o movie.avi -ovc lavc -oac lavc (mpeg4 default)
# -o = output file
# -ovc = output video codec
# -oac = output audio codec
One-pass FFmpeg (lavc) encoding:
mencoder file.avi -ovc lavc -oac lavc --ffourcc DX50 -o output.avi
mencoder file.avi -ovc lavc -oac lavc -lavaopts acodec=mp3 -o movie.avi
http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
Tuesday, December 26, 2006
OpenSSL Usage
List available Ciphers:
openssl ciphers -v
openssl ciphers -v tls1 #only TLS 1 ciphers
openssl ciphers -v tls1.2 #only TLS 1.2 ciphers
openssl list-cypher-commands
openssl ciphers -v 'HIGH' #only good ciphers
Test OpenSSL Speed:
openssl speed
openssl speed rsa #test only rsa
Generate self-signed cert:
openssl req \
-x509 -nodes -days 365 \
-newkey rsa:1024 -keyout mycert.pem -out mycert.pem
OR
openssl req \
-x509 -nodes -days 365 \
-subj '/C=US/ST=Oregon/L=Portland/CN=www.madboa.com' \
-newkey rsa:1024 -keyout mycert.pem -out mycert.pem
MD5 or SHA1 digest of file:
openssl dgst -md5 filename
openssl dgst -sha1 filename
Base64 encode / decode a file:
openssl enc -base64 -in infile.txt #encode to stdout
openssl enc -base64 -in infile.txt -out outfile.txt #encode to a file
echo "encode me" | openssl enc -base64 #encode through a pipe
echo "Zw5jb2RlIGllCg==" | openssl enc -base64 -d #decode through a pipe
Encrypt a file using 256-bit AES in CBC mode
openssl enc -aes-256-cbc -salt -in file.txt -out file.enc
openssl enc -aes-256-cbc -salt -in file.txt \
-out file.enc -pass pass:password
openssl enc -aes-256-cbc -salt -in file.txt \
-out file.enc -pass file:/path/to/passwd.txt
openssl enc -aes-256-cbc -a -salt -in file.txt -out file.enc #base64 for email
Decrypt binary / base64 AES CBC file
openssl enc -d -aes-256-cbc -in file.enc
openssl enc -d -aes-256-cbc -a -in file.enc # decode with base64
Encrypt a file using Triple DES with base64 "ASCII Armor"
openssl enc -e -a -salt -des3 -in file.txt -out file.des3
Decrypt a file encoded with Triple DES and base64 encoded
openssl enc -d -a -in file.des3 -out file.txt
Encrypt a file using Blowfish and base64 encode
openssl enc -e -a -salt -bf -in file.txt -out file.blowfish
Decrypt a file encoded with Blowfish and base64 encoded
openssl enc -d -a -bf -in file.blowfish -out file.txt
Generate an RSA key:
openssl genrsa
openssl genrsa -out mykep.pem 1024
openssl genrsa -des3 -out mykey.pem 1024
Generate a public RSA key:
openssl rsa -in mykey.pem -pubout
Generate a DES key:
openssl dsaparam -noout -out dsakey.pem -genkey 1024
Generate a shadow-style password hash:
openssl passwd -1 MySecret
openssl passwd -1 -salt sXiKzkus MySecret #specific salt
Test for prime number:
openssl prime 11905475924560753
Generate random number:
openssl rand -base64 128 #128 random base64 bits
openssl rand -out random_data.bin 1024 #1024 random binary bits
head -c 32 /dev/urandom | openssl enc -base64 #better entropy
Create an SSL certificate:
openssl genrsa -des3 -out server.key 1024 # create keys
openssl req -new -key server.key -out server.csr # create cert request
cp server.key server.key.org # remove passphrase
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt # create cert
Decode an SSL Cert:
openssl x509 -in certificate.crt -text -noout
http://www.sslshopper.com/certificate-decoder.html
Encrypt from STDIN to STDOUT with a simple AES password
echo "Plain Text" | openssl enc -aes-256-cbc -a
Decrypt from STDIN to STDOUT with a simple AES password
echo "Cyphertext from above" | openssl enc -aes-256-cbc -d -a
http://www.akadia.com/services/ssh_test_certificate.html
http://www.yatblog.com/2007/02/27/how-to-create-a-ssl-certificate/
http://www.vanemery.com/Linux/Apache/openSSL.html
http://www.madboa.com/geek/openssl/
openssl ciphers -v
openssl ciphers -v tls1 #only TLS 1 ciphers
openssl ciphers -v tls1.2 #only TLS 1.2 ciphers
openssl list-cypher-commands
openssl ciphers -v 'HIGH' #only good ciphers
Test OpenSSL Speed:
openssl speed
openssl speed rsa #test only rsa
Generate self-signed cert:
openssl req \
-x509 -nodes -days 365 \
-newkey rsa:1024 -keyout mycert.pem -out mycert.pem
OR
openssl req \
-x509 -nodes -days 365 \
-subj '/C=US/ST=Oregon/L=Portland/CN=www.madboa.com' \
-newkey rsa:1024 -keyout mycert.pem -out mycert.pem
MD5 or SHA1 digest of file:
openssl dgst -md5 filename
openssl dgst -sha1 filename
Base64 encode / decode a file:
openssl enc -base64 -in infile.txt #encode to stdout
openssl enc -base64 -in infile.txt -out outfile.txt #encode to a file
echo "encode me" | openssl enc -base64 #encode through a pipe
echo "Zw5jb2RlIGllCg==" | openssl enc -base64 -d #decode through a pipe
Encrypt a file using 256-bit AES in CBC mode
openssl enc -aes-256-cbc -salt -in file.txt -out file.enc
openssl enc -aes-256-cbc -salt -in file.txt \
-out file.enc -pass pass:password
openssl enc -aes-256-cbc -salt -in file.txt \
-out file.enc -pass file:/path/to/passwd.txt
openssl enc -aes-256-cbc -a -salt -in file.txt -out file.enc #base64 for email
Decrypt binary / base64 AES CBC file
openssl enc -d -aes-256-cbc -in file.enc
openssl enc -d -aes-256-cbc -a -in file.enc # decode with base64
Encrypt a file using Triple DES with base64 "ASCII Armor"
openssl enc -e -a -salt -des3 -in file.txt -out file.des3
Decrypt a file encoded with Triple DES and base64 encoded
openssl enc -d -a -in file.des3 -out file.txt
Encrypt a file using Blowfish and base64 encode
openssl enc -e -a -salt -bf -in file.txt -out file.blowfish
Decrypt a file encoded with Blowfish and base64 encoded
openssl enc -d -a -bf -in file.blowfish -out file.txt
Generate an RSA key:
openssl genrsa
openssl genrsa -out mykep.pem 1024
openssl genrsa -des3 -out mykey.pem 1024
Generate a public RSA key:
openssl rsa -in mykey.pem -pubout
Generate a DES key:
openssl dsaparam -noout -out dsakey.pem -genkey 1024
Generate a shadow-style password hash:
openssl passwd -1 MySecret
openssl passwd -1 -salt sXiKzkus MySecret #specific salt
Test for prime number:
openssl prime 11905475924560753
Generate random number:
openssl rand -base64 128 #128 random base64 bits
openssl rand -out random_data.bin 1024 #1024 random binary bits
head -c 32 /dev/urandom | openssl enc -base64 #better entropy
Create an SSL certificate:
openssl genrsa -des3 -out server.key 1024 # create keys
openssl req -new -key server.key -out server.csr # create cert request
cp server.key server.key.org # remove passphrase
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt # create cert
Decode an SSL Cert:
openssl x509 -in certificate.crt -text -noout
http://www.sslshopper.com/certificate-decoder.html
Encrypt from STDIN to STDOUT with a simple AES password
echo "Plain Text" | openssl enc -aes-256-cbc -a
Decrypt from STDIN to STDOUT with a simple AES password
echo "Cyphertext from above" | openssl enc -aes-256-cbc -d -a
http://www.akadia.com/services/ssh_test_certificate.html
http://www.yatblog.com/2007/02/27/how-to-create-a-ssl-certificate/
http://www.vanemery.com/Linux/Apache/openSSL.html
http://www.madboa.com/geek/openssl/
SSH PKI
To create ssh keys:
ssh-keygen -t dsa -d 2048
Optionally leave the passphrase blank
This will create a ~/.ssh/id_dsa and ~/.ssh/id_dsa.pub file.
Check for validity:
ssh-keygen -l -f ~/.ssh/id_dsa.pub
Copy the key to the remote server:
cat ~/.ssh/id_dsa ssh remote_host 'sh -c "cat - >>~/.ssh/authorized_keys"'
Convert commercial (SECSH) ssh private / public key to OpenSSH
ssh-keygen -i -f id_dsa.pub > id_dsa_openssh.pub # public key
ssh-keygen -i -f id_dsa > id_dsa_openssh # private key
Generate public key from private key
ssh-keygen -y -f id_dsa > id_dsa_openssh.pub
Convert OpenSSH private / public to commercial (SECSH) ssh
ssh-keygen -e -f id_dsa_openssh.pub > id_dsa.pub # public key
ssh-keygen -e -f id_dsa_openssh > id_dsa # private key
Changes the passphrase
ssh-keygen -p -N password -f id_dsa_openssh.prv > id_dsa
http://pkeck.myweb.uga.edu/ssh/
http://uaahosting.uaa.alaska.edu/axjww/sshkey/
ssh-keygen -t dsa -d 2048
Optionally leave the passphrase blank
This will create a ~/.ssh/id_dsa and ~/.ssh/id_dsa.pub file.
Check for validity:
ssh-keygen -l -f ~/.ssh/id_dsa.pub
Copy the key to the remote server:
cat ~/.ssh/id_dsa ssh remote_host 'sh -c "cat - >>~/.ssh/authorized_keys"'
Convert commercial (SECSH) ssh private / public key to OpenSSH
ssh-keygen -i -f id_dsa.pub > id_dsa_openssh.pub # public key
ssh-keygen -i -f id_dsa > id_dsa_openssh # private key
Generate public key from private key
ssh-keygen -y -f id_dsa > id_dsa_openssh.pub
Convert OpenSSH private / public to commercial (SECSH) ssh
ssh-keygen -e -f id_dsa_openssh.pub > id_dsa.pub # public key
ssh-keygen -e -f id_dsa_openssh > id_dsa # private key
Changes the passphrase
ssh-keygen -p -N password -f id_dsa_openssh.prv > id_dsa
http://pkeck.myweb.uga.edu/ssh/
http://uaahosting.uaa.alaska.edu/axjww/sshkey/
Friday, December 22, 2006
GPG Management Commands
Generates key pair:
gpg --gen-key
Lists public and private current keys:
gpg --list-keys
gpg --list-secret-keys
Exports public key / private key:
gpg --armor --export jaz@example.com
gpg --export-secret-key --armor "jaz@example.com" > private.key
Imports a public key / private key:
gpg --import joe.ca
gpg --allow-secret-key-import --import private.key
Delete public / private key:
gpg --delete-key "jaz@example.com"
gpg --delete-secret-key "jaz@example.com"
Encrypt a document with someone's public key:
gpg --output out.gpg --encrypt --recipient jaz@example.com doc
gpg -o out.gpg -e -r jaz@example.com doc
Decrypt an encrypted file:
gpg --output doc --decrypt doc.pgp
gpg -o doc --decrypt doc.pgp
Symmetric encryption:
gpg --output doc.gpg --symmetric doc
gpg -o doc.gpg -c doc
gpg --gen-key
Lists public and private current keys:
gpg --list-keys
gpg --list-secret-keys
Exports public key / private key:
gpg --armor --export jaz@example.com
gpg --export-secret-key --armor "jaz@example.com" > private.key
Imports a public key / private key:
gpg --import joe.ca
gpg --allow-secret-key-import --import private.key
Delete public / private key:
gpg --delete-key "jaz@example.com"
gpg --delete-secret-key "jaz@example.com"
Encrypt a document with someone's public key:
gpg --output out.gpg --encrypt --recipient jaz@example.com doc
gpg -o out.gpg -e -r jaz@example.com doc
Decrypt an encrypted file:
gpg --output doc --decrypt doc.pgp
gpg -o doc --decrypt doc.pgp
Symmetric encryption:
gpg --output doc.gpg --symmetric doc
gpg -o doc.gpg -c doc
Labels:
decrypt,
encrypt,
gpg,
key gen,
pgp,
private key,
public key
Copy File Trees With Tar Pipes
Copy files on a local filesystem:
(cd /foo; tar -cf - . ) | (cd /bar; tar -xpf - )
Copy files on a remote filesystem:
(cd /src; tar -cvf - foo) | (ssh other.machine 'cd /dst; tar -xf -')
http://www.cs.hmc.edu/qref/targzip.html
(cd /foo; tar -cf - . ) | (cd /bar; tar -xpf - )
Copy files on a remote filesystem:
(cd /src; tar -cvf - foo) | (ssh other.machine 'cd /dst; tar -xf -')
http://www.cs.hmc.edu/qref/targzip.html
Subscribe to:
Posts (Atom)
