The `w` command is a fundamental tool in Linux used to gather information about the users currently logged into a system and their ongoing activities. It provides a snapshot of user-related data, including login times, terminal types, and running processes.
In this article, we will explore nine useful examples of the `w` command in Linux.
1. List `w` Command Output Without Header
To display the `w` command output without header information, use the `-h` option:
w -h
The `-h` option instructs the command not to print the header.
2. Ignore User Name
To ignore the user name while obtaining information about current processes and CPU times, use the `-u` flag:
w -u
The `-u` flag disregards the username in the output.
3. Check `w` Command Version
To check the version of the `w` command, use the `-V` flag:
w -V
The `-V` flag displays version information.
4. Display `w` Command Output in Short Format
To view a shorter version of the `w` command output without login time, JCPU, and PCPU times, use the `-s` flag:
w -s
The `-s` flag enables the short format.
5. Display IP Address in `w` Command Output
To display IP addresses instead of hostnames in the `FROM` field, use the `-i` option:
w -i
The `-i` option shows IP addresses instead of hostnames.
6. Toggle `FROM` Field
The `-f` option toggles the display of the `FROM` field in the `w` command output:
w -f
The `-f` option toggles the printing of the remote hostname field.
7. Display Output in Old Style
To view the `w` command output in old-style format, use the `-o` flag:
w -o
The `-o` flag prints blank space for idle times less than one minute.
8. Display User Output
To check the activity of a specific user, use the username as an argument:
w username
Replace “username” with the desired user’s name.
9. Check Other `w` Command Options
To explore additional options available with the `w` command, use the `–help` flag:
w --help
The `–help` flag provides information about all available options for the `w` command.
In conclusion, the `w` command in Linux offers a variety of options to customize the output and gather specific information about user activity on the system. Understanding these options allows system administrators and users to tailor the command to their needs.
You may also like:- How to View SSH Logs on Linux
- How to Change User in Linux Command Line
- [Solution] Missing logstash-plain.log File in Logstash
- Understanding Netstat – The Network Monitoring Tool
- Top 40 Useful Linux Command Snippets
- Using Elasticsearch Ingest Pipeline to Copy Data from One Field to Another
- Top 10 Useful Windows Commands
- Essential Commands For Process Management in Kali Linux
- How To Install Python 2.7.18 From The Source
- How To Parse SSH Authentication Logs with Logstash