从特定排序开始

900*_*000 7 top

我想从top排序设置为常驻内存大小开始,而不是默认的 CPU 使用率。

我没有看到从命令行参数或启动文件中做到这一点的方法。显然我也不能echo "Oq" | top,因为我会阻止top使用 tty。

有没有办法做到这一点?

更新:我top在 Linux(最近的 Ubuntu 和 Debian,3.x 内核)上运行,例如安装为“procps 1:3.2.8-11ubun”,但我认为列排序功能可能是跨平台的。

Ram*_*esh 6

top -M 按常驻内存使用情况排序。

M 按常驻内存使用对任务进行排序。

这是我系统上的 top 版本。

top -v top:procps 版本 3.2.7

如果您的 Linux 发行版支持该-M标志,您可以按照此处所述使用它。

但是,如果您top不支持该-M标志,则可以top通过键入h检查排序字段来启动命令并进入交互模式。(我假设它在各种发行版中是相同的)

在我的系统(而不是我的系统top版本)中,我可以输入FO选择Q我的top版本的排序字段和键 ,让我可以对常驻内存进行排序。

如果您想保存您的配置,您可以执行 slm此处提到的操作。

保存配置

您可以使用Shift+W来保存更改,使其成为默认值:

  W         Write configuration file
Run Code Online (Sandbox Code Playgroud)

文件存储在这里,$HOME/.toprc,看起来像这样:

$ more .toprc 
RCfile for "top with windows"       # shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=1.000, Curwin=2
Def fieldscur=AEHIoqTWKNMBcdfgjpLrsuvyzX
    winflags=129016, sortindx=19, maxtasks=0
    summclr=2, msgsclr=5, headclr=7, taskclr=7
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
    winflags=63416, sortindx=13, maxtasks=0
    summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
    winflags=65464, sortindx=13, maxtasks=0
    summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr fieldscur=ABDECGfhijlopqrstuvyzMKNWX
    winflags=65464, sortindx=12, maxtasks=0
    summclr=3, msgsclr=3, headclr=2, taskclr=7
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅手册页的第 5 节“5. 文件”。