Pretty print all of the Linux vm sysctls for your viewing pleasure

find /proc/sys/vm -maxdepth 1 -type f | while read i ; do printf "%-35s\t%s\n" "$i" "$(<$i)" ; done | sort -t/ -k4
Sometimes you want to see all of the systcls for a given $thing. I happened to need to easily look at all of the vm sysctls between two boxes and compare them. This is what I came up with.
Sample Output
/proc/sys/vm/block_dump            	0
/proc/sys/vm/dirty_background_bytes	0
/proc/sys/vm/dirty_background_ratio	5
/proc/sys/vm/dirty_bytes           	0
/proc/sys/vm/dirty_expire_centisecs	3000
/proc/sys/vm/dirty_ratio           	10
/proc/sys/vm/dirty_writeback_centisecs	500
/proc/sys/vm/drop_caches           	0
/proc/sys/vm/hugepages_treat_as_movable	0
/proc/sys/vm/hugetlb_shm_group     	0
/proc/sys/vm/laptop_mode           	0
/proc/sys/vm/legacy_va_layout      	0
/proc/sys/vm/lowmem_reserve_ratio  	256	256	32
/proc/sys/vm/max_map_count         	65530
... snip ...

By: SEJeff
2012-05-25 16:34:16

These Might Interest You

  • From the manpage: man less -X or --no-init Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen. Bonus: If you want to clear the screen after viewing a file this way that had sensitive information, hit or just type clear. Since is readily available, I don't know why less bothers to automatically clear. If you're viewing the file at all, chances are you want to see the output from it after you quit. Show Sample Output

    less -X /var/log/insecure
    sonic · 2016-06-24 13:53:49 3
  • I've wanted this for a long time, finally just sat down and came up with it. This shows you the sorted output of ps in a pretty format perfect for cron or startup scripts. You can sort by changing the k -vsz to k -pmem for example to sort by memory instead. If you want a function, here's one from my aa_top_ps(){ local T N=${1:-10};T=${2:-vsz}; ps wwo pid,user,group,vsize:8,size:8,sz:6,rss:6,pmem:7,pcpu:7,time:7,wchan,sched=,stat,flags,comm,args k -${T} -A|sed -u "/^ *PID/d;${N}q"; } Show Sample Output

    command ps wwo pid,user,group,vsize:8,size:8,sz:6,rss:6,pmem:7,pcpu:7,time:7,wchan,sched=,stat,flags,comm,args k -vsz -A|sed -u '/^ *PID/d;10q'
    AskApache · 2010-05-18 18:41:38 1
  • Prints current runlevel and system start time. On older systems it also shows the last init state. Pretty useful on remote systems, pretty useless on local ones :) Show Sample Output

    who -r
    KoRoVaMiLK · 2010-05-05 12:58:09 1
  • pretty much the same. I use awk rather than grep and perl. It looks like the URL has been updated. The service tag can also be retrieved via snmp - potential for a for loop over a list of servers. I might have a look into doing an example. Show Sample Output

    curl -sL$(dmidecode -s system-serial-number) | html2text -style pretty | awk -F\. '/with an end date of/ { print $1 "."}'
    mhollick · 2013-07-30 14:46:12 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: