LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-15-2014, 11:35 PM   #1
MLS
LQ Newbie
 
Registered: May 2014
Posts: 5

Rep: Reputation: Disabled
Post How to display RAM usage per user using top command options


Hi! I've been trying to find an option to display the exact ram usage value of the user that has the highest. Top command only displays the whole process but I need a "per user" value. Please help
 
Old 05-15-2014, 11:41 PM   #2
LinBox2013
Member
 
Registered: Sep 2013
Location: Southern Kentucky
Distribution: Arch
Posts: 119

Rep: Reputation: 45
Quote:
Originally Posted by MLS View Post
Hi! I've been trying to find an option to display the exact ram usage value of the user that has the highest. Top command only displays the whole process but I need a "per user" value. Please help
Install smem and do a smem -u.

Or this: (echo "user rss(KiB) vmem(KiB)";
for user in $(users | tr ' ' '\n' | sort -u); do
echo $user $(ps -U $user --no-headers -o rss,vsz \
| awk '{rss+=$1; vmem+=$2} END{print rss" "vmem}')
done | sort -k3
) | column -t

Last edited by LinBox2013; 05-15-2014 at 11:43 PM.
 
Old 05-15-2014, 11:49 PM   #3
MLS
LQ Newbie
 
Registered: May 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Do I type those directly in unix?

---------- Post added 05-15-14 at 11:49 PM ----------

Quote:
Originally Posted by LinBox2013 View Post
Install smem and do a smem -u.

Or this: (echo "user rss(KiB) vmem(KiB)";
for user in $(users | tr ' ' '\n' | sort -u); do
echo $user $(ps -U $user --no-headers -o rss,vsz \
| awk '{rss+=$1; vmem+=$2} END{print rss" "vmem}')
done | sort -k3
) | column -t
Do I type these directly on Unix?
 
Old 05-15-2014, 11:53 PM   #4
LinBox2013
Member
 
Registered: Sep 2013
Location: Southern Kentucky
Distribution: Arch
Posts: 119

Rep: Reputation: 45
Quote:
Originally Posted by MLS View Post
Do I type those directly in unix?

---------- Post added 05-15-14 at 11:49 PM ----------



Do I type these directly on Unix?
Into a terminal.
 
Old 05-16-2014, 01:20 AM   #5
MLS
LQ Newbie
 
Registered: May 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by LinBox2013 View Post
Into a terminal.
It does not work.
 
Old 05-16-2014, 01:24 AM   #6
MLS
LQ Newbie
 
Registered: May 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
How will I see the RAM usage of other users also?
 
Old 05-16-2014, 09:09 AM   #7
geedoubleya
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by LinBox2013 View Post
Install smem and do a smem -u.

Or this: (echo "user rss(KiB) vmem(KiB)";
for user in $(users | tr ' ' '\n' | sort -u); do
echo $user $(ps -U $user --no-headers -o rss,vsz \
| awk '{rss+=$1; vmem+=$2} END{print rss" "vmem}')
done | sort -k3
) | column -t
This script is using an empty variable (users) which will need to be populated before the script is run for it to work:
users=`ps -eouser --sort user --noheader|uniq`
Or subsititue the command string in place of the $users entry.

An alternative string using less commands with less elegant output could be:
ps -eouser,size --sort user --no-header|awk '!($1 in a){a[$1];print rec,sum;sum=""}{sum+=$2;rec=$1} END {print rec,sum}'

The values are in KB. and represent the currently allocated and intented to be allocated memory not the virtual memory.
However This is still not ideal as it will only provide a rough value.

Cheers
 
Old 05-16-2014, 11:25 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by MLS View Post
Do I type these directly on Unix?
Unix or Linux?
 
Old 05-17-2014, 09:25 PM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by MLS View Post
Hi! I've been trying to find an option to display the exact ram usage value of the user that has the highest. Top command only displays the whole process but I need a "per user" value. Please help
You want to sort on the RES field (resident memory used), or the VIRT (total memory used by teh process - being swap + the in memory resident pages. (use the < and > characters to move the sort column left or right).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] listing cpu usage with top command dave12 Linux - Newbie 8 04-16-2010 07:13 AM
top command usage aloktiagi Linux - Newbie 1 08-11-2009 02:32 AM
TOP command: calculation of memory usage samiralmousawi Linux - Server 7 07-29-2008 03:16 PM
top command shows 249% usage pudhiyavan Linux - Server 7 02-27-2008 12:29 AM
Usage of TOP -U and multiple user accounts SROSean Linux - Newbie 1 09-05-2006 05:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration