One of the best things I have ever learned and continue to learn the terminal. Many developers do not yet use or know the power of the terminal (sometimes referred to as a Console).

I would suggest using a UNIX based terminal that comes with Linux and OSX by default. Windows uses Powershell and CMD (Command Prompt) as it's the default. You're far better off using Git-SCM for UNIX commands to start learning on Windows.

First, what is behind this black box? Here is some terminology for the curious.

  • POSIX: "Portable Operating System Interface is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating system." - Wikipedia
  • TTY: Teletypewriter.
  • SH: Shell
  • Bash: Bash Shell

What are Shells?

Shebang

If you ever see a file (script) ending with filename.sh then it is a shell script. These need permissions of +x or executable to run. That's done with the command: chmod +x filename.sh.

To run a shell script simply type ./filename.sh. There are also .run scripts and various others that follow the same procedure.

The first line at the top of the file is a line called shebang that looks like any of the following (or more) depending on the shell that is to run the script:

#!/bin/sh
#!/bin/bash

You may even have Python (among many other languages) shell scripts that would have the python extension, yet they are made to run in a terminal. You would run these the same way as a shell script.

#!/usr/bin/python
#!/usr/bin/python3

Why Does Scripting Matter?

Without knowing it, many of your programs run commands from a shell in the background to access lower level areas and/or automate tasks. They are also used to save time as a GUI is never necessary to get things done, that's only for the end-user.

Using a script to install common software, launch development tools, compile and debug are essential for any developer. This not only saves time but is often a requirement in many languages.

Quick Tip
When reading code samples for bash files you'll often see use of a $ dollar symbol. You do not actually type $ command . That just means they are providing an example and this is only what you type.

Basic Commands

The terminal can be quite odd and foreign at first but it will pay it's way tenfold in time. Here are some basic commands to get started.

Quick Tip
Any command with a single or double value represent flags: -x or --value . Single letter flags only use one dash (Often shorthand), multi letter arguments use two dashes.
Command Description
ls list directory
ls -a list directory and hidden files
cd .. move a directory up
cd dirname move to a specific directory
cd - move to the previous directory
mv file.txt newfile.txt rename a file to newfile.txt
cp file.txt newfile.txt copy a file to newfile.txt
file filename.txt get metadata on any file
ctrl+d often exits a program (Such as Python Shell)
ctrl+c cancels an operation

Those are some extremely basic navigation commands. You can learn a lot of the sub-commands by typing man prior to a command. This is short for manual. Type man ls to see all the flags you can use. To exit the manual type :x.

Image Examples

You can mass handle images with a shell script. This example is how to manually get an image size using file and resizing it with convert:

$ file filename.jpg	

The file command would return something like this with dimensions we want:

file.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 2000x1500, components 3

We can use convert with one of its many flags (man convert) like this:

$ convert file.jpg file-resize.jpg --resize 1000 750