Terminal, do you speak it?
"What OS you from?" "What?" "'What' aint no OS I ever heard of! They speak Terminal in 'what'?" "What?" "Terminal, motherfucker, do you speak it?"
Well maybe you don't, what happens then? Good question, let's ask the almighty Wiki. Maybe it can answer what a Terminal is? Almighty Wiki, what say ye about Terminal! Deep aussie accent:
A Termi... what now? Ohh, a Terminal! Well a terminal emulator provides an environment for Unix shells, which allows the user to interact with the operating system of any Unix-like computer in a text-based manner through the command line interface to the operating system!
Ok, thanks! You heard the thing. Now back to the point in hand. Along my years as a developer, I have never ever met a more useful tool than the above mentioned Terminal. You can do almost anything with a Terminal. We're referring here to the web related stuff, because can do other stuff also, stuff like playing games, seeing a doctor, watching a movie (hint: telnet) or letting the Terminal talk back to you (If you're into that sort of thing, weirdo!). You can write code and save it, connect remotely to a database and modify it to your hearts desire or you can go as far as never leave the Terminal and build an entire website using it.
Disclaimer: This is not a crash course in Terminal, if you need one of those you can search Wiki's long-lost cousin Google.
But there is more to this than just fun and games. From my own experience with a Terminal, whether it's a Linux one, a Mac OS one, or even a cloud based one, like the one Koding has, I have found a few commands that every web developer should use or could use to make his/hers life easier. Maybe the most useful command I found is the following one:
grep -r "word" *
Using this command you can search for a word in any file located in the current folder and it's children. So if you're in the root folder, this command will search every nook and cranny for that word, until it finds it. If, for example you're to lazy or you don't have enough time (Because you're to lazy!) to move files around and you have a big project with lots of files, then the following command is here to help. This will move all files from sub-folders to their correspondent parent folder.
mv *.* ..
Ok, these were commands useful on a day-to-day basis, but what if you have your own server and root access to it (hint: Koding offers those for free!). What can you do then? Well there's a simple answer to that question. Let's start from the premise that you have an Apache server. A good, useful command would be the following, for when things get a little out of hand:
sudo service apache2 restart
Because any respectable command starts with a sudo, so does this one. Basically this is the equivalent to the restart button on your old Windows machine, that your grandma' still uses. But what caused the error, that needed you to force choke your machine? This command may come in handy:
sudo tail -n 50 /var/log/apache2/error.log
It displays, in an orderly fashion, what happened to your precious. Having seen what you did wrong to your precious server, you're now heading to the root of all things evil. Your ex's heart? Haha, nice try, but we all know she doesn't have a heart. No, I meant the Apache config file (the source of all that is evil in the world), the one that you can edit using this:
sudo nano /etc/apache2/sites-enabled/default
Pretty straight forward, if I do say so myself. If that didn't do the trick then you can always check with the Sisters of Fate over at:
sudo tail -n 50 /var/log/syslog
and see what went wrong there. And finally to check if your precious is still alive you can use the pulse checking utility:
ping -n 5 www.example.com
I guess that ends our list of useful commands that you could use in a Terminal. But why is a Terminal useful? Well, my opinion is that maybe it gives us more control over the stuff we do. It lets us access the core of our system. It's kind of a gateway to our computer/server's mind, in more laymen terms.
Now don't expect to learn Terminal in a day, but if you do start learning about what it can do and what are the benefits of using one, then remember one thing: With great power comes ... aaa ... penguins? Yeah, penguins are the answer to everything, even a terminal.
I guess that's it. If you have suggestions or you thing I missed something let me know in the comments below and I'll add them to the list.
Until next time, code long and prosper!
Stefan