How to Check Disk Speed on Linux

June 26th, 2009 Masao No comments

/sbin/hdparm -tT /dev/sda

Categories: Linux Tags:

How to Fix “SSH Public Key Authentication Failed”

June 3rd, 2009 Masao 1 comment

If your SSH public key authentication is failing with errors like this:

$ ssh -vvv myhost.com
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/kitamura/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply

…try these permissions on the server:

server$ chmod go-w ~/    (same as 755)
server$ chmod 700 ~/.ssh
server$ chmod 600 ~/.ssh/authorized_keys

more troubleshooting tips

Categories: Linux, SSH, Troubleshooting Tags:

MySQL Schema Best Practices

May 14th, 2009 Masao No comments
  1. Use UNSIGNED INT or BIGINT for primary key, since you don’t need negative primary keys.
  2. Don’t use ON DELETE CASCADE, since you might delete rows you wanted to keep.  Explicitly delete rows in your code.
  3. Don’t use ON UPDATE CASCADE, since you might want to change the ID in the parent table of the row being referenced, without changing the ID of the child row.
  4. Always use foreign keys to constrain your data and require that foreign keys reference rows that actually exist.
  5. Use UNIQUE KEYS where necessary and where they conceptually make sense.  All fields in the UNIQUE KEY must be NOT NULL for the key to be effective.
  6. Use singular table names, unless a row represents a plural object.  (A table of chairs would be called “chair”, unless a row represented a set of “chairs”).  This makes code generation easier.

Thanks Damien.

Categories: MySQL Tags:

How To Install CPAN Dependencies Without Interaction

May 13th, 2009 Masao No comments

How to Automatically Install CPAN Dependencies without having to answer “yes” to each question:

export PERL_MM_USE_DEFAULT=1
Categories: Linux Tags:

How to List Files of a Package Installed by YUM/RPM

May 7th, 2009 Masao No comments
# rpm -ql mysql-devel
/usr/include/mysql
/usr/include/mysql/chardefs.h
/usr/include/mysql/decimal.h
/usr/include/mysql/errmsg.h
...
Categories: Fedora, Linux, RPM, YUM Tags:

How to Monitor Multi-Core CPU Usage on Linux

April 9th, 2009 Masao No comments

Here’s how to monitor multiple cores on Linux:

# mpstat -P ALL

Example:

Monitor all CPU’s in 1 second intervals forever

# mpstat -P ALL 1

Categories: Bash, Linux, Monitoring Tags:

How to Renew Your DHCP IP Address on Linux

April 7th, 2009 Masao No comments

If Synergy fails for you with this error: “Server refused client with name XXX”, then your IP might conflict with another machine on the same network.

Here’s how to renew your IP on Linux:

### Release your current IP
$ sudo dhclient -r

### Request a new IP
$ sudo dhclient
Categories: Linux, Synergy Tags:

How to Connect Vista and Samba on Fedora 10

April 6th, 2009 Masao No comments
  1. Go through the usual setup at Samba.org or use YUM (yum install -y samba)
  2. By default, the smb.conf allows sharing of home directories.
  3. Add a Samba user (smbpasswd -a myusername)
  4. On Fedora, run SELinux Administration
  5. On the left menu, click “Boolean”.
  6. Scroll down to “samba”, and check the box next to “Allow samba to share users home directories”.
  7. Also on Fedora, make sure your Firewall allows the Samba ports 139 and 445.
  8. On Windows Vista, now map the network drive.

Sample smb.conf:

[homes]
        comment = Home Directories
        browseable = no
        writable = yes
;       valid users = %S
;       valid users = MYDOMAIN\%S
Categories: Linux, Samba, Troubleshooting, Windows Tags:

How to Disable Media Manager Services

March 31st, 2009 Masao No comments

After installing Roxio Creator, you might have a system tray icon that you can’t seem to get rid of. Here’s how to do it:

  1. Start Roxio Creator
  2. On the left side, click Audio.
  3. Then click Audio CD
  4. On the left bottom, click Settings
  5. Uncheck Watch Folders at Startup
  6. Then click OK
Categories: Everything Else Tags:

How to Require Login to Edit Mediawiki

March 22nd, 2009 Masao No comments

Add this to LocalSettings.php:

$wgGroupPermissions['*']['edit'] = false;
Categories: Mediawiki Tags:

How To Get Yesterday’s Date using BASH Shell Scripting

February 17th, 2009 Masao 2 comments


# Yesterday in epoch seconds
$ yesterday=$((`date +'%s'` - 86400))

# Get default formatted yesterday's date
$ date -d "1970-01-01 $yesterday sec"
Tue Feb 17 01:27:32 PST 2009

# Same thing in YY-MM-DD
$ date -d "1970-01-01 $yesterday sec" +"%Y-%m-%d"
2009-02-17

Categories: Bash, Linux Tags:

How To Centralize Bookmarks using Firefox and Google Bookmarks

February 12th, 2009 Masao No comments
  1. Create a label in Google Bookmarks with all the bookmarks you want to centralize.
  2. Then, create a live bookmark in Firefox with the following URL, replacing the label name with the one you created:

http://www.google.com/bookmarks/lookup?hl=en&sort=title&output=rss&q=label:live

Categories: Firefox Tags:

How to Quickly Add Multiple Indexes to a MySQL Table

February 10th, 2009 Masao No comments

Instead of:


ALTER TABLE my_table ADD KEY `key1` (`apple`);
ALTER TABLE my_table ADD KEY `key2` (`banana`);

do this:


ALTER TABLE my_table
ADD KEY `key1` (`apple`),
ADD KEY `key2` (`banana`);

Categories: MySQL Tags:

ssh_exchange_identification: Connection closed by remote host

February 5th, 2009 Masao No comments

On the destination server, remove the known_hosts file:

rm ~/.ssh/known_hosts

Also, try this in your /etc/hosts.allow file

/etc/hosts.allow:
SSHD: ALL

Categories: Linux, SSH, Troubleshooting Tags:

How To Map Links Onto An Image

December 25th, 2008 Masao No comments

The mapping:

<map name="pressMap">
<area href="/weekly" coords="10,6,232,79">
<area href="/store" coords="245,6,469,79">
<area href="/yelp" coords="481,6,705,79">
<area href="/press" coords="718,6,941,79">
</map>

The image:

<img src="hpAdsStatic.png" usemap="#pressMap" />

Categories: HTML, Images Tags:

How to Fix a Failed Network Connection in Fedora 10

December 18th, 2008 Masao No comments
  1. Go to System -> Administration -> Network
  2. Select your “eth0″ device.
  3. Activate it.
  4. Click “Edit”.
  5. Check the box next to “Controlled by Network Manager”.
  6. Save and exit.

Your connection should now work.

Categories: Linux Tags:

How to Automatically Start Pageant with Private Keys in Windows

December 17th, 2008 Masao No comments
  1. In the Startup folder in the startup menu, right-click and create a New -> Shortcut.
  2. Browse to your pageant.exe file.
  3. Add the full path to your private key enclosed with quotes.
  4. Save the shortcut.

“c:\program files\putty\pageant.exe” “c:\documents and settings\esumbar\pka-putty\mykey.ppk”

Categories: SSH, Windows Tags:

How to Get Free Engineering Course Material Online

December 15th, 2008 Masao 1 comment
Categories: Everything Else Tags:

How to Make Firefox Always Start a New Session

December 3rd, 2008 Masao No comments

In Firefox, “about:config”, set

browser.sessionstore.resume_from_crash = false

Categories: Firefox Tags:

How to View a Specific Page or Section of Manpage

November 30th, 2008 Masao No comments

For example, the “kill” manpage shows:

SEE ALSO
bash(1), tcsh(1), kill(2), sigvec(2), signal(7)

This is how to view section 7 of the “signal” manpage:

man 7 signal

Categories: Bash, Linux Tags: