pvi Command

Purpose

Provides a privileged editor so that you can access privileged files.

Syntax

pvi [ -l ] [ -R ] [ -w Number ] [ -c | + [ Subcommand ] ] [ File ]

Description

The pvi command calls the pvi editor, a privileged version of the vi editor, to edit the file specified by the File parameter. Only one file can be opened at a time, and this file must have the security attributes that are defined in the privileged file database. You can display the file in the editor only when at least one of the authorizations matches at least one of the authorizations in the readauths or the writeauths attribute for the file. The contents of the buffer can then be modified. You can write to the file using the editor only when at least one of the authorizations matches at least one of the authorizations in the writeauths attribute for the file. Files opened by the pvi command can only be written to the same path they were opened from.

You enter and leave the pvi editor in command mode, but to add or change text, you must enter the text input mode. See the text input mode for information about the subcommands that initiate the text input mode. You can save the text to a file with one of the :w commands, and exit the pvi editor using the :q command.

The full-screen display editor, which is started by the pvi command, is based on the ex editor. You can use the ex subcommands within the pvi editor. Subcommands function at the cursor position on the display screen.

The pvi editor makes a copy of the file that you are editing in an edit buffer. The contents of the file are not changed until you save the changes.

Note: There are several functions of the vi editor that you cannot use with the pvi editor. If you refer to the information on the vi editor, be aware that the -r flag, the -t flag, shell escapes, user-defined macros, key mapping, and setting vi options permanently are not supported by the pvi editor. Only one buffer is opened at a time and a file can only be written to the same path from which it was opened.

Editor Limitations

The maximum limits of the pvi editor assume single-byte characters:

Editing Modes

The pvi editor operates in the following modes:

Item Description
command mode The pvi editor starts in the command mode. Any subcommand can be called except those that only correct text during the text input mode. To see a description of the subcommands, refer to the topics in "Subcommands for the pvi editor". To identify the subcommands that cannot be called from the command mode, refer to "Changing Text While in Input Mode". The pvi editor returns to the command mode when the subcommands and other modes end. Press the Esc key to cancel a partial subcommand.
text input mode The pvi editor enters the text input mode when you use a permitted command that adds or changes text. To see a list of subcommands that initiate text input mode, refer to "Adding Text to a File" and the subcommands that change text from the command mode, the C subcommand and the cx subcommands. After entering one of these subcommands, you can edit text with any of the subcommands that function in the text input mode. To see a list of the subcommands, refer to the topics in "Subcommands for the pvi Editor". To return to command mode from text input mode, press Esc for a typical exit or press the Ctrl + C keys to create an INTERRUPT signal.
last line mode Some subcommands read input on a line displayed at the bottom of the screen. These subcommands include those with the prefix colon (:), slash (/), and question mark (?). When you enter the initial character, the pvi editor places the cursor at the bottom of the screen so you can enter the remaining command characters. To run the subcommand, press Enter. To cancel the subcommand, press Ctrl + C to create an INTERRUPT signal. When you use the colon (:) to enter the last line mode, the following characters have special meaning when used before the commands that specify counts:
%
All lines regardless of the cursor position
$
Last line
.
Current line

Customizing the pvi Editor

You can customize the pvi editor on a temporary basis by following the directions in "Setting vi Editor Options".

Subcommands for the pvi Editor

You can find information about the vi editor subcommands that are applicable to the pvi editor in the following list:

Flags

Item Description
-c [ Subcommand ] Carries out the ex editor subcommand before the editing begins. This provides a line-oriented text editor. When you specify a null operand for the Subcommand parameter, for example, -c '', the editor places the cursor on the last line of the file.
-l Enters the editor in the list processing (LISP) mode. In this mode, the editor indents appropriately for LISP mode, and the (, ), {, }, [[, and ]] subcommands are modified to act in LISP. These subcommands place the cursor at the specified LISP function. For more information on the LISP subcommands, refer to "Moving to Sentences, Paragraphs, and Sections".
-R Sets the readonly option to protect the file against overwriting.
-w Number Sets the default window size to the value specified by the Number parameter. This is useful when you use the editor over a low-speed line.
+ [ Subcommand ] Same as the -c Subcommand.

Security

Access Control: This command grants the execute (x) access to all users.

Role-Based Access Control: The command grants read access to a file if the user has an authorization that matches one in the readauths or the writeauths authorization list in the privileged file database. The command only grants the write access to a file if the user has an authorization that matches one in the writeauths authorization list in the privileged file database.

Attention RBAC users and Trusted AIX® users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. To call a privileged editor to edit the plans file, enter:
    pvi plans
    This command puts the pvi editor into the command mode. To add or change text, you must enter the text input mode or use a command accepted in the command mode.
  2. To save the text that you create with the pvi editor, leave the text input mode by pressing Esc, and then enter:
    :w
  3. To exit the pvi editor from the text input mode, press Esc to enter the command mode, and then enter:
    :q!
    If the editor is already in the command mode, you do not need to press Esc before giving the quit (q!) command.

File

Item Description
/usr/bin/pvi Contains the pvi command.
/etc/security/privfiles Contains the security attributes for the privileged files.