Moving to UNIX If You Are a Windows User


Both UNIX-and its variants-and Windows have command-line and graphical user interfaces. While many UNIX users switch between the two environments depending on the task to be performed, most Windows users seldom use command lines. To effectively move from a Windows environment to a UNIX environment, you will need to understand the similarities and differences between the two systems. If you are moving to a UNIX environment from Windows, you will need to know a number of things to become as proficient as you were in your Windows environment. You need to know about the differences and similarities of the commands used. You need to understand how the user interfaces are different, but-in some instances-can be made to look the same. You need to know the differences in how files and directories are named and accessed. And you need to know how the environments and shells are different. These next few sections talk about these issues.

Differences Between Windows and the UNIX System

The UNIX System and Windows differ in many ways, most of which are hidden from the user. Unless you are an expert programmer, you do not need to know how memory is allocated, how input and output are handled, or how the commands are interpreted. But as a user, if you are moving from one to the other, you do need to know differences in commands, differences in the syntax of commands and filenames, and differences in how the environment is set up. You may also want to compare how the GUI (graphical user interface) environments of both UNIX and Windows are similar, and how they are different.

If you already use Windows, you have a head start on learning to use the UNIX System. You already understand how to create and delete directories; how to change the current directory; and how to display, remove, and copy files. DOS users under Windows are familiar with command-line interfaces to execute commands. Windows users are familiar with using icons and mouse movements to perform simple tasks such as moving and copying files.

While you may never need to understand the actual operations of the “clicks and drags” you use as a Windows user, you can get a clearer understanding of the UNIX System by understanding the corresponding UNIX System commands for these basic Windows commands. These Windows commands are executed as DOS commands in much the same way that commands performed under UNIX desktop environments, such as the Common Desktop Environment and K Desktop (CDE and KDE, discussed in Chapter 7) or the GNOME desktop (Chapter 6) are actually executed as UNIX commands. We will use the term DOS in this chapter to describe the command-line environment of Windows. In later versions of Windows such as 2000 and XP, the command-line interface to DOS is replaced by the notion of CMD.EXE instead of COMMAND.COM.

Graphical User Interfaces

Microsoft Windows presents users with a graphical user interface that lets them simplify many different tasks with the help of their mouse. The Windows GUI evolved from earlier GUIs developed at Xerox Park and at Apple Computers. Analogously, GUIs have been developed for UNIX users. Originally, different variants of UNIX had their own GUIs, but standardization efforts have led to the adoption of common GUIs across many variants of UNIX, such as the Common Desktop Environment (CDE), GNOME, and KDE. It is not difficult to move from one UNIX GUI to another, since the underlying principles behind the use of these GUIs are similar.

In the same way, moving from the use of Windows with a GUI to the use of UNIX with a GUI is relatively easy For instance, both the UNIX and Windows GUI environments use icons to represent tasks, files, and directories. As an example, both UNIX and Windows use the concept of a folder to represent a directory The metaphor of “icon dragging” applies to both the UNIX and Windows GUIs. You can move icons around on a page, move the active window, enlarge or minimize it, or move file folders or contents to other folders in both environments. Likewise, the metaphor of “double-clicking” applies. When you double-click an icon in either GUI, an application executes and a new window opens to allow you to run the application. When you are done, you exit the application by selecting an “exit” icon in the active window. Even “right-clicking” is similar. When you use your right mouse button, you see either a drop-down menu of options you can perform with the current icon, or more information about it.

General Differences Between the Command Line in UNIX and in Windows

Although UNIX and Windows tasks can be executed in much the same way by using a graphical user interface, a number of differences exist between them in the way commands are executed, the way files are named and structured, and the environment under which a user interacts with the system.

Some minor differences in command syntax can be confusing when moving from one system to the other. For example, as previously noted, DOS under Windows uses a backslash to separate directories in a pathname, where the UNIX System uses a (forward) slash. In addition, the two systems require different environmental variables, such as PATH and PROMPT, which must be set properly for programs to run correctly

The file system structures also differ from one to the other. Although both Windows and UNIX use the concept of hierarchical files, each disk on a Windows machine has an identifier (for instance, C: or D:) that must be explicitly mentioned in the pathname to a file. This is because each disk has its own root directory with all files on that disk under it in a hierarchy UNIX has only one root directory, and no matter how many physical disks are associated with the files under the root directory, the files are referenced as subdirectories under the root directory This process, called mounting, shields the user from having to know where the files reside. In fact, files may even reside on different machines and still be accessed using this single root concept via remote resource mounting. These concepts are discussed in more detail in Chapters 14, 15, and 17.

Finally, some fundamental concepts underlying the UNIX operating system are not present in DOS-such as standard input and output. And some concepts are used much less frequently in DOS, such as piping commands or using redirection of output. The differences will be outlined here, as these concepts are an essential part of learning the UNIX System.

Common Commands in UNIX and DOS

Most of the common commands in DOS have counterparts in the UNIX System. In several cases more than one UNIX command performs the same task as a DOS command; for example, df and du both display the amount of space taken by files in a directory, but in different formats. In this case the UNIX System commands are more powerful and more flexible than the DOS SIZE command (DOS 7.0 and newer versions use the CHKDSK command). Some commands appear identical in the two systems-for example, both systems use mkdir. Table 18–1 shows the most common commands in DOS and the equivalent commands in the UNIX System.

Table 18–1: Basic Commands in DOS and the UNIX System

Function

DOS Command

UNIX Command

Display the date

DATE

date

Display the time

TIME

date

Display the name of the current directory

CD

pwd

Display the contents of a directory

DIR, TREE

Is –l, find

Display disk usage

CHKDSK

df, du

Create a new directory

MD, MKDIR

mkdir

Remove a directory

RD, RMDIR

rmdir, rm –r

Display the contents of a file

TYPE

cat

Display a file page by page

MORE

more, pg

Copy a file

COPY

cp

Remove a file

DEL, ERASE

rm

Compare two files

COMP, FC

diff, cmp, comm

Rename a file

RENAME

mv

Send a file to a printer

PRINT

lp

Most of these UNIX commands are described throughout this book, especially in Chapters 3 and 19. In some cases, putting them together in a chart may be misleading, because they are not precisely the same. In general, the UNIX System commands take many more options and are more powerful than their DOS counterparts. For example, the UNIX cp command copies files like the COPY command does, but the UNIX ls command allows you to do a little more than the DIR command under DOS.

Command-Line Differences

The differences between how DOS and the UNIX System treat filenames, pathnames, and command lines, and how each uses special characters and symbols, can be confusing. The most important of these differences are noted here:

  • Case sensitivity   DOS is-by nature-not case sensitive (except if your system supports long filename capabilities). You may type commands, filenames, and pathnames in either uppercase or lowercase, and they will act the same (e.g., the commands DIR and dir will both list the current directory and myfile and Myfile are treated as the same file). However, the UNIX System is sensitive to differences between uppercase and lowercase. The UNIX System will treat two filenames that differ only incapitalization as different files (e.g., file1 versus File1). Two command options differing only in case will be treated as different; for example, the –f and –F optionstell awk to do different things with the next entity on the command line.

  • Backslash, slash, and other special symbols   These are used differently in the two operating systems. You need to learn the differences to use pathnames and command options correctly See Table 18–2 for an understanding of the differences in structure.

    Table 18–2: Differences in Syntactic Use of Slash, Backslash in DOS and UNIX

    Name/Function

    DOS Form

    UNIX Form

    Directory name separator

    C:\SUE\BOOK

    /home/sue/book

    Command options indictor

    DIR/W

    ls –x

    Path component separator

    C:\BIN;C:\USR\BIN

    /bin:/usr/bin

    Escape sequences

    Not used

    \n (newline)

  • Filenames   In earlier versions of DOS, filenames consisted of up to eight alphanumeric characters, followed by an optional dot, followed by an optional filename extension of up to three characters. Newer versions support something called long filenames, where the name can be up to 255 characters (or longer for some versions of XP). There still is a three-character limit on file extensions (see next entry)-since DOS uses the file extension to determine the type of file in many cases (and thus which program to associate it with). DOS filenames can have multiple dots; but if DOS detects a dot in the filename, it tries to interpret the next three characters after the last dot as the file extension. UNIX System filenames can have up to 256 characters and can include almost any character except “/” and NULL. UNIX files may have one or more dots as part of the name, but a dot is not treated specially except when it is the first character in a filename.

  • Filename extensions   In DOS, specific filename extensions are necessary for files such as executable files (.EXE or .COM extensions), system files (.SYS), and batch files (.BAT), as well as Windows files used by applications (such as .DOC, .PPT, .DLL, and .AVI). In the UNIX System, filename extensions are optional and the operating system does not enforce filename extensions. Some UNIX utilities, though, use filename extensions (such as .tmp, .h, and .c).

  • Wildcard (filename matching) symbols   Both systems allow you to use the * and ? symbols to specify groups of filenames in commands; in both systems the asterisk matches groups of letters and the question mark matches any single letter. However, if a filename contains a dot and filename extension, DOS treats this as a separate part of the filename. The asterisk matches to the end of the filename or to the dot if there is one. Thus, if you want to specify all the files in a DOS directory, you need *.*, whereas the UNIX equivalent is *. The UNIX System also uses the [] notation to specify character classes, but DOS does not.

Setting Up Your Environment

Both DOS and the UNIX System make use of startup files that set up your environment. DOS uses the CONFIG.SYS and AUTOEXEC.BAT files. The UNIX System uses a file called .profile. In order to move from Windows to the UNIX System, you need to know something about these files. In particular, you will need to understand how entries representing devices and services added under the Windows Control Panel are added to either the AUTOEXEC. BAT file or the CONFIG.SYS file, or both. You will also need to understand how the .profile file sets up certain aspects of your environment that affect how the UNIX shell is started up (see Chapter 4).

Creating the DOS Environment   When you start up a Windows machine running DOS, it runs a built-in sequence of startup programs, ending with CONFIG.SYS and AUTOEXEC .BAT if they exist on your hard drive (or a floppy that you are using to boot from). The CONFIG.SYS file contains commands that set up the DOS environment-such as FILES and BUFFERS, and some device drivers-which are TSR (terminate and stay resident) programs that are necessary to incorporate devices into the DOS system. Other devices are managed directly by Windows configuration files and do not become part of CONFIG .SYS. You can also specify that you wish to run a shell other than COMMAND.COM.

The AUTOEXEC.BAT file can contain many different DOS commands, unlike CONFIG .SYS, which may only contain a small set of commands related to your machine configuration. In AUTOEXEC.BAT you can display a directory, change the working drive, or start an application program. In addition, you can create a path, which tells DOS where to look for command files-which directories to search and in what order. You use a MODE command to set characteristics of the printer, the serial port, and the screen display You use SET to assign values to variables, such as the global variables COMSPEC and PROMPT.

Most of the previous functions are now handled by Windows automatically when it boots up, based on a file called the Registry, as well as internal settings of devices stored in the Control Panel. You can, however, usually see these activities happening by pressing the ESC key when your Windows screen first appears. This method is especially useful if you suspect that something has happened to your Windows system that is making it work incorrectly For example, you may not have sound coming out of your speaker. By looking at the actual DOS commands and environment setting routines that are being executed, you may discover that a specific device-such as the audio card that you are depending on-has a problem, and the driver for it is not being loaded at boot time.

Setting Up the UNIX Environment   In a UNIX system, the hardware-setting functions (performed by CONFIG.SYS and the MODE command on a DOS system) are part of the job of the system administrator. These and other administrative tasks are described in Chapters 13 and 14.

Both systems use environmental variables such as PATH in similar ways. In the UNIX System, your environmental variables are set during login by the system and are specified in part in your .profile file. Your UNIX .profile file corresponds roughly to AUTOEXEC .BAT on DOS. A profile file can set up a path, set environmental variables such as PORT and TERM, change the default prompt, set the current directory, and run initial commands. It may include additional environmental variables needed by the Korn shell, if you are running this. On a multiuser system, each user has a .profile file with his or her own variables.

Basic Features

Some of the fundamental features of the UNIX System include standard input and output, pipes and redirection, regular expressions, and command options. Most of these concepts are found in DOS also, but in DOS they are relatively limited in scope. In the UNIX System they apply to most of the commands; in DOS they are only relevant to certain commands.

  • Standard I/O   The concept of standard input and output is part of both systems. In both systems, the commands take some input and produce some output. For example, mkdir takes a directory name and produces a new directory with that name. sort takes a file and produces a new file, sorted into order. In the UNIX System, certain commands allow you to specify the input and output, for example, to take the input from a named file. If you do not name an input file, the input will come from the default standard input, which is the keyboard. Similarly the default standard output is the screen. This concept is relevant for DOS also. If you enter a DIR command in DOS, the output will be displayed on your screen unless you send it to another output.

  • Redirection   Redirection is sending information to a location other than its usual one. DOS uses the same basic file redirection symbols that the UNIX System does: < to get input from a file, > to send output to a file, and >> to append output to a file. An important difference is that DOS sometimes uses the > symbol to send the output of a file to a device such as a printer, whereas the UNIX System would use a pipe. For example, the DOS command

     C:\> dir > prn

    sends the output of the dir (directory) command to the printer. The UNIX System equivalent would be the following pipeline:

     $ ls lp

  • Pipes   Both systems provide pipes, used to send the output of one command to the input of another. In the UNIX System, pipes are a basic mechanism provided by the operating system, whereas in DOS they are implemented using temporary files, but their functions are similar in both systems.

  • Regular expressions   The concept of regular expression is used by many UNIX System commands. While the Search routine in DOS is limited to asterisks and question marks in searching files and folders, there are some counterparts in DOS in the JScript and VBScript routines. Regular expressions are string patterns built up from characters and special symbols that are used for specifying patterns for searching or matching. They are used in vi, ed, and grep for searching, as well as in awk for matching.

  • Options   Most UNIX System commands can take options that modify the action of the command. The standard way to indicate options in the UNIX System is with a minus sign. For example, sort –r indicates that sort should print its output in descending rather than ascending order. Options are used with DOS commands, too. They are called command switches and are indicated by a slash. For example, DIR /P indicates that DIR should list the contents of the directory one page (screen) at a time, which comes in handy when you are looking at large directories. The concept is the same in both systems, but options play a more important role in normal UNIX System use.

Similarities Between UNIX and Windows

UNIX and Windows both provide many useful features for their users. Original versions of Windows increased the ease of use of the GUI but did not do much to improve performance and services. Windows NT was the first Microsoft Windows-based system to do so. Newer Windows versions such as Windows 2000 and Windows XP have greatly improved multitasking capabilities and networking services.

Here are a few ways in which UNIX and Windows are the same: Both UNIX and Windows can be loaded on a PC as a client that accesses a server. Additionally both can be loaded onto a server and provide services such as printing and file serving for their clients on a network. UNIX and Windows are true multitasking machines; that is, you can perform multiple tasks simultaneously UNIX and Windows both provide management of your processes through a GUI interface (Microsoft calls it the Task Manager). Both UNIX and Windows can provide a full suite of networking tools and applications to allow connections to other machines, and software to allow sharing of files across the network. Finally, both UNIX and Windows have strong built-in security features that keep unwanted intruders out.




UNIX. The Complete Reference
UNIX: The Complete Reference, Second Edition (Complete Reference Series)
ISBN: 0072263369
EAN: 2147483647
Year: 2006
Pages: 316

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net