linux tools shell script.. computer science

profileSingpran
Simple-shellcommands1.ppt

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-5: The Old Password Prompt

3.1.2 Changing Your Password: The passwd Command

The passwd command changes your current password. If you do not have a password, it creates one.

  • Type passwd and press [Return]

(UNIX displays the Old password: prompt)

  • Enter your current password and press [Return]

(UNIX displays the New password: prompt)

Figure 3-6 New Password Prompt

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-7 Re-Enter New Password Prompt

  • Enter your new password

(UNIX shows the Re-enter new password: prompt)

  • Retype the new password

(UNIX is verifies that you did not make a mistake)

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-8 Sample of Error Messages

Password Format

Your password must comply with the following criteria:

• The new password must differ from the old one by at least three characters

• The password must be at least six characters long and must contain at least two
characters and one number

• The password must differ from your User ID

If UNIX detects anything wrong with your password, it displays an error message and shows the New password: prompt again.

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-9 Changing a Password in the Linux Environment

The wordings of the prompts are slightly different for the Linux system, but the

command and sequence of prompts are the same.

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-10 Sample of Error Messages

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

3.1.3 General Rules for Choosing Passwords


• Do not use a dictionary word (in any language)

• Do not use the name of a person, pet, location, or a character from a book

• Do not use any variation of your name and ID/account name

• Do not use known information about you, such as your phone number, birthday,
and so on

• Do not use a simple pattern or easy sequence of keyboard keys

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

3.1.4 Logging Off

  • The process of signing off when you have finished with the system is called
    logging off or logging out
  • To log off, press [Ctrl-d], which means to simultaneously hold down the key
    labeled Ctrl (for Control) and press the letter d
  • UNIX responds first by displaying logging off messages
  • Then UNIX shows the system’s standard welcome message and login: prompt
  • exit command

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-11: The Logging-In and Logging-Out Process

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-12 The Command Line Format

3.2.2 Basic Command Line Structure

Each command line consists of three fields:

• Command name

• Options

• Arguments

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-13 The date Command

3.2.3 Date and Time Display: The date Command

  • The date command displays the current date and time on the screen
  • The date and time are set by the system administrator and users cannot
    change them

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

3.2.4 Information on Users: The who Command

  • The who command lists the login names, terminal lines, and login times of

the users who are currently logged on the system

  • The who command is used to check the level of activity in the system or to
    find out whether a particular person is on the system

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-14 The who Command

1. The first column shows the login name of the user

2. The second column identifies the terminal being used

3. The tty number gives you some indication about the location of the terminal

4. The third and fourth columns show the date and time that each user logged in

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-15: The who Command with am i Argument

  • Type who am I or who am I

(UNIX displays who the system thinks you are)

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

who Options

Table 3.1 lists some of the who command options

  • Linux also provides some alternative and new options
  • Under Linux, some of these options are not available, or some of the options outputs are slightly different

1. Linux new and alternative options are listed under the Linux heading in Table 3.1

2. Linux new and alternative options are preceded by two minus signs (--)

Table 3.1 The who Command Options

Option Linux Operation
-q --count The quick who; just displays the name and number of users
-H --heading Displays heading above each column
-b Displays the time and date of the last reboot
--help Displays a usage message

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-16A The who Command with -H Option

Figure 3-16B The who Command Using Linux --heading Option

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-17A The who Command with -q Option

Figure 3-17B The who Command Using Linux --count Option

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-18 The who Command with -b Option

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-19 The who Command Using Linux --help Option

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

3.2.5: Display a Calendar: The cal Command

The cal command displays the calendar for the specified year.

  • If the year and the month are both specified, then the calendar for just that
    month is displayed
  • The default argument for the cal command is the current month

Displaying the calendar for the current month (see Figure 3.20).

(Assuming current month, year is November 2005)

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-20 The cal Command with No Option

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-21 The cal Command Output

Notes:

  • Type the specified year in full year value. For example, type cal 2010 (not cal 10)
  • Use the month number (1 to 12) and not the month name
  • The cal command without arguments displays calendar of the current month
  • The cal command with year argument but without month argument displays a calendar for the specified year

Displaying the calendar for November 2010.

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-22 Learn Utility Main Menu

3.3 GETTING HELP

3.3.1 Using the learn Command

The learn command brings up a computer-aided instruction program that is arranged in a series of courses and lessons.

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-23 Help Utility Main Menu

3.3.2 Using the help Command

The help command is more popular than the learn command and is available on many UNIX systems.

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

3.3.3 Getting More Information: The UNIX Manual

You can find a detailed description of the UNIX system in a large document called the User’s Manual.

  • Some installation may have a printed copy of this manual
  • The electronic version of the manual is stored on disk and is called the
    online manual
  • The UNIX user’s manual is tersely written and difficult to read
  • It is more like a reference guide than a true user’s manual

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

3.3.4 Using the Electronic Manual: The man Command

The man (manual) command shows pages from the online system documentation.

  • Type man followed by the name of the command

  • You can use man to get the details about the commands

For example type:

man cal [Return]
(UNIX responds by showing a page similar to Figure 3.24)

Note:

Nearly all UNIX installations provide the man pages, and the man command is the most popular way to obtain detailed information about command usage and options.

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-24 man Utility Display of cal

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

3.4 CORRECTING TYPING MISTAKES

The shell program interprets the command line after you press the [Return] key.

  • Erasing Characters
  • Use the [Backspace] key for erasing characters or use [Ctrl-h] once for each

character you intend to erase

  • Erasing an Entire Line
  • You can erase an entire line any time before pressing [Return]
  • [Ctrl-u] removes the entire command line and the cursor moves to a blank line
  • The character that erases the entire line is called the kill character

  • Terminating Program Execution
  • The character that terminates your running program is called the interrupt character
  • On most systems, [Del] or [Ctrl-c] is assigned as the interrupt character
  • The interrupt character stops the running program and causes the shell prompt $ to

be displayed

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*

* of 45

Chapter 3: Getting Started

Amir Afzal
UNIX Unbounded, 5th Edition

Copyright ©2008

Figure 3-25 UNIX Error Message

Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008

*