2011-12-25

Eclipse Indigo CDT 8.0.x Mac OS X Qt4 Indexer Fix

Run:
ln -s /Library/Frameworks/QtCore.framework/Headers /usr/include/QtCore
ln -s /Library/Frameworks/QtGui.framework/Headers /usr/include/QtGui
ln -s /Library/Frameworks/QtDBus.framework/Headers /usr/include/QtDBus
ln -s /Library/Frameworks/QtDesigner.framework/Headers /usr/include/QtDesigner
ln -s /Library/Frameworks/QtDesignerComponents.framework/Headers /usr/include/QtDesignerComponents
ln -s /Library/Frameworks/QtHelp.framework/Headers /usr/include/QtHelp
ln -s /Library/Frameworks/QtMultimedia.framework/Headers /usr/include/QtMultimedia
ln -s /Library/Frameworks/QtNetwork.framework/Headers /usr/include/QtNetwork
ln -s /Library/Frameworks/QtOpenGL.framework/Headers /usr/include/QtOpenGL
ln -s /Library/Frameworks/QtScript.framework/Headers /usr/include/QtScript
ln -s /Library/Frameworks/QtScriptTools.framework/Headers /usr/include/QtScriptTools
ln -s /Library/Frameworks/QtSql.framework/Headers /usr/include/QtSql
ln -s /Library/Frameworks/QtTest.framework/Headers /usr/include/QtTest
ln -s /Library/Frameworks/QtWebKit.framework/Headers /usr/include/QtWebKit
ln -s /Library/Frameworks/QtXml.framework/Headers /usr/include/QtXml
ln -s /Library/Frameworks/QtXmlPatterns.framework/Headers /usr/include/QtXmlPatterns
Go to project properties > C/C++ Build > Discovery Options, change Discovery profiles scope to "Configuration-wide"
(Clean and re)build the project.
Rebuild index.

2011-12-18

Mac OS X Lion with NTFS Read/Write support

Ref 1: https://github.com/osxfuse/osxfuse/wiki/NTFS-3G
Ref 2: http://blog.nolar.info/ntfs-3g-in-mac-os-x-lion-10-7-with-read-write-support

NTFS-3G for Mac OS X


Installation

Download and install the latest version of "FUSE for OS X" from http://osxfuse.github.com. When installing "FUSE for OS X" make sure to select the "MacFUSE Compatibility Layer" option. More information about the MacFUSE compatibility layer can be found in the Frequently Asked Questions.
"NTFS-3G for Mac OS X" - NTFS-3G 2010.10.2 - can be downloaded from this blog post ("NTFS-3G for Mac OS X" blog). This is the most recent installer package for OS X. When installing NTFS-3G click the "Customize" button in the "Installation Type" section and deselect the "MacFUSE" option. MacFUSE is fully replaced by "FUSE for OS X".
If you are installing "NTFS-3G for Mac OS X" on OS X 10.7 or later, read the "fuse_wait" section under "Known Issues".

Uninstallation

To unistall "NTFS-3G for Mac OS X" open the "System Preferences" application, go to the NTFS-3G preference pane and click on the "Uninstall NTFS-3G" button

Frequently Asked Questions

1. Why is NTFS-3G's write performance so poor with "FUSE for OS X"?

The ntfs-3g program opens and does I/O to the block device /dev/disk[number] of the NTFS volume in question. OS X does not have a VM buffer cache for block devices when they are accessed in this way. That is the most overwhelming factor, because both metadata operations and file data I/O boil down to read/writes by NTFS-3G to the block device.
Suppose we somehow automagically provided unified buffer caching for block devices by essentially making a disk look like a giant file. Even then, OS X and its buffer cache is really happy only when you do I/O that is in units of page size (4KB) and aligned on a page boundary. To get the most out of the I/O subsystem in OS X, ntfs-3g (or any other program for that matter) would really want to do I/O in multiples of 4KB.
For comparison, you should try writing to an NTFS disk image. You will see that it is considerably faster because you do have some caching in that case.
There are versions of NTFS-3G available that have additional user-space caching with drastically improved performance. See the "NTFS-3G for Mac OS X" blog.

2. After installing NTFS-3G, my Boot Camp volume stopped showing up in the "Startup Disk" preference pane. I am devastated. Is reinstalling OS X, Boot Camp, and Windows the only recourse?

Relax. The "Startup Disk" preference pane is simply filtering out (that is, not displaying) any mounted volumes that it does not consider bootable. Its definition of a Boot Camp volume includes that the mounted volume either be of type msdos or ntfs - this is hardcoded into the preference pane plugin. This does not mean your Boot Camp volume has become unbootable. It is merely not showing up in the graphical user interface. You can hold the "opt" key during startup and choose the Windows partition to boot from. You can also remount it (read-only) using the NTFS file system built into OS X and it should start showing up in "Startup Disk".

3. I am getting a timeout error every time I mount a NTFS formatted volume. What to do?

You are probably running OS X 10.7 or later. See the "fuse_wait" section under "Known Issues" for more details and a workaround.

Known Issues

fuse_wait: Timeout error on OS X 10.7 and later (NTFS-3G 2010.10.2 or earlier)

fuse_wait is a tool distributed with "NTFS-3G for Mac OS X". It executes a specified MacFUSE/"FUSE for OS X" mount program with all of its arguments and displays an error message in case the mount operation fails. Because of a change in OS X 10.7, fuse_wait displays a timeout error every time a NTFS volume is mounted.
A package containing a patched version of fuse_wait fixing this issue can be downloaded at bfleischer/fuse_wait/downloads. More information about the fix including manual installation instructions can be found at bfleischer/fuse_wait.
Note: This is an unofficial patch, that is intended as a workaround until a new official version of NTFS-3G is released.



Ref 2:

NTFS-3G in Mac OS X Lion (10.7) with read-write support

Posted by – August 20, 2011

UPD 21.08.2011: There is even better way to solve the same issue with native Mac OS X drivers, but it has its own pros and cons. Read at the end for details.
UPD 12.09.2011 (IMPORTANT): Native driver makes NTFS unusable. Read below for details.
Mac OS X Lion (10.7) was released recently, in the end of July 2011. And many users had started to complain that their NTFS disks stopped working. And the much worse problem is that “old” solutions do not work well.
But after one or two weeks of researching of this issue, I’ve managed to make NTFS work in Mac OS X Lion (10.7). The key here is a proper combination of software versions.
So I will shortly describe the usual choices for external data storages, and what problems arises with each of them. And later I will show how you can get the most universal way — NTFS — to work where it does not work by default, with links and pictures.

Data Storages

The only reason to worry about this problem is an ability to access external storage drives. Even if these are your own drives and you can select a filesystem to use, that choice is not easy.
There are few possible choices for large (~1TB) file storages, but each has very unpleasant limitations and issues:
* HFS+/HFSX (or “Mac OS Extended”/”Mac OS Extended (case sensitive)”) — okay with big volumes and big files, but works natively under Mac OS X and Linuxes only. Windows need third-party software, which is either free file browser/extractor or paid low-level drivers.
* FAT32 work in each and every OS now, but has limitation for file size up to 4GB (so, you cannot store DVD image, which is usually 4.5+ GB).
* FAT64 (exFAT) is a new solution, but it works natively only in Mac OS X and Windows 7. Older Windows systems (Vista, XP) require Service Packs and updates to support exFAT. Linuxes do not support exFAT yet at all. More on that, it has only one file table, so if this only place will be corrupted on write, I will get all the data lost.
* NTFS. Okay with big files an bug volumes. Works natively in all Windows systems. Works fluently in all Linux systems. Has native read-only support in Mac OS X. But has not write support under Mac OS X.
As you can see, in terms of cross-compativility, NTFS is the best choice: it works almost everywhere, and with no limitations. The only issue is write mode in Mac OS X.
Taking into account that you probably have a lot of friends with NTFS volumes, who can visit you and bring you something interesting there, you actually have no choice except as try to make NTFS working.
So, let’s do it.

Paid NTFS Solutions

But first, in case you want to make your own research, or you are looking for a solution that just works out of the box, and you are ready to pay for it, you can give a try to Paragon NTFS for Max OS X 9.0 for $19.99 (5-days trial). That is much cheaper than Tuxera NTFS for Mac for $36.02 (with 15-days trial).
The former one definitely works – I’ve tried it in trial. Just install and get everything ready: both read and write modes, auto-mount, and also NTFS formatting in Disk Utility, disk checking, etc.
I haven’t tested the latter one, so you can leave a comment here about your experience with Tuxera paid solution.

Free NTFS Solution

This free solution requires some efforts. Not so much, of course. Well, if you are going to make your own research, it can be lots of efforts, since the situation with NTFS-3G is not very clear now.
But if you are just about a ready, copy-n-install solution, it will be easy, and requires only these two or three steps:
* MacFUSE 64-bit.
* NTFS-3G stable.
* “15 seconds” error work-around (optional).

MacFUSE 64-bit

First, you need MacFUSE with 64 bit support. That is the main problem with Mac OS X Lion — it uses 64-bit kernel, and all previous version of Mac OS X used 32-bit one. So, old MacFUSE binaries won’t work anymore.
You can get Tuxera MacFUSE 2.2 image for free (could not find a page with it, just a download links) or try to compile OSXFUSE from sources. I’ve used the former one.
You can see MacFUSE preferences in “System Preferences”. Well, actually these are not preferences, but only “update” and “uninstall” actions, and current version info:

NTFS-3G stable

Second, you will need working copy of NTFS-3G. Long story short, NTFS-3G is either already dead or is going to die. There is its ancestor: Tuxera NTFS for Mac (paid).
But we are going to use old version of NTFS-3G — the one from 2010. I’ve got one from here. But you can try googling for it, or browse here for this exact version (not 2011 — I’m not sure they work).
I also tried to install later version from MacPorts, but it does not work too: mounts something that stills unreadable. That is in addition to an error in installation process (“mv” does not see the libntfs-3g file or so).
Now, when you have installed two binary packages, you can restart Mac OS X and try to attach the drive. It should work.
NTFS-3G preferences pane looks populated and interesting:

“15 seconds” error work-around

But it will show you the error message saying that there were not signal in 15 seconds:

This is not a big problem, because everything works fine. Only annoying message box is a problem.
So the third, optional step is to address this issue. You can follow this link: https://gist.github.com/1100318 (see first and the only comment under the code). You just download this attached C file, run “gcc” command line from the comment, and replaces the “fuse_wait” binary as said there. Yes, you will need “gcc” here.
Quoted comment
Because of a change in Mac OS X 10.7, fuse_wait (a tool distributed with NTFS-3G for Mac OS X) displays a "15 seconds" timeout error every time a NTFS volume is mounted.
Download this gist and run the following commands to build and install this unofficial version of fuse_wait, that fixes the issue. Please note that Xcode has to be installed for this to work.
sudo mv /usr/local/bin/fuse_wait /usr/local/bin/fuse_wait.orig
chmod +x build.sh
./build.sh . /tmp /
NTFS-3G and other filesystems using fuse_wait should now mount fine (without the timeout error) and stay mounted. Don't forget that this is just a workaround. This issue has to be fixed in an updated version of NTFS-3G.
To revert to the original fuse_wait, run the following command in Terminal:
sudo mv -f /usr/local/bin/fuse_wait.orig /usr/local/bin/fuse_wait
I hope this helps.
And voila! Now you have working NTFS filesystem for free with no “15 seconds” error message. Profit!

Problems

Nevertheless, Mac OS X is a Unix-based system. And Unix-based system is a big problem when they work as desktop OS (earlier I thought that on Linux-based system because of community-driven and crowd-based development concept). This solution has some problems too. Though they are not about the solution itself, but about the components used.
The most important problem now is the speed: with this NTFS-3G on MacBook Air (4GB, i7 CPU) write speed for USB 2.0 drive is about 3.3 MB/s. Just to compare, the same drive in the same port, but with exFAT/FAT64 partition can write with ~38 MB/s (or fast enough to make exact estimation; will try larger files later).
Also, immediately following the mount of a drive, there is a line in system log with an error message saying:
8/20/11 6:27:48.394 AM fseventsd: could not open <
> (No such file or directory) 8/20/11 6:27:48.434 AM fseventsd: log dir: /Volumes/MYPASSPORT/.fseventsd getting new uuid: FA7C5FF2-4B57-40CA-9BC6-871C36C13C23 Where MYPASSPORT is a volume label. This file exists there, but it is updated each and every time you mount this filesystem. I guess this is because of fuse_wait wrapper, which ignores the signals that filesystem was successfully mounted, and “fseventsd” tries to read the file while filesystem is only being mounted. But it makes no problems, luckily.

UPD: Using native drivers from previous Mac OS X versions to speed up write operations

There is even better way to solve the same issue with read-write access to NTFS volumes, which involves native drivers from previous Mac OS X versions. It is described in Russian here. Credits for this method go to Casing from macdaily.me blog.
In a nutshell, you should use classic solution with “/sbin/mount_ntfs” wrapper script (that does not work in Lion on its own), and you should replace the kernel extension module for NTFS with the one from Mac OS X 10.6.8 (only one binary file: /System/Library/Extensions/ntfs.kext/Contents/MacOS/ntfs).
To do so, download this archive (mirror: NTFS_Enabler.zip), and follow the instructions in “Terminal-CMD” text file. Do not forget to “disable” NTFS-3G (globally or for your specific drive) in System Preferences before using this method.
PROS:
  • High speed of write operations – about 30 MB/s (compare to 3 MB/s with NTFS-3G).
  • Deleted files go to the Trash folder rather than deleted instantly as with NTFS-3G.
CONS:
  • Well, this is a hack after all. One day it will stop working.
  • Mac OS X updates can overwrite your replaced NTFS driver, and you have to re-install it again.
  • Disk Utility cannot create new NTFS volumes with the native NTFS driver.
  • If a volume was ungracefuly unmounted in Windows, it will be mounted read-only in Mac OS X, saying this message in system log:
8/21/11 12:48:43.000 AM kernel: NTFS-fs error (device /dev/disk1s1, pid 4859): ntfs_system_inodes_get(): $LogFile is not clean. Mounting read-only. Mount in Windows.
All the “cons” can be solved by installing NTFS-3G and keeping it disabled all the time, except when you need to format new volume, or to mount a problematic volume. Actually, it is better to enable NTFS-3G, mount it with NTFS-3G, then unmount, disable NTFS-3G, and mount it with native drivers; or use “ntfsfix” if you are not afraid of command line after all these hacks ;-)
IMPORTANT UPD 12.09.2011: Please read comments below: people say that this driver makes NTFS filesystem corrupted and unusable.
I had the same experience: my NTFS volume become only partially readable in Mac OS X, and completely unusable in Windows.  More on that, when I tried to attach the drive, Windows kernel started to use 100% CPU, and did not stop to do so even when the drive were detached. Drive letter never appeared.
Luckily for me, I had two backups of the whole volume (I do so when experimenting with new drives, since I once lost my whole photo archive due to burned out new drive). To solve the whole problem of NTFS@Mac, I’ve finally bought Paragon NTFS for Mac.

2011-11-20

OAuth 2.0 Notes

Google Data API scope list: http://code.google.com/apis/gdata/faq.html#AuthScopes

Ref: http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html

For local applications

  1. Show user the page (modify as needed):
    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=YOU_CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/calendar

2011-09-11

SSH Problems with X-forwarding

If error reports:
D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
try to make a machine-id by dbus-uuidgen > /var/lib/dbus/machine-id

If windows popped up with not letters but squares, try yum install dejavu*

VirtualBox Notes

List all VMs:
VBoxManage list vms

Start a VM by name:
VBoxManage startvm vmname

Start a VM without GUI:
VBoxHeadless -s vmname

CentOS 6 Setup with LDAP

Install with "Minimal" configuration. So no sssd was installed.

If initially GUI was not installed but is wanted, run:
yum groupinstall Desktop
yum install xorg-x11-server-Xorg

Some other tools might be handy:
wget
vim
man
file
unzip

Configure network interface(s): /etc/sysconfig/network-scripts/ifcfg-eth* or system-config-network

For LDAP setup:
Make a host name for the LDAP server in /etc/hosts (IMPORTANT: using direct IP might fail to reach the LDAP server!)
Get CA certificate from the LDAP server: /etc/openldap/cacerts/cacert.pem and put it in the client's same place.
Install packages:
  openldap-clients
  nss-pam-ldapd (nss_ldap in CentOS 5)
Configure authentication by authconfig --enableldap --enableldapauth --enableldaptls --enablemkhomedir --ldapserver=ldap1.example.com,ldap2.example.com --ldapbasedn="dc=example,dc=com" --update

Ref: 1 2 3

2011-09-10

Ubuntu Server 11.04 As Desktop Use

Desktop - system
xserver-xorg
firefox
gnome-core
gdm
humanity-icon-theme

Desktop - apps
alacarte
gksu
gcalctool
flashplugin-installer
gnome-screenshot

Development
g++
gdb
openjdk-6-jre
make

2011-09-07

Areca RAID on CentOS

Reference

Host: CentOS 5.6 & 6.0 x86_64
RAID controller: ARC-1880IX-24

Setup hardware RAID volume(s) using RAID BIOS. (Tab/F6 at booting)

If CentOS was installed without Areca driver, follow these steps:
yum install gcc-c++ kernel-devel make
Download source tar ball from http://www.areca.com.tw/support/s_linux/linux.htm
Unzip and cd into it
make
chmod u+x arcmsr.ko
insmod arcmsr.ko
Use fdisk -l to verify the RAID volume(s) are visible.
Use fdisk/gparted(provided by EPEL repo) to create partition table and manage logic volumes.

2011-09-05

Qt Compile Dependency

System
Ubuntu 10.04 LTS
Qt 4.7.4


Switches used: ./configure -prefix /home/vincent/lib/qt4 -release -shared -fast -largefile -opensource -no-accessibility -qt-sql-mysql -qt-sql-psql -qt-sql-sqlite -no-qt3support -xmlpatterns -multimedia -audio-backend -phonon -phonon-backend -svg -webkit -javascript-jit -script -scripttools -no-declarative -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -openssl -optimized-qmake -platform linux-g++ -silent -dbus -sm -xshape -xcursor -xfixes -xrender -xrandr -fontconfig -xinput -glib -xkb -xsync -nomake examples -nomake demos

Packages installed (not comprehensive since a system libqt-dev was installed before):
libdbus-1-dev
libglib2.0-dev
libcups2-dev
libxrandr-dev
libglu1-mesa-dev
libxcursor-dev
libfontconfig1-dev
libxv-dev
libxinerama-dev
libxi-dev
libssl-dev
libmysqlclient-dev
libpq-dev
libphonon-dev
libpulse-dev
libgstreamer0.10-dev
libgstreamer-plugins-base0.10-dev
libasound2-dev

2011-08-11

Google Analytics API

To retrieve the report data:
DataQuery q = new DataQuery(new URL("https://www.google.com/analytics/feeds/data"));
q.setMaxResults(8192);
q.setStartDate("2007-01-01");
q.setEndDate("2012-12-31");
q.setDimensions("ga:pageTitle,ga:pagePath");
q.setMetrics("ga:pageviews,ga:entrances,ga:avgtimeonpage");
q.setSort("-ga:pageviews");
q.setIds("ga:" + profileId);
DataFeed dataFeed = client.getFeed(q, DataFeed.class);
for (DataEntry entry : dataFeed.getEntries()) {
  // Do something with entry
}


The profileId could be listed by:
ManagementFeed f = client.getFeed(new URL("https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties/~all/profiles"), ManagementFeed.class);
for (ManagementEntry entry : f.getEntries()) {
  System.out.println(entry.getProperty("ga:profileId"));
}


A list of Dimensions and Metrics could be found at http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html.

2011-08-10

Google Analytics API Notes

A general way to query Google Analytics API:
String feedUrl;

feedUrl = "https://www.google.com/analytics/feeds/datasources/ga/accounts";
feedUrl = "https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties";
feedUrl = "https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties/~all/profiles";
URL queryUrl = new URL(feedUrl);
ManagementFeed feed = client.getFeed(queryUrl, ManagementFeed.class);
for (ManagementEntry entry : feed.getEntries()) {
System.out.println("--- Account Entry ---");
for (Property property : entry.getProperties()) {
System.out.println(property.getName() + ": " + property.getValue());
}
}

2011-06-27

Install Notes Oracle Enterprise Linux 6.1

Download the ISO image from edelivery.oracle.com.

Install with "Desktop" pre-configured installation.
And remove Oracle's unbreakable enterprise kernel (uek): yum erase kernel-uek*
  • *kernel-devel (for VirtualBox driver compilation)
  • gcc-c++
  • make

2011-06-22

Apache2 PHP Ubuntu User Directory

  1. cd /etc/apache2/mods-enabled
  2. sudo ln -s ../mods-available/userdir.load .
  3. sudo ln -s ../mods-available/userdir.conf .
  4. sudo apache2ctl restart
  5. The items in ~/public_html should be accessible from http://host/~username

By default, PHP is disabled in user directories. To enable it:
  1. Edit /etc/apache2/mods-enabled/php5.conf
  2. Delete/comment out the lines related to disabling the user directory execution.

2011-06-15

CentOS 5 Configurations

    Apache httpd
  • yum install httpd
  • Append one line in /etc/sysconfig/iptables if it is not there: -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 80 -j ACCEPT

    GNOME
  • yum install xorg-x11-server-Xorg gnome-desktop gdm

2011-04-21

Blender Python Study Notes

The environment has:
C: handle to Blender context
__builtins__: Built-ins of Python 3
bpy: Top level Blender Python API module

2011-04-15

Ubuntu Server 10.04 As Desktop Use

(A modified version of previous installation guide, focusing on 10.04 LTS)

Configure Medibuntu source: https://help.ubuntu.com/community/Medibuntu

To disable installing recommended packages, create /etc/apt/apt.conf and put APT::Install-Recommends "false"; in it.

Desktop - system

xserver-xorg
gnome-core
gdm
gnome-themes-selected
humanity-icon-theme
dmz-cursor-theme

Desktop - apps


alacarte (menu editor)
file-roller
evince
gnome-screensaver
gksu
gcalctool
flashplugin-installer
chromium-browser
firefox (Chrome not able to display XML files with a XSL stylesheet)
language-support-??
brasero (ISO burner)
gnome-utils (including baobab -- a disk usage analyser, gnome-dictionary, gnome-search-tool, gnome-system-log, and gnome-screenshot)
gnome-bluetooth
*jockey-gtk (the proprietary driver manager)
*network-manager
*network-manager-openconnect (for Cisco AnyConnect VPN)
*kchmviewer
*gconf-editor

Development:
g++
gdb
openjdk-6-jre
*freeglut3-dev
*dia
*mysql-server
*libmysql-java (the JDBC driver)
*mysql-admin
*python-mysqldb
*apache2
*php5
*php5-mysql
*php5-sqlite
*libqt4-dev
*libqt4-opengl-dev

*libqt4-sql-sqlite
*qt4-doc
*qt4-dev-tools
*qt4-designer

Remote access
vinagre (the client; you might want to disable the keyboard shortcuts in the preferences menu)
vino (the server)


Media
alsa-base
alsa-utils
gnome-codec-install
audacious
libdvdcss2
non-free-codecs
*vlc
*mozilla-plugin-vlc
*banshee
*banshee-extension-soundmenu (for ubuntu 11.04)
*totem

Gaming
playonlinux (front end of wine)

Printing
system-config-printer-gnome
cups
*smbclient (for Windows shared printing)
*hplip (HP printer drivers)


Configuration

  • Enable audio:
    1. alsamixer
    2. Press "M" to (un)mute channels
  • Clear screen when logout:
    1. ~/.bash_logout
    2. insert single command clear
  • Disable Ctrl-Alt-Del:
    1. /etc/init/control-alt-delete.conf
    2. comment out the actual command line
  • Let vim display line numbers:
    1. sudo echo set nu >> /usr/share/vim/vimrc (if there is no such line)
  • Secure login/out logs:
    1. sudo chmod 640 `sudo find /var -name ?tmp`
  • NetworkManager system tray icon:
    1. edit /etc/NetworkManager/nm-system-settings.conf
    2. make the line read managed=true
    3. sudo /etc/init.d/network-manager restart
  • Stop GDM from auto starting:
    1. /etc/init/gdm.conf
    2. comment out all "start on" stuff
  • Configure GRUB:
    1. /etc/default/grub
    2. update-grub
  • MySQL
    1. Add line default-storage-engine=INNODB to /etc/mysql/my.cnf
    2. to reset root password: sudo dpkg-reconfigure mysql-server-5.1
  • Remote login
    1. vino-preferences

2011-03-01

KDE on Ubuntu Server 11.04

Configure Medibuntu source: https://help.ubuntu.com/community/Medibuntu

Packages

    Desktop

  • kde-plasma-desktop (xserver-xorg and kdm included)
  • chromium-browser
  • flashplugin-installer
  • language-support-??
  • kchmviewer
  • network-manager-kde
  • jockey-kde

    Development

  • g++
  • make
  • gdb
  • openjdk-6-jre
  • qt4-dev-tools

    Media

  • amarok

Configuration

    NetworkManager

  • edit /etc/NetworkManager/NetworkManager.conf
  • make the line read managed=true
  • sudo service network-manager restart

2011-02-22

Python Notes

os.wait() will return the oldest finished jobs

2011-02-15

Vim Recording

Ref: http://www.thegeekstuff.com/2009/01/vi-and-vim-macro-tutorial-how-to-record-and-play/

Start recording by pressing q, followed by a lower case character to name the macro
Perform any typical editing, actions inside Vim editor, which will be recorded
Stop recording by pressing q
Play the recorded macro by pressing @ followed by the macro name
To repeat macros multiple times, press : NN @ macro name. NN is a number

2011-02-11

32-bit and 64-bit packages in CentOS 5 x86_64

yum -y remove *.i386 *.i486 *.i586 *.i686

*Not recommended but you can prevent yum from installing 32-bit software by adding this line to section [main] in /etc/yum.conf:
exclude=*.i386 *.i586 *.i686

2011-02-09

MySQL (RHEL5)

chkconfig mysqld on
/etc/init.d/mysqld start
Login mysql
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'passpass'; (passpass is the password you use to login)
DROP USER 'user2'@'localhost'
GRANT ALL ON *.* TO 'user1'@'localhost'; (wildcard % is allowed for * match)
USE mysql
UPDATE user SET password=PASSWORD("passpass") WHERE User='user1';
FLUSH PRIVILEGES;

Modify MySQL configuration file (/etc/my.cnf for Fedora-based linux; /etc/mysql/my.cnf for Debian-based linux), so it looks like this:
[client]
max_allowed_packet=1024M
[odbc]
max_allowed_packet=1024M
[mysqld]
max_allowed_packet=1024M
slave_transaction_retries=128
default-storage-engine=INNODB
datadir=/mnt/MD_1000/mysql
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306


Open port 3306 for remote administration:
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
Or if the only allowed client (e.g. your web server) is 10.5.1.3, then:
/sbin/iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT

Save iptables rules:
service iptables save

Backup/dumping with limited rows (e.g. to build a sample database from a large one)
mysqldump -u [username] -p [databaseName] --where="true limit 100" > dump.sql

2011-02-01

Linux List The Open Ports And The Process That Owns Them

Ref: http://www.cyberciti.biz/tips/linux-display-open-ports-owner.html

How do you list the network open ports on your server and the process that owns them? The answer is simple use the following command (must run as root):
sudo lsof -i
sudo netstat -lptu

CentOS 5 FTP Setup (vsftpd)

Ref 1: http://www.linuxquestions.org/questions/fedora-35/vsftpd-error-553-could-not-create-file-390569
Ref 2: http://www.cyberciti.biz/tips/rhel-fedora-centos-vsftpd-installation.html

Disable SELinux on FTP, so that uploading works:
setsebool -P ftp_home_dir 1

Install the vsftpd package via yum command:
# yum install vsftpd

vsftpd Defaults


Default port: TCP / UDP - 21 and 20
The main configuration file: /etc/vsftpd/vsftpd.conf
Users that are not allowed to login via ftp: /etc/vsftpd/ftpusers

Configure Vsftpd Server


# vi /etc/vsftpd/vsftpd.conf

Turn off standard ftpd xferlog log format:
xferlog_std_format=NO
Turn on verbose vsftpd log format. The default vsftpd log file is /var/log/vsftpd.log:
log_ftp_protocol=YES
Above to directives will enable logging of all FTP transactions. Lock down users to their home directories:
chroot_local_user=YES
Create warning banners for all FTP users:
banner_file=/etc/vsftpd/issue
Turn on vsftpd on boot:
# chkconfig vsftpd on
Start the service:
# service vsftpd start
# netstat -tulpn | grep :21


Configure Iptables To Protect The FTP Server


# vi /etc/sysconfig/iptables
Add the following lines, ensuring that they appear before the final LOG and DROP lines for the RH-Firewall-1-INPUT:
-A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT
Open file /etc/sysconfig/iptables-config, enter:
# vi /etc/sysconfig/iptables-config
Ensure that the space-separated list of modules contains the FTP connection tracking module:
IPTABLES_MODULES="OTHER_MODULES ip_conntrack_ftp"
Save and close the file. Restart firewall:
# service iptables restart

Tip: View FTP Log File
Type the following command:
# tail -f /var/log/vsftpd.log

Tip: Restrict Access to Anonymous User Only
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
local_enable=NO

Tip: Disable FTP Uploads
Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf and add the following:
write_enable=NO

For upload to work except for anonymous, you might need to:
  • create a group, say ftpw
  • change the ownership of /var/ftp and its subdirectories to group ftpw
  • add ftpw group onto users with write privilege