Chapter 1. Using Unix

Table of Contents

1.1. Keep It Simple, Stupid
1.2. What is Unix?
1.2.1. Aw, man... I Have to Learn Another System?
1.2.2. Operating System or Religion?
1.2.3. The Unix Standard API
1.2.4. Shake Out the Bugs
1.2.5. The Unix Standard UI
1.2.6. Freedom of Choice
1.2.7. Fast, Stable and Secure
1.2.8. Sharing Resources
1.3. Self-test
1.4. Unix User Interfaces
1.4.1. Graphical User Interfaces (GUIs)
1.4.2. X11 on Mac OS X
1.4.3. Command Line Interfaces (CLIs): Unix Shells
1.4.4. Terminals
1.4.5. Basic Shell Use
1.4.6. Self-test
1.5. Still Need Windows? Don't Panic!
1.5.1. Cygwin: Try This First
1.5.2. Windows Subsystem for Linux: Another Compatibility Layer
1.6. Logging In Remotely
1.6.1. Unix to Unix
1.6.2. Windows to Unix
1.6.3. Terminal Types
1.6.4. Self-test
1.7. Unix Command Basics
1.7.1. Self-test
1.8. Basic Shell Tools
1.8.1. Common Unix Shells
1.8.2. Command History
1.8.3. Auto-completion
1.8.4. Command-line Editing
1.8.5. Globbing (File Specifications)
1.8.6. Self-test
1.9. Processes
1.9.1. Self-test
1.10. The Unix File system
1.10.1. Unix Files
1.10.2. File system Organization
1.10.3. Ownership and Permissions
1.10.4. Self-test
1.11. Unix Commands and the Shell
1.11.1. Internal Commands
1.11.2. External Commands
1.11.3. Getting Help
1.11.4. A Basic Set of Unix Commands
1.11.5. Self-test
1.12. Unix Command Quick Reference
1.13. POSIX and Extensions
1.14. Special Unix Tools
1.14.1. grep
1.14.2. awk
1.14.3. cut
1.14.4. sed
1.14.5. sort
1.14.6. tr
1.14.7. find
1.14.8. xargs
1.14.9. bc
1.14.10. tar
1.14.11. gzip, bzip2, xz
1.14.12. zip, unzip
1.14.13. make
1.14.14. time
1.14.15. top
1.14.16. iostat
1.14.17. netstat
1.14.18. iftop
1.14.19. Download Tools: curl, fetch, wget
1.15. File Transfer
1.15.1. File Transfers from Unix
1.15.2. File Transfer from Windows without Cygwin
1.15.3. Self-test
1.16. Environment Variables
1.16.1. Self-test
1.17. Shell Variables
1.17.1. Self-test
1.18. More Shell Tools
1.18.1. Redirection and Pipes
1.18.2. Subshells
1.18.3. Self-test
1.19. Process Control
1.19.1. External Commands
1.19.2. Special Key Combinations
1.19.3. Internal Shell Commands and Symbols
1.19.4. Self-test
1.20. Remote Graphics
1.20.1. Configuration Steps Common to all Operating Systems
1.20.2. Graphical Programs on Windows with Cygwin
1.21. Where to Learn More

Before You Begin

If you think the word "Unix" refers to Sumerian servants specially "trained" to guard a harem, you've come to the right place.

This chapter is designed as a tutorial for users with little or no Unix experience.

If you are following this guide as part of an ungraded workshop, please feel free to work together on the exercises in this text. It would be very helpful if experienced users could assist less experienced users during the "practice breaks" in order to keep the class moving forward and avoid leaving anyone behind.

1.1. Keep It Simple, Stupid

Most people make most things far more complicated than they need to be. Engineers and scientists, especially so.

Aside

A normal person says "If it ain't broke, don't fix it."

An engineer says "If it ain't broke, it doesn't have enough features yet."

We achieve more when we make things simple for ourselves.

We achieve less when we make things complicated.

Most people choose the latter.

The original Unix designers were an exception. Unix is designed to be as simple and elegant as possible. Some things may not seem intuitive at first, but this is probably because the first idea you would come up with is more convoluted than the Unix way. The Unix developers had the wisdom to constantly look for more elegant ways to achieve their goals instead of the most amazing ones or the first one that worked.

Learning the Unix way will therefore make you a wiser and happier computer user. I speak from experience.

Complexity is the product of carelessness or ego, and simplicity is the product of a wise and clear thinker.

Aside

"Simplicity is the ultimate sophistication."

-- Leonardo da Vinci

Unix is not hard to learn. You may have gotten the impression that it's a complicated system meant for geniuses while listening to geniuses talk about it. Don't let them fool you, though. The genius ego compels every genius to make things sound really hard, so you'll think they're smarter than you.

Another challenge with learning anything these days is filtering out all the noise on the Internet. Most tutorials on any given subject are incomplete and many contain misinformation or bad advice. As a result, new users are often pointed in the wrong direction and hit a dead end before long. One of the goals of this guide is a show a simple, sustainable, portable, and expandable approach to using Unix systems. This will reduce your learning curve by an order of magnitude.

Unix has grown immensely since it was created, but the reality is, you don't need to know a lot in order to use Unix effectively. The average Unix user can learn almost everything they'll need to know in a day or two. You can become more sophisticated over time if you want, but most Unix users don't really need to. It may be better to stick to the KISS principal (Keep It Simple, Stupid) and focus on becoming resourceful using the basic tools, rather than accumulating a lot of knowledge that you'll rarely use.

Aside

Einstein was once asked how many feet are in a mile. His reply: "I don't know, why should I fill my brain with facts I can find in two minutes in any standard reference book?"

Unix is designed to be as simple as possible and to allow you to work as fast as possible, by staying out of your way. Many other systems will slow you down by requiring you to use cumbersome user interfaces or spend time learning new proprietary methods. As you become a master of Unix, your productivity will be limited only by the speed of the hardware and programs you run.

If something is proving difficult to do under Unix, you're probably going about it wrong. There is almost always an easier way, and if there isn't, then you probably shouldn't be trying to do what you're trying to do. If it were a wise thing to do, some Unix developer would have invented an elegant solution by now. Adapt to the wisdom of those who traveled this road before you, and life will become simpler.