在Linux下怎样让top命令启动之后就按内存使用排序(或CPU使用排序)?

top 命令的参数中没有方法可以直接做到。

man top 写道
NAME
       top - display Linux tasks

SYNOPSIS
       top -hv | -bcHisS -d delay -n iterations -p pid [, pid ...]

The traditional switches ’-’ and whitespace are optional.

-b : Batch mode operation
       -c : Command line/Program name toggle
       -d : Delay time interval as:  -d ss.tt (seconds.tenths)
       -h : Help
       -H : Threads toggle
       -i : Idle Processes toggle
       -n : Number of iterations limit as:  -n number
       -u : Monitor by user as:  -u somebody
       -U : Monitor by user as:  -U somebody
       -p : Monitor PIDs as:  -pN1 -pN2 ...  or  -pN1, N2 [,...]
       -s : Secure mode operation
       -S : Cumulative time mode toggle
       -v : Version
       -M : Detect memory units

但是可以在文本全屏界面显示出来之后使用交互式命令来进行,比如 按大写M可以使进程显示按内存使用排序,按大写P按CPU使用排序。

按大写W可以将当前的设置保存到配置文件中,一般就是 ~/.toprc,这样就可以在下次启动top命令是按照设定的排序方式来显示了。

man top 写道
W :Write_the_Configuration_File
              This  will save all of your options and toggles plus the current
              display mode and delay  time.   By  issuing  this  command  just
              before  quitting  top, you will be able restart later in exactly
              that same state.

1 :Toggle_Single/Separate_Cpu_States  --  On/Off
              This command affects how the ’t’ command’s Cpu States portion is
              shown.  Although this toggle  exists  primarily  to  serve  mas-
              sively-parallel SMP machines, it is not restricted to solely SMP
              environments.

SORTING of task window
         For  compatibility,  this  top  supports  most of the former top sort
         keys.  Since this is primarily a service to former top  users,  these
         commands do not appear on any help screen.
            command   sorted field                  supported
              A         start time (non-display)      No
              M         %MEM                          Yes
              N         PID                           Yes
              P         %CPU                          Yes
              T         TIME+                         Yes

下面是一个 ~/.toprc 文件的样本。这个文件有点复杂,没仔细看过。

Text代码  
  1. RCfile for "top with windows"           # shameless braggin'
  2. Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
  3. Def     fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
  4. winflags=62777, sortindx=13, maxtasks=0
  5. summclr=1, msgsclr=1, headclr=3, taskclr=1
  6. Job     fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
  7. winflags=62777, sortindx=0, maxtasks=0
  8. summclr=6, msgsclr=6, headclr=7, taskclr=6
  9. Mem     fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
  10. winflags=62777, sortindx=13, maxtasks=0
  11. summclr=5, msgsclr=5, headclr=4, taskclr=5
  12. Usr     fieldscur=ABDECGfhijlopqrstuvyzMKNWX
  13. winflags=62777, sortindx=4, maxtasks=0
  14. summclr=3, msgsclr=3, headclr=2, taskclr=3

在Linux下怎样让top命令启动之后就按内存使用排序(或CPU使用排序)?相关推荐

  1. Linux/Unix下的任务管理器-top命令

    Linux/Unix下的任务管理器-top命令 Posted on 2012-07-11 09:14 fengyv 阅读(15453) 评论(1) 编辑 收藏 Windows下的任务管理器虽然不好用( ...

  2. linux启动sh文件命令,Linux下如何写 .sh 脚本启动 项目

    Linux下如何写 .sh 脚本启动 项目 创建文件   mealcoupon.sh 内容如下: #!/bin/bash #这里可替换为你自己的执行程序,其他代码无需更改 APP_NAME=xhqy_ ...

  3. Linux下安装mysql后无法启动的解决方法

    在Linux下安装完mysql后,mysql服务无法启动,总是failer.       这个不是因为mysql安装失败,而是因为启动了SELinux.       进入/etc/selinux/co ...

  4. Linux下su与su -命令的区别

    Linux下su与su -命令的区别 在启动服务器ntpd服务时遇到一个问题 使用 su root 切换到root用户后,不可以使用service命令: 使用 su - 后,就可以使用service命 ...

  5. linux下软件编译终止,[2018年最新整理]linux下编译运行程序命令大全.ppt

    [2018年最新整理]linux下编译运行程序命令大全 1. 项目课题引入 2. Vi编辑器的使用方法 3. Linux中C语言程序的编辑 4. Linux中C语言程序的运行 5. 现场演示案例 课题 ...

  6. Linux下Crontab定时执行命令

    Linux下Crontab定时执行命令 目录 Crontab概述及安装 Crontab规则 常见例子 1. Crontab概述及安装 1. Crontab指令是Linux下执行定时任务的一个命令. 2 ...

  7. linux查代替命令,Linux下查/删/替 命令(转)

    ▪查看某目录下所有文件的个数: [root@localhost1 opt]# ls -l |grep "^-"|wc -l ▪查看某目录下所有文件的个数,包括子目录里面的: [ro ...

  8. linux电脑关机命令是什么问题,linux下正常关机之命令详解 -电脑资料

    系统启动的时候生成一个文件,正常关机的时候会删除这个文件,管理过程中出现故障的机率. 步骤: 在/etc/rc.d/init.d/下编程脚本. 判断是否正常关机,和生成文件的脚本:touch-file ...

  9. linux查看显示器名称命令,linux 查看显示器信息Linux下查看硬件信息命令大全

    /proc 虚拟的目录,是系统内存的映射.可直接访问这个目录来获取系统信息.其中也包含下面的信息: 主机CPU信息:cpuinfo 主机DMA通道信息:dma 文件系统信息:filesystems 主 ...

最新文章

  1. Xcode升级到8之后的一些需要我们手动配置的地方
  2. spring boot应用启动原理分析
  3. JVM:类加载机制之类加载过程
  4. 02-NVIDIA Jetson TX2 通过JetPack 3.1刷机完整版(踩坑版)
  5. devexpress卸载不干净_最好用的卸载工具,清理彻底,专治各种流氓软件
  6. C++ 控制结构和函数(一) —— 控制结构
  7. [jQuery] 针对jQuery的优化方法有哪些?
  8. 【JMX】JMX 远程 连接 The client has been closed
  9. SpringMVC拦截器Interceptor
  10. Quoc Le,谷歌AutoML的幕后英雄
  11. CSS按钮动画(三)
  12. 16个车辆信息检测数据集收集汇总(简介及链接)
  13. python图像加密_图像加密注释的Python实现,笔记,python
  14. 2023年计算机考研需要考哪些科目?
  15. jsp + servlet 通过a 标签下载文件
  16. ByteBuffer常用方法与分析
  17. 中科大软件学院硕士:实习秋招百多轮面试总结(上)
  18. 获取A2B控制数据方法
  19. Ubuntu apt、pip离线安装包
  20. ARM64启动过程分析

热门文章

  1. 每日一皮:美丽的背后都妙不可言...
  2. RabbitMQ 的这些骚操作你知道吗?
  3. 25个面试中最常问的问题和答案
  4. 分数等级_志愿填报丨填报公办普通高中志愿,分数成绩和等级成绩均需关注
  5. linux添加理由,让大家使用Linux的6个理由
  6. YOLOv5-Lite 使用笔记
  7. png图片压缩原理解析
  8. python读取红外图
  9. ATSS EfficientDet
  10. There was a problem confirming the ssl certificate