Unix 101, Part 1

If DOS has been your only command line experience, learning Linux will be a shock to your system. For the next two weeks I'll review some key concepts where "Unices" like Linux differ profoundly from DOS. Also, you might visit the DOS2Linux HOWTO page at http://www.sunsite.edu/LDP/HOWTO/DOStoLinuxHOWTO.html.

Multi-User Environment

Most popular PC environments cater to a single user. Unix is different, for a single kernel is designed to handle numerous users with their commands simultaneously. Unix was one of the first time sharing environments. When you fire up Linux, the first thing you see is a login screen. You actually must create individual accounts for everyone in your household who uses your machine.

Being a multi-user platform, Linux must also be a multi-processing operating system. Each user must have their own "shell" or command line environment. This looks like a DOS prompt on the surface, but actually it's like a maseratti in volkswagon clothing. Your single Linux box can still support multiple users, however, though virtual consoles. If you type ALT-F2 you'll get another login screen. You can create as many virtual logins as you have function keys (possibly more with some tweaking), and you can run multiple processes from each one. One console can connect to your ISP, another can compile your kernel, etc etc.

Shells

If you've used Unix at the office, chances are you've enjoyed a windowing environment. You can create "shells" or command line interfaces to your heart's content there. You can even start multiple processes from a single shell by starting that process in the background (use a & after the command).

Strictly speaking, a shell is the type of command environment you use. Many different shells exist for Unix. Type the command echo $SHELL at your command prompt and find out which shell you're using. Popular ones include bash, csh, ksh, zsh, and variations of them. You can change your shell (not recommended without your sysadmin's approval) using the chsh command.

Most shells have numerous shortcuts you can use. Word completion can be used by typing the first few letters of a command, then hitting the TAB key twice. You'll see a listing of commands that start with the letters you typed. Very handy sometimes.

You can also configure your own shell with its unique environment definitions. You can create aliases for commands, set variables, and create environmental rules to follow as befits your taste. You can read some of these in your .*rc files where * is the name of your shell. Your shell is highly customizable.

Permissions

Permissions underpin the entire security of a Unix system. Three types of permission exist: r(ead), w(rite), x(ecute). These permissions exist for every file and for every program. Additionally, these permissions are defined for the owner of that file or program, the group of which he or she is a member, and all other users besides them.

So, if you created a file with the salaries of all executives in your company for your own use, you would not want others to see it. You would adjust the permissions so that you (the owner) could read the file, write the file (includes ability to delete file), and execute the file (if it were a program rather than a data file). But you would set the permissions for group and other to no permissions, since you don't want any one else to read or write to the file.

The group permission is handy if, for example, you're in accounting, and everyone in your group needs to look at the salaries of your company's executives. You simply add read and/or write permission to the group setting of the file.

All directories and files and programs on a Unix system have permissions. Thus, certain directories can be only read and not written to, while others can be fully accessed. Some directories only the superuser can read.

The single user on the system who has unlimited privileges is the superuser. This unlimited set of permissions is necessary for doing certain system maintenance. This user logs in as "root," and his password is the superuser password. It is the password that unlocks every aspect of the system to anyone who has it. With the root password a hacker can have unlimited access to a system and do untold damage.

Next week, we'll look at file system structure, processes, and the all-important init process.


Copyright, David S. Jackson, 1997.