w - Show who is logged on and what they are doing.
用法为:
1
$ w [options] user [...]
常用的两个选项为:
-h 不显示各栏位的标题信息列。
-s 简洁格式列表,不显示用户登入时间,JCPU或者PCPU的时间
默认的显示
显示当前用户的登录信息及执行的命令
1 2 3 4 5 6 7 8 9
$ w 16:29:03 up 26 days, 2:49, 6 users, load average: 1.00, 0.97, 0.96 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT user pts/4 :1 07Sep21 20days 9:59 1:53m bash user pts/0 :2 08Sep21 6days 0.70s 1:53m zsh user pts/1 :3 08Sep21 20days 1:13m 1:53m bash user :0 :0 15Sep21 6days 27days 21.36s zsh user pts/2 :0 15Sep21 14days 0.25s 0.25s zsh user pts/3 :3 16Sep21 24:45m 0.22s 0.22s bash
不显示标题行
1 2 3 4 5 6 7 8 9
$ w -h 16:29:16 up 26 days, 2:49, 6 users, load average: 1.20, 0.67, 0.76 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT user pts/4 :1 07Sep21 20days 9:59 1:53m bash user pts/0 :2 08Sep21 6days 0.70s 1:53m zsh user pts/1 :3 08Sep21 20days 1:13m 1:53m bash user :0 :0 15Sep21 6days 27days 21.36s zsh user pts/2 :0 15Sep21 14days 0.25s 0.25s zsh user pts/3 :3 16Sep21 24:45m 0.22s 0.22s bash
简洁模式显示
1 2 3 4 5 6 7 8 9
$ w -s 16:29:26 up 26 days, 2:49, 6 users, load average: 1.50, 0.67, 0.36 USER TTY FROM IDLE WHAT user pts/4 :1 20days bash user pts/0 :2 6days zsh user pts/1 :3 20days bash user :0 :0 6days zsh user pts/2 :0 14days zsh user pts/3 :3 24:45m bash
The yum history command allows users to review information about a timeline of Yum transactions, the dates and times they occurred, the number of packages affected, whether transactions succeeded or were aborted, and if the RPM database was changed between transactions. Additionally, this command can be used to undo or redo certain transactions. All history data are stored in the history DB in the var/lib/yum/history/ directory.
5.4.1. Listing Transactions
To display a list of twenty most recent transactions, as root, either run yum history with no additional arguments, or type the following at a shell prompt:
yum history list
To display all transactions, add the all keyword:
yum history list all
To display only transactions in a given range, use the command in the following form:
yum history list start_id..end_id
You can also list only transactions regarding a particular package or packages. To do so, use the command with a package name or a glob expression:
yum history list glob_expression…
Example 5.18. Listing the five oldest transactions
In the output of yum history list, the most recent transaction is displayed at the top of the list. To display information about the five oldest transactions stored in the history data base, type:
All forms of the yum history list command produce tabular output with each row consisting of the following columns:
ID — an integer value that identifies a particular transaction.
Login user — the name of the user whose login session was used to initiate a transaction. This information is typically presented in the Full Name form. For transactions that were not issued by a user (such as an automatic system update), System is used instead.
Date and time — the date and time when a transaction was issued.
Action(s) — a list of actions that were performed during a transaction as described in Table 5.1, “Possible values of the Action(s) field”.
Altered — the number of packages that were affected by a transaction, possibly followed by additional information as described in Table 5.2, “Possible values of the Altered field”.
Table 5.1. Possible values of the Action(s) field
Action Abbreviation Description
Downgrade D At least one package has been downgraded to an older version.
Erase E At least one package has been removed.
Install I At least one new package has been installed.
Obsoleting O At least one package has been marked as obsolete.
Reinstall R At least one package has been reinstalled.
Update U At least one package has been updated to a newer version.
Table 5.2. Possible values of the Altered field
Symbol Description
< Before the transaction finished, the rpmdb database was changed outside Yum.
After the transaction finished, the rpmdb database was changed outside Yum.
The transaction failed to finish.
The transaction finished successfully, but yum returned a non-zero exit code.
E The transaction finished successfully, but an error or a warning was displayed.
P The transaction finished successfully, but problems already existed in the rpmdb database.
s The transaction finished successfully, but the –skip-broken command line option was used and certain packages were skipped.
To synchronize the rpmdb or yumdb database contents for any installed package with the currently used rpmdb or yumdb database, type the following:
yum history sync
To display some overall statistics about the currently used history DB use the following command:
Yum also allows you to display a summary of all past transactions. To do so, run the command in the following form as root:
yum history summary
To display only transactions in a given range, type:
yum history summary start_id..end_id
Similarly to the yum history list command, you can also display a summary of transactions regarding a certain package or packages by supplying a package name or a glob expression:
yum history summary glob_expression…
Example 5.20. Summary of the five latest transactions
All forms of the yum history summary command produce simplified tabular output similar to the output of yum history list.
As shown above, both yum history list and yum history summary are oriented towards transactions, and although they allow you to display only transactions related to a given package or packages, they lack important details, such as package versions. To list transactions from the perspective of a package, run the following command as root:
yum history package-list glob_expression…
Example 5.21. Tracing the history of a package
For example, to trace the history of subscription-manager and related packages, type the following at a shell prompt:
~]# yum history package-list subscription-manager*
In this example, three packages were installed during the initial system installation: subscription-manager, subscription-manager-firstboot, and subscription-manager-gnome. In the third transaction, all these packages were updated from version 0.95.11 to version 0.95.17.
5.4.2. Examining Transactions
To display the summary of a single transaction, as root, use the yum history summary command in the following form:
yum history summary id
To examine a particular transaction or transactions in more detail, run the following command as root:
yum history info id…
The id argument is optional and when you omit it, yum automatically uses the last transaction. Note that when specifying more than one transaction, you can also use a range:
yum history info start_id..end_id
Example 5.22. Example output of yum history info
The following is sample output for two transactions, each installing one new package:
You can also view additional information, such as what configuration options were used at the time of the transaction, or from what repository and why were certain packages installed. To determine what additional information is available for a certain transaction, type the following at a shell prompt as root:
yum history addon-info id
Similarly to yum history info, when no id is provided, yum automatically uses the latest transaction. Another way to refer to the latest transaction is to use the last keyword:
yum history addon-info last
Example 5.23. Example output of yum history addon-info
For the fourth transaction in the history, the yum history addon-info command provides the following output:
In the output of the yum history addon-info command, three types of information are available:
config-main — global Yum options that were in use during the transaction. Refer to Section 5.5.1, “Setting [main] Options” for information on how to change global options.
config-repos — options for individual Yum repositories. Refer to Section 5.5.2, “Setting [repository] Options” for information on how to change options for individual repositories.
saved_tx — the data that can be used by the yum load-transaction command in order to repeat the transaction on another machine (see below).
To display selected type of additional information, run the following command as root:
yum history addon-info id information
5.4.3. Reverting and Repeating Transactions
Apart from reviewing the transaction history, the yum history command provides means to revert or repeat a selected transaction. To revert a transaction, type the following at a shell prompt as root:
yum history undo id
To repeat a particular transaction, as root, run the following command:
yum history redo id
Both commands also accept the last keyword to undo or repeat the latest transaction.
Note that both yum history undo and yum history redo commands only revert or repeat the steps that were performed during a transaction. If the transaction installed a new package, the yum history undo command will uninstall it, and if the transaction uninstalled a package the command will again install it. This command also attempts to downgrade all updated packages to their previous version, if these older packages are still available. If you need to restore the system to the state before an update, consider using the fs-snapshot plug-in described in Section 5.6.3, “Working with Plug-ins”.
When managing several identical systems, Yum also allows you to perform a transaction on one of them, store the transaction details in a file, and after a period of testing, repeat the same transaction on the remaining systems as well. To store the transaction details to a file, type the following at a shell prompt as root:
yum -q history addon-info id saved_tx > file_name
Once you copy this file to the target system, you can repeat the transaction by using the following command as root:
yum load-transaction file_name
You can configure load-transaction to ignore missing packages or rpmdb version. For more information on these configuration options see the yum.conf man page.
5.4.4. Starting New Transaction History
Yum stores the transaction history in a single SQLite database file. To start new transaction history, run the following command as root:
yum history new
This will create a new, empty database file in the /var/lib/yum/history/ directory. The old transaction history will be kept, but will not be accessible as long as a newer database file is present in the directory.