Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [linux]

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

3
votes
2answers
41 views

Creating remote directories in a bash script via ssh (with error trapping)

I'd like to create directories on a remote VM, but only if they do not exist. What's more, if creating the directory results in an error (exit status != 0) I'd like the script to exit as well, or at ...
1
vote
1answer
28 views

Tagging the directories and switching between them by tags - follow-up (Part 1/2: File management)

This is a rework of a small program for faster(?) switching working directories, and it looks like a pile of crap, I must admit. Could you give me pointers how to make it maintainable? dt_tag_entry....
1
vote
1answer
33 views

POSIX-ly finding a specific Java process

In this code I find a list all of the running java processes and give the below function a name to look for, it will do its best. But since I find my approach a ...
4
votes
1answer
58 views

Select second field in text table with shell script

I am writing a bash script to mount openshift service accounts into kubernetes objects. The right secret to use is highlighted in this text: $ oc describe sa sa-...
4
votes
1answer
121 views

Looping through multiple regex efficiently

I'm writing a program that adds all network interfaces with multiple parameters to a list. I have written the following code, which should work out of the box on any Linux system with Python and ...
8
votes
4answers
1k views

Reporting new USB storage devices on Linux and macOS with Python

Synopsis: I wanted something for macOS (and Linux; maybe eventually Windows) that would simply wait for the user to connect a storage device and automatically select, or otherwise output the ...
0
votes
0answers
23 views

Plugin generator in Go

This is my first go program. It is a plugin generator and works only with Linux. The repository is open. It basically creates some Go code in some temporary file defining a function taken from ...
2
votes
0answers
28 views

Flask app to administrate network interfaces

I made a Flask app that consists of 3 pages. Index: Indexes to the 2 pages SubnetOverview: SSH's into the server and executes ifconfig, then returns the output to ...
2
votes
1answer
49 views

Block same instance of a program for running again

I am implementing a library (Linux) and I created some functions to block new instances of a running program and I was wonder if there are some better improvements for it. Here is a program which ...
3
votes
2answers
52 views

Serial copying from disk images to folder in Bash

This is a Bash script that copies files stored inside disk images to a directory, using a defined structure provided via a JSON file. I've included the external programs it requires and the test I ...
2
votes
0answers
23 views

Script to report disk usage

I am trying to see how I can speed up the below script that reports disk usage. The timed find command towards the end is the problematic line that I am trying to ...
3
votes
1answer
91 views

BASH Script to Configure Monitors on Linux via xRandR

My main computer is a laptop which I run i3wm atop Arch Linux. As such, my monitor situation sometimes changes, so I wanted to code a script to configure my monitors based on which ones are connected ...
1
vote
1answer
22 views

Detecting the total amount of RAM installed on a hardware from a Linux system using a POSIX shell script

Today, I gave myself a small task of detecting the total amount of RAM installed on a hardware from a Linux system using a POSIX shell script. I ended up using ...
1
vote
0answers
32 views

Interactive Linux upgrade script - Follow-up #1

One year ago I asked for a yearly revision of my Interactive Linux upgrade script. There is nothing new to the conditions, therefore please read the original question before you decide to comment and ...
1
vote
0answers
49 views

Script for checking to leak via /dev/hands

I wrote so code to check leak. Please check it. All correctly in this code, or maybe something to correct? ...
1
vote
1answer
175 views

SSMTP configuration in Ubuntu 18.04 with Bash in my own system (one user)

This is how I configure the utility SSMTP that allows me to send mail via smtp protocol through a Google-Gmail proxy instead I'll have to manually configure an "...
11
votes
2answers
1k views

malloc() and free() for Linux with system calls

I have written an implementation of malloc() and free() for Linux using the sbrk() system ...
3
votes
0answers
46 views

Cache line versus struct size testing

There's a mission-critical ring buffer in production on which I'm curious to test some optimizations. Specifically, I'm wondering how much of a performance difference struct size will make on issues ...
3
votes
1answer
36 views

Script to clean up old files that should only run one instance

I'm writing a bash script for deleting old files on a Linux server. Here are some relevant facts about this script: As currently written, it does work as expected. However, it's entirely possible ...
3
votes
3answers
367 views

Simple puts() function in x64 assembly

I'm trying to write as simple I/O library in x64 using linux syscalls ...
4
votes
1answer
41 views

Shell function to convert .png to .svg file

I needed to convert some custom icons that were in .png format to .svg format and did not want to use an online converter for it. I could not find an out-of-the-box solution online so I created my ...
3
votes
1answer
46 views

Bash program that sets up and configures the environment for new Debian installs

Here is my second version of a bash program I'm writing, as per @hjpotter92 I've updated and cleaned it since last: This script is run directly after a fresh install of Debian, to do: sets up ...
0
votes
1answer
23 views

Shell POSIX OpenSSL file decryption script follow-up #3 (final)

From original very simplistic code: Shell POSIX OpenSSL file decryption script I learned a lot both from the first follow-up review, and the second one as well, many thanks! I just need one final ...
2
votes
0answers
20 views

Shutdown or reboot system from LAN

I've written a simple web service which allows a user to shutdown or reboot a system from the LAN. Although written to be used on an RPI which lacks a power or reset button, it can be used on any ...
2
votes
1answer
79 views

Password encrypting tool

I wrote a tool that takes a domain name and a password, concatenates them, hashes the result with sha512, and returns the result encoded in base64 truncated to 32 characters. The main idea behind this ...
0
votes
1answer
39 views

Shell POSIX OpenSSL file decryption script follow-up #2

This question is the second follow-up of: Shell POSIX OpenSSL file decryption script The first follow-up was: Shell POSIX OpenSSL file decryption script follow-up #1 Both of which have proven very ...
2
votes
2answers
117 views

Bash script to change network interface parameters/configuration and start virtual machines

On my Arch Linux system I have created a script that should do the following on system startup: detect all network interfaces check if physical interfaces are up check if bridge interfaces are up ...
2
votes
1answer
26 views

Ubuntu kernel update and removal automation script

This is my first bigger than a few lines bash script. It automates kernel updating and removing on Ubuntu through ukuu (Ubuntu kernel update utility). I'm not yet ...
1
vote
3answers
118 views

Convert integer to decimal string

I have a need to do some conversions in a loop to display the results using C++98 on Linux, which doesn't have any itoa() to complement ...
6
votes
1answer
69 views

Bash script to send notifications when low on ram

Backstory Recently, we've changed the PCs at my workplace to un Linux Mint. It works amazing, is blazing fast and the adjustment time was very short. However, I noticed my PC would freeze completely,...
1
vote
0answers
27 views

Reducing force unwraps in CLI utility

This is a CLI utility for managing the allocation of investment. It's an exercise, don't take it too seriously. So the utility asks the user a series of questions about it's finances and suggests a ...
9
votes
1answer
132 views

Systemd service configuration helper script

I've written a script that semi-automates the process of configuring/creating a new systemd service. The script is working perfectly well, however, I've had some trouble with the styling and ...
5
votes
1answer
107 views

Bash script to setup new Debian installs

This script is run directly after a fresh install of Debian, to do: sets up syntax highlighting in nano, sets up iptables, sets ...
10
votes
3answers
412 views

Implementation of Linux cp in modern C++

This is my simple implementation of the Unix cp command. It is a C++ program but makes use of some of the lower level C library I/O functions. Any suggestions for ...
3
votes
2answers
144 views

Find duplicate files in Linux

This code finds duplicate files in Linux. I assume that MD5 hash will return unique hash number. What can I improve in this code? ...
1
vote
2answers
44 views

Running shell script as root via external binary

I'm not an experienced Linux user and I wanted an easy way to run shell scripts as root from a PHP script, I came up with this: ...
2
votes
1answer
72 views

Sysinfo parser for a window manager status bar

The program is written mainly for the status bar in dwm (a window manager for Linux), but it can be used for any manager that takes input from the root window in X. It queries different resources in ...
6
votes
2answers
75 views

Interactive bash script to create new permanent swapfiles

I started self-learning Bash scripting yesterday, and I finished my first successful "advance" script. Goal To create an interactive step-by-step script to that allowed customizing various parts of ...
3
votes
1answer
94 views

Function for scanning /proc

I wrote a function, scan_ps(), for scanning /proc, to replace a combination of popen() and <...
2
votes
1answer
45 views

Making a disk usage breakdown

I'm looking for a better way of doing this code I made. I work for tech support and one of the biggest questions I am asked is: "Hey, how did my disk get so full in my VPS?" I am aiming for output ...
7
votes
1answer
201 views

Debian Firefox Quantum update script

I wrote a little script to automate upgrading Firefox to a new version under Debian, since I don't want to install it from unstable and the snap version has ...
1
vote
1answer
49 views

Haskell game server auth: cookie key generate&check

C++ code version (description copied from it) gameKeys id is authentication function of an MMO game server. When someone wants to play with friends, he sends ...
4
votes
2answers
92 views

Game server auth: cookie key generate&check

UPD: Haskell version, please check it too. gameKey(long id) is authentication function of an MMO game server. When someone wants to play with friends, he sends ...
5
votes
1answer
76 views

C application for capturing keyboard shortcuts

I'm writing an application for capturing keyboard shortcuts on Linux, but I don't have a lot of experience with C or the Linux API, so I'm wondering about problems with the code or maybe parts that ...
3
votes
1answer
72 views

Running xinput to change touchpad settings

I am looking for some feedback on the code below, mainly for efficiency or mechanism correctness (like eval vs. subprocess). I am also curious if ...
9
votes
2answers
157 views

Laptop battery level monitor for Linux

I come from a C background and am trying to learn Rust. I wrote my first Rust program, to check the battery level on my laptop and warn me if it's low/critical. It works fine, but I wrote it in a ...
1
vote
2answers
162 views

Long-term archiving + encrypting shell script

Yesterday, I very quickly, in an hour, wrote the very first version of my long-term archiving + encrypting shell script. I am aware it may have too many flaws, but none of them really prevent it from ...
4
votes
1answer
2k views

Python script for monitoring systemd services (cpu/memory usage)

This is a python (2.7.13 according to sys.version) script that reads systemd service names from a file and gets their CPU and Memory usage. It does that by first ...
1
vote
2answers
39 views

chmod all .htaccess files under all website dirs under public_html dir

This is my code to chmod all .htaccess files under all website dirs under public_html dir. The reason I use this code is to make sure WordPress plugins won't "...
1
vote
2answers
72 views

Portable (Linux, Cygwin,…) Makefile for my own Shell OpenSSL file en-/decryption scripts

Let it be clear that in this question I ask for further guidance with my current version of Makefile used for my own Shell OpenSSL file en-/decryption scripts, not ...