Provides access to the system console.
The /dev/console special file provides access to the device or file designated as the system console. This file can be designated as the console device by the person administering the system or a user with the appropriate permissions. The console character special file provides access to the console device driver. The console device driver in turn directs input and output to the device or file selected as the system console.
The system console is typically a terminal or display located near the system unit. It has two functions in the operating system. First, it provides access to the system when it is operating in a non-multiuser mode. (This would be the case during maintenance and diagnostic sessions.) A console login is also normally provided on this device for all operating system run levels.
Second, the system console displays messages for system errors and other problems requiring intervention. These messages are generated by the operating system and its various subsystems when starting or operating. The system console can also be redirected to a file or to the /dev/null special file for systems operating without a console device.
Console driver configuration support allows the system console to be assigned or reassigned to a specified device or file. Such support also provides query functions to determine the current and configured path names for the device or file designated as the console. This configuration support is used by the swcons, chcons, and lscons high-level system management commands. It is also used by the console configuration method at system startup.
The swcons (switch console) command can be used during system operation to switch the system console output to a different target temporarily. This command switches only system information, error, and intervention-required messages to the specified destination. The swcons command does not affect the operation of the system console device that provides a login through the getty command. The device or file specified when using the swcons command remains the target for console output until one of the following happens:
If an open or write error is detected on the device or file specified by the swcons command, the console device driver switches all output back to the device or file providing console support when the system started.
The chcons (change console) command can be used to switch the system console output to a different device or file for the next startup. This command does not affect the current console selection, but becomes effective when the system is started again.
When requested to activate a login on the console device, the getty program (which provides login support) uses the console configuration support to determine the path name of the targeted console device used at startup. This action ensures that the swcons command does not effect the console device being used for login.
The open, close,read, write, ioctl, select, and poll subroutines are supported by the console device driver and may be used with the /dev/console special file. These subroutines are redirected to the device or file serving as the current system console device by the console device driver.
When an open subroutine call is issued to the console device driver, it is redirected to the device or file currently chosen as the console device. If the system console choice is a file, the file is opened with the append and create options when the first open of the dev/console file is received. Subsequent opens have no effect when the console selection is a file. However, the opens are then passed to the device driver supporting the device chosen as the console.
If the console selection has been temporarily switched using the swcons command and the first open of the new underlying device fails, the console device driver switches back to the console device or file with which the system was booted. This prevents important system messages from being lost.
An ext parameter passed using the openx subroutine is passed to the device driver supporting the console target or else ignored. (The latter is true if the console selection is a file.)
The close subroutine support is standard.
The select, poll, and ioctl subroutines are redirected to the current system console device when the console selection is not a file. If the selected console device is a file, the console device driver returns an error indicating that the subroutine is not supported.
An ext parameter passed to the ioctlx subroutine is then passed to the device driver supporting the console target, or else ignored. (The latter is true if the console selection is a file.)
The write subroutine calls are redirected to the current console device or file. If the console selection has been temporarily switched using the swcons command, and the write to the targeted device or file is unsuccessful, the console device driver switches back to the console device or file from which the system was started and tries the write again. This prevents important system messages from being lost in case the temporary console target is unavailable or unsuccessful. The console device driver should stay connected to the original system device until another swcons command is issued.
If the current console selection is a device, it redirects the read subroutine call. If the current console selection is a file, the read call is rejected with an error (EACCES).
An ext parameter passed to the readx or writex subroutine is passed to the device driver supporting the console target, or else ignored. (The latter is true if the console selection is a file.)
All output sent to the console is logged to a system log file. Only output sent to the console is logged. Any output sent to a device acting as the console is not logged. This means that system informational, error, and intervention-required messages are captured (logged), while other types of output seen at the console are not; e.g., getty output, smitty output, user interaction at the console device, etc.
The log file is based on the alog format; this format allows the file to wrap after it attains a predetermined maximum size. The alog command is typically used to view the console log file. The console log file deviates from the normal alog format in that each record of the file contains, in addition to the logged text, the user id who wrote to the console and the epoch time when it was written. The epoch time is formatted and displayed in the user's locale date and time when the file is output by the alog command.
When the console device is configured or when any modification is made to the console log file, ownership of the file is set to root and permissions are set to 622 to match that of the console device driver special file. The root user can modify the ownership or permissions, but they will not persist across boots.
The swcons command is used to make changes to console logging parameters during system operation; these changes are rescinded at the next console device configuration (typically reboot), and the original console logging parameters are reinstated.
The chcons command is used to make changes to the console logging parameters for the next console device configuration (typically reboot). These changes do not apply to the current running system.
The console logging facility can also be configured using the alog command. When the alog -C flag is used, changes are effective in the current running system and are persistent across boots. When the -s flag is used (without) the -C) to change the file size, the file is changed immediately but this change is not saved in the ODM and is not persistent across boots.
The parameters that control the console logging facility are the pathname of the log file, the maximum size of the log file, and the verbosity index for logging. Restrictions on these parameters are:
A facility is provided to prefix each console output message with the effective user ID of the user that sent the message to the console. Only output sent to the console is tagged, any output sent to the device acting as the console is not.
Both the swcons command and the chcons commands can be used to enable and disable console output tagging with the same caveats about the persistence of the values applying as mentioned above in Console Output Logging.
The console output tagging verbosity value is limited to the range 0-9. Any value greater than 0 causes all console output to be tagged.
The console special file is part of Base Operating System (BOS) Runtime.
/dev/null | Provides access to the null device. |
The chcons command, getty command, lscons command, swcons command, alog command.
The consdef file.
The close subroutine, ioctl subroutine, lseek subroutine, open subroutine, poll subroutine, read subroutine, select subroutine, write subroutine.