Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
4
votes
1
answers
3729
views
Why is ncdu reporting different data from df?
`df -h` prints: ``` Filesystem Size Used Avail Use% Mounted on /dev/root 59G 6.6G 50G 12% / devtmpfs 1.8G 0 1.8G 0% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 2.0G 9.0M 1.9G 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/mmcblk0p1 253M 54M 199M 22% /boot tmpfs 391M...
df -h
prints:
Filesystem Size Used Avail Use% Mounted on
/dev/root 59G 6.6G 50G 12% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 9.0M 1.9G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 54M 199M 22% /boot
tmpfs 391M 0 391M 0% /run/user/1000
while ncdu /
prints:
Total disk usage: 1.8 GiB Apparent size: 1.8 GiB Items: 176500
Why is one reporting 6.6+ GiB used while the other reports only 1.8 GiB
?
Iulian Onofrei
(176 rep)
Mar 29, 2020, 06:54 PM
• Last activity: Apr 2, 2024, 07:00 PM
5
votes
2
answers
1631
views
On Screen Protractor
A handy program for measuring the pixel dimensions of something on-screen is screen ruler: sudo apt install screenruler ; screenruler I like how you can place it anywhere on your screen and it stays on top of all other applications as you use it. I'm hoping to find something similar to this that's a...
A handy program for measuring the pixel dimensions of something on-screen is screen ruler:
sudo apt install screenruler ; screenruler
I like how you can place it anywhere on your screen and it stays on top of all other applications as you use it.
I'm hoping to find something similar to this that's a protractor instead of a ruler.
I searched for "protractor" in the repository of Debian 11 and got no results:
sudo apt-cache search "protractor"
Such a tool would be great for measuring angles on-screen. However, ultimately, I will likely need something that can actually draw a line based on a specified angle.
Hopefully I won't have to learn something as sophisticated as AutoCad in order to accomplish this. What's the simplest way to measure and draw angles in Linux?
Lonnie Best
(5415 rep)
Nov 15, 2022, 03:58 PM
• Last activity: Jun 12, 2023, 11:09 AM
1
votes
1
answers
435
views
How to measure how long linux takes to shutdown
I need to calculate how long linux takes to shutdown. I am running an embedded busybox linux on ARM i.MX7. I looked in `/var/volatile/log/messages` but that only shows the last startup. I need to know how long the system takes to shutdown after eg `shutdown -h -P now`. How can I get a reasonably pre...
I need to calculate how long linux takes to shutdown. I am running an embedded busybox linux on ARM i.MX7. I looked in
/var/volatile/log/messages
but that only shows the last startup. I need to know how long the system takes to shutdown after eg shutdown -h -P now
.
How can I get a reasonably precise measurement?
arcomber
(284 rep)
Jun 7, 2022, 07:08 AM
• Last activity: Jun 8, 2022, 02:18 PM
58
votes
5
answers
42567
views
Measuring RAM usage of a program
`time` is a brilliant command if you want to figure out how much CPU time a given command takes. I am looking for something similar that can measure the max RAM usage of the program and any children. Preferably it should distinguish between allocated memory that was used and unused. Maybe it could e...
time
is a brilliant command if you want to figure out how much CPU time a given command takes.
I am looking for something similar that can measure the max RAM usage of the program and any children. Preferably it should distinguish between allocated memory that was used and unused. Maybe it could even give the median memory usage (so the memory usage you should expect when running for a long time).
So I would like to do:
rammeassure my_program my_args
and get output similar to:
Max memory allocated: 10233303 Bytes
Max memory used: 7233303 Bytes
Median memory allocation: 5233303 Bytes
I have looked at memusg
https://gist.github.com/526585/590293d6527c91e48fcb08edb8de9fd6c88a6d82 but I regard that as somewhat a hack.
Ole Tange
(37348 rep)
Aug 16, 2011, 02:18 PM
• Last activity: May 5, 2022, 05:47 AM
14
votes
1
answers
2962
views
Measuring disk I/O usage of a program
`time` is a brilliant command if you want to figure out how much CPU time a given command takes. I am looking for something similar that can measure the disk I/O of the program and any children. Preferably it should distinguish between I/O that was cached (and thus did not cause the disk to spin) an...
time
is a brilliant command if you want to figure out how much CPU time a given command takes.
I am looking for something similar that can measure the disk I/O of the program and any children. Preferably it should distinguish between I/O that was cached (and thus did not cause the disk to spin) and I/O that was not cached.
So I would like to do:
iomeassure my_program my_args
and get output similar to:
Cached read: 10233303 Bytes
Cached write: 33303 Bytes # This was probably a tmp file that was erased before making it to the disk
Non-cached read: 200002020 Bytes
Non-cached write: 202020 Bytes
I have looked at vmstat
, iostat
, and sar
, but none of these are looking at a single process. Instead they look at the whole system.
I have looked at iotop
, but that only gives me a view this instant.
--- edit ---
snap's answer seems close.
'File system inputs:' is the non-cached reads in 512-byte blocks.
'File system outputs:' is the cached writes in 512-byte blocks.
You can force the cache empty with:
sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
I tested with:
seq 10000000 > seq
/usr/bin/time -v bash -c 'perl -e "open(G,\">f\"); print G ;close G; unlink \"f\";" seq'
Ole Tange
(37348 rep)
Aug 16, 2011, 02:11 PM
• Last activity: Oct 25, 2020, 04:17 PM
4
votes
1
answers
1307
views
Is "top" accounting for Kernel Interrupts?
I have a simple interrupt that is triggered by a GPIO-input. The IRQ only increments a variable and returns. When I turn the frequency of the interrupts up to somewhere around 10-20 kHz, the system becomes unresponsive. I measure the CPU-load using `top` while turning the frequency up, but there is...
I have a simple interrupt that is triggered by a GPIO-input. The IRQ only increments a variable and returns. When I turn the frequency of the interrupts up to somewhere around 10-20 kHz, the system becomes unresponsive. I measure the CPU-load using
top
while turning the frequency up, but there is no significant change in any of the metrics from the top
command.
So the processor CPU gets loaded, but I can't measure it with top
!
How is top
making its measurement? How come the very frequent interrupt isn't visible?
**How can I measure the impact the interrupt has on the overall performance of the system?**
**EDIT**
By setting the CPU-frequency governor to "performance", and setting the frequency to static 1GHz, I was able to get the interrupt frequency up to 150kHz, before the processor crashed..
Wiingaard
(141 rep)
Nov 13, 2015, 03:44 PM
• Last activity: Jul 10, 2019, 07:01 PM
-1
votes
1
answers
76
views
How do I check how much RAM a process consumes like the way `time` is used to measure the elapsed time?
How do I check the maximum amount a RAM a process uses similar to how `time` works? $ time mvn package real 0m35.796s user 0m32.925s sys 0m1.559s $ maxmem mvn package 688 MB
How do I check the maximum amount a RAM a process uses similar to how
time
works?
$ time mvn package
real 0m35.796s
user 0m32.925s
sys 0m1.559s
$ maxmem mvn package
688 MB
Chloe
(538 rep)
Feb 4, 2019, 08:19 PM
• Last activity: Feb 4, 2019, 09:55 PM
1
votes
1
answers
938
views
How to measure disk and network IO more frequently than a second?
I am running some experiments that use cpu, disk, and network resources. (by the way, I use Cent OS 7) I want to measure its cpu, disk, and network resource usage. Some tools I know (dstat, iostat) only provides a second as the minimum interval between two measurements. How can I take several measur...
I am running some experiments that use cpu, disk, and network resources.
(by the way, I use Cent OS 7)
I want to measure its cpu, disk, and network resource usage.
Some tools I know (dstat, iostat) only provides a second as the minimum interval between two measurements.
How can I take several measurements even within a second?
I googled a lot but couldn't find one.
Thanks
syko
(695 rep)
Jul 1, 2017, 02:55 PM
• Last activity: Jul 2, 2017, 04:10 AM
4
votes
1
answers
1134
views
How to output process stats after completion?
I would like to run a process from `bash` in Cygwin so that I have some short summary after execution like peak memory usage or average CPU usage, like `time` but with more information. Are there any options?
I would like to run a process from
bash
in Cygwin so that I have some short summary after execution like peak memory usage or average CPU usage, like time
but with more information.
Are there any options?
Euri Pinhollow
(231 rep)
Feb 19, 2017, 09:04 AM
• Last activity: Feb 19, 2017, 06:00 PM
1
votes
0
answers
20
views
Measuring, how much power the wireless connection takes
In theory, disabling the wireless connection on my laptop should improve the overall battery life. In fact the battery consumption is a complex process; when I tried to measure, how longer life I could achieve by disabling wireless, I paradoxically got a lower result. Is there any way to measure how...
In theory, disabling the wireless connection on my laptop should improve the overall battery life.
In fact the battery consumption is a complex process; when I tried to measure, how longer life I could achieve by disabling wireless, I paradoxically got a lower result.
Is there any way to measure how much battery juice is given to the network card when wireless is off? Does the wireless off mean that the network card takes absolutely no power?
I'm mainly interested in finding out that
wireless uses x % of the overall power consumption
, but other forms of the result are appreciated too.
marmistrz
(2792 rep)
Sep 21, 2016, 07:47 PM
2
votes
1
answers
655
views
performance comparison of multiple commands excutions
I've got three different programs written in three different languages, and I'm trying to compare their performance in terms of runtime, and memory consumption. What I'm looking for is some command that looks something like: $ SOMETHING (python test.py) $ SOMETHING (ghc -o test test.hs; ./test) $ SO...
I've got three different programs written in three different languages, and I'm trying to compare their performance in terms of runtime, and memory consumption. What I'm looking for is some command that looks something like:
$ SOMETHING (python test.py)
$ SOMETHING (ghc -o test test.hs; ./test)
$ SOMETHING (gcc -o test test.c; ./test)
the reason for this is that I want to have a unified Unix(y) way of looking at the performance results of these programs as oppose to using the profiling tools in these different languages.
I'd like also to know what are some other general/essential criteria software professionals measure beside runtime and memory consumption to get some useful stat out of these programs. Thank you
7kemZmani
(121 rep)
Jul 18, 2016, 03:20 PM
• Last activity: Jul 18, 2016, 04:18 PM
0
votes
1
answers
186
views
I want to measure the time between two jobs in a logfile
I have a logfile which name/directory is: `/srv/uni/kani/LogDay.09-03-2016` The name of the logfile changes date every day. So tomorrow will be: `LogDay.10-03-2016' and so on... I would like help to create a script who looks through that file and finds this line: 08-03-2016 19:00:01 b5121 DISPLAY ID...
I have a logfile which name/directory is:
/srv/uni/kani/LogDay.09-03-2016
The name of the logfile changes date every day. So tomorrow will be: `LogDay.10-03-2016' and so on...
I would like help to create a script who looks through that file and finds this line:
08-03-2016 19:00:01 b5121 DISPLAY ID(IP[RANDOMIPADRESS] PID) MSG[BEGIN JOB /srv/uni/PROD/PNRUN/PN4949D
and measures the time in minutes until this job is written in the log:
08-03-2016 19:19:17 b7285 DISPLAY ID(IP[RANDOMIPADRESS] JOB[FO1008] PID) MSG[END JOB /srv/uni/PROD/PNRUN/FO1008D, , 27392]
There is alot of other lines in the log.. with other jobs saying BEGIN job and END job and so on. But its those 2 specific i want to measure the time between.
I would like to use this script at the end of the evening to see how long all the jobs took totally. Instead of having to go in the log and count manually...
And I want to put it in a bash script :)
I would like the output to say something like.
Tonights work took totally X hour X minutes.
Can anyone help me with that?
David
(1 rep)
Mar 9, 2016, 03:05 PM
• Last activity: Mar 10, 2016, 08:47 PM
4
votes
1
answers
1610
views
How can I make fullscreen cross hairs appear centered on the pointer?
How can I make fullscreen crosshairs, centered on the mouse, appear on my screen? I read a lot of science papers with graphs that I want to quickly be able to see what feature is horizontal/vertical with another feature. I'm looking for something like the below screenshot of LibreCAD, but for the en...
How can I make fullscreen crosshairs, centered on the mouse, appear on my screen? I read a lot of science papers with graphs that I want to quickly be able to see what feature is horizontal/vertical with another feature.
I'm looking for something like the below screenshot of LibreCAD, but for the entire screen.
I searched the repositories with
$ apt-cache search cross | grep hair
amongst other attempts, and wasn't able to find anything.

user1717828
(3592 rep)
Feb 18, 2016, 07:48 PM
• Last activity: Feb 19, 2016, 12:37 AM
2
votes
2
answers
2877
views
Resource usage (% CPU) for given command on OS X
The `time -v` command outputs _% CPU utilization_ for a given command on Linux. How do I do this on OS X? The Linux/OS X difference is illustrated [here][1]. I would like to measure multi-core utilization across the total execution period of a short-running program, so `top` probably wouldn't work,...
The
time -v
command outputs _% CPU utilization_ for a given command on Linux. How do I do this on OS X? The Linux/OS X difference is illustrated here . I would like to measure multi-core utilization across the total execution period of a short-running program, so top
probably wouldn't work, as it measures/averages at particular points in time.
user12719
(121 rep)
Jan 5, 2016, 06:59 PM
• Last activity: Jan 11, 2016, 05:22 PM
2
votes
1
answers
1439
views
How do I measure the RAM usage of desktop environments?
I would like to measure the RAM usage of several desktop environments (including Cinnamon, GNOME, KDE, LXDE, LXQt, MATE and Xfce) running on my Sabayon machine. I would prefer a command-line way of checking RAM usage, if possible. I have tried using this [ps_mem.py](https://github.com/pixelb/ps_mem/...
I would like to measure the RAM usage of several desktop environments (including Cinnamon, GNOME, KDE, LXDE, LXQt, MATE and Xfce) running on my Sabayon machine. I would prefer a command-line way of checking RAM usage, if possible. I have tried using this [ps_mem.py](https://github.com/pixelb/ps_mem/) script (by running
python ps_mem.py -p Cinnamon
for Cinnamon, for example) but unfortunately it requires PIDs for programs and will not simply accept the name of the DE and I'm not sure which programs belong to my DE and which do not.
Josh Pinto
(3533 rep)
Sep 28, 2015, 07:16 PM
• Last activity: Sep 28, 2015, 08:17 PM
1
votes
1
answers
175
views
Measure the network traffic on a long-term basis
I'd like to find out how much network traffic my computer uses, i.e. whether a limit of 30GB of transfer wouldn't be too little. What's the best tool to measure it? Using Linux Mint 17
I'd like to find out how much network traffic my computer uses, i.e. whether a limit of 30GB of transfer wouldn't be too little. What's the best tool to measure it?
Using Linux Mint 17
marmistrz
(2792 rep)
Mar 3, 2015, 07:01 PM
• Last activity: Mar 3, 2015, 07:25 PM
0
votes
0
answers
246
views
How do I measure the amount of network traffic that passed my debian installation?
So my raspberry pi is acting as a Router and Web/Mail/FTP/SQL/Media/Clash of Clans/Home server right now and I'm looking for a way to monitor the consumed bandwidth, much like NetWorx for windows. I found some solutions (webmin's bandwidth monitoring) but it takes up too much space (several GB) and...
So my raspberry pi is acting as a Router and Web/Mail/FTP/SQL/Media/Clash of Clans/Home server right now and I'm looking for a way to monitor the consumed bandwidth, much like NetWorx for windows.
I found some solutions (webmin's bandwidth monitoring) but it takes up too much space (several GB) and CPU time. Can you recommend me something that only measures the current bandwidth speed and the amount of data that passed through, without using the logs? (Webmin's bandwidth monitoring turns on IPTables' packet logging then later analyzes the logs, which consumes too much disk space and CPU)
This is networx bandwidth summary
Networx average speed


Aloha
(2171 rep)
Feb 1, 2015, 04:12 AM
1
votes
1
answers
396
views
Random lag on connection
when i try to connect to my friend's server, the connection seems randomly laggy, sometimes it's 50ms, 40ms, 60ms, but sometimes it tooks 1, 3 or 7 seconds time curl -vv 'http://ipaddress/foo.json' * Hostname was NOT found in DNS cache * Trying ipaddress... --> SLOW AT THIS LINE !!! * Connected to i...
when i try to connect to my friend's server, the connection seems randomly laggy, sometimes it's 50ms, 40ms, 60ms, but sometimes it tooks 1, 3 or 7 seconds
time curl -vv 'http://ipaddress/foo.json '
* Hostname was NOT found in DNS cache
* Trying ipaddress... --> SLOW AT THIS LINE !!!
* Connected to ipaddress (ipaddress) port 80 (#0)
> GET /foo.json HTTP/1.1
> User-Agent: curl/7.37.0
> Host: ipaddress
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 24 Jun 2014 02:51:45 GMT
* Server Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4 is not blacklisted
< Server: Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4
< Last-Modified: Tue, 24 Jun 2014 02:42:12 GMT
< ETag: "2e8109e-871-4fc8be82affe4"
< Accept-Ranges: bytes
< Content-Length: 2161
< Content-Type: application/json
How could I know which part of the system that causes this?
I've tried to disable mod_bwlimited, but the lag still happened
I've tried to use another web server (monkey) on another port, it still happened
the server:
Linux bar 2.6.32-042stab090.3 #1 SMP Fri Jun 6 09:35:21 MSK 2014 x86_64 x86_64 x86_64 GNU/Linux
Also when I tried to change
/etc/sysctl.conf
and using sysctl -p
using root
:
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
fs.file-max = 524288
It shows:
error: permission denied on key 'net.ipv4.tcp_tw_recycle'
error: permission denied on key 'net.ipv4.tcp_tw_reuse'
error: permission denied on key 'fs.file-max'
Maybe that values was restricted by the hosting company?
Kokizzu
(10481 rep)
Jun 24, 2014, 02:58 AM
• Last activity: Jun 24, 2014, 12:40 PM
16
votes
2
answers
5174
views
How to detect if a disk is seeking?
I can use a variety of tools to measure the volume of disk I/O currently flowing through the system (such as `iotop` and `iostat`) but I'm curious if it's possible to easily detect if a disk is seeking a lot with only a small amount of I/O. I know it;s possible to extract this information using `blk...
I can use a variety of tools to measure the volume of disk I/O currently flowing through the system (such as
iotop
and iostat
) but I'm curious if it's possible to easily detect if a disk is seeking a lot with only a small amount of I/O.
I know it;s possible to extract this information using blktrace
and then decode it using btt
but these are somewhat unwieldy and I was hoping there was a simpler alternative?
Gearoid Murphy
(742 rep)
Aug 23, 2013, 01:38 PM
• Last activity: Aug 23, 2013, 04:56 PM
9
votes
1
answers
8833
views
How to measure an operation's duration in terminal, not in code
For example, I need to do "make " for some software. I want to measurement how long this is going take. Is there easy and accurate way to do so?
For example, I need to do "make " for some software.
I want to measurement how long this is going take.
Is there easy and accurate way to do so?
Anders Lind
(2525 rep)
Mar 7, 2012, 06:28 AM
• Last activity: Mar 7, 2012, 10:41 PM
Showing page 1 of 20 total questions