Skip to content

Tag: linux

How to receive a file using sendfile?

send a file with sendfile is easy: but how to receive a file using sendfile? since I don’t know the length of the file, should I send the file length first? There seems to be two ways of doing this: send the filestat.len first use a loop in the receive end: Which one is better? Should I handle the buffe…

Epoll_wait returning events on closed file descriptor

I’m working with a multithreaded embedded application in which epoll is used for IO in one of the threads. I’m relying on a particular feature of epoll that specifies that closing a file descriptor automatically removes it from the epoll set (Question/Answer 6 in man 7 epoll). In this case, the fi…

how to identify names of the partitions

From below partitions how know which partitions is boot and which one is system. Is there any different command I need to execute to read the partitions names. with df command Answer You can use df command. This will display something like that: The second option would be to read the /proc/self/mountinfo file…

Disabling disk cache in linux

In a class project my teacher told us to make some code evaluations (C language) and to do so we need to disable the disk caching during the tests. Currently I’m using Ubuntu 12.04, how can I do this? Thanks. Answer You need root access to do this. You can run hdparm -W 0 /dev/sda command to disable wri…

Extract the Linux serial number without sudo

It is possible to extract the Linux serial number without using sudo? I know it is possible to do in Windows: wmic bios get serialnumber and in macOS: system_profiler | grep “r (system)”. Both of them do not require root privileges. In Linux this can be used: sudo dmidecode -s system-serial-number…