Archive for the ‘All’ Category

by @ 20:25   All | Code | Linux / Unix   Permalink

HOW TO: Random password generator on Ubuntu and other Linux systems

Sunday, February 7th, 2010

Recently I had need to generate random passwords. I did not want to make a script for it and I certainly did not want any applications to do the tasks. Here is the command line argument for such a task:


</dev/urandom tr -dc A-Za-z0-9_ | head -c8


Note that the ‘tr’ strips out everything except characters in the ranges (alphanumeric, mixed case and underscores). This is a nice approach as piping to head means the minimum number of bytes required to generate a password of appropriate length are taken from /dev/urandom vs other methods which take more than you should need but still have a chance of not having obtained enough random data to generate a password of the required length. You can change the parameter to head to get passwords of any length.

NOTE: I have only run this command on Ubuntu, its possible it works on other Linux systems but I have not checked.

 Page 1 of 2  1  2 »

HOW TO: Perform system backup in Ubuntu – Part 2 – Restore

Sunday, February 7th, 2010

The restore will need to be perfomred as root

tar xvpzf filename.tgz -C /

the mkdir options are mandatory, and you will notice that they are the directories that are excluded from the backup. this is fine, but the folders do need to be replaced BEFORE YOU DO ANYTHING AFTER THE RESTORE

mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
mkdir media
mkdir cdrom
mkdir home

now reboot

everything should now be cushdy

 Page 1 of 2  1  2 »

HOW TO: Perform system backup in Ubuntu – Part 1 – Backup

Sunday, February 7th, 2010

I had a few issues with my Ubuntu system after installing KDE4. I don’t think KDE4 caused the issue, but a combination of the software I use and the things I do was causing me login issues and X session headaches. I would have programs close immediately after opening, which I could only solve with a reboot. Files were locked, preventing me from running applications like the Terminal and a few other apps. System updates would fail for an unknown reason.

I had to rebuild the system. I saved off all my personal data and reinstalled everything.

Once I was back at my desktop, after configuring my dual screen setup on an Nvidia card and getting my email and browser back the way I like them I decided it was time to make some changes.

The /home folder needed to be moved from the OS drive, (that’s the next post) and I needed a way to back everything up, and I mean everything. Because of the way Linux structures its OS it is geniusly easy to backup the system. You cannot do this on windows without expensive software to ghost the drive.

What we are going to do here is use TAR to compress and zip up the entire root structure, with a few exclusions.

NOTE
I run the command as sudo from my own account. I am pretty sure it would be benneficial to quit all X sessions and drop to the command prompt rather than run from a live session. I have no evidence to suggest that doing this from the desktop will cause any problems. If you have a suggestion on this please comment below.

I will show you how I backed up my root directory and then I will supply a generic command that will suffice for most people. My command is slightly different as I moved my /home folder onto a seperate hard drive. I will cover my reasoning for this in my next post.

This is the command I use to backup my OS

sudo tar cvpzf /media/500/000_Backups/System/system_backup-$(date +%d-%m-%Y).tgz –exclude=/proc –exclude=lost+found –exclude=/mnt –exclude=/media –exclude=/cdrom –exclude=/home –exclude=/old_home /

As you can see I have excluded the /home directory in my backups as it is on a seperate partition. Now, lets break this down into its component parts so you can better understand how this works.

“tar” is obvious. this is the application we will be using to create the archived backup. Make sure you have tar installed. It should be by default but just incase you will need to run this command in the Terminal

sudo apt-get install tar

or, click <a href=”apt:tar”>here</a>

the tar parameters “cvpzf” are as follows.
c – this tells tar that we are creating an archive
v – verbose mode, this command outputs each file being archived into the terminal window
p – retain all file permissions as is
z – compress as gzip – use j for bzip2 but make sure you change the file extension to tar.bz2
f – filename follows this parameter.

system_backup-$(date +%d-%m-%Y).tgz – this is the filename followed by the date of the day the backup is made, in the format dd/mm/yyyy

I chose to date it as I will have incremental backups running via cron. This is a little out of the scope of this post, but happy to help those if you post a comment and ask.

–exclude=/ – we are going to exclude some folders that are not required in the backup. proc, lost+found and cdrom are not required in the backup, and if you do not want to backup any drives, dvds or cdroms that are mounted inside mnt or media, make sure you exclude those as well or the backup could become extremely large.

/ – this is the folder we are backing up. and as we are backing up the whole system we need to backup from the root directory which is /

Now we have our backup command explained you are ready to get down to running your own. Obvioulsy please dont use the one above as it is for my machine, below is the generic code that should suffice 99% of people.

NOTE
please change the “pathtofolder” to a location you would like to save the file once it is completed.
this will take a while once you execute the command, so don’t be tempted to cancel the operation.

sudo tar cvpzf /pathtofolder/system_backup-$(date +%d-%m-%Y).tgz –exclude=/proc –exclude=lost+found –exclude=/mnt –exclude=/media –exclude=/cdrom /

Now that you have your backup, you are going to need to restore it someday. Below are simple instructions on how to extract and restore your data

sudo tar xvpzf system_backup-dd-mm-yyy.tgz -C /

the mkdir options below are mandatory, and you will notice that they are the directories that are excluded from the backup. this is fine, but the folders do need to be replaced BEFORE YOU DO ANYTHING AFTER THE RESTORE

mkdir proc
mkdir lost+found
mkdir mnt
mkdir media
mkdir cdrom

Now reboot your PC and your data will be restored. This includes all applications, mail and broswer settings, everything, except the folders you did not backup.

 Page 1 of 2  1  2 »

Sharepoint Services not configured for use with ASP.NET 2.xxxxx

Thursday, November 26th, 2009

As I use my sharepoint system very rarely I had not noticed that there was an error when trying to access http://companyweb. I have an SBS 2003 server that deals with all my mail etc and recent updates seem to have killed off the sharepoint service.

This is the full error that I get

This Windows SharePoint Services virtual server has not been configured for use with ASP.NET 2.0.50727.3603. For more information, please refer to Knowledge Base article 894903 at http://go.microsoft.com/fwlink/?LinkId=42660.

The article the link refers to is a good starting point, but it fails to actually tell you where the stsadm file is, and running the command as microsoft have put it will just result in a file not found error. I had to go hunting for the file myself, and as the search function failed it was a manual hunt.

I finally found the file, so here is the command that actually works

“c:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN\stsadm” -o upgrade -forceupgrade -url http://companyweb

That command obviously depends on the virtual sharepoint site actually being called companyweb. If you have changed it you will need to amend the end of the command.

Once it finished running I was asked to login to the sharepoint service on the server itself. After trying multiple combinations of usernames/domains and passwords it failed. I jumped onto my desktop and logged into sharepoint without issue and all is now working again. My guess (as I have not fully investigated it and won’t be on my home system as it’s not really needed) is that the DNS is either out or logging into sharepoint on the server itself is just not cricket.

 Page 1 of 2  1  2 »

Iphone posting

Sunday, August 16th, 2009

Test post from my iPhone. Pic is my mates dog jasper. He’s a good lad but not the sharpest tool in the box bless him ;)

 Page 1 of 2  1  2 »

Contact