Archive for Linux

Quick notes for DokuWiki

Notes from tonight’s playing with DokuWiki. Initially saved it as a text file, then thought, what the hell, it might benefit somebody.

1. Got DokuWiki. Learned this from my buddy Baron, who I admire and whose recommendations I take seriously.

2. Fired up ami-23b6534a, an Amazon virtual instance with Apache pre-configured.
/var/www/html is the web root directory, fairly common.
use this code snippet to find out user and group that Apache httpd runs under:

< ?php

if(function_exists('posix_geteuid')){
    // use posix to get current uid and gid
    $uid   = posix_geteuid();
    $usr   = posix_getpwuid($uid);
    $user  = $usr['name'];
    $gid   = posix_getegid();
    $grp   = posix_getgrgid($gid);
    $group = $grp['name'];
}else{
    // try to create a file and read it's ids
    $tmp = tempnam ('/tmp', 'check');
    $uid = fileowner($tmp);
    $gid = filegroup($tmp);

    // try to run ls on it
    $out = `ls -l $tmp`;
    $lst = explode(' ',$out);
    $user  = $lst[2];
    $group = $lst[3];
    unlink($tmp);
}

echo "Your PHP process seems to run with the UID $uid ($user) and the GID $gid ($group)\n"; ?>

Or phpinfo, which is a bit too much data.

3. Downloaded DokuWiki and expanded it, and put it under the web root directory.

4. Permission stuff.

chmod 775 conf/
chgrp apache conf/
chgrp apache data/
chmod 775 data/
chmod 775 data/pages/
chgrp apache data/pages/
chmod 775 data/attic/
chgrp apache data/attic/
chgrp apache data/media/
chmod 775 data/media/
chmod 775 data/meta/
chgrp apache data/meta/
chgrp apache data/cache/
chmod 775 data/cache/
chmod 775 data/locks/
chgrp apache data/locks/
chgrp apache data/index/
chmod 775 data/index/
chmod 775 data/tmp/
chgrp apache data/tmp/
mv data /home/myname/
modify conf/local.php to include this line:
$conf['savedir'] = ‘/home/myname/data/’;
mv conf /home/myname/
add preload.php under /var/www/html/inc with this content:

define(’DOKU_CONF’,'/home/myname/conf/’);

To do:

1. a quick once-over of Wiki syntax.
2. Possibly search for transferring from one wiki platform to another?
3. Creating a test page. Shandong comes to mind.

该洗洗睡了。明天再说。记着和老婆一起把外面那个桌子搬到地下室里,记着教孩子中文要耐心!

Comments (1)

AWS Management Console is nice

If you want to play with Amazon cloud computing stuff, I think using AWS Management Console web interface is the best, easiest, and most intuitive approach, based on my experience so far.

My usage with Amazon Web Services has been only with EC2 up to this point. Prior to AWS Management Console, I had to set up Java, EC2 API tools, various path and environmental variables, certificates, keys, etc., etc.. It is a fairly convoluted process.

AWS Management Console is much easier, except for downloading PuTTY and PuTTYgen on Windows and tsclient on Linux, and a private key pair, everything else is handled inside the browser. Here are a few things I learned:

  • Once you are in, create a Key Pair. The web interface will prompt you to save it. Do so, because you will need it to start instances and, depending on what type of instances you start (Windows or Linux), you will need it for shell access (Linux) or for getting Windows administrator password for remote desktop access;
  • If you are working with Windows machine running Linux EC2 instances, get PuTTY and PuTTYgen. Follow instructions here to generate key that can be used by PuTTY. It worked for me. I got my private key pair file on Linux first, and then moved to Windows. It even worked with the ^M characters inside the file.
  • For security groups, I found the ones proposed by Amazon works fine. For instance, for a typical LAMP server, it proposes a webserver group where it opens up SSH port 22, MySQL port 3306, and HTTP port 80, which is normally what you want.

Good luck!

Comments (2)

In search of a better dev environment setup

Now my make-shift working area is no longer the dining table after the move, I am eager to set up a proper environment for learning and developing software at home.

My thought is to have one decent computer that powers a few virtual machines. I like the idea of virtual machines as opposed to physical ones, which are more costly and messy. And I was pretty determined to run a Linux distro as the host, because I want to live and breathe in it for a while, to bring my Linux skill to a similar level of my Windows knowledge.

I’ve learned a few things during my quest for a better computer configuration. At times, it was really frustrating.

  • SSD (Solid State Disk) is nice. It provided a tangible, fairly obvious performance boost to my system. I am no longer afraid of the previously daunting prospect of long running install and uninstall, such as SQL Server. Better yet, when I want to test something that can potentially have a negative side effect, I now would do it in a virtual machine. Before such test starts, I take a snapshot. Prior to SSD, it would take a long time to do a snapshot of the VM. With SSD, it is much quicker now. If the test didn’t go well, I would roll back the virtual machine to the state when snapshot was taken;

    Begin rant

  • So far I am disappointed with all Linux distro that I’ve tried. Part of it is understandable, as vendors will make their devices working on Windows as a priority. I remember clearly the frustration I had when trying to get dial-up modem work properly on Red Hat, and my struggle later with wireless card. But things like these are inexcusable:

    1. Mouse freezes up for no apparent reason. When that happened, I always had to do a hard shutdown. Yes, I’ve tried various ways to restart X, but a) it didn’t work; b) Even if it worked, I would not take it. Please spare me the lecture of always using keyboard all the time. This is the deal breaker for me;
    2. Sound card stopped working after some system update from Ubuntu’s repository;
    3. Wireless card is flaky. It does not work on a consistent basis, in other words;
    4. System updates broke my display driver. I was forced to use a lower resolution display than what the monitor is capable of. I think if I recompile, I could fix it, but I was so pissed off that I didn’t bother;
    5. I couldn’t enable file sharing. It told me to resolve some dependency issues, but there were none!
    6. Ubuntu comes with Firefox 3.0, and there is no decent way of upgrading it to Firefox 3.5, other than Ubunzilla, but I cannot install Ubunzilla because the aforementioned dependency issue! And if I use apt-get install firefox-3.5, why deliver Firefox 3.0, 3.1, and a beta version of 3.5?
    7. Could we please stop using code names like Hardy Heron, Intrepid Ibex, and Jaunty Jackalope? Use that internally is fine. Version number 8.04, 8.10, and 9.04 will do for the general public.

  • After my frustration with Ubuntu, I decided to try Fedora and suseLinux (both gnome and kde). Maybe I didn’t give them enough time, but I encountered mouse and windows freeze issue as well. Ditto for Kunbuntu.

    End Rant

So I came back to Windows. Now the host runs Windows 7 Enterprise with VMWare virtual machines running Windows XP and Linux Mint 7, which looks anesthetically pleasing to me, for now.

For virtual machine software, I am using VMWare Workstation 6.5. I’ve looked at and tested a few other choices: Xen, Microsoft hyper-v, Virtual PC, Virtual Server. And VMWare Workstation came out on top, in my personal opinion. I plan to give VMWare 180 bucks for a license.

PS. I tested VirtualBox before and was reasonably impressed. I really hoped I could use it at home. But it will not make the cut, I am afraid. Read Emilian’s great critique here. I just want to add, in addition to snapshot issues, I had trouble getting the shared folder working.

Should I try FreeBSD as host?

Comments

Resolving nvidia card display issue on Ubuntu

Today I purchased a HP Pavilion p6130y desktop as my main development workstation at home. I pulled the Intel X-25M SSD out of my laptop, and put it into this new box as the primary disk, and loaded Ubuntu 9.04 64-bit on it. So far, I am impressed. Things are fast and the machine is also quite.

However, I did notice a display problem. Out of the box, the default resolution was perhaps 1024×768, certainly below 1920×1080 that this Dell display can handle. So I went to System -> Administration -> Hardware Drivers to get the latest nvidia driver, because nvidia graphics card (NVIDIA GeForce 9100 GS) comes with this HP on the motherboard. It looked nice initially, but whenever I try to maximize a window, the system would freeze, forcing me to shut down the machine ungracefully by holding down the power button. Opening Firefox would cause the same thing, because my Firefox window opens in full / maximized mode.

I then spent the next few hours trying to figure this out. I opened the display setting window and tweaked the values here and there, hoping that would resolve the issue. I also uninstalled and reinstalled the driver a few more times. I ened up rebooting this machine so many times that I lost count.

Then it occured to me that instead of googling and scaning information that looked pretty irrelevant to my issue, I should try nvidia’s site directly. Sure enough, I could download Linux 64-bit display driver on its site! The download file was a .run file. I followed directions here, but the driver wouldn’t install because X is already running. So I booted into recovery mode, ignored the “telinit 3″ (which starts X) prompt, and just followed the directions in the terminal. The process tried to download some kernel files without success, so it compiled. One step also asked for 32-bit compatibility, which I answered “yes”, whether that step was successful was not confirmed. After the driver was successfully installed, I ran “telinit 3″ and the display issue went away.

Hope this helps somebody out there.

Update: to install the same driver on Fedora 11, get into the screen where you can edit grub loader entry, press a, space key, 3, then enter. That will start Fedora without X running. Then run “sh NVidiaDriverFileName.run”, follow instruction on screen and you will be good to go.

Comments

Geeky notes: monitors, WinSplit, PrintServer, Intel SSD

Long time no see, dear reader.

Quite a few things have happened. Frankly, I feel pretty drained in the last a year or two. Lately, I’ve spent time pondering about some metaphysical questions, such as the meaning of life, identity issues, and things of that nature. Hopefully those thinking will make me a better human being. I may write some of that out, time permitting. In the meantime, here is some technical notes for my own recordkeeping. Hopefully this benefits somebody, somehow.

  • I’ve used dual monitors at past employers, and didn’t find the productivity increase that were mentioned by a lot of people. When having two monitors, I found that my eyes lost “the center of attention”, so to speak. Maybe 3 monitors would have been better, but that sounds pretty expensive, overly complicated, and messy.
    So after our move and donating away our 7-year old HP CRT monitor to Salvation Army, I finally decided to move to the flat-panel age and bought a Dell LCD. I’ve also thought about acquiring a large LCD (I’ve heard people using 30 inch ones), but a few visits to computer stores convinced me that a 30 inch is just way too big. So after further research, I settled for a Dell S2409W. I also bought the AX510PA1 Sound Bar (speakers) that hangs under the LCD, which was pretty nice.
    Now this (the single LCD setup) is just my own experience. Your mileage may vary. Update: I bought my Dell monitor directly from Dell on its web site, and received a much bigger discount than if had I bought it at Microcenter. So it pays to surf around for a better price.
  • With a bigger monitor, it is important to have an easy way to manage the real estate space. Enter WinSplit. I particularly like the Ctrl-Alt-NumberPad key combination: 1 is lower left hand position, 9 is upper right hand position, 5 is center, etc. The layout of these positions correspond to the number pad layout, very intuitive. Keep pressing Ctrl-Alt-Number will toggle between different window size, very neat. For the window that gets my focus, I will use Ctrl-Alt-5 a few times to put it in the center and get the size I like, usually taking perhaps 2/3 of the screen. I can still monitor the other windows with side glances, if I want to.
    It would be very nice to have a WinSplit type application for Ubuntu. I haven’t done much googling on that yet. Any recommendations, dear reader?
  • After the move, the family machine will be a generic, no-brandname black box, close to 10 years old. So natually it does not support DVI, not to mention HDMI. The funny thing was when I put Ubuntu on this machine with VGA connection to the newly acquired S2409W, the screen looks sharp and nice. But with Windows 7, pictures look a bit distorted. I had to purchase a EVGA e-GeForce 8400 GS 512MB DDR2 PCIe Graphics Card, which has DVI support, for it to support Windows 7 properly. Windows 7 seems to work pretty well, though.
  • Now our place is bigger than 75 square meters, we have room for a small office. Toward that end, I bought a DPR 1260 print server to hook it up with our existing EPSON RX600 printer. DPR 1260 is a wireless printer server device that make the printer available to all PCs in the house. So far I am pleased with it. My Ubuntu laptop can print from it, but I haven’t figured out how to make it scan. (Update: after choosing some different options on the web interface, I could scan with Ubuntu also, it’s just a bit slower). I can scan with Windows machines, though. I thought the wireless print server was pretty neat.
  • Intel X-25M SSD is really nice. It makes my Ubuntu laptop much responsive than before. I settled on X-25M after some reading on the web. I’d like to hear real world SSD experience with different brands, such as OCZ, PNY, and Samsung.
    If your PC has SATA hard drives and you are considering upgrading, I’d highly recommend a SSD upgrade.
  • Lastly, I am working with a great partner on developing a software product. I will definitely write more about it in the future.

Comments

Get to MySQL data directory on Ubuntu

I’ve been asked about this and realized that it may not be obvious to people who are more familiar with Windows than with Ubuntu. So here is a tip.

When learning MySQL on Ubuntu, it is helpful to be able to get to MySQL’s data directory and observe file creation and modification while you are performing database and table creation and modification, index creation and modification, etc. You can find out MySQL’s data directory by running:

show variables like ‘datadir’;

Suppose your datadir is /var/lib/mysql. And suppose you have a database called test. After opening a terminal window and type:

cd /var/lib/mysql/test/

You will likely receive an error like below:
bash: cd: /var/lib/mysql/test/: Permission denied

Now if you try the command below, as it seems logical on Ubuntu

sudo cd /var/lib/mysql/test/

You will likely get this message:

sudo: cd: command not found

A quick way to get around it and run with root privilege, is through

sudo -i

You will then be able to get to MySQL data directory without any problems. Hope this helps somebody out there trying to learn.

Comments

Enter Chinese and do msn chat on Ubuntu

Version: Ubuntu 7.10, the Gutsy Gibbon released in Oct. 2007. I run it on VMWare Player.

Assumption: Ubuntu is connected to the web.

Do msn (Windows Live) chat on Ubuntu:

1. Application -> Add/Remove…

2. Click Internet tab on the left pane, then pick aMSN for install. As this writing, it has 4 stars under Popularity column.

3. Launch and enjoy.

By the way, so far I almost never do msn chat, but that can change if/when necessary. Once in a while, I do Skype chat.

Install and set up Chinese entry on Ubuntu, with a hat off to Nathan Sivin for his instruction. I followed his steps and just rehashed them here:

1. System -> Administration -> Language Support. Enter password as needed;

2. In Language scroll window, pick Chinese;

3. Click Apply button;

4. Check “Enable support to enter complex characters”;

5. Click Apply button. When done, close the window;

6. Open a shell, type:

locale | grep LANG=

Record the result because you will need it later. For US based Ubuntu, most likely it will be en_US.UTF-8;

7. Type:

sudo apt-get install scim-qtimm im-switch scim-pinyin

Enter password as necessary;

8. When done, type:

im-switch -z en_US.UTF-8 -s scim

Replace en_US.UTF-8 with whatever you get from step 6;

9. Reboot. For Chinese entry, press

Ctrl and Space bar

You should see a language bar in the lower right-hand corner. On the language bar, click the button immediately to the right of SCIM icon, and pick your Chinese entry methods. Press

Shift

to toggle between English (or whatever your default language) and Chinese. Press

Ctrl and Space bar

again to get rid of the language bar.

Hope this helps you. 希望这可以帮助你。

Comments (3)

My best investment so far

I’ve been using Jon’s excellent tools, ViEmu for Visual Studio, Outlook, Word, and Sql Server Management Studio for close to a year now. They make the default editor in those tools behaves like VI, with regular expression support. I bought the Enterprise Pack. Highly, highly recommended. Of course you need to know VI first.

I had some issues with ViEmu for Sql Server Management Studio on Sql Server 2008 CTP 6. So I wrote Jon. He got back to me very quickly. It turned out that the version I installed was an older one. I downloaded the newer one and it worked out of the box.

So I am a VI / Vim aficionado. In fact, I consider learning VI to be the second best investment I ever made so far in my life. The best ever happened about 5 years ago, when I finally taught myself touch typing. (I didn’t see or touch a computer and typewriter until my early twenties.) I tried to teach myself touch typing maybe ten years ago, using a high school typing book I borrowed from the local library here. That didn’t work out very well. Five years ago, I purchased a touch typing software off the web, maybe 25 dollars or so, and finally became a decent touch typist. Now I kick myself for not learning touch typing earlier.

After that, typing is not a hindrance anymore. Using Vim actually makes it enjoyable. It has made a huge difference in my life.

There is so much to learn in Vim. So far these are my most-used commands:

w
b
)
(
G
gg
cw and cNumberw
cfSomeAlphaNumericCharacter
ctSomeAlphaNumericCharacter
dw and dNumberw
C
cG
dd
.
yy
p
P
fSomeAlphaNumericCharacter
;
*
i
I
a
A
o
O
/
%
:g/^$/d to remove blank lines
Macros (q, then a letter, followed by actions that you want repeated later. For example, suppose I have a list of tables that need to be truncated, I will go to the first line, start macro recording, press I truncate table, Esc, j, then q to stop recording. For the rest of the lines, I just do Number@MacroName)

That’s all I can think of now. According to Vim Tips Wiki site, this collection of tips is the best. I found that most of the tips need to be followed consciously for a while before they become part of you. What are yours you can share with me?

Comments

Drawing Swedish flag with Logo

After our last experiment, we drew a Swedish flag with Logo. Major code improvement:

1. Introduction of variable for flag size;
2. Using the direction keyword instead of turnright and turnleft to make it less ambiguous to the code reader.

Here is the final product:

Swedish flag

Here is the code for it.

# Begin logo code

reset
x=400
canvassize 1.6*x,x
canvascolor 65,105,225
penwidth 0.2*x
pencolor 255,255,0
go 0,0.5*x
direction 90
forward 1.6*x
go 0.6*x,0
direction 180
forward x

# End logo code

Chinese flag is next. This will be a bit challenging. We will need to figure out how to draw the stars, and tilt them in the right direction. That should also give us ideas on how to draw the US flag.

2 things are of interest:

1. The code above works for KTurtle 0.6 on Ubuntu 7.1 with KDE 3.5.8, but the same code does not work on Sabayon Professional 1.1, with KTurtle 0.6, KDE 3.5.7;
2. After the Swedish flag, I thought drawing other Nordic flags is just a matter of changing colors. Turns out that is not the case, because there are subtle design and dimension differences, especially for Norwegian and Icelandic flags.

Comments

HP dv6253cl laptop fixed

It took me a while to fix the wireless problem on my HP dv6253cl.

As documented here, I tried various ways to make the wireless card work on this laptop, to no avail. I tried 3 different distros: Sabayon 3.4, Ubuntu 7.1, and Kubuntu 7.1, with different Broadcomm driver combinations I found at ndiswrapper’s wiki site. I even downloaded and compiled different ndiswrapper packages.

HP had asked me to send it back for repair in December last year. It sent me a box for packing with a prepaid FedEx label, since the laptop is still under warranty. I held on to it until late February. I got the box back 2 days ago. In all, I was pretty impressed with HP’s speed, considering the horror stories I’ve read on the web.

So I wiped everything out earlier, and installed Sabayon x86-64-3.4 MiniEdition (a flavor of Gentoo distro) on it. I am happy to report that I got wireless working on this Linux machine.

Here are the steps:

1. The first startup after Linux installation, the wireless indicator is blue;

2. I logged in as root and fired up WPA_Supplicant Administration GUI to see if I could scan and detect my wireless network. It didn’t work;

3. lspci command has this to say about the Broadcomm wireless card

03:00.0 Network controller: Broadcom Corporation BCM94311MCG wlan mini-PCI (rev 01)

4. I pretty much followed documentation here. First I removed the existing Broadcom driver (as root). After this command, the indicator turned orange:

# rmmod bcm43xx

5. Google for dv6253cl, follow the HP link to download wireless driver. Run sp36684.exe to expand the installtion file on a Windows machine. By default, the expanded files are in C:\SWSetup\SP36684A

6. Grad bcmwl5.inf and BCMWL564.SYS and transfer them to your Linux. Make sure they are in the same directory. If you have 32-bit Linux, get bcmwl5.sys instead

7. Run the following:

# ndiswrapper -i /path/to/bcmwl5.inf

8. Verify the installation:
localhost haidong # ndiswrapper -l
bcmwl5 : driver installed
device (14E4:4311) present (alternate driver: bcm43xx)

9. Run this and the indicator turned blue:

# modprobe ndiswrapper

10. Set the WEP key:

# iwconfig wlan0 key restricted 123456789A

11. Set the SSID:

# iwconfig wlan0 essid MySsidName

12. Bring up the interface:

# dhclient wlan0

Update: This morning I installed Sabayon Professional 1.1. I got wireless working again, but the strange thing is that the indicator is orange.

The wireless scanning function is absolutely necessary. Anybody out there knows which program works to scan available wireless networks?

Comments

« Previous entries