LinuxQuestions.org
Register a domain and help support LQ
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-16-2014, 12:35 AM   #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-16-2014, 12:41 AM   #2
LinBox2013
Member
 
Registered: Sep 2013
Posts: 86

Rep: Reputation: 8
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-16-2014 at 12:43 AM.
 
Old 05-16-2014, 12:49 AM   #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-16-2014, 12:53 AM   #4
LinBox2013
Member
 
Registered: Sep 2013
Posts: 86

Rep: Reputation: 8
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, 02: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, 02: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, 10: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, 12:25 PM   #8
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,182
Blog Entries: 10

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

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
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 08:13 AM
top command usage aloktiagi Linux - Newbie 1 08-11-2009 03:32 AM
TOP command: calculation of memory usage samiralmousawi Linux - Server 7 07-29-2008 04:16 PM
top command shows 249% usage pudhiyavan Linux - Server 7 02-27-2008 01:29 AM
Usage of TOP -U and multiple user accounts SROSean Linux - Newbie 1 09-05-2006 06:21 PM


All times are GMT -5. The time now is 02:32 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration