Wednesday, November 18, 2009

Lesson04:Executing Commands

Executing Commands

In this lesson, you will study how to run commands at the command prompt, and in the process, you will examine some simple commands.

After completing this lesson, you will be able to meet the following objectives:

• Run commands at the command line
• Use the date and cal commands


Running Commands

Commands have the following general syntax:

command options arguments

When you enter a command but do not get any prompt back, the command may be busy executing or may be waiting for input.To interrupt a command that is taking too long to execute, type Ctrl-C.

Occasionally you might enter a command without an argument, where the command waits for input to come from the keyboard. In this case, type Ctrl-C to terminate the command.

You can use semicolons to separate multiple commands on the same line. When the first command finishes, the next one will execute.

For example:






Simple Commands: Examples

The date command prints the system date and time.To configure the format, you can use optional formatting strings. For more information, run the date --help command.

This example demonstrates configuring the format of the date command.

date
date +"Today is %A,%B,%d,%Y.%nIt is %r,%Z."








You can also set the system time using the date command. To do this, use the date --set command. For example, to set the system clock forward by 40 minutes, use the following:

date --set="+40 minutes"







For more command options, con sult the man pages for the date command. Use the following:

man date

The cal command prints an ASCII calendar of the current month (by default, with no arguments provided). When provided with a single numeric argument, the cal command will give a calendar for the given year. Remember to use a four-digit year; the command cal 09 will give a calendar for the year 09, not the year 2009.

If cal is provided with a month and year as arguments, it will display the calendar for that particular month.

For example:


0 comments:

 
Home | About | Link | Link
Simple Proff Blogger Template Created By Herro | Inspiring By Busy Bee Woo Themes