What is equivalent of Linux's 'free' command on FreeBSD v8.1 [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
What is equivalent of Linux's 'free' command on FreeBSD v8.1?
I am calling 'free' from my application and reporting the results in my application's log file. What would be the replacement when porting to FreeBSD v8.1?
Here is a sample run of 'free' on Linux:
[centos4x32 ~] free
total used free shared buffers cached
Mem: 774452 733044 41408 0 98040 328880
-/+ buffers/cache: 306124 468328
Swap: 2031608 224 2031384

vmstat has default output which is similar in nature and takes many options that give extremely detailed information, eg vmstat -m
swapinfo would cover the swap part
top -d1 causes top to print one screen and exit, and the banner is very similar to free. Use top -d1 | head -n 7 to see only the banner

Maybe freecolor command is a choice. Install it:
# cd /usr/ports/sysutils/freecolor
# make install clean
Use it:
# freecolor
Physical : [#################################..] 94% (1907820/2018396)
Swap : [###################################] 100% (1048540/1048540)
# freecolor -m -o
total used free shared buffers cached
Mem: 1971 107 1863 0 0 0
Swap: 1023 0 1023
Please refer FreeBSD find out RAM size Including Total Amount of Free and Used Memory Size.

vmstat -s gives some more human-readable or script-parseable information, including listing the page size. Otherwise, it gives output in numbef of pages. With no options, vmstat gives a brief summary.
The vmstat command also exists on NetBSD.

just use old good htop
install htop
pkg install htop
to run
htop

Other option:
# vmstat fre
procs memory page faults cpu
r b w avm fre flt re pi po fr sr in sy cs us sy id
0 0 0 13475M 24M 689 1 2 0 344 394 14693 37734 60809 7 43 50

You can use this script.
# fetch http://www.cyberciti.biz/files/scripts/freebsd-memory.pl.txt
# mv freebsd-memory.pl.txt /usr/local/bin/free
# chmod +x /usr/local/bin/free
source: http://www.cyberciti.biz/faq/freebsd-command-to-get-ram-information/

Related

How can I deliberately reduce free memory in linux by a given amount? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am looking for a quick and dirty way to analyze how a memory intensive third party application behaves under reduced memory conditions and determine a "minimum viable free memory" threshold.
you#yours:~$ free
total used free shared buffers cached
Mem: 993M 879M 113M 1.1M 15M 116M
you#yours:~$ hogMem 100 &
you#yours:~$ free
total used free shared buffers cached
Mem: 993M 979M 13M 1.1M 15M 116M
you#yours:~$ date; runTheThing; date;
you#yours:~$ fg
you#yours:~$ ^C
you#yours:~$ free
total used free shared buffers cached
Mem: 993M 879M 113M 1.1M 15M 116M
In the above, what could I use for hogMem?
I hope to do it with existing commands, without getting into a complicated programming problem. Googling this issue gets me 1,000s of pages about how to get more free memory, not less.
Update 2016/04/28 :
So, I found a super convenient way to do this, thanks to the hint by #Cyrus
you#yours:~$ sudo mkdir -p /media/temporary_ram_disk
you#yours:~$ sudo mount -t tmpfs -o size=2048M tmpfs /media/temporary_ram_disk/
you#yours:~$ sudo chown you:you /media/temporary_ram_disk/
you#yours:~$ cd /media/temporary_ram_disk/
you#yours:/media/temporary_ram_disk$ free -h
total used free shared buffers cached
Mem: 993M 879M 113M 1.1M 15M 116M
you#yours:/media/temporary_ram_disk$ fallocate -l 100M empty_file_100M
you#yours:/media/temporary_ram_disk$ ls -l
total 5120
-rw-r--r-- 1 you you 5242880 Apr 28 12:05 empty_file_100M
you#yours:/media/temporary_ram_disk$ free -h
total used free shared buffers cached
Mem: 993M 879M 13M 1.1M 15M 116M
So the hogMem I'm using is in fact fallocate !
Probably the best way to see "how a memory intensive third party application behaves under reduced memory conditions," is to run it under reduced memory conditions. On linux, this is easily done with prlimit.
For example, to see how date runs with its address space limited to 1,000,000 bytes, run:
$ prlimit -v1000000 date
Segmentation fault
To see how it runs with its address space limited to 10,000,000 bytes, run:
$ prlimit -v10000000 date
Wed Apr 27 12:00:13 PDT 2016
It is also possible to limit the target program's access to many other resources. For example the maximum number of open files or the maximum CPU time can also be limited.
prlimit is included in the util-linux package. For more details on its operation, see man prlimit.

debian wget cannot fork [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
wget not working on my debian server from now:
wget http://anydomain.hu/anyimage.png
/usr/local/bin/wget: 3: /usr/local/bin/wget: Cannot fork
running "top" command:
Tasks: 89 total, 1 running, 88 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1,0 us, 0,0 sy, 0,0 ni, 99,0 id, 0,0 wa, 0,0 hi, 0,0 si, 0,0 st
KiB Mem: 1017080 total, 64316 used, 952764 free, 2264 buffers
KiB Swap: 1675260 total, 42488 used, 1632772 free, 22564 cached
i don't know what's the problem pls help me
Have you tried to reinstall wget? If not try apt-get install --reinstall wget
and try again to download anything.
The wget command is normally in /usr/bin. Since yours is in /usr/local/bin, it appears you've installed a different command with the same name.
And given that the error message appears to include a line number, I'm guessing that your /usr/local/bin/wget is a shell script that's intended to be a wrapper around the standard wget command.
For example, if you had something like:
#!/bin/bash
wget -q "$#"
because you want to turn off wget's output, then your script will invoke itself recursively. After some number of iterations it will be unable to fork a new process, and it will terminate.
If so, changing the script to invoke /usr/bin/wget explicitly should fix it.

Limit top command to only display top X processes on command line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 12 months ago.
The community reviewed whether to reopen this question 12 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I'm not sure why there is not an option in the top command that does this, as it seems to be a natural request.
If I pipe the output of top to head, then the list doesn't update and I get static output once. I could then bring the watch command into action, which would do the job. But, is there a simpler solution?
I use a trick, specially for batch mode. I pipeline the exit to grep, with option "-A", to show N lines after match.
As in the first line of top there is something like: "load average", I grep that, for instance:
$ top -d 5 -b|grep "load average" -A 15
top - 09:42:34 up 38 min, 1 user, load average: 0.22, 0.39, 0.53
Tasks: 294 total, 2 running, 291 sleeping, 0 stopped, 1 zombie
%Cpu(s): 3.5 us, 0.9 sy, 0.0 ni, 94.6 id, 0.5 wa, 0.3 hi, 0.1 si, 0.0 st
KiB Mem : 8065144 total, 2213800 free, 2733524 used, 3117820 buff/cache
KiB Swap: 24575996 total, 24575996 free, 0 used. 4613128 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2744 lrojas 20 0 3376820 752000 116588 R 20.2 9.3 9:30.01 firefox
1869 lrojas 9 -11 566164 18336 14300 S 5.2 0.2 2:35.78 pulseaudio
2401 lrojas 20 0 740092 200456 87256 S 2.4 2.5 0:57.29 skype
2402 lrojas 20 0 617872 172924 76172 S 2.2 2.1 0:57.17 skype
1333 root 20 0 459028 60992 48024 S 1.6 0.8 0:36.14 Xorg
1838 lrojas 20 0 2103336 184468 64724 S 1.4 2.3 0:56.85 gnome-shell
2359 lrojas 20 0 741212 35068 24620 S 1.4 0.4 0:06.83 gnome-terminal-
2404 lrojas 20 0 1867556 229912 83988 S 0.8 2.9 0:19.63 thunderbird
1249 apache 20 0 461436 10196 3404 S 0.4 0.1 0:00.57 httpd
This way it will continue in batch mode, always showing only the first N lines of output.
Completely standard solution, for any version of top.
> top
then, press n to set maximum tasks displayed.
When operating top, one of the most important key is help (h or ?) to see the available options (n is given in help).
UPDATE (after the the comment):
PERSONAL Configuration File might help for the batch mode. Run top then set the maximum tasks displayed with n and use the W interactive command to create or update the configuration file. top will be ran according to the configuration file next time.
Perhaps you should add the -b parameter which runs top in the batch mode: watch -n 5 'top -b -d 5 | head -n 10'
You can make config file for top (for example: run top command in interactive mode, then press "n" and write limit for number of processes, then press "W" to save this in your configuration file).
In the next step, you can run top in batch mode; parameter in config file limits output to requested value. So, then simple:
top -b > top.log
will be enough.
The solution for MAC is :
top -a -n20 | awk 'FNR>=11 && FNR<=31{print $0};FNR==31{exit}' > cpustat.txt

No space left on device [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am getting the error "No space left on device" when i tried to scp some files to a centos machine,
tried to check:
[root#...]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol01 18G 18G 0 100% /
And when I do
du -sh / -> it gives only 5G
[... ~]$ df -i /
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/VolGroup00-LogVol01
4685824 209516 4476308 5% /
seems like file system is full.
How can i find which one is taking these much size?
Such difference between the output of du -sh and df -h may happen if some large file has been deleted, but is still opened by some process. Check with the command lsof | grep deleted to see which processes have opened descriptors to deleted files. You can restart the process and the space will be freed.
Maybe you are out of inodes. Try df -i
2591792 136322 2455470 6% /home
/dev/sdb1 1887488 1887488 0 100% /data
Disk used 6% but inode table full.
To list processes holding deleted files a linux system which has no lsof, here's my trick:
pushd /proc ; for i in [1-9]* ; do ls -l $i/fd | grep "(deleted)" && (echo -n "used by: " ; ps -p $i | grep -v PID ; echo ) ; done ; popd
You can execute the following commands
lsof / |grep deleted
kill the process id's, which free up the disk space.

create a virtual floppy image without mount? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
There are a lot of posts to show to create a virtual floppy image file as a super user or users can run sudo command. The basic steps are:
create empty 1.44MB image file by dd command
format the image file by mkfs.msdos
mount the image file to some mount point
copy something to the mount point
umount the virtual floppy image file
my question is, in case I am just a common user who cannot run sudo command, how can I follow above steps to create a virtual floppy image and write something in it?
Thanks a lot.
Yes, of course you can do this. Use mtools for the FAT and e2tools or genext2fs for the ext2 filesystems.
$ dd if=/dev/zero of=/tmp/disk1.img count=1440 bs=1k
1440+0 records in
1440+0 records out
1474560 bytes (1.5 MB) copied, 0.00569719 s, 259 MB/s
$ /sbin/mkfs.msdos /tmp/disk1.img
mkfs.msdos 3.0.12 (29 Oct 2011)
$ mdir -i /tmp/disk1.img
Volume in drive : has no label
Volume Serial Number is 9913-BFF6
Directory for ::/
No files
1 457 664 bytes free
$ mcopy -i /tmp/disk1.img /etc/issue.net ::/
$ mdir -i /tmp/disk1.img
Volume in drive : has no label
Volume Serial Number is 9913-BFF6
Directory for ::/
issue net 28 2012-06-26 10:49
1 file 28 bytes
1 457 152 bytes free
And of course, I have no root rights.

Resources