Command-line Basics

Jul
19

A blinking bar in a pitch-black background.

Console, terminal, shell, command-prompt: It comes in many names and flavors.

Many are not aware that the command-line interface plays an important role. Whether as a tool that revolutionized the computing industry, or a tv-inspired device turned into an iPhone app – this too won’t be replaced any time soon.

And if you’re a programmer or web-developer, knowing a thing or two about basic shell commands doesn’t hurt at all. In fact, you might even find it addicting. Not only does it boost productivity (faster processing), you can do cool things that GUIs cannot.

Access apps via SSH

Every WebEnabled environment comes with its own SSH (Secure shell) access (username & password). Windows users actually find it very easy to set-up. Linux and Mac machines come with a terminal program.

Common command-line tasks

Find Files

When building web-apps it’s impossible to keep track of all the files & folders, especially when you have downloaded tons of modules, components, or themes.

du list all files & sub-folders of a directory
ls list files / folders of the current directory
grep search & filter results of another command
Manage Files

It’s also possible to manipulate your apps files in order to structure them to the way you need.

rm remove (delete) files / folders
cp copy files / folders
mv rename or move files / folders
chmod change permission settings
nano a simple keyboard-oriented text editor
vi the most popular, modal text editor
Acquire Files from another server

When getting files from a remote server, you don’t have to download files to your local machine and upload them again. Save bandwidth by using these tools.

scp securely copy a remote file
wget download or copy a file referenced by a hyperlink
rsync synchronize files & directories from one location to another
Learning new commands

Use these if you wish to know more about a specific command.

man
info provides a hypertextual documentation page of a command
provides extensive documentation pre-installed with a command
Learning resources

If you want to get serious with shell commands, take a look at these resources:

Lullabot.com Moving around using the command-line
Lullabot.com SSH and SCP
Lullabot.com Basic Keyboard Shortcuts plus a cheat-sheet.
Youtube.com command-line videos
Joshua Schroeder (Slideshare) Command-line Drupal