Linux is a Free (libre), Open Source, Unix-like operating system.

learn more… | top users | synonyms

3
votes
2answers
110 views

Checking percentage of free memory using top and awk

The following Awk code was created in order to verify if free memory from the top command is less than 20% of the total. I've noticed that I actually do not need the ...
3
votes
2answers
67 views

Parsing arguments for cd command

This file manager has a code snippet that handles an argument of the "cd" console command. It converts the argument to a valid path, expands ~ and environment variables into the corresponding values: ...
6
votes
4answers
220 views

Mounting multiple partitions on a disk

Is it possible to improve the code of this bash script? ... or should I just use another language? (If so, which one would fit the best the situation, according to you?) Here is the code (simplified, ...
3
votes
2answers
124 views

Editing /etc/network/interfaces

I am trying to change static to dhcp in the /etc/network/interfaces file and vice versa ...
6
votes
1answer
101 views

Using /proc/stat to calculate CPU usage

Inspired by this question: To calculate the total CPU usage as a percentage I wrote the following bash script (as an answer) to calculate the CPU usage for a (configurable) period over all CPU cores ...
11
votes
2answers
405 views

To calculate the total CPU usage as a percentage

I have been developing the below method to calculate the CPU usage of a Linux system at a point in time, as a percentage of the total number of cores available in the system. ...
10
votes
2answers
316 views

Minimalistic rmdir

In my eyes most of the GNU stuff is bloated and doesn't really fit my view of how a Linux environment should look like. I have come up with my own minimalist implementation of the GNU Coreutils, but ...
4
votes
1answer
32 views

Script to fix audio level

I need to fix and maintain the master volume in PulseAudio (so that I don't blow up my speakers). E.g. call gfaaudio -v 25 to fix volume at 25%. Is there a cleaner ...
10
votes
2answers
125 views

Parsing of a (Linux) netlink hotplug uevent packet

The netlink service is used, among other things, to notify userspace about hotplug events (e.g. "a device has been connected"). These events come in the form of packets, which follow the following ...
3
votes
2answers
106 views

Group and send all files to filetype folder

I have around ~2M of files in one folder, which I need to manage. So, I want to separate them in groups by their filetypes. Example: filenames ...
10
votes
3answers
433 views

Parsing ARP cache in C

How can I make this better? ...
3
votes
1answer
45 views

Perl script to check disk usage

I'm looking for input on the code itself and formatting/style. This script parses the output of df -h on a Linux server and emails the user if the usage percentage ...
2
votes
0answers
56 views

Linux-based WiFi AP daemon [closed]

I've written this small Linux-based daemon to create a WiFi AP that should work across various distros like Ubuntu, Fedora, etc. I'm not a great expert in Python, nor do I know that the various ...
-2
votes
1answer
34 views
4
votes
1answer
31 views

Generic Makefile

I decided to setup a generic makefile to compile SFML programs, as I'm going to be making a bunch of small apps over the next few weeks playing around with it. I'm still new to writing makefiles ...
5
votes
2answers
418 views

Small bash script to start and stop named services

I've been working on ubuntu since many years but not quite familiar with bash scripting. My development tools involve servers like nginx and apache, the mysql database and beanstalkd. Obviously, I ...
5
votes
2answers
97 views

Benchmarking our LAMP servers with this php script

I've written a small script to benchmark our LAMP hosted servers that assess the performance based on three factors: Disk I/O Database I/O (mysql) Database I/O (sqlite) The logic is as follows: ...
2
votes
1answer
47 views

Optimizing string replacement program that uses recursion

I have the following string replacement program for a string of size 256: I am replacing the string "\'" with the string ' Please suggest any modifications if needed or any ...
3
votes
1answer
170 views

Converting from std::wstring to std::string in Linux

I was bothered by inability of C++ to mix cout and wcout in the same program - so I've found this question: Converting between ...
2
votes
1answer
27 views

IPtables for webserver with ssh

I've had a bit of help but I'm still a bit unsure. I have an nginx webserver with SSH only required. I wrote this rule set based on information I found on the internet: ...
4
votes
1answer
140 views

Is there a better way to copy into two different folders on a machine simultaneously?

I am trying to copy files from machineB and machineC into machineA as I am running my below ...
5
votes
1answer
100 views

How to copy files as fast as possible?

I am running my shell script on machineA which copies the files from machineB and machineC ...
2
votes
0answers
158 views

Script for obtaining images from an IP security camera

I am fairly new to Python and programming in general so I hope the code in this post is not too messy. I have the following code which I use for taking images from an IP security camera: ...
10
votes
1answer
149 views

Set of wrapper functions for POSIX signal APIs on Linux

Please feel free to comment on the accuracy/validity of the following wrapper source for processing signals using the new POSIX sigaction API. If you feel I'm doing anything wrong or potentially ...
3
votes
1answer
115 views

Finding world-writable files in local directories only

Over at Stack Overflow I asked how to scan a local filesystem ignoring all remote mount points. I only really wanted a push in the right direction and received it. After clacking away on my keyboard I ...
4
votes
2answers
79 views

Packaging a single-file Python copy-tool

I'm currently working on a very simple one-file project: Lumix provides the possibility for the camera TZ41 (and others) to load GPS data and tourist information from a DVD to a SD-card so that you ...
3
votes
1answer
112 views

Ping Pong Pi - A ping pong score and serving manager

I have spent a few hours on this code, but think it could be improved a bit. It requires eSpeak to be installed to run the speech synthesis, but the voice can be toggled on or off using the ...
12
votes
1answer
385 views

Linux NASM assembly linked list implementation

Inspired by all of the lovely linked lists lately, I decided to implement one in assembly language. This code maintains two linked lists - one is a free store and the other is the active linked list. ...
5
votes
2answers
100 views

VLC media player watchdog daemon v6

This question is a follow-up to a previous version of this program, which I wrote because I found it annoying that VLC Media Player (which I love) prevents the screensaver from starting after playback ...
8
votes
3answers
192 views

Iptables Lockdown

I have nginx serving files with uwsgi and I wanted to lock my server down just to allow SSH and Nginx to run. This is what I have: ...
9
votes
3answers
399 views

Bash script that updates Intel e1000e driver

I am now writing a small bash script that updates an Intel NIC driver to the latest version from the official website. Is there any way to improve\simplify the script? I want to avoid a lot of ...
7
votes
1answer
174 views

Bash script - automate an upload image + description process on a server

I was tasked at work to improve a system where through a web interface a client, which eventually became us, uploads a bunch of images with descriptions (latter coming from csv files), the images are ...
5
votes
2answers
2k views

Running a shell command and getting output

This is the code I'm currently using to run a shell command on the current machine, intended for use only with GNU/Linux at the moment: ...
13
votes
1answer
146 views

Regular backup/snapshots

A (long) while ago I set up a file server in my basement running Linux. I am OCD when it comes to backups. I set the server up with (remember, this was a while ago): disk for OS disk for 'valuable' ...
1
vote
1answer
261 views

Interactive menu system in Bash [closed]

This is a simple loop menu script that I have for class. The goal was to make a menu with applicable commands. Menu: A. Greet me. (Greet the user by their username (using the whoami ...
2
votes
0answers
55 views

Synchronize 3 processes with fork() [closed]

I was given the following exercise in my university: Given 3 processes: d1 - print("I"), print("D") d2 - ...
6
votes
1answer
643 views

Correctness of calculations with struct timespec

I've noticed some discrepancies in timings in our system, and I'm trying to narrow down what could be causing them. I'm reviewing out time abstraction, and as far as I can determine it's fine. Am I ...
8
votes
1answer
198 views

VLC media player watchdog daemon

I'm looking for bugs, ways to make it more portable or standardized, improvements of any kind. Seems to do what it is supposed to on my Ubuntu 12.04 PC. ...
6
votes
1answer
366 views

Calculate query coverage from BLAST output

I have a BLAST output file and want to calculate query coverage, appending the query lengths as an additional column to the output. Let's say I have 2 7 15 ...
16
votes
4answers
1k views

Recording audio in C

This is a program I wrote as a .wav audio recording library for Linux. It was developed on a Raspberry Pi, so that may affect the dependencies required.(1) Here ...
8
votes
2answers
165 views

Self-mutating C (x86_64)

As a learning exercise I wrote a short C program that changes the instructions of a function at runtime in order to execute a shell. It's obviously dependent on x86_64 architecture and Linux (for the ...
6
votes
2answers
138 views

Batch rename flac files

This is my first real program in python (and my first real program) and I would like to have input by some more advanced programmers on the code, on the writing style and on the amount of comments (is ...
2
votes
1answer
301 views
0
votes
2answers
67 views

Optimize this path location script?

Example Script is located in /home/insp/public_html/deploy/ I want to return the /home/insp/ section ...
4
votes
4answers
86 views

apt alternative for proxy environment with bash shell

As I am new to bash scripting, and want to use apt-get in my university. I know that many people have issues when trying to do so. My focus is simplicity and ease of use, but still need to be ...
2
votes
1answer
293 views

Bash to find all placeholder variables in a file and replace will real variables

I am looking to make a generic config file using variables such as: $PLACEHOLDER_USER Then after moving the file into the correct position I want to replace every instance of *$PLACEHOLDER_VARIABLE* ...
2
votes
1answer
227 views

Bash script to set up an ad hoc wireless network

This script creates an adhoc network using hostapd. I have tested it and seems to work reliably. I am new to linux networking and not sure if this is a recommended way to create an adhoc network this ...
3
votes
1answer
692 views

Moving and organizing files in download folder

This is a Python script that I use on my Android tablet. It moves the files in the Download folder to a folder on the external SD card. The files are sorted based ...
3
votes
2answers
170 views

Simple linux char driver, am I following recommended and modern idioms?

Since the resources I found to learn are generally out of date, I'm having to read a lot of documentation, which makes the learning process somewhat haphazard. The module makes a simple character ...
4
votes
1answer
236 views

Is this CPUID parser ideal for any usage?

NOTE: I'm not perfectly sure of some of the parsed data, so any corrections are more than welcome. Parser (cpuid.c): ...