I have a vmlinuz ELF image file. I need to get the kernel version from the image file without disassembling it. Is it possible to get kerenel version from offsets of that compressed image file? The file is ELF 64-bit MSB executable, statically linked, not stripped. Answer As previously mentioned, the version …
Why does a timerfd periodic Linux timer expire a little before than expected?
I am using a Linux periodic timer, in particular, timerfd, which I set to expire periodically, for instance, every 200 ms. I noticed, however, that the timer seems to expire, sometimes, a little before with respect to the timeout I set. In particular, I’m using the following C code to perform a simple t…
top and grep output nothing when run from shell script
I am trying to create shell script that ssh into a remote server and run a script there and print the output in the local server but when I run the script in the local server it most of the time outputs nothing and rarely outputs data : and when I ssh in the local server to the remote server
blocking all internal traffic except incoming traffic from a specific ip on a single port
I’m trying to use IPtables to block all internal traffic with the exception of one server, here are my rules but when i telnet from another instance i can still connect…. Answer When debugging iptables I normally: reset all the counter – ‘iptables -Z’ make the connection then rev…
Unable to get the absolute value of command output
So I wanted to make a simple script to keep checking the CPU temperature of my RasPi, which is stored in /sys/class/thermal/thermal_zone0/temp , and hence cat /sys/class/thermal/thermal_zone0/temp would give the temp, but like this : which essentially means 38.459 degree Celsius. I was unable to format the ou…
conditionally merge files by appending in bash
I have two files and would like to merge them – by appending to the last line. file1.txt content file2.txt content Desired outcome – file3.txt How do I go about this, please? Note, zero is in place for null in the Stack line. Answer Using awk: When file2.txt is read, store field2 in array a using …
How can I time out an input/output redirection in Linux?
I was wondering whether or not it is possible to time out an input/output redirection in Linux. Meaning that I would like to redirect certain input/output to a file just for a time span of 2s for instance. In a practical case, I am looking to cat the tty0 to a file only during 2s How can I achieve this?
How do I add a numbered suffix at the end of my files using split on Linux BASH?
I’m using the split command in a Macbook and instead of getting numbers, I’m getting files such as output_aa, output_ab, output_ac, and what I need is output_1 , output_2, output_3, and so on. Here’s the code I’m using, it’s on a .txt of a book (Harry Potter) and I’m trying…
Shell : create and assign variables inside for loop
i ve this shell script ; it’s a loop which set in the variable “a” each time result : My Purpose is how to change “a” by a dynamic variable name which be $item_MYPREFIX (concatination :$item + _MYPREFIX ) So that my code would be generic , something like this : and i would be abl…
Why does SIGHUP not work on busybox sh in an Alpine Docker container?
Sending SIGHUP with to a busybox sh process on my native system works as expected and the shell hangs up. However, if I use docker kill to send the signal to a container with it doesn’t do anything. The Alpine container is still running: By the way, with an Ubuntu container (which runs bash) it does wor…