How To: Extract .tgz files with Tar

How To: Extract .tgz files with Tar

.tgz files have been used in Unix for years. Originally created to handle backups to tape, it’s now commonly used to archive groups of files together such as installers for software. This is where most people run across the confusing .tgz, tar.gz, or tar.bz2 file extensions.

These instructions should be universal for most Unix systems, Linux, BSD, OS X, and even Solaris. Please feel free to leave a comment if they’re not.

To get to tar’s help files, simply type: man tar

The output will look something like this:

TAR(1) tar TAR(1)

NAME
tar – The GNU version of the tar archiving utility

SYNOPSIS
tar [options]

Operations:
[-]A –catenate –concatenate
[-]c –create
[-]d –diff –compare
[-]r –append
[-]t –list
[-]u –update
[-]x –extract –get
–delete

Common Options:
-C, –directory DIR
-f, –file F
-j, –bzip2
-p, –preserve-permissions
-v, –verbose
-z, –gzip

So for extracting tar files, we will use the x and f options. Thus:

tar xf filename.tar

Will work fine. Note that the same command should usually work for any file that has the tgz, tar.gz, or tar.bz2 extensions too. The tar command should automatically detect the file type and call gzip or b2zip. If it doesn’t there are two more commands.

For .tgz or tar.gz files, add a z to the command: tar xzf filename.tgz

For .bz2 files, add a j : tar xjf filename.tar.bz2

At this point the file should unzip and untar into the same directory as the archive file. Sometimes an auto installer will come up, but that is still pretty rare.

How To: Edit MAC Address on Linux

How To: Edit MAC Address on Linux

Your network card in your linux box just got replaced. Or the onboard one on the mother board went bad and now you need to get it up. But Linux is not automatically recognizing the new card correctly.

Get to a terminal prompt. Type ifconfig to get the current mac address. Keep in mind that you may need to watch the boot up process to find out what your network card’s device name really is. It’s usually eth0, but em0 or even en0 are common. Also it may not be the first or ‘0’ device, so eth1 is entirely valid. Out put will look something like this:

eth0: flags=8863 mtu 1500
inet6 fe80::21f:5bff:fee8:b40d%en0 prefixlen 64 scopeid 0x4
inet 127.1.1.1 netmask 0xfffffc00 broadcast 127.1.1.255
ether 00:1f:5b:72:b4:aa
media: autoselect (1000baseT ) status: active
supported media: autoselect 10baseT/UTP 10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT none

The MAC address is the 6 hexadecimal numbers on the line that says “ether” so 00:1f:5b:72:b4:aa is the MAC address. This number is also written on a sticker on almost every device with a network device these days. It’s even included on the outside box of many new computers as it’s a very distinctive number.

Next is to edit the file this info is kept in. Go to:

/etc/sysconfig/network-scripts/ifcfg-

Edit (or totally remove if you’re using DHCP boot) the MAC address line. Save the file and reboot!

How To: Budget Network Attached Raid 5 Fileserver, Part 2

How To: Budget Network Attached Raid 5 Fileserver, Part 2

In Part One I talked about selecting the hardware and my thoughts behind the choices I made. It’s all been put together and the next step is to install an OS. For various reasons I decided to install FreeNAS which is based off of FreeBSD. It can be grabbed from here.

After a few minutes of looking at FreeNAS I was really quite impressed with it. They’ve taken a quite hard and convoluted process, added menus and made quite easy to setup. Like FreeBSD in general it can feel picky about hardware. If you’re using some off the shelf no-name SATA RAID controller, the odds are it’s not going be supported. But a lot of the more popular and better quality models are supported. The FreeNAS website (and also the FreeBSD website,) are both a tiny bit hard to find information and support when first using it. Counter intuitively you need to click on the Wiki link first, then knowledge base, not the Support link to find Installation and Configuration documentation. Luckily the menus within FreeNAS are fairly self explanatory.

The first step is of course to download the image. In my case I grabbed the live CD so that I could simple have the machine boot off of it and was good to go. Another option is to use a USB thumb drive to boot off of. I’m personally disinclined to use one as they stick out and get broken easily.A UNIX installer screen will come up and start probing and self configuring hardware in the machine. A FreeNAS graphic screen may come up, and eventually it’ll beep when ready. Hit the escape key and choose option 2 to get an IP address via DHCP. Make sure to hit “Yes” when it wants to choose a IPv6 address. That step messed me up the first time I saw it, but it’ll simply fail as most likely there is not an IPv6 server around. Most home routers have a DHCP server built in, but there may be some configuration needed so check the router’s documentation.

Once the IP address has been discovered, type the address it gives you into a web browser to open up the FreeNAS configuration page. The default user name and password is admin:freenas, it’s highly suggest you change the password ASAP. Once everything is fully configured we’ll go ahead and change this. At this point the instructions proved useful.

Step One is to add the physical disks. Under Disks Click on Management, then the + sign. This brings up the disk management screen:

As can be seen the available disks are at the top. In this case ad0 is the 40gb IDE drive I’m going to eventually use as a boot disk. Per the instructions change the “Preformatted file system” option to “Software raid” (the other options in that article may not be available). In this case I have four SATA drives so each needs to be added individually. Hit the apply button and each drive is added.

The next step is to create the raid partition. Go to Disks, Software RAID, then choose RAID5. Choose a RAID name it doesn’t matter what. For simplicity I used “server” put a check next to all the disks that are going to be part of the RAID then another on the “Format and Initialize” box. Hit OK, then once again “Apply”. Now sit back and wait. On this screen very little is going on. But on the RAID server itself messages will start popping up. Even better, they’re helpful!GEOM_RAD5: server: all(-1): re-sync in progress: 0.01% p:x ETA:232min (cause: store verify progess). After 232 minutes of waiting we then got this screen:

As can be seen my four 250gb SATA drives have been built into a 715gb RAID5 Partition. It now needs to be formatted which is done in Disk, Format. Choose the RAID array, give it a name again, no hurt in using the same name again. We’ll format it out to UFS+ with GPT and Softupdates as the as the filesystem. The other options may work, but are not recommended by the FreeNAS team. Hit the format button and thirty seconds later the drive is ready to mount.

The mounting screen is sort of confusing at this point. After all we’ve already created and formatted the RAID drive so it should be ready. But this physically mounts it so that it can actually be accessed.

Under Disks, click on Mount Point. Pick the disk. Then choose “EFI GPT” under the partition menu. This menu was a bit confusing for me at first, and once again FreeNAS’s documentation left this step out. Reading it at first it seems option 1 was wanted as we’d setup UFS before. The filesystem stays UFS though, and the name can be what ever. I choose the simple “raid” moniker for simplicity. The last option could be a real life saver if the power ever goes out. “Enable foreground/background file system consistency check during boot process,” would run fsck and other filesystem utilities when the machine was powered back on. It might take longer to get the RAID back up, but could save problems in the long run.At this point we’re ready to start mounting the RAID and writing data to it. I’ll talk about doing that in the next article in this series, including troubleshooting and setting up Time Machine to back up to the RAID automatically.

Part Three

How to: Run Gimp from Linux Machine and display on Mac OSX

How to: Run Gimp from Linux Machine and display on Mac OSX

Unix machines are known for their great versatility in configuration, and their “power”. Traditionally Unix machines were “headless” or without a monitor or other display device except for Terminals. These days another whole computer can replace the terminal. But Unix machines as the whole tend to be pretty beefy machines when it comes to CPU and RAM. Instead of just using it as a glorified File Server, with a few simple commands they can used to run pretty complex pieces of software such as the Gimp.

On the OS X side make sure you’ve got X11 installed. Follow the XCode Install Directionshere.

Once that is done, launch an X11 window and type ‘xhost +’ or optionally ‘xhost +machinename’ or ‘xhost +username’ xhost allows other computers to use your X11 program as the display instead of their own display. The + means everybody which might be bad for security, but good if you’re going to be using a lot of different machines. Looking at the man page it can be limited to just machine name or even specific users names.

Login to the remote machine using ssh or telnet.

type ‘setenv DISAPLY :0.0’ in a tsch or csh shell. Bash will not work. This tells the remote machine to redirect it’s display to your machine.

Launch software! In this case just type gimp, but you may have to type in the full path to the software.