Posts Tagged ‘Linux’

Linux File System Summary

Saturday, January 19th, 2008

As you probably know in Ubuntu everything is under the root or /. All drives that you will ever use will start with /. That doesn’t mean that they’re not segregated from your OS and application stuff.

Let’s say you have 3 drives. You have one drive house the / paritition. Within that, you can have another drive house the /home partition, and yet another the /media/files partition. If your / drive somehow dies, you still have the /home and /media/files housing drives intact! You can simply reinstall the OS and get back to work. The point I’m trying to make is that while it seems that everything in Ubuntu is a single drive, is may only seem this way.

By default, unfortunately, everything like / and /home and /etc and /bin and al the other directories are on the same drive. In this case, you are putting everything on the equivalent of the C: drive in Windows. So the thing that you need to do if you happen to be a neat freak like me, is put /home on a separate partition (or preferably drive). This will allow you to keep using your /home after reinstalling and often even using other flavors of Linux. And best of all, you keep most of your program settings. This is the equivalent of being able to move Windows user folders located under documents and settings between computers (which you can’t). Most people I know who use more than a couple of hard drives simply mount all their hard drives under /media. Let’s say that you have /media/storage and /media/storage2. This is the equivalent of D: and E: in windows. If you lose the main OS install for some reason, you will still be left with both storage and storage2.

So in conclusion, in Linux you will always see the same basic structure, but beneath it you can have the order you love.
You can easily see which partition is mapped to which location in your file system by running a simple command. Open a Terminal window and type:

df -h (note: the -h modifier is used to present you with human readable size information)

Linux Partitions — They Make Sense!

Saturday, January 19th, 2008

90% of computer users use Windows. In Windows the command line is largely foregone in favour of GUI (graphical user interface) tools like ‘Computer Management’ and just right-clicking on everything and selecting ‘Properties.’ While Linux (a.k.a. GNU/Linux) has about as many GUI tools intended for administration, it is much more convenient and consistent to use a single tool–the command line interface (CLI).

Regardless of the Linux distribution (i.e. Ubuntu, Mint, Fedora, etc.) that you’re running, you have your CLI interface available with largely the same functionality, regardless of the flavour of Linux (and even BSD) you happen to be running.

Today I’m going to show my fellow Windows users how to look at their partition and drive information using the CLI. Using a few simple commands, you can instantly see your drive configuration, usage information, and much more useful stuff.

In Windows all hard drive/flash drive partitions get a drive letter, as do CD/DVD-Rom and Floppy drives. Usually the main system partition is called C:, the CD-DVD-Rom drive gets the D: letter, and the floppy drive gets the A: letter. A hard drive partition can consist of a whole drive or just a part of a drive. Usually, drives are not “sliced up” in several partitions. The C: drive can just be the C: drive, or is can be the C:, E:, F:, and G: drives.

In Linux the concept of drive letters does not exist. Instead, drives have names and numbers. PATA (wide cables) drive get the name of ‘hd,’ while SATA (narrow cables) drives get the name of ’sd’. After the name of the drive comes a letter which signifies the order in which the drive is looked at. For example, the first PATA drive is ‘hda’ and the first SATA drive is ’sda’. After the order of the drive comes the partition number. Again, the PATA drive’s two partitions will be known as ‘hda1′ and ‘hda2,’ similarly, the SATA drives get ’sda1′ and ’sda2.’

Let’s say that you have two SATA drives in your system, each with three partitions. You will have the following naming scheme:

First SATA drive: sda1, sda2
Second SATA drive: sdb1, sdb2

So, how do you find out what kind of hard drive configuation you have? It’s simple! Open up a Terminal window (if you don’t know how to do this, google “terminal [your distro]“)

less /boot/grub/device.map (note: this will show your your physical drives and their order)
sudo fdisk -l [or] su && fdisk -l (note: this will expand upon the previous command by showing you all parition information)

Next up, I’ll write about the linux file system. It too makes sense!

Clearing Out Your Bash History

Friday, January 18th, 2008

At this point most people have heard of GNU Linux is and why it’s either good or bad for them. A point that often comes up when GNU Linux is discussed is the fact that command line interface (CLI) knowledge is part of the skills required to operate a GNU Linux computer. This is a valid argument as graphical user interface (GUI) based applications on most GNU Linux distributions (i.e. Ubuntu, Fedora) are still not truly at the point where they can be considered replacements for direct CLI intervention. GUI applications are often simply front ends for CLI utilities and as such often do not truly capture all the power and extensibility of the latter.

The Bash Shell is often referred to as CLI. It is in fact only a single type of CLI, with its own command syntax rules. There are many other types of CLI implementations, but in GNU Linux the Bash Shell is usually the go-to CLI interface.

The Bash Shell is used to directly interface with all CLI based applications in GNU Linux. It also has its own commands which determine the way Bash Shell itself operates. These commands determine things like: how long of a history Bash Shell keeps, whether a user may use piped commands, keeping track of user assigned aliases for often used commands, etc. The Bash Shell can be the only place a user ever operates in as it provides all the necessary tools for day to day tasks like e-mail, internet access, word processing applications, and pretty much anything else you would normally see in on a Windows and/or GNU Linux user’s screen.

To open the Bash Shell and start playing with it, you will need to know where it is. It is usually located in a system tools or accessories menu branch and is referred to as the Terminal. This nomenclature is a callback to the olden days there an operator would sit at a CLI terminal and enter commands.

Sometimes during your day to day CLI activities you’re forced to write passwords directly into your CLI of choice due to poor programming practices, poor user practices (if you’re me), or simply because you don’t have time to be the James Bond of the CLI. In such cases you need to make sure that the password doesn’t stay logged on your system.

Everything you type (that’s not intentionally obfuscated by the application or OS) into your CLI is usually logged. I use bash for my CLI needs. In bash all commands written in the CLI are stored in a file located in

~/.bash_history

or

/home/(username)`_history

If you do a

tail ~/.bash_history

you will see all the commands (up to around 200 by default) that you’ve written into your terminal. This is usually very helpful because it lets you retrace your steps if something breaks, and allows you an easy way to recall long commands to the screen (by pressing the up arrow several times).

Sometimes you need to erase your bash history because it may contain important information. This is very easy to do. The first option is to run

history -c

This will nuke your whole history file. What if you want to only remove a specific entry in your history file? You’re in luck! the history command gives you a chance to do that

history | tail

This pipes the output of your perhaps long history into a readable format with the latest commands first. Now you have to find the number of the command you want to remove. Get it and remember it.

history -d (number)

That’s all! This should give you a reasonable assurance that your commands will not be visible to would be root pirates (a.k.a. hackers arrrrrrrg!), smart dogs, and curious siblings.

Switching to Linux 2

Friday, December 7th, 2007

My laptop is 100% “Linux-sized” now. Ubuntu 7.10 Gusty Gibbon it is. I’ve been using it for a couple of days now and I have to say that I really enjoy the compiz effects. My Intel graphics card was on the compiz black list, but the fix for that was easy.

I’m currently sitting on my tower computer, which happens to be my main computing location.  I have 2 USB hard drives attached to it, trying to extract all the valuable data off the NTFS volumes. There are thousands of duplicate files from years of reinstalling, a few months of running a Mac Mini, and them getting back to Windows. The situation is a mess.

I have one problem left which is making me think that I will need a Windows installation on the tower computer. The issue has to do with my iPod Video (5th gen 80 gig). I know that there are linux programs like GTKPod and Amarok which can utilize the iPod, and I may have gone with them in the past, but I know that they are not exactly perfect. I happen to enjoy my iTunes experience a lot and I don’t want to go back to hunting down podcasts and uploading them individually.

So here’s the plan: Dell Laptop = Linux; Tower = Linux and Windows XP. I promise that I will only use the Windows partition for syncing my iPod.

Switching to Linux

Wednesday, December 5th, 2007

Ever since 1995 I have been a user of Windows. It all started with my mother bringing a Windows 95 computer into the house. Long story short: I know Windows inside out. I wasn’t satisfied with this. I wanted more toys. There is only so deep you can go with Windows. The innards of the operating system are always hidden from you; you cannot change them in any sensible and easy way. What’s in the NT kernel? Can I read the source code? Legally? Nope, I cannot.

So in 2002, I went into a CompUSA store and purchased (or was it a gift?) a copy of RedHat 7.3. I tried installing it and it didn’t work! I tried again and it didn’t work again. I got frustrated and quit trying for four whole years.

In 2006, I discovered Ubuntu. I liked it, but I wanted to keep exploring. I tried everything I could get my hands on. Debian, Slackware, Knoppix, DSL, Gentoo, FreeBSD, OpenBSD, Mint, PCLinuxOS, and many, many others. I remember the days when I reinstalled Gentoo over 40 times in a row. Compiling that thing over 40 times and then emerging X11 + KDE was great.

The thing is, I never switched to Linux. I tried, but it never lasted. I have one Dell Vostro laptop and a huge tower (dual core opteron, 3 GB of Ram, 1 TB of storage) at home. Up to now, I have been dual booting the laptop between Windows XP and Ubuntu and the only thing I have on the tower is Windows. Why do I keep living like this? I know what I’m doing (well, I do reasonably well) when it comes to Linux and BSD. I guess old habits die hard. Between running a Windows environment at work and doing the same at home, I never wanted to get off my rhythm. Well, that’s over folks.

The reason why I’m writing this is because my case is by no means an anomaly. There are thousands upon thousands of folks out there who like Linux–who use Linux! Yet, they never got around to switching. Do it now! Learn! Grow!

In a future post (hopefully tomorrow), I will outline the reasons why I believe free, libre and/or open source software is superior to commercial software (in certain situations).

Note: Linux = GNU/Linux and vice versa. I won’t want to bother with this argument… yet.

IPCop vs Router vs Electicity

Friday, November 30th, 2007

I love IPCop. It’s great! And yet, I’m not using it because electricity bills tend to come around and show me the value of a dollar. It’s this sort of lose-lose situation where you can’t run a distro like IPCop on a proper tower machine and at the same time, you can’t buy a smaller machine because the truly small ones cost a fortune.

So I’m back to my trusty old [insert brand] router. I don’t love it, but I have to use it.

IPCop — Fun For The Casual Hacker (O’Reilly Definition)

Friday, October 12th, 2007

Would you like a corporate grade firewall and IDS for your SOHO network? Do you have an old spare PC sitting around? If you answered yes to both questions then you’re in luck because IPCop is there for you. IPCop is a Linux firewall distribution which is configured to allow even new users to configure and use it.

First make sure that you have an old but functional computer lying around. Anything will do as long as if has a 386+ CPU, 32MB+ RAM and 200MB+ (5GB+ if you want to run a proxy server) of storage space. Now the most important thing you have to keep in mind that will will be just like your “router” (the little NetGear/Linksys/Dlink box) you have at home. In fact those like boxes are in fact just tiny computers themselves. Well, what do they all have in common? They have multiple ports. Usually there is one port called something along the lines of Cable, or Internet. This is the connection which goes into your cable modem or DSL model. They also have 4-6 connections which you can use to connect your local computers to. Well, you will need at least 2 network cards if you want to use IPCop. One will be the “Internet” interface and the other will be your local interface.

Make sure that the computer you’ve built is running reliably and that both network cards are plugged in securely. You may also want to check the hardware compatibility list to make sure that your network cards will be recognized.

Next download the appropriate IPCop ISO image and burn it with software like Nero or the free CDBurnerXP Pro. Put the CD in the CD tray of your spare computer, boot it up and make sure you set the BIOS boot sequence to boot from CD. Once you’re in the main setup screen, follow the prompts and configure your GREEN (local) and RED (internet) interfaces with the appropriate IP addresses. Make sure that the local network has an IP address somewhere in the 192.168.x.x, 172.16.x.x, or 10.x.x.x ranges and set the internet interface to get all of its information via DHCP. Connect the cable coming from your modem box to the RED interface and the cable from your home computer to your GREEN interface. If you have more than one computer on your network, you can instead connect the green interface to a switch or a hub and plug in all your boxes in it. If you have a wireless access point or you want to have a DMZ network, I STRONGLY urge you to get separate network cards for them and configure them as the BLUE (wireless) and ORANGE (DMZ) networks and put them on different subnets.

When you’re done with the setup, go back into the BIOS and disable the CD-Rom from participating in the boot sequence. You can also remove the CD-Drive altogether because you won’t need it anymore. Boot up the newly installed firewall and watch it boot. Once you’re presented with a login screen, go to a computer which is on the GREEN (local) network and connect to https://ipofgreeninterface:445. Use the admin password you set during setup to configure all the options you want. By default, the original configuration will keep you very safe.

If you get stuck somewhere along the way, just e-mail me and we’ll solve the problem together.

Edit:

I forgot to mention that there are awesome guides for both installing and configuring IPCop at IPCop.com > Documentation

Remember to visit the donations page and see how you can help if you like IPCop.