linux cmd

linux cmd misc

check kernel config on board

cat /proc/config.gz | gunzip

ps(show the command)

ps -a -ubuild -o pid,ppid,stat,command
PID PPID STAT COMMAND
17009 1 Ds -bash
17065 1 D ls --color=tty -al
17577 1 D /usr/java/jdk1.5.0_17/bin/java -Xmx512m -classpath /usr/local/a
17629 1 D /usr/java/jdk1.5.0_17/bin/java -Xmx512m -classpath /usr/local/a

console:/ # ps -eo uid,pid,ppid,pri,rtprio,ni,time,comm,cmd
UID PID PPID PRI RTPRIO NI TIME COMM CMD
0 1 0 19 - 0 00:00:02 init init
0 2 0 19 - 0 00:00:00 2 kthreadd

sort,以一行中的某列数字大小排序

console:/proc/4219 # pmap 4219 |sort -k2,2nr |head -n 10
total 5093020K
00000074c31f0000 2093396K r---- [anon:cfi shadow]
00000074665aa000 1048576K ----- [anon:libwebview reservation]
0000000076475000 524288K rw--- [anon:dalvik-free list large object space]
00000000277c0000 372992K rw--- [anon:dalvik-main space (region space)]
00000000725c7000 55996K ----- [anon:dalvik-non moving space]
0000000096475000 32768K rw--- [anon:dalvik-zygote-data-code-cache]
0000000098475000 32768K r---- [anon:dalvik-zygote-jit-code-cache]
000000009a475000 32768K rw-s- /memfd:/jit-cache (deleted)
000000009c475000 32768K r-xs- /memfd:/jit-cache (deleted)

上述-k代表以第二列来排序,n代表以数字来排序,r表示以相反的顺序来排。

 ps -o option help

Command line field types:

  ARGS    CMDLINE minus initial path     CMD     Thread name (/proc/TID/stat:2)
  CMDLINE Command line (argv[])          COMM    EXE filename (/proc/PID/exe)
  COMMAND EXE path (/proc/PID/exe)       NAME    Process name (PID's argv[0])

Process attribute field types:

  S       Process state:
          R (running) S (sleeping) D (device I/O) T (stopped)  t (trace stop)
          X (dead)    Z (zombie)   P (parked)     I (idle)
          Also between Linux 2.6.33 and 3.13:
          x (dead)    K (wakekill) W (waking)

  SCH     Scheduling policy (0=other, 1=fifo, 2=rr, 3=batch, 4=iso, 5=idle)
  STAT    Process state (S) plus:
          < high priority          N low priority L locked memory
          s session leader         + foreground   l multithreaded
  %CPU    Percentage of CPU time used    %MEM    RSS as % of physical memory
  %VSZ    VSZ as % of physical memory    ADDR    Instruction pointer
  BIT     32 or 64                       C       Total %CPU used since start
  CPU     Which processor running on     DIO     Disk I/O
  DREAD   Data read from disk            DWRITE  Data written to disk
  ELAPSED Elapsed time since PID start   F       Flags 1=FORKNOEXEC 4=SUPERPRIV
  GID     Group ID                       GROUP   Group name
  IO      Data I/O                       LABEL   Security label
  MAJFL   Major page faults              MINFL   Minor page faults
  NI      Niceness (static 19 to -20)    PCY     Android scheduling policy
  PGID    Process Group ID               PID     Process ID
  PPID    Parent Process ID              PR      Prio Reversed (dyn 39-0, RT)
  PRI     Priority (dynamic 0 to 139)    PSR     Processor last executed on
  READ    Data read                      RES     Short RSS
  RGID    Real (before sgid) Group ID    RGROUP  Real (before sgid) group name
  RSS     Resident Set Size (DRAM pages) RTPRIO  Realtime priority
  RUID    Real (before suid) user ID     RUSER   Real (before suid) user name
  SHR     Shared memory                  STIME   Start time (ISO 8601)
  SWAP    Swap I/O                       SZ      4k pages to swap out
  TCNT    Thread count                   TID     Thread ID
  TIME    CPU time consumed              TIME+   CPU time (high precision)
  TTY     Controlling terminal           UID     User id
  USER    User name                      VIRT    Virtual memory size
  VSZ     Virtual memory size (1k units) WCHAN   Wait location in kernel
  WRITE   Data written   

快速创建大文件cmd

fallocate -l 1G test_big.bin   #创建一个1G的大文件test_big.bin 

truncate -s 100M test_big.bin #调整test_big.bin的大小到100M

上述两个cmd因为并没有将数据持久化,所以没有IO,所以会立即完成

sed d option

匹配一个关键字并将这个关键所在的行删除

sed -i /"[wlan]"/ test.txt

-i选项表示直接在输入文件上操作,将命令执行后的结果写入输入文件

原文地址:https://www.cnblogs.com/aspirs/p/12631884.html