Start *top* command with memory sort? (or any other available field)
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Start *top* command with memory sort? (or any other available field)
Top is a program that I have used for years, even with a few "deep" uses of its features: kill, renice, sort by other fields.
Now I want to start top with other sorting field, not CPU usage. One of the memory related fields is what want.
Even before looking at its documentation, I was planning a natural thing to many other *nix programs: to make an alias for it setting the wanted sort field. Something like:
Code:
alias topmem='top -sortfield n' # %MEM
alias topswp='top -sortfield p' # swapped size
alias topvrt='top -sortfield o' # virtual image
But reading 'man top' did not show anything to do this. Or I missed it.
I do not want to change the behavior of top, it should continue existing. I want to call the normal top in one terminal and "topswp" or others in another one, at (possibly) the same time.
I also do not want to do what I do now:
- start top
- type F
- type the letter for another sort field
- type space to get back to main screen
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
I just had a look in man top and it looks like the "-o" option does what you want, and the column names can be found with the "-O" option -- does htat help?
Subthread: where would I find the source code for top?
Do you know where would I find the source code for top? Or which package is it part of? (which would help me to find the source code in the app repository)
This computer is with Ubuntu 10.04.
Code:
# partial output of
$ man top
# [...]
7. BUGS
Send bug reports to:
Albert D. Cahalan, <albert@...........>
8. HISTORY Former top
The original top was written by Roger Binns, based on Branko
Lankester's <lankeste@.................> ps program.
Robert Nation <nation@.................> adapted it for
the proc file system.
Helmut Geyer <Helmut.Geyer@...................> added support
for configurable fields.
Plus many other individuals contributed over the years.
9. AUTHOR
This entirely new and enhanced replacement was written by:
Jim / James C. Warner, <warnerjc@................>
With invaluable help from:
Albert D. Cahalan, <albert@..............>
Craig Small, <csmall@....................>
# [...]
Do you know where would I find the source code for top? Or which package is it part of? (which would help me to find the source code in the app repository)
This computer is with Ubuntu 10.04.
Code:
# partial output of
$ man top
# [...]
7. BUGS
Send bug reports to:
Albert D. Cahalan, <albert@...........>
8. HISTORY Former top
The original top was written by Roger Binns, based on Branko
Lankester's <lankeste@.................> ps program.
Robert Nation <nation@.................> adapted it for
the proc file system.
Helmut Geyer <Helmut.Geyer@...................> added support
for configurable fields.
Plus many other individuals contributed over the years.
9. AUTHOR
This entirely new and enhanced replacement was written by:
Jim / James C. Warner, <warnerjc@................>
With invaluable help from:
Albert D. Cahalan, <albert@..............>
Craig Small, <csmall@....................>
# [...]
No clue to where the project is...
Wow, you're out of date...10.04 was EOL over a year and a half ago. That's why you're missing the -o option in newer versions.
While you could probably compile the newer version, I'd STRONGLY suggest just backing up all your information, and reinstalling with a newer, supported version like 14.04 or 16.04.
Wow, you're out of date...10.04 was EOL over a year and a half ago. That's why you're missing the -o option in newer versions.
While you could probably compile the newer version, I'd STRONGLY suggest just backing up all your information, and reinstalling with a newer, supported version like 14.04 or 16.04.
That will not happen. And if I ever reinstall the system for this machine, it will be a Mint, not an ugly and much worse to use Ubuntu with Unity Desktop or Gnome 3.
At least, Mate Desktop was born...
Do you know which are the best places to find source code for top? I am guessing that this should be the path I will take here.
NO, that shouldn't be the path. You're running an outdated OS with no more security patches or updates. Unless you're going to start compiling every program from source to keep up with security updates, then you should update to an OS that gets security updates. Regardless if it's Ubuntu, Mint, Arch, OpenBSD, Haiku, Windows, MacOS, or what.
Now, CAN you just update that one program, sure. But running an outdated OS is never a good thing, just ask everyone who's still using Windows XP...
Last edited by Timothy Miller; 01-02-2017 at 10:31 AM.
How about using a ~/.toprc to order what you want?
Here's mine,
[...]
This is not an option unless I can have two different files with two different settings. It seems that there is not a command line option fot that, as some programs have. As I said above, I want to have the normal top too.
NO, that shouldn't be the path. You're running an outdated OS with no more security patches or updates. Unless you're going to start compiling every program from source to keep up with security updates, then you should update to an OS that gets security updates. Regardless if it's Ubuntu, Mint, Arch, OpenBSD, Haiku, Windows, MacOS, or what.
Now, CAN you just update that one program, sure. But running an outdated OS is never a good thing, just ask everyone who's still using Windows XP...
I have seen Win XP running in several companies in the last months. But you will also complain about their security, about many other details. They still have it and will keep it for, at least, a few more years.
And I am not planning to change my OS so soon either.
Please, can anyone point me to which package or site top is in? Or show me a path to know for sure?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.