Linux is a free (libre), open source, Unix-like operating system.

learn more… | top users | synonyms

8
votes
3answers
133 views

My own little memory manager in C

I have implemented a simple version of malloc() and its associated functions, free(), calloc(), and realloc(). When free() is called, my implementation simply puts this memory on its own internal ...
6
votes
1answer
41 views

LXC Bootstrap - A wrapper script around lxc utility scripts to create and set up an LXC container based on settings

So some background here. I recently discovered the ease of LXC containers on Ubuntu. I've been building some 'test' containers locally for testing things I develop on Ubuntu, but the evil thing is ...
7
votes
2answers
81 views

Generating bounded & unique random numbers in the Linux kernel

I recently needed to generate a series of unique random numbers (non-repeated) within a bounded range inside of the Linux kernel. The code I came up with is below. I'd appreciate any feedback -- again,...
6
votes
2answers
125 views

Find prime factors and reverse strings

I'm currently taking an introductory course to Bash at my university, and was hoping to get some peer-review from whoever might have some time. Full disclosure: the quality of the code isn't ...
1
vote
1answer
69 views

Terminfo parser in C++

I've written a pretty minimal parser for terminfo files which works as intended. It compiles fine and I've actually setup some tests over here which pass successfully too. Now I would like to get it ...
5
votes
2answers
87 views

Parsing the lsblk output

I am a Python beginner learning Python 3. I have written two small functions that parse the lsblk output and return Linux physical and logical disks. Here is the first function: ...
1
vote
1answer
32 views

Linux background changing daemon in Rust

I'm working on a program that updates the background of an x11 desktop at a specified interval. However, it eats large amounts of my CPU just sitting idle. I know this is due to the main loop running ...
3
votes
1answer
48 views

Service to keep variables in memory

I'm a beginner C programmer. I want to write a program with the following characteristics: The program is essentially a 'daemon' or a 'service' that sits in the background doing nothing except ...
1
vote
0answers
75 views

Touchscreen Right Click

I have built a small script that provides touch screen right click context menu with long touch press in my ELAN touchscreen. There is no need to remove your finger in order context menu to pop up. ...
3
votes
0answers
49 views

Iterating through an array once [closed]

I am tasked with writing a script that analyzes code and attaches a comment with #Loopn or #Selection n that corresponds with ...
2
votes
1answer
114 views

Keep NumLock always on in C++ on Linux

I intend to replace my bash script executing these two very same commands infinitely, for the bash script seems rather ineffective: /usr/bin/numlockx on ...
3
votes
0answers
48 views

Linux performance using multi-threads (vs one thread) and ssh message

My server receives requests in one thread and responds in another. I am using thread pools of pthread-s for both receiving and sending. The performance is not that bad, however... When I am doing the ...
4
votes
1answer
79 views

Countdown AppIndicator

I've decided to translate an old Unity AppIndicator I had written in C to Ruby, so I can practice coding with it (got a little bored with the completely beginner lessons I've been following, which I'...
3
votes
0answers
29 views

msysGit to Unix sockets

I wrote this small script to help porting msysGit sockets to WSL ("Bash for Windows"). I'm not a big Python programmer so any feedback would be well appreciated. By the way, I made it a public Gist ...
3
votes
1answer
50 views

Waiting for input with timeout

When my program begins, I want to allow the user to hit a key to enter debug mode for one of the modules. Many of the solutions (involving alarm(), in particular) ...
1
vote
1answer
76 views

Simple Linux upgrade script in Bash revision 2

As I will be deploying this script on multiple machines with the very same system Linux Mint 18 with rather same configuration, I would like to be semi-sure I won't screw things up much. This little ...
6
votes
1answer
92 views

Simple Linux upgrade script in Bash

As I will be deploying this script on multiple machines with the very same system Linux Mint 18 with rather same configuration, I would like to be semi-sure I won't screw things up much. This little ...
4
votes
2answers
73 views

Optimize text search in files with Bash

I would like to get some performance improvement suggestions to a simple project I made using Bash in Linux. The target is to read all the *.desktop files, and ...
8
votes
3answers
264 views

Removing multiple slashes from path

I have been trying to write a sample code block to remove multiple backward or forward slashes from a path (e.g. //a//b should be ...
2
votes
2answers
56 views

Passing help options to a bash script

I used this code to give -h(help) options to my bash script. It's working fine and I wanted to get the code reviewed. ...
10
votes
2answers
172 views

mini-(Docker)-shell

I was given an assignment to write a mini-shell: To write your own shell, you will need to start with a C program that will prompt the user for input and accept in a number of arguments from a ...
4
votes
2answers
45 views

Parse a substring out of string, allocate memory accordingly

I have written the following code in order to: Find begin and end of FTP user and password from a given URL (ftp://[user[:password]@]host[:port]/url-path) Allocate ...
3
votes
2answers
71 views

Finding duplicate files using md5sum Unix command

This is an exercise from Think Python: How to Think Like a Computer Scientist Here's its description: In a large collection of MP3 files, there may be more than one copy of the same song, stored ...
1
vote
0answers
19 views

Parsing GTF file using command-line

I am extracting exons details from a GTF file using command line in Unix like cut, awk, grep or sed. input file.gtf: ...
5
votes
1answer
48 views

Bash function that allows running user aliases with sudo on Ubuntu

I wrote this little Bash function to replace my sudo command. It checks whether I have an alias for the given command and runs the aliased command instead of the ...
1
vote
1answer
31 views

Parse child value from XML using ezxml

I'm parsing an XML file and searching for a child value. As I'm familiar with this XML file structure, I know that the final value is a child of a child, and so I wrote the following code section: <...
2
votes
2answers
35 views

High CPU utilisation for Logs Manager shell script

I have written a shell script to manage the tcpdump pcap logs and syslog files in my Linux board, so as to maintain the disk usage to maximum of 70%. The script checks for the disk usage every ...
6
votes
2answers
94 views

CPU core temperature Unity indicator

Project now on Github: https://github.com/IanCaio/TempI I just finished a working version of a small Unity indicator in C, that is supposed to take the output of the application "sensors" (...
1
vote
1answer
19 views

Pausing script while waiting for Docker container and printing updates

I'm looking to improve it in brevity, readability, and simplicity. Basically, I'm just looking for a more elegant solution. What improvements can I make? ...
0
votes
1answer
85 views

Basic GNU/Linux C++ serial I/O class

I have wrote a small C++ class that provides some basic serial I/O functionality (it uses the standard GNU/Linux API). At this stage is working fine, before adding new functionality I want to get ...
1
vote
2answers
57 views

Iterating over a range of dates in a shell script

I have been working on a script that can be used to automatically pull the batch ids that were processed 4 days ago and which need to be processed tomorrow on the server. The batch IDs from 3 days ago ...
2
votes
0answers
54 views

Multithreaded C program to calculate CPU usage of cgroups

I am writing a program in an environment that makes use of cgroups to identify and group processes together. I want to parse the CPU utilization of each cgroup by sampling ...
4
votes
2answers
104 views

Simple program to read memory usage by PID in Linux

I just learn a little bit about C Programming and try to create a modular program so I created simple program to read memory usage by pid(s) in Linux. ...
3
votes
1answer
64 views

Automation of application utilities on Linux

I am working on a project to automate utilities of our application on Linux. The utilities are basically chunks of programs with specific options for specific tasks. They are run like UNIX commands. ...
1
vote
2answers
102 views

Hexdump utility in x86 NASM assembly

It's a simple hexdump that prints to stdout. I wanted to handle correctly input coming from the user typing at the terminal, this made the logic a little more complicated than just exiting after ...
6
votes
1answer
54 views

Extracting Linux configuration information using Bash and Perl

For few days I'm thinking about making my code faster and using less CPU. This code is a statusbar that runs in a loop. I'm asking because there's a lot of perl and I'm wondering if it could be done ...
4
votes
1answer
36 views

Yum Notification Script

This is a Bash script I wrote to email me when updates are available for my server. I'm new to bash programming, so I don't know if I've done this well. ...
5
votes
1answer
17 views

Script to record an inventory of a backup

This is a script designed to make an inventory file which records the contents of a directory allowing verification that a backup has the same data. The same script can also A full github repo is ...
15
votes
2answers
1k views

Tetris in C, in 200 lines

I aimed at making fully functional (real) Tetris, in the shortest way possible in C. The result is a terminal game for Linux, that uses ncurses. I made it for my friend, who wanted to play it on his ...
3
votes
1answer
61 views

File shredder in x86 NASM Assembly

This is a file shredder utility that runs on Linux. It writes random bytes over the file contents, repeating this 48 times and calling sys_fsync after each pass to ...
5
votes
1answer
39 views

Program to print all evironment variables

I'm learning x86 assembly on Linux and this is the first program I wrote, so I'm looking for all kinds of ways to improve it. ...
0
votes
0answers
36 views

Check the battery's charge level and emit an alert on low/high value

The following script check constantly the battery's charge level of the user's laptop via the acpi command. When such level reach a low/high value, the script will ...
5
votes
1answer
64 views

Brightness Web Server

This is the first real program I've written in Go so have at it! I wrote it because I use a tiling window manager that doesn't have any brightness control functionality (at least not that I know of). ...
4
votes
1answer
119 views

Raspberry Pi headless server using bash and USB automounting

Revised from: Bash scripts and udev rules to handle USB auto mounting / unmounting Tested: Uses USB insert/remove to control a headless Raspberry Pi 3 with Raspian Jessie Lite Changes: Implement ...
2
votes
1answer
109 views

Bash scripts and udev rules to handle USB auto mounting / unmounting

Very new to Raspberry Pi and bash, but working on a headless server that will run a streaming app from USB audio card. The plan is to take a USB card with settings file, and when inserted, the usb ...
5
votes
3answers
2k views

Snake game in C for Linux console

Please help me improve this code. Move snake using : a w s d. (My compiler doesn't support initialization of index variables inside loops, so please ignore this part) ...
8
votes
1answer
110 views

Baby-sitting bash script using DVD drive

This is the script I wrote to make an automated POC baby-sitter in 5 lines. I first found this on a GIF or meme site and thought of making a POC script that does the same. ...
8
votes
2answers
220 views

Thread to send heartbeat UDP packets

This C code will run on an embedded machine with a Linux OS. It should create data packets (ASCII) to repeatedly be sent to a UDP server. Just to give an overview about what functions should do: <...
5
votes
2answers
100 views

Thread synchronization with mutex

This program prints odd numbers by thread1 and even numbers by thread2 sequentially. Can this code be optimized or made more ...
1
vote
1answer
79 views

Disable reboot on control-alt-delete for RedHat/CentOS 5/6/7

As root, run: ...