ubuntu

iPhone iOS 4.2+ no longer automounting in Ubuntu

I had this problem, which meant my iPhone no longer automatically mounted in Ubuntu 10.10. I had recently upgraded the iOS to 4.3.1 and this turned out to be the cause of the issue.

So, to fix it:

  1. Click on the System menu, then Administration and Software Sources. You’ll have to enter you administrator password.
  2. The Software Sources window will open.
  3. Click on the Other Software tab and click on the Add… button.
  4. Enter the following into the APT line box:
  5. ppa:pmcenery/ppa
  6. Press “Add Source”
  7. Then click “Close” And then “Reload” on the next question.
  8. Click back on the System menu. then Administration and finally Synaptic Package Manager.
  9. Once the window has loaded, click into the search box, and search for:
  10. libimobiledevice1
  11. The program may tell you that it will need to uninstall libimobiledevice0 and upgrade some other thing. I said OK to all this and then press Apply.
  12. It will run through, download the new modules and install them.
  13. Restart your computer for these changes to take effect.

How to use Nano on Unix-like systems

Nano is a basic text only text editor in Unix. It has no real GUI as such, and there is very little mouse interaction. But this makes it very useful, especially when SSHing to your web server. Here are some basic commands for you.

Opening Nano to edit a file is as simple as

Nano filepath/filename &

Note the & on the end to tell Terminal to carry on and not wait.

Key Shortcuts

With all these key shortcuts, the shortcut is called by holding CTRL and pressing the shortcut key:

Moving around the file:

CTRL + A -> Move the cursor to the start of the line.
CTRL + E -> Move to the end of the line.
CTRL + Y -> Page Down.
CTRL + V -> Page Up.
CTRL + _ -> Move to a specific line/column.

The mouse wheel on my Ubuntu will move the cursor up and down. I don’t know if this is design or just luck.

Editing the file:

CTRL + K -> Cut the whole line the cursor is on. (Similar to deleting, however you can re-paste these – see below)
DELETE -> Deletes the character ahead of the cursor (as you’d expect).
BACKSPACE -> This deletes the character before the cursor (again, as expected).

Copy and Paste:

ALT + 6 will copy a line into the copy buffer. You may copy more multiple lines into the buffer, and when you paste them, they will paste in the order that you coped them.
CTRL + K to cut a line

CTRL + U will paste what ever is in the buffer. As mentioned before, if you copy multiple lines, they will be pasted in the order that you copied them. Neat.

Saving:

CTRL + O -> Save the current file. You will be prompted for the filename which will default to the current file.
CTRL + X -> This will quit the application. However, if the file has changed, you will be prompted if you want to save changes.
CTRL + T -> When performing file actions, CTRL+T will show you a basic file browser…

More:

CTRL + G -> This will show the full Nano help file with many more commands.

Accessing /var/www/ as normal user

Some useful linux commands to help with editing web pages on a server:

To give access to others to my www folder (so I don’t have to login as sudo):

chmod 2775 . -R

To show the groups for the selected user:

groups <username>
groups www-data

To add the www-data user to the local user’s group. (When you create a user, i.e. Bob, Ubuntu will create a Bob group.)

sudo usermod -G Bob www-data

To add a bunch of groups to a user:

sudo usermod -G groups,separated,by,commas username

Setting up postfix on Ubuntu for mailing from PHP

To allow your Ubuntu server to send emails from PHP, then you need to install postfix. Postfix is a mailer for *nix platforms.

So, to install it:

sudo apt-get install postfix

When this is installing, you’ll need to enter some options, like what sort of server you’re connecting to. I use my companies details in here, and this means I need to enter the domain into the origins so that we don’t get refused mail.

sudo nano /etc/postfix/main.cf

Un-comment the line that states myorigin = /etc/mailname

Also, I have to enter the ip address of my mail server in the relayhost section.

CTRL X and save the file.

Now, we need to create the file /etc/mailname

sudo nano /etc/mailname

In this empty file, enter the domain name for your mailserver.

christatedavies.co.uk

CTRL X and save the file.

Now, just restart postfix:

sudo /etc/init.d/postfix restart

Job’s a goodun.

Remove svn folders from Ubuntu

When backing up a source code working copy, you don’t always want all the little .svn folders everywhere.

You can “export” the working copy, or if you forgot, you have remove them all.

Change the the folder containing the working copy (this is very important*)

cd /home/username/www/sitename/

And then remove them all, recursively with this command:

find -name ".svn" -exec rm -rf {} ;

This will find all .svn files/folders in the current folder, and remove them and everything in them.

*if you do not ensure you are in the right folder, this command will remove all recursive folders, so if you are in the web root, it will remove all the svn information from all your sites… This is very important (that’s twice I’ve said that, so it must be)

Installing Tahoma font in Ubuntu

The stylesheet of our intranet is primarily Tahoma, and Firefox on Ubuntu doesn’t look good.

To install the Microsoft Core Fonts package in Ubuntu, run the following in your terminal:

sudo apt-get install msttcorefonts

And then this should go away and get them. Lovely.

NB, if this doesn’t take immediate effect, you can rebuild the font cache by running

sudo fc-cache -fv

Now, the Tahoma font is excluded these days from this package, so you’ll need to install that one manually, by following the instructions found here

Installing Tahoma font in Ubuntu

The stylesheet of our intranet is primarily Tahoma, and Firefox on Ubuntu doesn’t look good.

To install the Microsoft Core Fonts package in Ubuntu, run the following in your terminal:

sudo apt-get install msttcorefonts

And then this should go away and get them. Lovely.

NB, if this doesn’t take immediate effect, you can rebuild the font cache by running

sudo fc-cache -fv

Now, the Tahoma font is excluded these days from this package, so you’ll need to install that one manually, by following the instructions found here

Help in using Ubuntu Terminal Console

Help in using Ubuntu Terminal Console


Remote connection

To ssh to another Lunix terminal, use this command:

ssh username@host -p port

The default SSH port is 21, but you could change it to anything, i.e. 9100

Remote teminal will prompt for your password, and job done.


File/Folder functions

cp – Copy file

cp /usr/bin/file /tmp/location

mkdir – Create directory/folder

mkdir /home/chris/newfolder

rm – Delete files in folder

rm -rf /home/chris/foldertoremove

The -rf tells Linux to remove files in the folder. This will remove all files and sub folders though, so be careful. There is no undelete.

mv – Rename a file, or move a file

mv /home/chris/index.htm /home/chris/home.htm
mv /home/chris/index.htm /home/chris/site/index.htm

The first command will rename a file, and the second will move it (effectively renaming it into another directory)

pwd – see what folder you are in

pwd
/home/chris/Desktop

 

Ubuntu Console commands for SVN

Console commands in Ubuntu for use with subversion

Checkout a branch:

svn checkout url@revision path

To update your local source:

svn up

And to commit a single file:

svn ci -m "message for commit" <files>

Multiple committing is just without the <files>.

To download a revision

svn co -r 1671<remotefolder> <localfolder>
<remotefolder> could be any folder in the svn structure, i.e.
http://www.mydomain.com/svn/project/trunk/folder

Getting a list of revisions for a page (if you’re trying to find when you changed a page)

svn log -g <files>

Merging a branch into another

svn merge http://svn.branch.url localfolder .

That will merge the specified url into the localfolder. Ensure that your local changes in your working copy have been committed before you do this.