Archive for the ‘Information Technology’ Category
The Universally Unique Identifier can be used to identify a device independent form its mount point or device name.
This is more and more important as many devices today support hot-plugging or are external anyway.
Therefore it makes sense to access a device not by device name but by the UUID, especially in /etc/fstab.
There are a lot of way to get a device UUID, the first one is to check in your /dev/ directory, but not all Linux Distribution have it implemented (i.e. Debian),
to do so, execute the following commands :
ls -l /dev/disk/by-uuid
and you should have something similar :
lrwxrwxrwx 1 root root 10 Aug 29 04:20 015770bc-2c9b-4654-9087-af8bc9f163f3 -> ../../sdd1 lrwxrwxrwx 1 root root 10 Aug 29 04:20 1cf18ff6-2f6e-4eb3-97a5-fb6d3b4e346b -> ../../sde7 lrwxrwxrwx 1 root root 10 Aug 29 04:20 41c9b6af-86d9-4893-8502-4c0edb556986 -> ../../sde1 lrwxrwxrwx 1 root root 10 Aug 29 04:20 60a56eaa-8a3c-4d1f-8017-24af2905aebf -> ../../sde5 lrwxrwxrwx 1 root root 10 Aug 29 04:20 8ee89635-33cb-4a42-b488-26fdd2f293ad -> ../../sde2 lrwxrwxrwx 1 root root 10 Aug 29 04:20 91967f22-c1f3-436c-b769-ccd6fcc29e4e -> ../../sde8 lrwxrwxrwx 1 root root 10 Aug 29 04:20 c693372b-7147-4fb3-aaf7-edbf5f79f7f7 -> ../../sde6
Another way is to use the “blkid” command.
To do so, and to gain the UUID for your /dev/sda1, execute :
blkid /dev/sda1
and you should have something similar :
/dev/sda1: LABEL="root" UUID="41c9b6af-86d9-4893-8502-4c0edb556986" SEC_TYPE="ext2" TYPE="ext3"
Another tool (maybe a little more hidden) will be “vol_id”
On certain systems (i.e. Fedora or VMware ESX) you should find it in “/lib/udev/vol_id”, to use it execute the following :
/lib/udev/vol_id /dev/sda1
and you should have something similar :
ID_FS_USAGE=filesystem ID_FS_TYPE=ext3 ID_FS_VERSION=1.0 ID_FS_UUID=41c9b6af-86d9-4893-8502-4c0edb556986 ID_FS_LABEL=root ID_FS_LABEL_SAFE=root
When you got your devices UUID you should fill the /etf/fstab like the following, to avoid that other operations, for examples adding disks or volume, cause problems to your mounting process :
UUID=41c9b6af-86d9-4893-8502-4c0edb556986 / ext3 defaults 1 1
if you wonder how “unique” this UUID is, the following is a Wikipedia quote:
1 trillion UUIDs would have to be created every nanosecond for 10 billion years to exhaust the number of UUIDs.
Hope this help
Bye
Riccardo
Print This Post
To reset the sys password of a database, do the following:
1) rename/delete ${ORACLE_HOME}/database/PWD{ORACLE_SID}.ora
2) enter the command: orapwd file=${ORACLE_HOME}/database/PWD{ORACLE_SID}.ora password=newpassword
3) start “sqlplus /nolog”
4) login with sys and the newpassword (SQL> connect sys/newpassword as sysdba)
5) now reset other passwords or just be done
Hope this help (especially me)
Bye
Riccardo
Print This Post
This is a list of handy MySQL commands that I use frequently.
Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.
To login (from unix shell) use -h only if needed.
# [mysql dir]/bin/mysql -h hostname -u root -p
Create a database on the sql server.
mysql> create database [databasename];
List all databases on the sql server.
mysql> show databases;
Switch to a database.
mysql> use [db name];
To see all the tables in the db.
mysql> show tables;
To see database’s field formats.
mysql> describe [table name];
To delete a db.
mysql> drop database [database name];
To delete a table.
mysql> drop table [table name];
Show all data in a table.
mysql> SELECT * FROM [table name];
Returns the columns and column information pertaining to the designated table.
mysql> show columns from [table name];
Show certain selected rows with the value “whatever”.
mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";
Show all records containing the name “Bob” AND the phone number ‘3444444′.
mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';
Show all records not containing the name “Bob” AND the phone number ‘3444444′ order by the phone_number field.
mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;
Show all records starting with the letters ‘bob’ AND the phone number ‘3444444′.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';
Show all records starting with the letters ‘bob’ AND the phone number ‘3444444′ limit to records 1 through 5.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;
Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with a.
mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";
Show unique records.
mysql> SELECT DISTINCT [column name] FROM [table name];
Show selected records sorted in an ascending (asc) or descending (desc).
mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
Return number of rows.
mysql> SELECT COUNT(*) FROM [table name];
Sum column.
mysql> SELECT SUM(*) FROM [table name];
Join tables on common columns.
mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;
Change a users password from unix shell.
# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'
Change a users password from MySQL prompt. Login as root. Set the password. Update privs.
# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;
Recover a MySQL root password. Stop the MySQL server process.
Start again with no grant tables.
Login to MySQL as root.
Set new password.
Exit MySQL and restart MySQL server.
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
Set a root password if there is on root password.
# mysqladmin -u root password newpassword
Update a root password.
# mysqladmin -u root -p oldpassword newpassword
Allow the user “bob” to connect to the server from localhost using the password “passwd”. Login as root. Switch to the MySQL db. Give privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;
Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;
or
mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;
To update info already in a table.
mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
Delete a row(s) from a table.
mysql> DELETE from [table name] where [field name] = 'whatever';
Update database permissions/privilages.
mysql> flush privileges;
Delete a column.
mysql> alter table [table name] drop column [column name];
Add a new column to db.
mysql> alter table [table name] add column [new column name] varchar (20);
Change column name.
mysql> alter table [table name] change [old column name] [new column name] varchar (50);
Make a unique column so you get no dupes.
mysql> alter table [table name] add unique ([column name]);
Make a column bigger.
mysql> alter table [table name] modify [column name] VARCHAR(3);
Delete unique from table.
mysql> alter table [table name] drop index [colmn name];
Load a CSV file into a table.
mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
Dump all databases for backup. Backup file is sql commands to recreate all db’s.
# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
Dump one database for backup.
# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
Dump a table from a database.
# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
Restore database (or database table) from backup.
# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql
Create Table Example 1.
mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));
Create Table Example 2.
mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');
Ubuntu Lucid Lynx is coming …. are you ready ?
Fedora Goddard is also coming
Bye
Riccardo
The following is a simple (and very row) init script for Symantec Backup Exec Agent for Linux.
I wrote it because I really hate to execute script not registered with chkconfig on a production systems.
I’ve added the “status” function by checking if an executable called “beremote” is listening on 10000/tcp on IPv4 on the localhost.
If you are planning to run ralus on a different TCP port, please fix the script.
The following is the script :
#!/bin/sh
#
# RALUS Control Script
# chkconfig: 2345 99 01
# Description: Here is a little startup/shutdown script for RedHat/CentOS systems
#
# Author : Riccardo Riva
#
# description: Symantec Backup Exec Linux Agent Init Script
#
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
# See how we were called.
if [ ! -d /opt/VRTSralus ]
then
echo "Symantec Backup Exec Remote Agent missing /opt/VRTSralus [FAILED]"
exit 1
fi
if [ ! -d /etc/VRTSralus ]
then
echo "Symantec Backup Exec Remote Agent missing /etc/VRTSralus [FAILED]"
exit 1
fi
if [ ! -d /var/VRTSralus ]
then
echo "Symantec Backup Exec Remote Agent missing /var/VRTSralus [FAILED]"
exit 1
fi
CMD="$1"
case "$CMD" in
'start')
if [ -x /opt/VRTSralus/bin/beremote ]
then
echo -n "Starting Symantec Backup Exec Remote Agent "
rm -f /var/VRTSralus/ralus.pid
rm -f /var/VRTSralus/ralus.errpid
/opt/VRTSralus/bin/beremote >/var/VRTSralus/beremote.service.log 2>/var/VRTSralus/beremote.service.log &
PIDWAIT=30
while [ "$PIDWAIT" != "0" ]
do
if [ -f /var/VRTSralus/ralus.pid ]
then
PIDWAIT=0
else
PIDWAIT=$(($PIDWAIT-1))
echo -n "."
sleep 1;
fi
if [ -f /var/VRTSralus/ralus.errpid ]
then
PIDWAIT=0
fi
done
if [ -f /var/VRTSralus/ralus.pid ]
then
RETVAL=0
else
RETVAL=1
fi
echo
else
RETVAL=1
fi
if [ "$RETVAL" = "0" ]
then
echo "Starting Symantec Backup Exec Remote Agent: [ OK ]"
else
echo "Starting Symantec Backup Exec Remote Agent: [FAILED]"
fi
;;
'stop')
if [ -f /bin/grep ]
then
PID=`/bin/ps -e | /bin/grep beremote | /bin/sed -e 's/^ *//' -e 's/ .*//'`
else
PID=`/usr/bin/ps -e | /usr/bin/grep beremote | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
fi
if [ "${PID}" != "" ]
then
echo -n "Stopping Symantec Backup Exec Remote Agent "
if [ -f /bin/pkill ]
then
/bin/pkill -15 beremote
else
/usr/bin/pkill -15 beremote
fi
RETVAL=$?
PIDWAIT=15
while [ "$PIDWAIT" != "0" ]
do
if [ -f /var/VRTSralus/ralus.pid ]
then
PIDWAIT=0
RETVAL=0
else
PIDWAIT=$(($PIDWAIT-1))
echo -n "."
sleep 1;
fi
done
echo
rm -f /var/VRTSralus/ralus.pid
rm -f /var/VRTSralus/ralus.errpid
else
RETVAL=1
fi
if [ "$RETVAL" = "0" ]
then
echo "Stopping Symantec Backup Exec Remote Agent: [ OK ]"
else
echo "Stopping Symantec Backup Exec Remote Agent: [FAILED]"
fi
;;
'restart')
$0 stop
$0 start
RETVAL=1
;;
'status')
if [ $(netstat -tulpan | grep beremote |grep 0.0.0.0:10000 | wc -l) -eq 1 ];
then
echo "Symantec Backup Exec Remote Agent running and listening on tcp port 10000"
else
echo "Symantec Backup Exec Remote Agent not running"
fi
;;
*)
echo "Symantec Backup Exec Remote Agent for Linux/Unix Servers"
echo "Usage: VRTSralus.init { start | stop | restart | status}"
RETVAL=1
;;
esac
exit $RETVAL
#
# -- End of file
You should download the file here : http://www.riccardoriva.com/shared-files/ralus_init_script.sh
Hope this help
Bye
Riccardo
Print This Post
If you use Postgrey (and you should do it) on your mail servers and you want to have some statistics on the amount of greylisted messages and other information, you should find useful the following script.
The scripts assume that you have installed Postgrey (http://postgrey.schweikert.ch/) on RHEL (http://www.redhat.com) or CentOS (http://www.centos.org).
If you are using other distros you may fix some path problems.
Create a file called “greylisting_statistics.sh” in your “/usr/local/bin” folder with the following content :
#!/bin/sh
LOGFILE=/tmp/greylist-statistics
YOURMAIL=you@yourdomain.com
echo -n "Total amount of GreyListed messages" > $LOGFILE
cat /var/log/maillog | /usr/sbin/postgreyreport --delay=300 >> $LOGFILE
echo -ne "\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -n "Get only the top 20 sources getting greylisted out" >> $LOGFILE
cat /var/log/maillog | postgreyreport | awk '{print $1}' | sort | uniq -c | sort -nr | head -n20 >> $LOGFILE
echo -ne "\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -n "Get a list of the top 20 email address that the greylisted sources are sending email to" >> $LOGFILE
cat /var/log/maillog | postgreyreport | awk '{print $4}' | sort | uniq -c | sort -nr | head -n20
echo -ne "\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
echo -ne "-------------------------------------\n" >> $LOGFILE
cat $LOGFILE | mail -s "Greylisting Statistics of `hostname` for `date +%Y-%m-%d`" $YOURMAIL
#--- End of file ---
Assign to it the correct ownership and permission by running :
chmod 700 /usr/local/bin/greylisting_statistics.sh chown root:root /usr/local/bin/greylisting_statistics.sh
Schedule the execution using “crontab -e” and adding the following line to have a daily based statistics :
59 23 * * * /usr/local/bin/greylisting_statistics.sh
Hope this help
Bye
Riccardo
Print This Post
This simple How-To will explain a raw and dirt method to daemonize to http manager for ARECA Raid Controller.
If you have this controller on your system you should find in the bundled CD-ROM the following folder :
root PACKAGES -> Linux -> CLI -> version -> i386 -> cli32 PACKAGES -> Linux -> CLI -> version -> x86-64 -> cli32 PACKAGES -> Linux -> HTTP -> version.x.y.x -> i386 -> archttp32 PACKAGES -> Linux -> HTTP -> version.x.y.x -> x86-64 -> archttp32
Create a folder in your /usr/local folder called “areca” e and create into it two folders called “http” and “cli”
Copy the “cli32″ and “archttp32″ executable file that match your architecture (i386 or x86-64) in the specified folder, so you should have something similar :
[root@relay ~]# ls -lahR /usr/local/areca/ /usr/local/areca/: total 20K drwxr-xr-x 4 root root 4.0K Feb 12 10:28 . drwxr-xr-x 13 root root 4.0K Feb 12 10:26 .. dr-xr-xr-x 2 root root 4.0K Feb 12 10:27 cli dr-xr-xr-x 2 root root 4.0K Feb 12 10:42 http /usr/local/areca/cli: total 1.6M dr-xr-xr-x 2 root root 4.0K Feb 12 10:27 . drwxr-xr-x 4 root root 4.0K Feb 12 10:28 .. -r-xr-xr-x 1 root root 1.6M Dec 26 2008 cli32 /usr/local/areca/http: total 1.6M dr-xr-xr-x 2 root root 4.0K Feb 12 10:42 . drwxr-xr-x 4 root root 4.0K Feb 12 10:28 .. -r-xr-xr-x 1 root root 1.6M Dec 26 2008 archttp32 -rw-r--r-- 1 root root 91 Feb 12 10:42 archttpsrv.conf
Create a new file called “areca” in your /etc/init.d folder with the following content :
#!/bin/sh
#
# Startup script for the ARECA RAID CONTROLLER HTTP Monitor
#
# chkconfig: 2345 62 38
# description: HTTP Tools to monitor and manage ARECA RAID Controller
#
# processname: archttp32
# config: none
# lockfile: /var/lock/subsys/archttp32
#
# Author: Riccardo Riva
# WebSite: http://www.riccardoriva.com
#
# This script is realeased under the terms of the GPL.
#====================================================================
# Source function library
. /etc/init.d/functions
RETVAL=0
start() {
echo -n $"Starting ARECA HTTP Manager: "
daemon /usr/local/areca/http/archttp32 2>&1>/dev/null &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/archttp32
return $RETVAL
}
stop() {
echo -n $"Stopping ARECA HTTP Manager: "
killproc archttp32
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/archttp32
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading ARECA HTTP Manager: "
killproc archttp32 -ALRM
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status archttp32
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/archttp32 ] && restart || :
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
esac
exit $?
#---End of file---
Assing to it the right permission and ownership
chmod 755 /etc/init.d/areca chown root:root /etc/init.d/areca
You should also place in the executable file folder the configuration file, called “archttp32srv.conf” with the following content :
[GENERAL] BindingIp=0.0.0.0 HTTPPort=81 SMTPPort=25 ScanPci=YES ScanRs232=NO ScanInband=NO ConnInfo=NO [MAIL] Server=MAIL.SERVER.IP.ADDRESS # Please Change ME Sender=SENDERNAME # Please Change ME SenderMail=SENDERMAIL # Please Change ME Account= Password= MailToName1=RECEIVERNAME # Please Change ME MailToName2= MailToName3= MailToName4= MailAddr1=RECEIVERMAIL # Please Change ME MailAddr2= MailAddr3= MailAddr4= EvtLevel=3 NotifyForNoEvent=NO [SNMP] TrapIp1=SNMP.SERVER.IP.ADDRESS # Please Change ME TrapIp2=0.0.0.0 TrapIp3=0.0.0.0 TrapPort1=162 TrapPort2=162 TrapPort3=162 Community=public EvtLevel=3
And configure it for startup at boot time.
chkconfig areca on
I know it very dirt, but I had no time left to search a better way, maybe in the future.
Hope this help
Bye
Riccardo
Print This Post
The following is a simple (and very row) init script for Bacula 5.0.
I wrote it because I really hate to execute script not registered with chkconfig on a production systems.
The following is the script :
#!/bin/sh
#
# BACULA Control Script
# chkconfig: 2345 99 01
# Description: Here is a little startup/shutdown script for RedHat/CentOS systems
#
# processname: bacula
# bacula-dir pidfile: /var/run/bacula-dir.9101.pid
# bacula-fd pidfile: /var/run/bacula-fd.9102.pid
# bacula-sd pidfile: /var/run/bacula-sd.9103.pid
#
# bacula-dir config: /etc/bacula/bacula-dir.conf
# bacula-fd config: /etc/bacula/bacula-fd.conf
# bacula-sd config: /etc/bacula/bacula-sd.conf
#
# Author : Riccardo Riva
#
# description: It comes by night and sucks the vital essence from your computers.
#
SCRIPTDIR=/etc/bacula
#
# Disable Glibc malloc checks, it doesn't help and it keeps from getting
# good dumps
MALLOC_CHECK_=0
export MALLOC_CHECK_
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
# See how we were called.
case "$1" in
start)
[ -x ${SCRIPTDIR}/bacula-ctl-sd ] && ${SCRIPTDIR}/bacula-ctl-sd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-fd ] && ${SCRIPTDIR}/bacula-ctl-fd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-dir ] && ${SCRIPTDIR}/bacula-ctl-dir $1 $2
;;
stop)
# Stop the FD first so that SD will fail jobs and update catalog
[ -x ${SCRIPTDIR}/bacula-ctl-fd ] && ${SCRIPTDIR}/bacula-ctl-fd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-sd ] && ${SCRIPTDIR}/bacula-ctl-sd $1 $2
[ -x ${SCRIPTDIR}/bacula-ctl-dir ] && ${SCRIPTDIR}/bacula-ctl-dir $1 $2
;;
restart)
$0 stop
sleep 2
$0 start
;;
status)
[ -x ${SCRIPTDIR}/bacula-ctl-sd ] && ${SCRIPTDIR}/bacula-ctl-sd status
[ -x ${SCRIPTDIR}/bacula-ctl-fd ] && ${SCRIPTDIR}/bacula-ctl-fd status
[ -x ${SCRIPTDIR}/bacula-ctl-dir ] && ${SCRIPTDIR}/bacula-ctl-dir status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
#--- End of file ---
You should download the script from here :
http://www.riccardoriva.com/shared-files/bacula_init_script.sh
Hope this help
Bye
Riccardo
Print This Post
In this tutorial I will describe how setup a complete mail server for relaying mail to another server, for example an IMAP server or an Exchange, tipically this machine will be placed in a DMZ network and will be reachable from internet.
I will explain how to install and configure :
- Postgrey : to do GreyListing on incoming mails and avoid SPAM.
- Postfix : to receive mails for local or remote mailboxes and do some checks for trash mail using RBL and internal options.
- Amavisd-New : to scan incoming mails form Viruses and SPAM.
- Clamd : to avoid Amavisd-new virus scan.
- Spamassassin : to avoid amavisd-new SPAM scan with Razor, Pyzor and DCC.
- Altermime : to add a disclaimer (both text and html) for the outgoing mail.
- Cyrus-Sasl : to enable sasl authentication for road warriors.
- Fetchmail : to eventually fetch the mail from another mail server.
- Apache : to create a reverse proxy to reach a webmail service on the internal web server.
I’ll describe all steps needed to install it on RHEL or CentOS because the steps are identical for both distributions and because are my favourites ones.
I’m assuming you’re going to install a 64bit operating system, but if you choose to install the 32bit version pay only attention for some packages to fit your architecture.
First of all you have to install you operating systems. I’ll not explain this process because it’s very simple, but I’ll suggest you to NOT customize the system during the installation procedure, it will be done later.
At the first reboot, disable both Selinux and Firewall, then reboot again and login to your system as user root.
Virtualization Technology (VT) is a set of enhancements to CPU that improve performance for running a virtual machine by offloading some of the work to the new cpu extensions. Both AMD and Intel have CPU that support this technology.
In some cases it will be very usefule to know if your system can handle it.
It will be very simple from a Linux system because you should only take a look to /proc/cpuino looking for one of the following value :
- vmx – (intel)
- svm – (amd)
You can use grep to quickly find if either value exists in the file by running the following command:
egrep ‘(vmx|svm)’ /proc/cpuinfo
If your system supports VT, then you’ll see vmx or svm in the list of flags.
My system has four quad core AMD processors, so I’ll find the following repeated from 16 times :
My system has two processors, so there are two separate sections:
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt
VT technology can still be disabled in your computer’s BIOS, however, so you’ll want to check there to make sure that it hasn’t been disabled. The flags in cpuinfo simply mean that your processor supports it.
VT is required to run 64-bit guests using Hypervisor like VMware Server or others similar products.
Hope this help
Bye
Riccardo
Print This Post
This post will explain how to create users and mailboxes for Zarafa.
I’ve tested it with CentOS 5.4 X86_64 and Zarafa 6.30.9 but it will fit with nearly all installation.
First of all you have to create a test file with all the users you want to create, providing the following information :
- username
- password
- email address
- name
- surname
For example :
johndoe password johndoe@example.com John Doe
janedoe password janedoe@example.com Jane Doe
Save the text file whatever you want.
The following is the shell script that read your text file and create all Zarafa users.
If you use the script, all the users will not be administrator, so you have to create manually and administrator.
#!/bin/bash # Written by Matteo Predieri - m.predieri_AT_damsistemi_DOT_it # Written by Riccardo Riva - r.riva_AT_damsistemi_DOT_it # # Simple and raw script to create zarafa users and mailboxes from a test file # # The full fill-in of the text file is mandatory # So fill in both "Name" and "Surname" with the following syntax # # username password email name surname # USERS_LIST=/tmp/userlists.txt ZARAFA_CMD=/usr/bin/zarafa-admin LOGFILE=/tmp/zara_user_creation.log echo "Zarafa User Creation Log" > $LOGFILE what="user"; for item in $( cat $USERS_LIST ); do if [ $what = "user" ]; then user=$item; what="passwd"; else if [ $what = "passwd" ]; then passwd=$item; what="email"; else if [ $what = "email" ]; then email=$item; what="name"; else if [ $what = "name" ]; then name=$item; what="surname"; else surname=$item; echo "Result in creating User: $user, with password: $passwd, with email address: $email with Full Name: $name $surname :" >> $LOGFILE FULLNAME="'$name $surname'" $ZARAFA_CMD -c $user -p $passwd -e $email -f "$FULLNAME" -a0 >> $LOGFILE echo -ne "-------------------------------\n" >> $LOGFILE what="user"; fi fi fi fi done # --- End of file ---
You’ve done.
Hope this help
Bye
Riccardo
Print This Post
If you have a standalone VMware ESX 4 unmanaged or you haven’t yet configured VMware Update Manager, and you want to update it, you should do the following.
Download the update package from VMware Web Site : ESX-4.0.0-update01.zip
Copy it to your ESX Server 4 (i.e. on /tmp).
Connect to your ESX Server with SSH or to a local console.
Execute :
esxupdate --bundle=ESX-4.0.0-update01.zip update
Hope this help
Bye
Riccardo
Print This Post
Hi all,
unfortunately I’m trying Windows 7 as my primary notebook OS (obviously on a Virtual Machine) and the main problem I’ve found was the inability to run VMware Vsphere client.
As you can see below, the client was installed correctly without any errors :
Vsphere Client 01
When attempting to run the client I’ve received the following errors and I was unable to proceed in any way :
“Error parsing the server “<server name” “clients.xml” file.”
Vsphere Client 02
and “The type initializer for ‘VirtualInfrastructure.Utils.HttpWebRequestProxy’ threw an exception”.
Vsphere Client 03
Luckily there have been a few good VMware communities forum posts .
Follow these 4 basic steps and you should use the client in a couple of minutes.
Step 1.
Download this DLL called system.dll
*Note: This DLL is usually found in the %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\ directory of a non Windows 7 PC with .NET v3.5 SP1 installed.
Step 2.
Once downloaded copy it in the “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\lib” directory. If the ‘lib’ directory doesn’t exist, create it and copy the dll file into it.
Step 3.
Edit the “VpxClient.exe.config” file which can be found in the “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher” directory and add the following three lines to it in the location specified in the screenshot below. Then save the changes.
<runtime> <developmentMode developerInstallation> </runtime>
Vsphere Client 04
Vsphere Client 05
Step 4.
From the Windows 7 ‘System Properties’ click the ‘Advanced’ tab and then the ‘Environment Variables’ button as we want to add a new ‘System’ variable.
Create a new ‘System’ variable called ‘DEVPATH’ and assign the following variable value:
C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\Lib
Vsphere Client 06
Vsphere Client 07
You are now ready to start using the VMware vSphere Client on your Windows 7 machine!
If you have any problem, try to run it as “Administrator”.
Hope this help
BySome people have reported having to run the client as an ‘Administrator’ so if you are having difficulties it may pay toe
Riccardo
Print This Post
From : SevenForums.com
By default Quick Launch is disabled in Windows 7. This will show you how to enable or disable Quick Launch on the taskbar in Windows 7 as a toolbar with small or large icons.
Quick Launch is used to open a program quickly from a shortcut on the taskbar. In this case in a toolbar The Quick Launch folder is located at the hidden system folder location (step 2) of:
C:\Users\(user-name)\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch
Hope this help
Bye
Riccardo
Karmik Koala is coming …. are you ready ?
for the impatience, you can download the beta from here :
http://www.ubuntu.com/testing/karmic/beta
Bye
Riccardo
This how-to will explain how to use LDAP authentication to Microsoft Active Directory with an IPSEC VPN to a Fortinet device.
I’ve tested it with a Fortigate 60B and a Fortigate 100A with success.
This post assume you have a fully function VPN IPSEC configuration on your fortinet device with authentication based on a Fortigate group.
Connect to your device with SSH (or as you prefer, even with the web browser), and login as “admin”.
From the console insert the following :
config user ldap edit "GroupName" set server "my.adserver.ip.address" set cnid "sAMAccountName" set dn "ou=xxx,dc=yyyy,dc=zzzz" set type regular set username "domain\\Administrator" set password ENC ******************************************* next end
Where :
- “GroupName” will be a lable of the Auth Group
- cnid will be the common name identifier, with this syntax you check the AD login name
- dn will be your LDAP tree path to reach the Organization Unit on which your users are
- type regular will be the authentication type
- username will be an account who can read your AD ldap tree (you should, and it will be better, use an account different than Administrator).
- password will be the password of tha account above
Then edit your local group with the following command
config user group
locate your VPN group and add the LDAP group created before.
Test it with a Fortinet VPN Client (http://www.fortinet.com/products/forticlient/)
Hope this help
Bye
Riccardo
Print This Post
This is a simple shell script that count all files in a local directory and all subdir. It doesn’t care what extention the file has, it will just recursively go through each directory and count any files within it, plus recurse into any more directories it finds. Give it as a parameter the directory you want to count.
#!/bin/sh
NUMBER=0
count ()
{
for temporary in $1/* ; do
if [ -d "$temporary" ] ; then
count "$temporary"
elif [ -f "$temporary" ] ; then
NUMBER=$(($NUMBER+1))
fi
done
}
count $1
echo "I found $NUMBER files, in the specified folder and all subfolders"
I know you should also did it with
ls -R | wc -l
but it was a shell exercise.
Hope this help
Bye
Riccardo
Print This Post
This wuold be a simple reminder for the most common tips for VI or VIM.
It would not be a deep dive on it, simply a memo for the most common feature used by me.
Search and replace a string in a document :
:.,$s/search_string/replacement_string/g
Disabling highlighted patterns :
Type “:nohl” to disable highlighting
Comment out several lines at once (I like that one) :
1. Ctrl + V (visual block)
2. Select the lines you want to be commented out
3. Shift + I (insert mode)
4. Add the “#” character on the first line
5. Press escape
Copy and paste several lines :
1. Shift + V (visual line)
2. Select the lines
3. Press “yyN” (N lines yanked), for example to copy 3 lines use “yy3″
4. Go where you want the block to be pasted and press “p”
Cut and paste several lines :
1. Let’s say you want to cut 3 lines, put your cursor on the first of the 3 lines
2. Type : 3dd
3. Locate your cursor where you want the block to be pasted
4. Type “p”
Some key combinations :
dd : Delete current line
D : Delete from cursor to end of line
d$ : Delete from cursor to end of line
d0 : Delete from cursor to beginning of line
dw : Delete from cursor to end of current word
db : Delete from cursor to beginning of current word
yy : Copy current line (use “p” to paste)
Here’s a great cheatsheet from http://www.worldtimzone.com/res/vi.html
Cursor movement
* h – move left
* j – move down
* k – move up
* l – move right
* w – jump by start of words (punctuation considered words)
* W – jump by words (spaces separate words)
* e – jump to end of words (punctuation considered words)
* E – jump to end of words (no punctuation)
* b – jump backward by words (punctuation considered words)
* B – jump backward by words (no punctuation)
* 0 – (zero) start of line
* ^ – first non-blank character of line
* $ – end of line
* G – Go To command (prefix with number – 5G goes to line 5)
Note: Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
Insert Mode – Inserting/Appending text
* i – start insert mode at cursor
* I – insert at the beginning of the line
* a – append after the cursor
* A – append at the end of the line
* o – open (append) blank line below current line (no need to press return)
* O – open blank line above current line
* ea – append at end of word
* Esc – exit insert mode
Editing
* r – replace a single character (does not use insert mode)
* J – join line below to the current one
* cc – change (replace) an entire line
* cw – change (replace) to the end of word
* c$ – change (replace) to the end of line
* s – delete character at cursor and subsitute text
* S – delete line at cursor and substitute text (same as cc)
* xp – transpose two letters (delete and paste, technically)
* u – undo
* . – repeat last command
Marking text (visual mode)
* v – start visual mode, mark lines, then do command (such as y-yank)
* V – start Linewise visual mode
* o – move to other end of marked area
* Ctrl+v – start visual block mode
* O – move to Other corner of block
* aw – mark a word
* ab – a () block (with braces)
* aB – a {} block (with brackets)
* ib – inner () block
* iB – inner {} block
* Esc – exit visual mode
Visual commands
* > – shift right
* < – shift left
* y – yank (copy) marked text
* d – delete marked text
* ~ – switch case
Cut and Paste
* yy – yank (copy) a line
* 2yy – yank 2 lines
* yw – yank word
* y$ – yank to end of line
* p – put (paste) the clipboard after cursor
* P – put (paste) before cursor
* dd – delete (cut) a line
* dw – delete (cut) the current word
* x – delete (cut) current character
Exiting
* :w – write (save) the file, but don’t exit
* :wq – write (save) and quit
* :q – quit (fails if anything has changed)
* :q! – quit and throw away changes
Search/Replace
* /pattern – search for pattern
* ?pattern – search backward for pattern
* n – repeat search in same direction
* N – repeat search in opposite direction
* :%s/old/new/g – replace all old with new throughout file
* :%s/old/new/gc – replace all old with new throughout file with confirmations
Working with multiple files
* :e filename – Edit a file in a new buffer
* :bnext (or :bn) – go to next buffer
* :bprev (of :bp) – go to previous buffer
* :bd – delete a buffer (close a file)
* :sp filename – Open a file in a new buffer and split window
* ctrl+ws – Split windows
* ctrl+ww – switch between windows
* ctrl+wq – Quit a window
* ctrl+wv – Split windows vertically
Hope this help
Bye
Riccardo
Print This Post
The following is a great memo for a lot of bash shortcuts.
Original link : HowToGeek
CTRL Key Bound
Ctrl + a – Jump to the start of the line
Ctrl + b – Move back a char
Ctrl + c – Terminate the command
Ctrl + d – Exit the current shell
Ctrl + e – Jump to the end of the line
Ctrl + f – Move forward a char
Ctrl + h – Same as backspace
Ctrl + k – Delete to EOL
Ctrl + l – Clear the screen
Ctrl + r – Search the history backwards
Ctrl + R – Search the history backwards with multi occurrence
Ctrl + t : Swap the last two characters before the cursor
Ctrl + u – Delete backward from cursor
Ctrl + w : Delete the word before the cursor
Ctrl + xx – Move between EOL and current cursor position
Ctrl + x @ – Show possible hostname completions
Ctrl + z – Suspend/ Stop the command. “fg” restores the suspended command.
ALT Key Bound
Alt + < – Move to the first line in the history
Alt + > – Move to the last line in the history
Alt + ? – Show current completion list
Alt + * – Insert all possible completions
Alt + / – Attempt to complete filename
Alt + . – Yank last argument to previous command
Alt + b – Move backward
Alt + c – Capitalize the word
Alt + d – Delete word
Alt + f – Move forward
Alt + l – Make word lowercase
Alt + n – Search the history forwards non-incremental
Alt + p – Search the history backwards non-incremental
Alt + r – Recall command
Alt + t – Move words around
Alt + u – Make word uppercase
Alt + back-space – Delete backward from cursor
More Special Keybindings
$ 2T – All available commands(common) (2T means press the TAB twice)
$ (string)2T – All available commands starting with (string)
$ /2T – Entire directory structure including Hidden one
$ 2T – Only Sub Dirs inside including Hidden one
$ *2T – Only Sub Dirs inside without Hidden one
$ ~2T – All Present Users on system from “/etc/passwd”
$ $2T – All Sys variables
$ @2T – Entries from “/etc/hosts”
$ =2T – Output like ls or dir
Hope this help
Bye
Riccardo
Print This Post
The following is a simple memo on how to use the three powerful tools above.
It will not be a complete guide, and you should find only a small part of the possible use, but this would be a review only for the most common use (for me) and would not go a deep dive.
Grep
grep : print lines matching a pattern (equals “grep -G” which is the default)
egrep : equals grep -E (interpret extended regexp)
grep -n : line numbered
grep -i : ignore case
grep -c : count matches
grep -v : print non-matching lines
grep -r : recursivity, read all files under each directory
grep pattern file.txt
Will display the lines containing the pattern
grep -c pattern file.txt
Will display how many lines contain the pattern
grep -i pattern file.txt
Will display the lines containing the pattern regardless of the case
grep -A 1 -B 1 pattern output.txt
Will print the one line before (-B) and one line after (-A) the matching pattern
Awk
awk '{ print $0 }' file
Output the content of the file
awk '{ print $2 }' file
Output the second field of data of the file, space is the default separator
awk -F ':' '{ print $2 }' file
Same but separator is “:”
Sed
cat file | sed -e 's/old_pattern/new_pattern/g'
sed would replace old_pattern by new_pattern in the output
cat file | sed -e '4,10s/old_pattern/new_pattern/g'
sed would replace old_pattern by new_pattern in the output between line 4 and 10
cat file | sed '/pattern/d'
Delete a pattern
cat file | sed '/pattern/!d'
Delete everything but the pattern (this equals grep “string_to_remove”)
Hope this help
Bye
Riccardo
Print This Post























