free -m | awk '/Swap/ {print $4}'

free swap

simple way to show free swap
Sample Output
2979

-2
By: voyeg3r
2009-09-02 11:46:17

These Might Interest You

  • Report memory and swap space utilization statistics e.g. memory free/used, swap free/used


    -2
    sar -r
    sharfah · 2009-05-19 11:47:38 2
  • free swap


    0
    free -b | grep "Swap:" | sed 's/ * / /g' | cut -d ' ' -f2
    opexxx · 2009-09-02 07:16:34 0
  • When you run a memory intensive application (VirtualBox, large java application, etc) swap area is used as soon as memory becomes insufficient. After you close the program, the data in swap is not put back on memory and that decreases the responsiveness. Swapoff disables the swap area and forces system to put swap data be placed in memory. Since running without a swap area might be detrimental, swapon should be used to activate swap again. Both swapoff and swapon require root privileges.


    10
    swapoff -a ; swapon -a
    alperyilmaz · 2009-03-25 03:30:41 0
  • A short way to give us relevant report in a moment done about quantities on disk usage, memory and swap in our Linux Systems. Show Sample Output


    -9
    alias dfr='df;free'
    ximo88 · 2009-04-28 11:30:31 0
  • Here we instead show a more real figure for how much free RAM you have when taking into consideration buffers that can be freed if needed. Unix machines leave data in memory but marked it free to overwrite, so using the first line from the "free" command will mostly give you back a reading showing you are almost out of memory, but in fact you are not, as the system can free up memory as soon as it is needed. I just noticed the free command is not on my OpenBSD box. Show Sample Output


    3
    free -m | awk '/buffer/ {print $4}'
    DaveQB · 2010-06-27 23:30:27 3
  • In addition to a swap partition, Linux can also use a swap file. Some programs, like g++, can use huge amounts of virtual memory, requiring the temporary creation of extra space.


    8
    dd if=/dev/zero of=/swapfile bs=1M count=64; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile
    starchox · 2009-02-16 18:36:38 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?

commandlinefu.com 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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: