Reading entropy_avail file appears to consume entropy [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
The question have been asked in here http://www.gossamer-threads.com/lists/linux/kernel/1210167 but I don't see an answer.
AFAIK /proc/sys/kernel/random/entropy_avail should return the size of available entropy but should not consume it. At least I don't see any reason for that.
However, I have been noticing the same thing as OP for at least a year and now I executed in quick succession
% cat /proc/sys/kernel/random/entropy_avail
3918
% cat /proc/sys/kernel/random/entropy_avail
3447
% cat /proc/sys/kernel/random/entropy_avail
2878
% cat /proc/sys/kernel/random/entropy_avail
2377
% cat /proc/sys/kernel/random/entropy_avail
1789
% cat /proc/sys/kernel/random/entropy_avail
1184
% cat /proc/sys/kernel/random/entropy_avail
577
% cat /proc/sys/kernel/random/entropy_avail
161
% cat /proc/sys/kernel/random/entropy_avail
133
% cat /proc/sys/kernel/random/entropy_avail
171
a while later I did the same with the same result, so I'm pretty sure the depletion of entropy is caused by the cat command.
Can anyone explain why this happens?

Found an answer in here http://blog.flameeyes.eu/2011/03/entropy-broken
Starting a process consumes entropy

Related

How to log timestamp before every line in log? [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 3 years ago.
Improve this question
I want to log memory usage every 5th second and hence I am using free -s 5 -m> memory.log
How to add timestamp before every lie in this log?
Expected output:
Tue Jan 21 06:50:44 UTC 2020
total used free shared buffers cached
Mem: 7809 6268 1540 0 57 3497
-/+ buffers/cache: 2713 5095
Swap: 0 0 0
Tue Jan 21 06:50:49 UTC 2020
total used free shared buffers cached
Mem: 7809 6268 1540 0 57 3497
-/+ buffers/cache: 2713 5095
Swap: 0 0 0
I found out that there is no single line command to do that and this can be achieved by writing and executing a script.
So the shell script is:
#!/bin/bash -e
echo " date time $(free -m | grep total | sed -E 's/^ (.*)/\1/g')" >> /var/log/memory_utilisation.log
while true; do
echo "$(date '+%Y-%m-%d %H:%M:%S') $(free -m | grep Mem: | sed 's/Mem://g')" >> /var/log/memory_utilisation.log
sleep 5
done

Why is du command showing incorrect results [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 8 years ago.
Improve this question
The below output showing 21GB files each.
[root#myhost data]# ls -l
total 100092
-rw-rw---- 1 ora4 ora4 **22548586496** Dec 18 21:09 temp01.dbf
-rw-rw---- 1 ora4 ora4 **22548586496** Dec 18 19:38 temp02.dbf
But when i used du command, its shows only 49MB.
[root#myhost data]# du -sh *
49M temp01.dbf
49M temp02.dbf
Could you please let me know, how to correct the values.
execute the ls -lh ls -l. will display the size in the bytes. du -sh in du command you are mentioning the h for displaying the result in human readable format. If you check with the du it will display the output in kb(kilo bytes). Compare the results with ls -lh and du -sh *.

Piping stdout to specific location, Linux [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i hope you'll get my point here :)
without piping the command is:
aircrack-ng handshakes.cap -w wordlist.txt
redirecting crunch stdout to aircrack:
these commands are not working:
crunch 8 8 abc123 | aircrack-ng handshakes.cap -w -
crunch 8 8 abc123 | aircrack-ng handshakes.cap -w-
crunch 8 8 abc123 | aircrack-ng handshakes.cap -w
crunch 8 8 abc123 | aircrack-ng -w "-" handshakes.cap
The other thing to try would be process substitution:
aircrack-ng handshakes/PTCL-Broadband.cap -w <(crunch 8 8 abc123)
Whether this works will depend on exactly what aircrack wants to do with the input file.
You can also do it in two goes:
crunch 8 8 abc123 > /tmp/somefile
aircrack-ng handshakes/PTCL-Broadband.cap -w /tmp/somefile

Check what partition is used? [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 8 years ago.
Improve this question
I'm working on a SBC6845 card with Linux on it:
I have 4 partitions installed:
Creating 5 MTD partitions on "atmel_nand":
0x000000000000-0x000000100000 : "Factory"
0x000000100000-0x000000300000 : "Kernel1"
0x000000300000-0x000000500000 : "Kernel2"
0x000000500000-0x000008280000 : "Rootfs1"
0x000008280000-0x000010000000 : "Rootfs2"
I want to make a shell script that display which partition is currently used but I don't see how.
the command "df -h" returns:
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 178.8G 65.4G 104.3G 39% /
tmpfs 61.7M 0 61.7M 0% /dev/shm
tmpfs 61.7M 36.0K 61.7M 0% /tmp
and also fdisk doesn't work on this system.
Anyone have an idea how to resolve this?
So you want to know on which partition your script is currently located ? df can help you with this! You just have to give it the path to your script as an argument:
#!/bin/sh
df $0 | tail -1 | awk '{print $1}'
And sh myscript.sh gives me: /dev/sda1
Explanations:
df $0 outputs the partition in which myscript.sh is
tail -1 ignores the first line of df (name of the columns)
awk '{print $1}' returns the first column of df, which is the partition
I hope this is what you expected!

How to get the percentage of memory free with a Linux command? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I would like to get the available memory reported as a percentage using a Linux command line.
I used the free command, but that is only giving me numbers, and there is no option for percentage.
Using the free command:
% free
total used free shared buffers cached
Mem: 2061712 490924 1570788 0 60984 220236
-/+ buffers/cache: 209704 1852008
Swap: 587768 0 587768
Based on this output we grab the line with Mem and using awk pick specific fields for our computations.
This will report the percentage of memory in use
% free | grep Mem | awk '{print $3/$2 * 100.0}'
23.8171
This will report the percentage of memory that's free
% free | grep Mem | awk '{print $4/$2 * 100.0}'
76.5013
You could create an alias for this command or put this into a tiny shell script. The specific output could be tailored to your needs using formatting commands for the print statement along these lines:
free | grep Mem | awk '{ printf("free: %.4f %\n", $4/$2 * 100.0) }'

Resources