• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

UNIX commands

hans030390

Diamond Member
I'm trying to find a command that prints out a list of the user names logged onto our schools Linux network along with the commands they're running. I also need to have the names sorted and dumped into a txt file. Same with the commands, but sorted by CPU usage. I'm not sure if these can be in the same file or not.

Any help with this? I'm trying to figure this out for a class, if you didn't notice.
 
Nevermind, just found what I was looking for. Still trying to figure out how I can sort those two (username and CPU usage seperately), if I can. Trying to sort the output of the w command alone screws things up, since it includes the first two lines (which it doesn't need to sort)
 
On OpenBSD top can be filtered to only show users, maybe the linux version can do it too (-U user). Try something like:
top -U USERNAME -d 1 -o cpu

Then just do that for every user.

Try who instead of w. It's more limited on OpenBSD (I need a linux machine 😛).
 
Also to output to a text file:

[command] >> file.txt (This appends to whatever is in the file already and creates it if it doesn't exist)
[command] > file.txt (Same as above except it overwrites instead of appends)

-Kevin
 
Well, I had to turn the assignment in a little bit ago...still didn't quiet find what I was looking for. No big deal. Thanks for the help. 🙂
 
Back
Top