Questions tagged [linux]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
32 views

Automatic CRL files converter

In my job we use our internal CA runs on a Windows server. When I want to use it’s CRL on a Linux machine I have to do these steps: download root CA and intermediate CAs covert them to x509 merge ...
3
votes
1answer
20 views

Running a shell command when a file is added to FTP on Linux Ubuntu

I've recently set up a continuous integration pipeline to deploy a .NET Core application to my Linux machine living on the cloud. My CI pipeline publishes my application, (specifically a .NET web ...
1
vote
2answers
55 views

Creating a backup of a website directory inside the Web Application Root directory in *nix

In CentOS I have a Web Application Root on which I have a website directory. I would like to make an immediate backup of that website's directory by using the zip ...
2
votes
0answers
28 views

NRPE script for monitoring cpu usage

This script uses information from /proc/stat for counting current cpu usage. More precisely, it counts with these lines: ...
1
vote
1answer
35 views

NRPE script for monitoring memory usage

This script based on previous NRPE script for monitoring load average. Same purpouse - get NRPE friendly output with minimal usage of non built in commands. In this case wasn't need to count with ...
7
votes
3answers
219 views

NRPE script for monitoring load average

This script converts a server load value into percentage, compares it with non desired state ($warning and $critical) and returns all information in NRPE (Nagios Remote Plugin Executor) friendly ...
1
vote
3answers
46 views

Python startswith and then look a word in a conditional block

I have below working code which works fine, but just looking way around if there is an another elegant way of doing this, because here i'm using else condition to print the last line or dataBlock to ...
2
votes
1answer
49 views

Upgrade Firefox Quantum with logging and version check

This is the updated version of the script first posted here. Specifically, I first wanted to save the logs to a log file at "$HOME/.logs/ffupgrade.log", but I'm ...
2
votes
0answers
58 views

Apache reverse proxy security configuration

Could someone share some light and check if this is okay for apache httpd security/good standards? I'm using apache httpd to call my Node.js app that is running with Express and also configuring SSL. ...
1
vote
1answer
53 views

Serial port library for unix systems in C using callback model

I wrote a blocking serial port library, Blocking serial port C library, but prefer non-blocking so wrote this library where user can specify callbacks. So it is event driven. The code assumes C99 or ...
1
vote
0answers
47 views

C++ - simulating Windows' IO completion ports in Linux

This is a simple implementation of IO completion ports in user mode for Linux. In Windows IO completion ports work like this: There is a global queue for issuing IO requests. Some worker kernel ...
1
vote
1answer
40 views

Remap ls to honor .hidden files

I wrote this code in my .bashrc to remap ls to honor .hidden files. I'm pretty new to shell/bash scripting, so I feel like this is not the most performant way to handle this, and it has some ...
1
vote
0answers
19 views

Cycle through filenames in vim

So I have a list of files which names are something like this ...
3
votes
1answer
34 views

Syncing GitHub repositories local, remote and forks

It's a simple bash script but I'm hoping for feedback, advice and examples on how to improve the script and code. Can you guide me how to put more checks in the code and more if possible? This code: ...
2
votes
0answers
38 views

Blocking serial port C library

I am planning to write a reasonably feature rich serial library but wanted to cut my teeth on something fairly basic. This serial library is fairly simple. It is a thin wrapper on the UNIX open, ...
2
votes
0answers
39 views

Code to backup the history file in Linux

How is the logic, efficiency and can it be improved? This is a snippet from my .bashrc file; I just wrote it and I've tested it and it almost works. This was the ...
1
vote
1answer
69 views

Bash Code to backup the history file in Linux [closed]

How is the logic, efficiency and can it be improved? This is a snippet from my .bashrc file, I just wrote it. The code is supposed to do this: Backup my ...
17
votes
7answers
5k views

Tic-Tac-Toe for the terminal

I recently started learning C, and this is my first fairly large (to me) program. It's a basic Tic Tac Toe game for the console. There's no AI, it's just a 2-player game. Is there anything I can ...
4
votes
1answer
63 views

Shell script to calculate the total space consumed by a user by file-size

I'm working with a small bash code which is working fine but i'm just looking if there is better way to formulate this, In this code i'm looking for the Files between year 2002 and 2018 on the 7th ...
4
votes
1answer
77 views

Bash script to setup new Debian installs - follow-up

I have this bash script I've been working on and I have updated it. I was hoping for some advice and/or input on the code. This script is run directly after a fresh install of ...
2
votes
1answer
73 views

Editing system files in Linux (as root) with GUI and CLI text editors

My intention is to POSIX-ly write one generalized function for running various text editors I use for different purposes through sudoedit, i.e. editing files as ...
1
vote
0answers
89 views

Implementing std::filesystem::remove_all() for Android

I needed to use some c++ code on both standard Linux and the Android variant, and the code will use filesystem library but it isn't yet in the ndk. So I'm making a one to use on Android It will be ...
3
votes
1answer
24 views

Is device mounted? Both UUID and device names accepted

I am trying to write is_device_mounted script, which in turn will serve a greater purpose in my home Linux system. It does not even have an error reporting ...
2
votes
1answer
54 views

Multithreaded local server

I'm writing several local servers which have almost the same code in main.cpp. Appreciate your comments, improvement suggestions and especially notes on potential ...
7
votes
2answers
105 views

Color ASCII drawing class

I am working on a pseudo graphical interface for a Chess engine I wrote. I want to draw a colored Chess board with ASCII pieces. To abstract the pure ...
4
votes
2answers
56 views

Append a note to one of three files based on user choice

The user selects one of the three categories then makes a note on that selection. Then the note is appended and saved to the appropriate list. It took me four hours to write this. I'm trying to learn ...
2
votes
0answers
95 views

Simple Go Linux daemon to send/receive gob-encoded data on a socket

I'm currently working on a linux daemon and would like some feedback. The program is a simple unix socket server that sends around gob encoded messages. I'm still getting the hang of concurrency in go ...
5
votes
1answer
107 views

sed to fix a messy nginx.conf

I have a few servers to fix that repeatedly get their nginx.conf file messed up due to a rogue deploy script. These are the three sed commands I'm using to fix at present: ...
9
votes
2answers
552 views

Bash script to truncate subject line of incoming email

I'm going to put this script into production in a mail server /etc/aliases file: we have a system that receives email but the subject line must be limited to a certain size. The proposed usage in the ...
2
votes
0answers
21 views

Cross-platform standard library-only data synchronization script

The script below is intended to retrieve digital signage data from a server on Linux and Windows systems. The script needs to be copy and run, so I am limited to Python's standard library. The script ...
3
votes
2answers
51 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
33 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....
2
votes
2answers
42 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
69 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
169 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
25 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
73 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
51 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 ...
4
votes
2answers
61 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
27 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
118 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
33 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
35 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
1answer
511 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
48 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 ...
4
votes
1answer
52 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
728 views

Simple puts() function in x64 assembly

I'm trying to write as simple I/O library in x64 using linux syscalls ...