I recently migrated all of my sites to a new web host, which meant downloading all my files and databases from my old web host and uploading them to my new host. It’s not exactly that simple, because my new host does some things radically different than my old host, but it’s close to that simple.

A great deal of what makes that process simple is using the command line. With the command line, you can do things almost instantaneously. Of course, you can also monumentally screw things up almost instantaneously using the command line, so it pays to know where the potential problem areas are.

I’m going to write a series of tutorials on migrating servers, but because most of the steps involved use the command line, I’m first going to write a series of tutorials that will tell you most of what you need to know to make all of this happen.

Platform

My new webhost is running Ubuntu 16.04. My old host was running either Ubuntu 14.04 or Ubuntu 16.04. (Their reluctance to update software was a factor in my decision to leave.) I’m also running Ubuntu 16.04 on my local machine.

All of the screencaps on this series of posts are taken on that local machine running Ubuntu 16.04. If I get the time, I might power up my old Mac Mini (running OSX 10.4) or my Windows 7 machine to grab some screen caps there. No promises, though.

Obviously, if you are running a different flavor of Ubuntu or Linux, things may not work exactly as I’ve described here. The Google, as always, is your friend, but feel free to ask questions in the comments. (I may also add a section about this to my forum if there is interest. Let me know.)

Accessing the Command Line

On Ubuntu, you can press Ctrl + Shift + t to immediately open a Terminal window.

On OSX, go to your “Utilities” folder and double-click the Terminal app.

On Windows, you’ll need to install PuTTY. You can download it and read its documentation from its official stie. (Since PuTTY is well documented, as well as being easy to use, I won’t provide instructions for getting it running here. As always, feel free to ask questions in the comments.)

A Note on Terminology

Ubuntu (the client version, that is), Mac OSX, and Windows are all GUIs — graphical user interfaces. That is, we interact with files, apps, and directories by interacting with icons that represent those items. By contrast, the command line is just a black box that quickly fills with text.

For reasons I don’t understand, the terminology in these two environments is a bit different.

On a GUI, we talk about locations. “It’s on the Desktop.” “It’s in my Documents folder.” “It’s in the Trash.”

On the command line, we talk about paths. “It’s in /user/home/public_html/wordpress/”.

Similarly, on a GUI, we talk abou folders, but on the command line, we talk about directories. The two are essentially one and the same, and we can nest directories inside other directories the same way we can add a folder to another folder by simply dragging the first one’s icon onto the top of the second one.

I will try to be as nomenclaturally correct as possible, just to avoid confusion, but keep in mind that there are no nomenclature police (other than self-appointed ones) to monitor to this. So if you refer to your public_html folder, when you’re really talking about your public_html directory on your webserver, people will know what mean. (And only the most pedantic will call you out on it.)

I’m only pointing out these differences so that if you are only familiar with GUI way of talking about things, you’ll know what people are talking about when the use the command line way of talking about things.

A Word of Warning

GUIs are very forgiving. When you drag a folder  to the Trash, your GUI will very politely ask if you are sure you want to do that. When you empty the Trash, it will again ask if you are sure. When you attempt to save a file to a folder which contains a file with the same name, it will ask you if you want to overwrite the file that was already there.

Given that, it’s amazing that people make mistakes with them, but they still do. And in a lot of cases, there’s a great big “Undo” button that you can hit (often multiple times) to return things to the way they were.

Not so with the command line. If you tell it to delete a file or group of files, it doesn’t ask you if you’re sure or puts them in a trash can or a recycling bin that you can later pull them out of. They’re just gone. I think it is this aspect of the command line that most frightens people. But it need not be so. It just requires a slight shift in thinking.

Working with a GUI encourages this kind of thinking:

The GUI way of thinking

Working with the command line requires this kind of thinking:

The CLI way of thinking

Viewed this way, the command line is much more like real life — decisions have consequences and can’t be undone, so think carefully about whether you want to do them before you do them.

The purpose of a GUI is to insulate us from the consequences of our decisions. Not a bad way to do things on a computer, but it is not how real life—or the command line—works.

Not to fear, though. Like I said, I will show you where some of the biggest problem areas are, as well as some ways to help avoid them.

Conclusion

Although the command line may seem intimidating to people who have never used it (which includes most people who have never used MS-DOS, or in my case, TRS-DOS), it’s actually quite easy, and amazingly fast. Follow along, try things out on your local machine, and soon you’ll be comfortable enough with the command line to execute a lot of common tasks in a lot less time.

© 2017 Kenneth John OdlePermalink for this article:
http://techblog.kjodle.net/2016/10/22/introduction-to-the-command-line/