Eject CD from Open Firmware

Turn the power on with the power button and hold Command-Option-O-F — this will boot you into open firmware. Now type eject cd and wait until the CD pops out. Type mac-boot to reboot.

 

Linux Basics

This post outlines a couple of commonly used Linux commands.

man – command used to display manual pages for specific commands (e.g., “man ls”). Man pages are your friend!

ls – similar to the DOS dir command. It lists directory contents. Try “ls -al” for a detailed directory listing.

cd – change directory. “cd ~” will take you to your home directory.

rm – used for deleting files and folders. Similar to the DOS del command.

mv – move or rename a file

cp – copy a file

ps – shows running processes. “ps aux” shows a good amount of info.

startx – Starts X windows if run from the system console (assuming it is configured).

pwd – displays your “present working directory” or current directory.

exit – closes a shell session or logs you out of the console.

./file – executes the file located in the current directory. The current directory is represented by “./”. This is useful when you want to execute a command or script that isn’t located within the system path.

shutdown -r now – reboot the system NOW.

shutdown -h now – halt the system NOW.

vi – starts up a popular but not very user-friendly editor. vi is a very powerful editor but it takes a little getting used to.

df – shows free disk space on all volumes

free – shows free memory. Use the “-m” parameter to show memory in MB.

du – shows directory usage in terms of space for current directory and all subdirectories.

top – shows system processes. Hit “q” to exit.

uptime – shows uptime and system load statistics

cat – concatenate files and print on the standard output. To display a text file on the screen, type “cat filename”

There are many more commands; too many to cover here. However, the commands listed above should be enough to allow you to navigate around a linux system.

A couple more notes:
- “.” represents the current directory.
- “..” represents the parent directory (e.g., “cd ../images” will change directory into the images folder in the parent directory).
- “~” represents your home directory (e.g., /home/jsmith). The “~” can be used in path representations such as “cd ~/public_html” which is the same as typing “cd /home/jsmith/public_html”.

 

Backup and Restore Databases

The following steps can be executed as a non privileged user on the server, however, the username and password you use with the commands needs to be a database user that has r/w privileges within MySQL (think “sa” account for Microsoft SQL Server).

1. Export the database to a SQL file.

[user@host]$ mysqldump --opt --user=dbuser \
--password database > dumpfile.sql

2. Edit the dump file and put these lines at the beginning:

SET AUTOCOMMIT = 0;
SET FOREIGN_KEY_CHECKS=0;

3. Put these lines at the end:

SET FOREIGN_KEY_CHECKS = 1;
COMMIT;
SET AUTOCOMMIT = 1;

4. Import the database SQL file into MySQL. This will overwrite the contents of the current database.

[user@host]$ mysql --user=dbuser \
--password database < dumpfile.sql

Click here for a good shell script that automates the backup of MySQL databases. Version 2.5 is available here for download.