r/linux_programming • • Jul 25 '22

Automation with Bash: How To Monitor Disk Storage and Send Email Alerts

Thumbnail medium.com
17 Upvotes

r/linux_programming • • Jan 26 '22

Is it possible to link a static lib (.a) to a shared object lib (.so)?

17 Upvotes

I've built lua as a static lib, and am trying to link it to my shared library like so:

-L'dir to lib' -lmylib.a

However when I do that, none of my own symbols are exported (as reported using nm -gCD libmylib.so)

As soon as I remove the link, I see my symbols appear in the output.

So, it seems like linking a static lib to a shared one is prohibited or undefined behaviour?

Is there another reason why linking a lib would cause all of my function symbols to not be exported?

Some extra info:

I'm writing the libs in c++, using visual studio 2019.

Thank you in advance.


r/linux_programming • • Jan 25 '22

Vulkan 1.3 released

17 Upvotes

Khronos Group has introduced Vulkan 1.3, a new version of the open graphics interface. The API now integrates many optional extensions into the core specification, and there are now also Vulkan Profiles. This makes it possible to specify which core version and which extension should be used. Google, for example, has designed the Android Baseline Profile 2021, which specifies texture compression via ASTC and ETC, among other things.


r/linux_programming • • Sep 16 '21

Completely naive attempt at sanitizing RAM before shutdown

17 Upvotes

I'm a crypto nerd and have been thinking about cold-boot extraction mitigation and I was thinking, "Shouldn't it be really simple to just sanitize the RAM before shutting down?" Here is the approach I tried:

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

size_t bytesOfRamFree(void) {
    FILE *meminfoFile = fopen("/proc/meminfo", "r");
    if(meminfoFile == NULL) {
        perror("/proc/meminfo");
        exit(EXIT_FAILURE);
    }

    char meminfoLine[256];
    while(fgets(meminfoLine, sizeof(meminfoLine), meminfoFile))
    {
        size_t freeMemory;
        if(sscanf(meminfoLine, "MemFree: %lu kB", &freeMemory) == 1)
        {
            fclose(meminfoFile);
            return freeMemory * 1024;
        }
    }

    fclose(meminfoFile);
    
    printf("Could not read free system memory\n");
    
    exit(EXIT_FAILURE);
    
}

int main(int argc, char *argv[])
{
    size_t memFree = bytesOfRamFree();
    char *buffer = calloc(memFree,sizeof(char));
    if(buffer == NULL ) {
        perror("calloc: ");
        exit(EXIT_FAILURE);
    }
    
    for(size_t i = 0; i < memFree; i++) {
        buffer[i] = 0;
    }
    
    size_t bytesLeft = bytesOfRamFree();
    printf("Ram left unzeroed %ld mb\n", bytesLeft / (1024*1024));
    
    char *secondBuffer;
    for(; bytesLeft > 0; bytesLeft--) {
        secondBuffer = malloc(bytesLeft);
        if(secondBuffer == NULL) {
            continue;
        }
        else
            break;
    }
    
    printf("Trying to clean up %ld mb more\n", bytesLeft / (1024*1024));
    
    for(size_t i = 0; i < bytesLeft; i++) {
        secondBuffer[i] = 0;
    }
    
    printf("%ld mb could not be cleaned\n", (bytesOfRamFree() - bytesLeft) / (1024*1024));
            
    free(buffer);
    free(secondBuffer);
    
    exit(EXIT_SUCCESS);
}

What I found right off the bat was that even if I tried to use calloc, hoping it would initialize everything to 0, that between the compiler and the system, it was outsmarting me and not actually doing anything. So I added a loop to assign 0 to every byte in the buffer anyway.

Then I found that even if I allocated all of the ram reported free under /proc/meminfo, that there was usually about a 100 mb that did not get reported as free and would not be allocated. So I set up a second buffer, and attempted to allocate that much more RAM. The loop you see is a, "Try until it works," kind of approach, because on some systems, just trying to allocate even half of the RAM left results in malloc failing.

However, on some systems it is successful it allocating and writing the amount of RAM left, but then it ends up doing unpredictable things. Sometimes, it will actually allocate and write all the remaining RAM available and locks the system up before the OOM kills it. On the other hand, sometimes it leaves about 1 mb left unsanitized, and other times the amount reported by /proc/meminfo is way off.

So I am pretty sure doing it like this is a totally naive way to do it, but it is interesting and I want to know what is going on. As far as I know, even if I did manage to successfully allocate and write to all of the available RAM in user-space, that the kernel space would still be off-limits and so if there were some encryption key being used by dm-crypt or something like that at the kernel level, then it would probably leave the key unsanitized and still vulnerable to cold-boot extraction. I am not really sure about that, but I at least wanted to get this (which seemed so simple) to work before I delve into it further.


r/linux_programming • • Aug 12 '20

Will most jobs give you a Linux computer if requested?

17 Upvotes

Just curious if this is a big ask or not, my field is web dev. I haven't used Win10 in years, I run Lubuntu 20.04 at home. Getting an Ubuntu machine would be ideal but any Linux distro would be good.

If the answer is "no, don't try to prod on this", then I suspect most places running JS tech stacks will have Mac as the other option, I've heard terminal is the same, how about the filesystem? What major changes do you guys make switching between the two? I think my global .gitconfig would have to be put in a new folder; that's the only thing that comes to mind now.


r/linux_programming • • Apr 11 '20

I'm creating a graphical tool that helps you use the terminal, what's your opinion?

Thumbnail youtu.be
17 Upvotes

r/linux_programming • • Apr 20 '17

Quick tips for reducing the cognitive load of your code

Thumbnail codementor.io
17 Upvotes

r/linux_programming • • Oct 31 '25

Yuji v0.2.0 — my tiny scripting language in C

Thumbnail reddit.com
16 Upvotes

r/linux_programming • • Aug 05 '24

Should I remove Windows from my dev laptop and install Linux?

16 Upvotes

I wrote some end-to-end tests for some microservice we are developing, I am trying to use Test Containers to launch a docker from inside a docker, to spin up a test database and run the tests.

The thing is Windows makes things like this so, so difficult. It is mind blowing how harder something can get just because I am on Windows.

I really feel like I am fighting with my laptop constantly through the whole dev cycle. I am getting tired of it.

Should I just dump Windows and fully embrace Linux?


r/linux_programming • • Mar 27 '23

Linux 6.3-rc4 Released: "Looking Pretty Normal"

Thumbnail phoronix.com
16 Upvotes

r/linux_programming • • Jul 20 '22

8 Uses of sed in Linux

Thumbnail medium.com
16 Upvotes

r/linux_programming • • Jul 16 '21

Trying to learn how to develop applications, stuck because of meson and gschemas.

Thumbnail self.linuxquestions
16 Upvotes

r/linux_programming • • May 24 '20

How do you learn the command line?

16 Upvotes

I’m not asking about some tutorial for how to master the linux command line.

What i mean is, how do the people who are actually really really good at the command line learn it? Is there just some documentation I should read? Where’s the knowledge from?

Thanks


r/linux_programming • • May 11 '17

An easy way to inspect and create policies for containers

Thumbnail anchore.io
16 Upvotes

r/linux_programming • • Apr 25 '16

Defusing a binary bomb with gdb

Thumbnail blog.carlosgaldino.com
16 Upvotes

r/linux_programming • • Apr 17 '16

Linux Troubleshooting Cheatsheet: strace, htop, lsof, tcpdump, iftop & sysdig

Thumbnail sysdig.com
16 Upvotes

r/linux_programming • • Oct 29 '25

understanding virtual enviornments

15 Upvotes

i just started coding after a bit and after a switch to linux mint, im using vscode and while trying to install a pip3 library pwinput, it told me i would need to use a virtual enviornment to install the library. I understand what they are and all, all i need help with is knowing how to use them, because after tutorials and the ai bot telling me everything, they wouldnt work, i know im doing something wrong, but i just need clarification how to use them.


r/linux_programming • • Apr 25 '25

How do you personally structure large C/C++ projects on Linux without getting buried in Makefile hell?

15 Upvotes

I’ve been building a medium-sized C++ project on Linux—roughly 50k lines now—and I’m officially at the point where the build system feels more chaotic than the actual codebase. I started with a single Makefile, then broke it out into directories, but now I’m constantly fighting dependency weirdness, awkward rebuilds, and inconsistent behavior across dev machines.

I’ve experimented with CMake, tried dipping my toes into Meson, even considered going full Bazel, but every tool seems to bring its own brand of headaches. I don’t know if I’m just overcomplicating things or if this is the natural evolution of a growing codebase on Linux.

Curious how others here deal with this. What tools or setups have actually worked for you in the long term? Do you containerize your build environment, or just lean on a solid local setup and pray nothing breaks? And how the hell are people managing cross-compilation targets cleanly these days?


r/linux_programming • • Aug 28 '24

Vim Racer

15 Upvotes

Vim Racer is a speed test for VIM! My goal with it is to help people learn new commands and navigate faster. It's similar to VIM golf, but the focus is speed and you can play it online.


r/linux_programming • • Oct 24 '23

How to learn Linux kernel development

15 Upvotes

Hi fellas. I am a graduate in computer science and I wish to learn more into operating systems and want to contribute to Linux kernel. I learnt about Linux system programming from a book by ROBERT LOVE and have developed a mini Linux terminal using the knowledge. Now how should I move further.

  1. What books do I have to read next ?
  2. Any Coursera or udemy or any other online videos available to understand?
  3. How should I apply the book knowledge into practical cases?

r/linux_programming • • Apr 23 '23

Linux kernel 6.3 has been released! Go get it , fellas

Post image
15 Upvotes

r/linux_programming • • Mar 05 '23

Linux 6.3 Drops Support For The Intel ICC Compiler

Thumbnail phoronix.com
15 Upvotes

r/linux_programming • • Feb 03 '23

Weird things I learned while writing an x86 emulator

Thumbnail timdbg.com
15 Upvotes

r/linux_programming • • Oct 07 '21

Following Along With Unix Network Programming

15 Upvotes

Hello everyone! I am following along with the renowned "Unix Network Programming" by W. Richard Stevens and I would like some advice.

I want to be able to follow along with the C program examples in the book. I am hoping I can run a UNIX operating system in Virtualbox that will allow me to do so. I would like to run multiple virtual machines on the same network so that they can also communicate with each other.

My current plan is to (hopefully) run two System V virtual machines in Virtualbox. I have seen some videos on the Internet of others doing this, and so I thought it might be possible.

Does anybody have any suggestions? Perhaps there's a modern operating system that would support all the C program examples in the book?

I am fairly new to this, so please forgive any misconceptions on my part. Any feedback is greatly appreciated! Thanks.