One the reasons that I've gone with vps.net for my web hosting and blogging is because some of their virtual machine install options are full virtual machines with ssh access. That means that I can log into the "machine" remotely via a text terminal, move files, change software configurations, and even write software I want to. I'm a slightly old-school computer person; I prefer to use keyboard commands to a mouse if at all possible, and the command-line suits me very well. This is the first in what I hope is a series of blog posts on what command-line style system configuration is, some of the basics of doing it, how and why you'd want to, and some of the neat tricks that are available to you when you have a direct connection to the machine.
There are a lot of factors that make command-line different than graphical-type controls; I'll talk about some of those factors in future posts. One of the advantages of a command-line interface is it gives you direct access to configuration files in the machine's file system. Some configuration is store in databases, but a whole lot of operating systems and software read configuration from text files on disk when they start up. A command-line interface gives you the ability to read and modify the location and contents of those files directly. This is a very powerful tool when something goes wrong and the graphical tools can't fix it.
I ran into an example of this type of utility while preparing this post. I needed to add a configuration option to the Apache web server on my vps.net virtual machine. Apache has been around a long time; it's very much an old-school text-file configuration piece of software. I wanted to enable a user (me) to display a page from their own directory, rather than putting in the main web directory. To do this, I had to turn on the "user directory" option.
Here's sort of what it looks like. The lines that look like this: "craig@openclasses 09:11 ~ $" is what's called a "prompt". This is a string of text that says the computer is ready for my next command. What comes after that on the same line is what I typed. Then between that line and the next line is what the computer sent back to me in response.
Here's me logged into my server. The "cd" command is me going from my home directory to the configuration directory that Apache uses. Then I use the "ls" command to check for the "user directory" module. The list of files in that directory doesn't have anything that says "userdir". I then do a listing of a different directory, which does contain two userdir files (highlighted in red).
The fact that the userdir files are in the "available" directory means I've installed the userdir option into Apache, but I haven't told Apache to enable it.
So to do that, I make a symbolic link from the "available" directory to the "enabled" directory. This is like a "shortcut" in windows. It makes a file appear to also be somewhere else. "ln" is the command to create a link. I forgot I need administrator privileges to do that, so it tells me "permission denied". "sudo" is a command that gives you administrator rights for a single command, in this case "ln" to create a link. Then I ls the directory again, and this time the userdir files are there. Success!
So that was a real-life example of logging into a server quick to change the configuration of a piece of software via the command-line interface. There will be more to come here, stay tuned!
Craig Steffen cut his command-line teeth on MS-DOS 2.11; his first Unix-like OS was NeXT-Step on NeXT computers. He used Solaris, Irix, and increasingly Linux in graduate school, and runs mostly Linux nowadays. He lives in Appalachia but oddly works for a mid-west University. In his spare time he mucks around with his vintage VW and occasionally flies small airplanes. You can see more thoughts of his at his blog and on twitter.