简体   繁体   中英

How to find unix/linux sytem info using java or shell script?

How to find unix/linux system info like OS version, RAM, no. of processors, hard disk, memory dedicated to a particular process, memory utilization of java using java or shell scripts.

To find the version of the kernel, use uname -r in a shell script. All kinds of information regarding the hardware can be retrieved from the files in /proc .

/proc/cpuinfo contains information about the CPU's, including their number. /proc/meminfo shows the total physical memory, free memory, etc.

If you only want to fetch a particular field, you can filter the output like this:

cat /proc/cpuinfo | grep "model name"

df shows you all of the mounted storage devices and their used space.

/proc/PID/status shows the amount of virtual memory dedicated to the process, where PID is the numeric process id.

Have a look at sysinfo.sh for a starter - it's easy to extend with your own modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM