'bash' tag

Updating Slice Software

0

This is one of those things that I don’t do often enough to commit to memory, so for future reference:

sudo aptitude update; #updates source repositories
sudo aptitude safe-upgrade;
sudo aptitude full-upgrade;
#tada!

Importing MySQL DBs via command line

0

Okay, so wow. I had a pretty obese database I wanted to move from one server to this one (my Slicehost acct) and PHPMyAdmin just couldn’t handle an 11MB table or something; I was even breaking it down so that it only had to import one table at a time, to no avail.

So naturally this seemed like something that could be done from the command line with ease. Heh.

First, I uploaded the exported version of my gzipped database to the root of my home directory.

gunzip mydb.sql.gz #unzip the database
mysql -u username -p newdbname < ~/mydb.sql

That's it. Seriously.
One thing to note is that I already had '

newdbname

' created. But otherwise it was extremely straightforward (after I spent at least an hour figuring it out :P).

Auto-Update SVN Bash Script

3

I’ve got at least 4 installs of WordPress on my server and I have them all checked out from WordPress’ SVN repository because uploading WordPress files whenever there is an update is incredibly annoying.

I know this means I may be using unstable and unreliable code and all that, but so far I haven’t had much of an issue. Worst case scenario I have to do a server rollback or something.

But anyway, having something like 4 SVN WordPress Installs it’s become apparent that I need an easier solution to running svn update on all the directories.
SO I MADE A BASH SCRIPT.

The Script

#!/bin/bash
# Updates all of my wordpress installations at once ...

echo '--Updating benwatts.ca';
cd ~/benwatts.ca
svn update

#[..] repeat for the other installs

echo "Done and done.";

Storing the Script

Then I created a bin folder in my user folder

mkdir ~/bin

and moved it there

mv ~/updatewordpress ~/bin/updatewordpress

.

Using it

Unfortunately, to use it you have to specify the path (so …

cd ~/bin; ./updatewordpress

). That kind of sucks. Not a whole lot … but I wanted to be a bit adventurous and make it so that I just have to type ‘updatewordpress’ and it’ll go ahead and do it. As it turns out, at least in my version of linux it already searches ~/bin for shell scripts … so all I had to do was log out and log back in again and now the command is there … NICE!

Bash File Manipulation/Navigation

0
  • ls [-la]

    ‘list’ … lists the contents of the directory you’re in. The [-l] flag adds detailed info about the files/folders in the directory. The [-a] flag shows hidden files.

  • cd [name of folder to open]

    ‘change directory’ … the main way you navigate the filesystem.

  • mkdir [name]

    ‘make directory’

  • rm [-r] [name]

    ‘remove’ … deletes a file. to delete a directory you need the [-r] flag. It recursively deletes the directory and all sub-directories.

  • mv [source] [destination]

    ‘move’ AND rename. It can move a file/directory and at the same time rename it.

  • ln [-s] [source] [name of link]

    ‘link’. Creates a shortcut to a file or folder in the directory you’re in. Can prevent a lot of extra typing. Always use the -s flag. It keeps the links symbolic. I don’t know what that means … but it’s the only way you can create a shortcut to a folder.

  • du -sh [directoryname]

    Calculates the size of a directory. -s = summary, -h = human readable.

  • df -h

    Calcualtes disk usage. -h = human readable.