Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Executing Utilities

July 19, 1998

To use utilities, you must use the shell. Specifically, you tell the shell to execute a utility on your behalf.

The most basic tool provided by the shell is the command interpreter. Specifically, the shell executes utilities (or programs) specified by the user. To execute a utility, you must follow the basic format of command followed by a "-" followed by optional options and arguments as in:

command -options arguments

Right off the bat, you may execute any of the utilities found in "/bin" or "/usr/bin". You can also use the command interpreter to execute any executable utility that you install.

Another cool way to run commands is to use the backtick character (`). Essentially, the backtick surrounding a command means that the shell should execute it. This is most commonly used when more than one command are interacting as you will see later...

We are going to talk more about all the utilities you have at your disposal in the next couple of days, but for now, lets just work with the "ls" utility used to list the contents of a given directory. This utility demonstrates how "all" commands are executed in general.

As we said, a utility can be run simply by typing its name at the command line as in the following case where we simply type "ls" at the command line: (Notice that the "ls" utility reports that there are three files in this directory).

[ls]

However, many utilities also take options that modify how the command is executed. For example, consider the -l option for the "ls" command. This option produces a more detailed listing. We will talk more about the meaning of the listing later. Just notice how the option was applied to the command generically.

In order to stop a command while it is running, you should press the BREAK or DELETE key. If that does not work, try hitting CNTRL-D or CNTRL-C.

[ls-l]

Finally, many utilities also take arguments. For example, to get a listing of all the files with . extensions, you might use the following: (We will talk more about the "*" argument later. For now, just notice the lack of the Mail directory which appeared in the other listings).

[ls arguments]

You can execute several commands on the same command line by separating them with a semi-colon such as:

$ ls -l; who; cal; pwd.

Likewise, if you do not want to wait for the command to finish before you continue working, you can request that UNIX performs the command in the background. To do so, you use the "&" character such as:

$(ls > dir.txt)&

Finally, you can keep a job alive even after you logout by using the nohup (no hang up) utility such as:

nohup sort address_book > sorted_addresses &

If you are not sure what arguments or options a command takes you can always use the generic -? or --help, which will give you some hints. the following image shows a help request for the "pwd" command.

[Command Help]

Of course, the "man" command, that we will discuss later, or a good reference book may be a better resource.

Built-in Utilities
Introduction to UNIX for Web Developers | Table of Contents
Wild Cards


Up to => Home / Internet / UNIX / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers