This subchapter looks at cool shell tricks for UNIX, Linux, and Mac OS X to give you an idea of the power of the shell.
A quick summary of how to get to the shell is included in this chapter (more detailed explanations, including what to do when things go wrong, are in following chapters.
UNIX is one of the ground-breaking operating systems from the early days of computing. Mac OS X is built on top of UNIX. Linux is a variation of UNIX.
The shell is the command line interface for running UNIX (and Mac OS X and Linux) with just typing (no mouse).
This subchapter looks at cool shell tricks for UNIX, Linux, and Mac OS X to give you an idea of the power of the shell.
A quick summary of how to get to the shell is included in this subchapter (more detailed explanations, including what to do when things go wrong, are in following subchapters.
cool shell tricks
This chapter has a handful of cool shell tricks. These are intended to show a beginner that a command line shell can be as fun as any graphic user interface and get across the idea that there is a lot of power in the shell that simply doesnt exist in a standard graphic user interface.
definitions
UNIX is one of the ground-breaking operating systems from the early days of computing. Mac OS X is built on top of UNIX. Linux is a variation of UNIX.
The shell is the command line interface for running UNIX (and Mac OS X and Linux) with just typing (no mouse).
operating system The software that provides a computers basic tasks, such as scheduling tasks, recognizing input from a keyboard, sending output to a display screen or printer, keeping track of files and folders (directories), running applications (programs), and controlling peripherals.
UNIX UNIX (or Unix) is an interactive multi-user multitasking timesharing operating system found on many types of computers. It was invented in 1969 at AT&Ts Bell Labs by a team led by Ken Thompson and Dennis Ritchie. Some versions of UNIX include: AIX, A/UX, BSD, Debian, FreeBSD, GNU, HP-UX, IRIX, Linux, Mac OS X, MINIX, Mint, NetBSD, NEXTSTEP, OpenBSD, OPENSTEP, OSF, POSIX, Red Hat Enterprise, SCO, Solaris, SunOS, System V, Ubuntu, Ultrix, Version 7, and Xenix.
Linux An open-source version of the UNIX operating system.
graphical user interface A graphical user interface (GUI) is a windowing system, with windws, icons, and menus, operated by a mouse, trackball, touch screen, or other pointing device, used for controlling an operating system and application programs (apps). The Macintosh, Windows, Gnome, and KDE are famous examples of graphical user interfaces.
command line interface A command line interface (CLI orcommand line user interface CLUI) is a text only interface, operated by a keyboard, used for controlling an operating system and programs.
shell The shell is the command line interface for UNIX, Linux, and Mac OS X. In addition to intrepetting commands, it is also a programming language.
shell uses
The UNIX shell is a very powerful programming language, with access to hundreds of useful tools that are designed to work with each other, and access to the very heart of the operating system (although this is only available to the root or superuser account for security reasons).
UNIX (and therefore also Mac OS X and Linux) has more than 200 basic commands (also called tools or utilities) that are distributed with the standard operating system. This collection and the ease with which they work together is the major source of the power of UNIX. The vast majority of these standard tools are designed to be used from a command line (the shell).
The shell is most commonly used to control servers. Servers are the computers used to host websites. The most common operating system for the worlds web servers is Linux. If you learn shell scripting and system administration, you can run your own server and possibly get a job.
The shell can be used to control a desktop or portable computer. Some tablets and smart phones have a shell. The iPhone actually has a shell, but it cant be accessed witout jailbreaking the iPhone.
The shell will often run even when a computer is partly broken. Both Mac OS X and Linux (as well as almost all versions of UNIX) can be run in a special single user mode. This starts up the computer or server with just the command line shell running. This can be used to service a computer or server, including both diagnosis and repair.
The shell is extremely useful for programming. Even when a programmer uses a graphical integrated development environment (IDE), the programmer is likely to still heavily use the shell for programming support. Some IDEs even have shell access built-in.
Shell scripts are widely used by system administrators for performing common tasks.
command line interface
Before the widespread introduction of graphic user interfaces (GUI), computers were controlled either by punched cards, paper tape, or magnetic tape (a batch system) or a command line interface (CLI) using an interactive terminal (originally, some variation of a teletype machine from the telegraph technology). The earliest computers were controlled by front panel lights and switches or even by directly changing the wiring.
The command line interface on interactive terminals was a major advance. Because of limitations of the early hardware (at a time when a computers entire memory might be measured in hundreds of bytes), the first CLIs compressed the number of characters, using two or three letter abbreviations for commands and single character switches for options to commands.
The modern UNIX/Linux shells carry over this early limitation because there is the need to remain backward compatible and still run shell scripts that are decades old, but essential to continued operation of legacy systems.
This historical limitation makes it difficult for newcomers to figure out how to use a UNIX/Linux shell.
how to find Terminal
You can run these commands by copying and pasting into Terminal, a program that is available for free and preinstalled on Mac OS X and most versions of Linux. Some of these commands will only work on a particular operating system (this will be indicated), but most can be run from Mac OS X, any distribution Linux, and any kind of UNIX.
On Mac OS X, you will find Terminal by opening the Applications folder (on your main hard drive), then opening the Utilities folder, then scrolling down the list until you find Terminal or Terminal.app. Drag it to your Dock, because you will be using it a lot.
On Ubuntu Linux, look in Applications menu > Accessories > Terminal. Single click and hold, then drag to your panel, because you will be using it a lot.
On some versions of Linux, you can press the CONTROL and the ALT and the F1 keys all at once to bring up Terminal.
In Gnome, use the Applications menu > Accessories > Terminal or the keyboard shortcut of CONTROL and ALT and T (all at the same time).
In KDE, use the KMenu > System > Terminal Program (Konsole).
In Linux Mint you can use the keyboard shortcut of holding down the CONTROL and ALT and T keys all at once.
warnings
Be careful about any hints you find on the internet. There are people who suggest very destructive commands in the guise of a useful or fun hint just to trick beginners into destroying their computers.
Be very careful if you use any command that includes sudo, because it runs at the root level, allowing complete access to the entire computer with all safeguards turned off. Very powerful. Potentially very distructive in a hurry. There are legitimate hints and cool tricks that use sudo, but be careful to type them exactly as you you see them in the hint (or copy and paste) and only use sudo hints from trusted soruces.
Watch out for anything that includes the command rm or rm *. That is the remove command versions of it can literally wipe out all of your hard drives in seconds in such a way that only a very expensive data recovery specialist (thousands of dollars) can get your data back.
Also watch out for anything that includes the command shred. That is the secure delete and even the most expensive data recovery specialist in the world cant get your data back.
cool ASCII art
If your computer is connected to the internet, you can use the shell to watch the entire Star Wars Episode IV in old fashioned ASCII. Type telnet towel.blinkenlights.nl followed by ENTER or RETURN. If you have IPv6, you get extra scenes and color support.
$ telnet towel.blinkenlights.nl
play a CD
On Linux you can play a CD from the command line. The following example plays the first track of the CD. Change the number to play a different track.
$ cdplay play 1
On Linux you can get a free coffee cup holder (eject the CD-ROM tray).
$ eject
$ telnet towel.blinkenlights.nl
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
Create your own copy from the original source code/ (presented for learning programming).
Work on this project is very slow because I am homeless. I am available for work if someone can provide an indoor place to work in Costa Mesa, California, electricity, internet connections, a flat raised working surface (such as a table or desk), a sitting device (such as a chair or stool), and a fully functional reasonably modern used computer. Im already homeless, so you dont need to pay me (and I understand how much business people hate the minimum wage law). Just give me a chance to work.
Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.
If you like the idea of this project, then please donate some money.
send donations to: Milo
PO Box 1361
Tustin, California 92781
At the time I am homeless. This greatly interferes with my ability to create this project, which can help nearly 20 million U.S. college students and more than 150 million students world-wide. I am looking for 30 rich people or corporations willing to donate $10 a month to my church so that the church can provide a place indoors for me to continue work. If you want to donate, please see help project. Thanks much.
Supporting the entire project:
If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)
UNIX used as a generic term unless specifically used as a trademark (such as in the phrase UNIX certified). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Names and logos of various OSs are trademarks of their respective owners.