Homebrew – “the missing package manager for OS X”

I made a pretty neat discovery recently. There’s this package manager for Mac OS X called Homebrew that allows you to install Unix packages from the command line, using the brew command. It’s patched together from Ruby scripts and shell scripts and uses git as a backend. You can install it on Mac OS X using the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This is much better than using apt-get in Mac OS X (now no longer an option), where it would barf because I didn’t have the XCode command line tools, but it would provide no indication of how to get said tools. That script installs the XCode tools automatically if they’re not there. It’s also better than manually compiling code from source, which can be a major pain the ass, especially when you run into dependency issues (which is more often than not the case).

Homebrew is very similar to apt-get in its command structure. For example, here is how you install a package:

brew install lynx

There are several other Homebrew commands worth remembering. For example:

brew edit lynx

This opens the source code for the installer script for the package in the default text editor.

Also:

  • remove – uninstalls a package
  • list – lists installed packages
  • search – lists currently available packages
  • update – updates a package

All of these have the same command structure: brew <command> <package>.

I’ve installed several packages so far. I will list them here:

  • Lynx – the text-mode browser
  • Snownews – an RSS feed aggregator for the CLI
  • Bitchx – a text-based IRC client
  • NASM – an x86 assembler
  • wget – allows you to download files from the command line
  • CLISP – Command Lisp compiler, interpreter, and REPL

This is an exciting discovery. Now I can use all my favorite Linux software in Mac OS X!

A problem I’ve had with the X Window System in Slackware

Linux comes in many flavors. Some, like Ubuntu, are idiot-proof. They provide easy-to-use tools like the Synaptic Package Manager, GParted, etc. to accommodate those who are afraid of typing. Many Linux distros are set up so you can use them without ever having to touch the command line. Slackware is not one of these distros. And that’s why I like it.

Slackware is not graphical by default. It boots into the Bourne shell and gives you a prompt, with no indication of how to activate the GUI. You can of course activate the X Window System by using the startx command. I wanted to have some graphics on my system so that I could play with different desktop environments (I’ve seen some screenshots of Fluxbox and it looks amazing).

My Slackware installation has a problem, however. When I type startx, I get an error message saying that no screens were found and telling me to look at the log file /var/log/Xorg.0.log. Allow me to give you a visual of the log file in question:

Log_file_troubleshooting_Slackware

It looks like I’m missing a couple of drivers.  One is fbdev, a loadable kernel module, and the other is the module corresponding to the device file /dev/dri/card0.  As is usually the case, I have no idea what these drivers do, so I proceeded to do some research on Google.  I didn’t find much in the way of documentation, just a lot of Linux forum threads started by people who had the same problem I did.

I don’t know what to do now.  I mean, I have a vague notion of what to do, but I don’t know where I can find these drivers.  Since my Slackware installation can’t access the network, I will have to get a specific URL (which I’ve inquired about on linuxquestions.com), then download the packages through Mac OS X, wrap them in an ISO file which I will then import into the Slackware VM, then use pkgtool to install the packages from a local directory.

Exploring packages in pkgtool

I like to look through the package repositories in pkgtool, the Slackware package manager, to see what packages are installed in my Slackware installation. pkgtool provides a menu-driven interface for installing, updating, removing, and viewing packages. One of the (possibly unintended) effects of this is that it adds a level of discoverability to the Slackware command line.

pkgtool-1

pkgtool-2

I’ve found a lot of neat or useful commands by looking through packages on my system. I will list a few of them:

Midnight Commander (mc): An MDI for Unix-based systems, including a file manager, a document viewer, and a text editor.

Midnight_Commander

mc-view

bpe: The Binary Patch Editor, a hex editor for Linux.

bpe

sc: The Spreadsheet Calculator. Looks a lot like Visicalc, but it appears to have different commands. I just found it and have no idea how to use it yet. Will have to explore it some more.  For now I’ve just taken a screenshot of a blank spreadsheet, because I don’t know how to add data to it.

sc

So far this is all I’ve used pkgtool for, at least directly. I haven’t used it to install packages, because I’m not entirely sure yet how to do that. Apparently you have to get packages from somewhere else and then install them from a local directory. I’m not sure. More to learn about, I guess.

The Slackware installation process

Recently I installed Slackware Linux.  In this blog post, I will detail the installation process I went through as well as my first impressions of the OS.

Slackware is a Linux distro that is supposed to be hard to install, hard to configure, and hard to use.  This is the main reason I wanted to install it – for the challenge and for geek cred.  Every time I engage in a major project like this, I learn something from the experience.  That’s why I love it.  This is especially true of the Slackware installation process, because Slackware makes you choose all of your packages and settings, and it also makes you partition the hard drive from the command line.  Now I was doing this whole installation without reading the guide, so I’m not sure if I did everything right, but I got the crucial parts of the operating system installed (still a few kinks to work out with graphics and networking, but otherwise it works fine).

The first step in the Slackware installation process is of course to download the ISO file, which can be found here. If you’re installing it directly to your computer, you can then burn the ISO to a DVD or Flash drive using a utility like dd. Since I was installing Slackware to a virtual machine, I skipped this step.

The next step is to insert the install disk (or ISO file) into your computer (or virtual machine) and boot from the disk. Then this screen appears:

Slackware 1

At this point I just typed Enter twice to skip the maintenance and keyboard selection steps.

Slackware 2

Then enter “root” to log in as root.

Slackware 3

The next step is to partition the drive.  There are four options at this stage: you can use either an MBR or a GPT partition table, and you can use either a full-screen, menu-driven program or a command-driven program.  The four programs are fdisk, cfdisk, gdisk, and cgdisk.

Here are is a screenshot of fdisk when you start it:

fdisk 1

And the commands for fdisk:

fdisk 2

Here is a screenshot of cfdisk, with three partitions set up:

cfdisk

Originally I had an 8 GB hard drive with 6 GB for the filesystem and 2 GB for the swap space, but I soon realized this was not enough, so I created a 20 GB hard drive.

When you partition the drive using an MBR scheme, you will have to decide what partition type to use for each partition.  A partition type is an 8-bit field in the MBR that denotes how the partition is used.  Here is the list of partition types as shown by fdisk:

fdisk 4

As you can see, a standard Linux partition has a partition type of 83h and a Linux swap partition has a partition type of 82h.

An explanation of the swap partition is probably in order, for those who are unfamiliar with Linux.  Basically, an operating system will run out of space in RAM and will swap pages of memory out to the hard drive.  Linux gives you two options for how this is done – either a swap file in the Linux partition, or a separate partition devoted to swapping.  The latter is generally more efficient.

Now we get to the fun part – actually installing Slackware.  In the setup directory in /usr/lib/setup you will see several executables.

setup

The program you want to run is setup. Type setup at the command prompt. You will then see this screen:

VirtualBox_Slackware 15

Go down to “TARGET” and press the Enter key.  The Slackware installer will now format your target partition with a Linux filesystem of your choice:

VirtualBox_Slackware 17

VirtualBox_Slackware 19

As you can see, there are several filesystems to choose from.  I chose Ext4 just because I’m not familiar with the non-Ext filesystems.

After formatting, you will be prompted for what media you are installing Slackware from.  This part is pretty straightforward.

VirtualBox_Slackware 21

Then you will be prompted to choose which categories of packages to install.  Each category is explained pretty well, so I feel no need to explain them further:

VirtualBox_Slackware 22

Then you choose what installation mode to use:

VirtualBox_Slackware CLI_27_05_2016_10_44_21

I chose newbie mode the first time I installed it (I had to install it multiple times before I got it right), because I wanted to understand each of the packages that were being installed.  Newbie mode isn’t recommended, though, because it takes a really long time, especially if you’re installing the X environment.

Here is a sample screenshot of the kernel being installed:

newbie install 7

The Slackware installer doesn’t tell you this, but what it’s actually doing is running the pkgtool utility. This is a menu-based package manager that provides an easy installation process for Slackware packages. Part of the Slackware philosophy is that the operating system should be complete out-of-the-box. This means that the initial installation comes with a lot more software than, say, Debian. This makes Slackware preferable in my opinion, because searching the Internet for drivers and other packages is a pain in the ass.

The next step is to configure the system. The installer runs several config programs for you. You can run these programs again at any time if you want to change the configuration of your system.

mouse_config

window_manager_config

network_config

When I finished with the installation and rebooted, I found that the Linux partition was unbootable.  I went to a Linux forum and asked about this problem, and they suggested using the chroot command to change the mount point for /dev/sda1 to my root. That worked.

There are still some problems with this installation that I haven’t worked out. There’s no network access. The X Window System can’t find my screen when I try to start it up. And the top utility makes it so my commands don’t echo. I will have to figure out how to solve these problems in the future.