Tag Archives: bash

Site backup script example

This handy script will backup a directory and database. To use, create a new file on your server, probably in your user’s root, called backup.sh and add the below, making sure to update the source and destination path varaibles and database name. To run the script, do this:

All About $PATH

When issuing commands from a shell, the system will check for programs in the directories listed in your $PATH variable. Multiple paths are the norm, and each should be divided with a colon. Earlier directories will be searched before whatever follows. Here’s an example $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin To see what’s currently in your $PATH variable Adding […]

Update or Install Joomla over SSH

This procedure comes in handy if, like me, you have trouble using the one-click Joomla updater on some servers. First, find out the web address of the upgrade or install package that you need straight from joomla.org. Make a note of the URL of the package. Next, shell into your server and cd to the […]

MySQL command line cheat sheet

Selecting a database Listing databases Listing tables in a db Describing the format of a table Creating a database Creating a table Inserting one row at a time Retrieving information (general) Fixing all records with a certain value Retrieving unique output records Sorting Date calculations MONTH(some_date) extracts the month value and DAYOFMONTH() extracts day. Pattern […]

Symbolic Links

Symbolic links come in real handy when you need to create multiple paths to the same directory. Why would you need to do this? Dependencies are one great reason. Let’s say you install a new package that needs to be configured to point to another library, and let’s suppose that library gets updated, and let’s […]

Delete files and directories recursively

Be careful with this one! The -r flag means it’s recursive, the f suppresses the need to confirm every file deletion.

Securely copy folders between UNIX Machines

You will be prompted for a password after issuing this command.

Zip files or directories

Replace filename with the name you want to give the zip file. The .zip extension is automatically appended to the end of the filename. Replace inputfile1 and inputfile2 with the names of the files you wish to include in the zip archive. You can include any number of files here, or you may use an […]

Copy Directories

The first directory listed is the one to copy, the second is where it’s copied to.

Directory Permissions

chmod the current directory, and all subdirectories and files. The below will make the current directory, and all subdirectories and files readable, writable, and executable for the owner and group, ensuring they’re only readable and executable for everyone else. Recursively chmod Directories or Files