You are here: Home Tech Notes Linux
Linux - Tech Notes



Ubuntu Lucid Upgrade: Dell T3500 Disaster PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Tuesday, 18 May 2010 17:47

My system at work had been acting funky for months. Every now and again, the monitor would go non-linear and I'd get no response from the mouse or keyboard. It would normally still be accessible remotely. So, I'd just reboot it that way and move on. I was pretty sure it was a memory or video card issue.  But, I read where Ubuntu had some problems with the NVidia cards. I figured I'd wait 'til Ubuntu released 10.04 and do a fresh install.

Read more...
 
Linux CLI: Copy MySQL Database PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Tuesday, 06 April 2010 11:57

There is no command in MySQL to copy a database. One method to copy a database is as follows;

  1. Create a new empty database.
  2. Export the source database using mysqldump.
  3. Import the database to the new empty database created in step 1 above.

(See Linux CLI: MySQL Database Backup & Restore article for mysqldump usage).

Alternatively, phpMyAdmin can be used for small databases. More often-than-not, databases exceed size limits imposed by phpMyAdmin forcing CLI use or another method.

 
SSH: Stop Asking to Add New Hosts PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Tuesday, 29 December 2009 11:33

An annoying little thing. When connecting via SSH to another machine for the first time SSH always prompts;

---
The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is ..............
Are you sure you want to continue connecting (yes/no)?
---

Typing "yes' each time can be pain in the butt. There is a way to change that behavior but, some believe it exposes you to a Man-in-the-middle attack.You've been advised!

I've changed settings in most of my /etc/ssh/ssh_config files to stop the machine from begging for a "yes" response, to just automatically adding the new host to the known_hosts file. I did that by changing the parameter value of StrictHostKeyChecking to "no" and restarting the SSH service.

Note: This does not stop SSH from checking that the host exists in the known_hosts file. It simply adds new hosts to the file without prompting.

 
PHP CLI: Rsync Script PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Wednesday, 23 December 2009 17:01

Here's a handy script to run rsync from the command-line that prompts for source and destination paths;

#! /usr/bin/php

<?php
## Control CLI parameters
if (($argv[1]=="") OR ($argv[2]=="")) {
echo "Options not specified.\r\n";
echo "Program Usage: ";
echo $argv[0]." <i.e.: /source/path> <i.e.: /destination/path>\r\n\r\n";
exit;
}else{
$srcpath=$argv[1];
$dstpath=$argv[2];
}

$starttime=date('G:i:s', strtotime('now'));

echo "Starting rsync...\r\n";
$retval=system("sudo rsync -avrl --delete ".$srcpath." ".$dstpath, $retval);
if (!$retval==false) {
echo "Backup from ".$srcpath." to ".$dstpath." is complete!\r\n\r\n";
}else{
echo "Backup from ".$srcpath." to ".$dstpath." FAILED!\r\n\r\n";
}

$endtime=date('G:i:s',strtotime('now'));


echo "\r\nStart time - ".$starttime."\r\n";
echo "End time - ".$endtime."\r\n\r\n";
echo "Script complete!\r\n";

?>

Note:

  • The sudo command in the system call allows the script to be used to sync root user files. This can be removed if that behavior is not desired.
  • The script also utilizes the --delete feature of rsync to remove files in the destination that do not exist in the source. Evaluate that behavior for your application as well.
 
Ubuntu: Change Hostname PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Monday, 02 November 2009 09:20

I had to snag this one for posterity from http://www.ducea.com/2006/08/07/how-to-change-the-hostname-of-a-linux-system/

 

Permanent hostname change on Debian based systems

Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh

/etc/hostname
server

So on a Debian based system we can edit the file /etc/hostname and change the name of the system and then run:

/etc/init.d/hostname.sh start

to make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script we used hostname.sh).

 
Linux: Copy Directory Structure Only PDF Print E-mail
User Rating: / 2
PoorBest 
Tech Notes - Linux
Written by Rick   
Friday, 11 September 2009 18:00

I ran across the need to copy a large directory structure to a remote machine this week. I just needed the directory structure, not the files. There is a way to do this locally using the cp command with the --parent switch, though I haven't tried it yet.

Doing it remotely requires rsync;

rsync -av --include '*/' --exclude '*' source-dir dest-dir

Works like a charm.
 
<< Start < Prev 1 2 3 4 5 Next > End >>

Page 1 of 5