How to find swap space and usage in Solaris? Swap Command Example

Swap space in Solaris or any UNIX host is a vital disk space that is used for the swapping process from physical memory (RAM)  to disk. Virtual memory allows a process to run even if physical memory gets full by using swap space (which is located on your hard disk) to swap out memory pages that are not currently in use. This is a very important concept which every programmer and Linux user should know. It is even more important if you are working in IT support or as a system admin because if swap space is full then swapping will fail and no new process will be able to start. 

In this UNIX command tutorial, we will see some Solaris commands to find configured and current usage of swap space. Remember if your machine runs out of swap space then you can not start a new process and also an old process that will try to expand itself will likely fail. 

Another interesting point about swap space is that every process reserved swap space, equivalent to its physical memory requirement so that it can swap out completely when required. Which means current usage of swap space denotes total memory used by all process at that time. 

This UNIX command tutorial is next in our series of articles like UNIX command to find links, grep command examples in UNIX, and  10 most popular Linux Interview questions, if you haven't check them then you should check them to learn essential Linux commands and interview questions. 




Solaris command to find Swap memory

Here is an example of the Solaris “swap” command to find how much swap memory is left on the server. Remember if your host runs out of swap you can not start a new process, so be careful with how much swap space you set, and your process doesn’t eat all swap memory available in Solaris host.

And, if you need a refresher about virtual memory in Linux, Linux System Programming Techniques & Concepts course on Udemy has two wonderful chapters on virtual memory. 

How to find swap space and usage in Solaris - UNIX command



Anyway, here is the output of the swap command with both swap -l and swap -s options to see how much swap space is left in the machine:

test ~ $ swap -l
swapfile             dev  swaplo blocks   free
/dev/sd/dsk/swap 181,2       8 134217720 134217720

test ~ $ swap -s
total: 22189856k bytes allocated + 8594616k reserved = 30784472k used, 80563112k available


That’s all on how to find swap space usage in Solaris or How much swap space is used currently, how much swap space is available now etc. There are a couple of more Solaris commands which display information about swap space, like vminfo and sar.  

You can further check The Linux Command Line: A Complete Introduction to learning more about useful commands like viminfo and sar


How to find swap space in Solaris - command


You can also look on the internet on How to use them to find swap space and then cross-check with the output of the swap command. By the way, I always prefer the swap command to find swap usage in the Solaris operating system.


Other Linux Articles and Resources you may like
  • Top 5 Courses to learn Vim Editor (online courses)
  • VI Editor examples and tips for beginners (vi examples)
  • How to set up cron jobs in Linux (Crontab example)
  • 10 example of Networking commands in Unix (nslookup)
  • 5 Example of kill commands in Unix and Linux (example)
  • 10 examples of lsof command in Linux? (examples)
  • 7 Best Linux Courses for DevOps Engineers (Linux courses)
  • How to use the netstat command to find which process is listening on a port? (example)
  • Linux find + du + grep example (example)
  • 10 Linux command line courses for Beginners (courses)
  • How does the nslookup command work in UNIX? (answer)
  • 10 Examples of curl command in Linux (cURL)
  • 10 Examples of chmod command in Linux (chmod)
  • A Practical Guide to Linux Commands, Editors, and Shell Programming (guide)

Thanks for reading this article so far. If you like this Linux tutorial and my explanation of swap space then please share it with your friends and colleagues.

P. S. - If you are looking for some free online courses to start your Linux journey, you should check out my list of Free Linux Courses for Programmers, Cloud Engineers, Data scientists,  IT Professionals, and System Administrators.

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.