Helpful reminders for working with your Bash, Terminal and command line.

Process status, see what processes are running on the machine

ps -ax

Confirm Apache is running

ps -ax | grep http

Confirm MySQL is running

ps -ax | grep mysql

list files and directories.


Change directory.


Create a new directory.


Copy files or directories.


Move (rename) files or directories.

mv myfile.txt destination-directory

Command Line Interface / Terminal Commands

  • {control}+{c}
    Abort the current line or running script.
  • {command}+{k}
    Clear the interface.
  • {control}+{a}
    Put the cursor at the beginning of the current line.
  • {control}+{e}
    Put the cursor at the end of the current line.
  • cd -
    Switch to the last directory you were in.
  • pwd
    Print the current working directory path.


Export a Database

You should not be logged-in to your MySQL server, simply run this command from the directory where you want the backup file put.

mysqldump -u [username] -p [database name] > [filename].sql

If you use MAMP, the mysqldump script is located in the MAMP application directory. You can make an alias to MAMPs version of mysqldump in your bash profile, or call it directly with something like:

/Applications/MAMP/Library/bin/mysqldump -u [username] -p [database name] > [filename].sql

Import a Database

You can import an .sql file from the command line, and from the MySQL shell.

Command Line

You must have an empty database ready to import data to, so if you don’t, login to the MySQL shell and create the database with CREATE DATABASE [database name];, then log-out of the MySQL shell.

To import, on the command line navigate to the directory where your .sql import file is located and enter the command:

mysql -u [username] -p [database_name] < [dumpfilename.sql]

You will be prompted for your password, then the import will proceed. When it is finished, your command prompt will return to normal.

MySQL Shell

This method will allow you to monitor the import progress. To import a .sql file into your local MySQL database, first login to the MySQL shell:

mysql -u [username] -p

Then run these commands in the MySQL shell to create a new database, switch to using it, then import a .sql file:

CREATE DATABASE [database name];
use [database name];
source [path to your sql file to import];