mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
[手动选题][tech]: 20230107.0 ⭐️ Learn w Command in Linux & BSD with Examples.md
This commit is contained in:
parent
5dba280521
commit
5e71697d6f
@ -0,0 +1,115 @@
|
||||
[#]: subject: "Learn w Command in Linux & BSD with Examples"
|
||||
[#]: via: "https://www.debugpoint.com/w-command-linux-examples/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Learn w Command in Linux & BSD with Examples
|
||||
======
|
||||
|
||||
**Here’s a beginner’s guide on understanding the w command in Linux & BSD with several examples.**
|
||||
|
||||
![][1]
|
||||
|
||||
_This article is part of the [Linux command][2] learning series._
|
||||
|
||||
### w command
|
||||
|
||||
The `w` command is a utility in Linux that displays information about the users currently logged into the system and their processes. It shows who is logged on and what activities they are doing. That means it can show what processes they are running in their system.
|
||||
|
||||
### Syntax
|
||||
|
||||
Here is the basic syntax of the `w` command:
|
||||
|
||||
```
|
||||
w [options] [username]
|
||||
```
|
||||
|
||||
The `w` command takes an optional list of options, followed by an optional username. If a username is specified, `w` will only show information about processes owned by that user.
|
||||
|
||||
### Examples of the w command and its usage
|
||||
|
||||
Here are some examples of using the `w` command.
|
||||
|
||||
When you run it with only w, it shows the following output.
|
||||
|
||||
```
|
||||
$ w
|
||||
21:45:07 up 1 day, 12:48, 1 user, load average: 1.05, 0.85, 0.56
|
||||
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
|
||||
debugpoi tty2 Thu08 36:48m 0.03s 0.03s /usr/libexec/gnome-session-binary
|
||||
```
|
||||
|
||||
![a basic output of w command in Linux][3]
|
||||
|
||||
Explanation: The USER column gives you the username, followed by the terminal number, login date-time, IDLE time, CPU usage, and the process being executed by the user.
|
||||
|
||||
- `USER` – Logged on user name in your Linux or BSD system.
|
||||
- `TTY` – Terminal identifier number for the current session.
|
||||
- `FROM` – Hostname or IP address of the user.
|
||||
- `LOGIN@` – User logged in time. It sometimes shows dates based on your system settings.
|
||||
- `IDLE` – Idle time elapsed since the user interacted with the terminal.
|
||||
- `JCPU` – CPU time used by all the user processes for that session.
|
||||
- `PCPU` – Time used by the process for the user, which is mentioned in the WHAT field.
|
||||
- `WHAT` – Current process with arguments.
|
||||
|
||||
Here’s another example of the w command with two users logged in a virtual machine environment. As you can see, two user names are shown with separate processes with process parameters currently running.
|
||||
|
||||
![w command output for a demo multi-user environment][4]
|
||||
|
||||
Let’s take a look at some options for this command.
|
||||
|
||||
To show stop showing header, use the`-h` option. It’s identical to the `--no-header` switch.
|
||||
|
||||
```
|
||||
$ w -h
|
||||
```
|
||||
|
||||
The -f option toggles the visibility of FROM field in your output.
|
||||
|
||||
```
|
||||
$ w -f
|
||||
```
|
||||
|
||||
Use the `-s` option to print a short version of the output excluding JCPU, PCPU and LOGIN@ information.
|
||||
|
||||
```
|
||||
$ w -s
|
||||
```
|
||||
|
||||
To show a list of all processes owned by a specific user (for example, `debugpoint`):
|
||||
|
||||
```
|
||||
$ w debugpoint
|
||||
```
|
||||
|
||||
### Closing Notes
|
||||
|
||||
I hope this article helps you to understand w command and its basics. You can also read the [w man pages][5] to learn more. Let me know if you have any questions.
|
||||
|
||||
**This article is part of the [Linux command][2] learning series**.
|
||||
|
||||
[_Using Mastodon? Follow us at floss.social/@debugpoint_][6]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/w-command-linux-examples/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://www.debugpoint.com/wp-content/uploads/2023/01/whead.jpg
|
||||
[2]: https://www.debugpoint.com/category/linux-commands
|
||||
[3]: https://www.debugpoint.com/wp-content/uploads/2023/01/a-basic-outout-of-w-command-in-Linux.jpg
|
||||
[4]: https://www.debugpoint.com/wp-content/uploads/2023/01/w-command-output-for-a-demo-multi-user-environment.jpg
|
||||
[5]: https://linux.die.net/man/1/w
|
||||
[6]: https://floss.social/@debugpoint
|
Loading…
Reference in New Issue
Block a user