Tuesday, July 27, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Replacing one of the repeated words

Posted: 27 Jul 2021 10:42 AM PDT

Hi Im new to this so please bear with me. I have a .txt file where I want to replace a word in that .txt file but the problem is, that word is being repeated over and over again (lets assume you have million of lines like this)

TOPIC:  APPLE  APPLE  APPLE  BANANA    TOPIC:  APPLE  APPLE  APPLE  STRAWBERRY    TOPIC:  APPLE  APPLE  APPLE  PEAR  

I want to replace Apple to Mango like this under the second topic

TOPIC:  APPLE  APPLE  APPLE  BANANA    TOPIC:  MANGO  APPLE  APPLE  STRAWBERRY    TOPIC:  APPLE  APPLE  APPLE  PEAR  

Is there a way to do this through sed or awk specifically(from what I understand sed can be used to replace words but not multiple lines of inputs - in my case I just want to replace the very first word) btw if its doable through other tools thats fine as well

Network statistics: incoming broadcast count

Posted: 27 Jul 2021 10:19 AM PDT

I would like to write the c program to monitor network statistics for incoming and outgoing packets, collisions etc. There is a function call getifaddrs with a great code example: https://man7.org/linux/man-pages/man3/getifaddrs.3.html

Using the example from the link above almost all packet statistics could be retrieved. I did not find however the way to monitor the number of incoming and outgoing broadcast packets. Does anybody could help with some suggestion how to get the number of (incoming and outgoing) broadcast packets count per network interface.

Does ${@:-1} really return last argument?

Posted: 27 Jul 2021 10:07 AM PDT

I am running the following code when I have two arguments

if (( $# == 2 )); then    : ${fdir:="${@:-1}"}    pfm -w2 "" "unspecified -d option"    echo "use last argument as substitute"    printf '%s\n\n' "fdir: ${@:-1}"    echo "\$1: $1  \$2: $2"  

This is the result

pregion --dyn "John" ./01cuneus  pregion --dyn John ./01cuneus    unspecified -d option  use last argument as substitute  fdir: John    ./01cuneus    $1: John  $2: ./01cuneus  

Creating an alias for the find command in Linux

Posted: 27 Jul 2021 09:57 AM PDT

I have created the following alias in my .bashrc file:

alias find='find . -type f -name'  

This obviates the need to type . -type f -name every time I do a file search. However, I still have to enclose search strings with '*...*'. How could I include these in the alias, so that instead of having to type:

find '*string*'  

I could just type,

find string  

Cannot update PopOS

Posted: 27 Jul 2021 09:52 AM PDT

I am trying to upgrade PopOS through the PopShop.

When I click the upgrade button I get the following error

The following packages have unmet dependencies:    libqt5svg5: Depends: libqt5widgets5 (>= 5.14.2+dfsg~) but it is not going to be installed    libegl1: Depends: libegl-mesa0 but it is not going to be installed    libmutter-7-0: Depends: libc6 (>= 2.33) but 2.32-0ubuntu3 is to be installed                   Depends: libgdk-pixbuf-2.0-0 (>= 2.22.0) but it is not installable                   Depends: libgl1 but it is not going to be installed                   Depends: libx11-xcb1 (>= 2:1.7.0) but 2:1.6.12-1ubuntu0.1 is to be installed    systemd-sysv: Depends: systemd (= 247.3-3ubuntu3.4pop0~1626806865~21.04~19f7a6d)    fwupd: Depends: libc6 (>= 2.33) but 2.32-0ubuntu3 is to be installed           Depends: libfwupdplugin1 (>= 1.5.8-0ubuntu1pop0~1617221312~21.04~a9de48d) but 1.5.8-0ubuntu1pop0~1617221312~20.10~a9de48d is to be installed           Depends: libgnutls30 (>= 3.7.0) but 3.6.15-4ubuntu2 is to be installed           Depends: libgusb2 (>= 0.3.5) but 0.3.4-0.2 is to be installed           Depends: libtss2-esys-3.0.2-0 (>= 2.3.1) but it is not installable    linux-headers-5.11.0-7620-generic: Depends: libc6 (>= 2.33) but 2.32-0ubuntu3 is to be installed    gnome-terminal: Depends: libvte-2.91-0 (>= 0.62.1) but 0.62.0-1ubuntu1 is to be installed                    Recommends: yelp but it is not going to be installed  

When I try to install the first missing package it seems to be installed

08:53:22 jphamlett@pop-os Freelance → sudo apt-get install libqt5widgets5  [sudo] password for jphamlett:   Reading package lists... Done  Building dependency tree         Reading state information... Done  libqt5widgets5 is already the newest version (5.14.2+dfsg-6).  0 upgraded, 0 newly installed, 0 to remove and 61 not upgraded.  

Even just a simple apt-get -f install did nothing

Any help?

Disabling user I/O during loop (temporarily)

Posted: 27 Jul 2021 09:37 AM PDT

I have a shell script that backs up my git repos that are all saved in one specific file. I wanted to add a cool "spinning load thingy" just for fun and that's pretty simple. The problem is I realized I could still enter inputs into the terminal while it was loading and even worse I could still enter commands. You can find the back-up script on my GitHub page here or this is most of the code below.

function runCommand() {       load &      local whilePID=$!      tar -czf ${zipFileToUpdate} ${directoryToBackUp} &      local backupPID=$!      wait $backupPID      kill $whilePID      echo -ne "done"  }    function load() {      while true; do          echo -ne "/\r"          sleep .1          echo -ne "-\r"          sleep .1          echo -ne "\ \r"          sleep .1          echo -ne "|\r"          sleep .1      done  }    stty -echo     # stop input  tput civis     # cursor invisible    runCommand     # main func    tput cnorm     # cursor norm  stty echo      # resume input  

I started with the problem of being able to continuously type while the loading loop was running, with stty -echo I got that to stop but once I turn on the inputs again they all show up. So if I press the up arrow and enter, it'll just wait until it's done, then show that the script is running again. If anyone has any knowledge of how to capture the input instead of hiding it that'd be great!

I'm also new to bash, so if you could explain any commands or arguments that belong to commands that'd also be awesome. Thanks in advance

Arch os-prober won't find Windows 10 on different disk

Posted: 27 Jul 2021 09:29 AM PDT

Ok so I have read similar questions but I haven't been able to solve my problem so far. I have just installed an Arch in a SSD (located on /dev/sdc) and I have a Windows 10 on another SSD (/dev/sda).

My problem is that when executing grub config (grub-mkconfig -o /boot/grub.d/grub.cfg) and having enabled os-prober, it still won't find the Windows 10 entry.

The output of fdisk -l is:

Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors  Disk model: INTEL SSDSCKKW24  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disklabel type: dos  Disk identifier: 0xd67b45de    Device     Boot     Start       End   Sectors   Size Id Type  /dev/sda1  *         2048   1026047   1024000   500M  7 HPFS/NTFS/exFAT  /dev/sda2         1026048 467744983 466718936 222.5G  7 HPFS/NTFS/exFAT  /dev/sda3       467746816 468856831   1110016   542M 27 Hidden NTFS WinRE      Disk /dev/sdb: *Omitted*       Disk /dev/sdc: 465.76 GiB, 500107862016 bytes, 976773168 sectors  Disk model: Samsung SSD 870  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disklabel type: gpt  Disk identifier: E2F762F9-0255-497D-934E-0B8DF1009AD8    Device        Start       End   Sectors   Size Type  /dev/sdc1      2048   1050623   1048576   512M EFI System  /dev/sdc2   1050624  34605055  33554432    16G Linux swap  /dev/sdc3  34605056 976773134 942168079 449.3G Linux filesystem  

How could I fix it so that os-prober detects my Windows 10 system?

Edit

As some answers to similar questions suggested, I already tried installing ntfs-3g, mounting the Windows partitions and re-running grub-mkconfig but it still won't detect the system.

The difference between upstream and downstream kernel

Posted: 27 Jul 2021 09:24 AM PDT

What is the difference between upstream and downstream kernel?

Upstream kernel refer latest kernel.

Downstream kernel?

How to filter ARP-Requests with Nftables using a Raspberry Pi as AP (using hostapd)

Posted: 27 Jul 2021 09:13 AM PDT

I´m trying to filter ARP-requests coming from certain IP-addresses in my network. I tried :

table arp filter {          chain input {                  type filter hook input priority 0; policy drop;                  arp saddr ip 192.168.2.1 counter accept #ISP-Router                  arp saddr ip 192.168.1.100 counter accept #Laptop                  arp operation reply counter accept}}  

It should drop all ARP-requests not coming from either the router or the laptop. But requests send by my smartphone are still recieved by my laptop. (My Pi acts as routed access point, it is connected to the ISP-Router via ethernet and uses interface wlan for AP function.)

Then I tried to use table netdev with ingress hook because (at least in theory) it should resolve first:

table netdev wlan {          chain wlanFilter {                  type filter hook ingress device wlan0 priority 0;                  meta protocol arp counter drop # ARP-requests were still getting from smartphone to laptop, but ARP-Cache on Pi was incomplete afterwards                    meta pkttype {broadcast, multicast} counter drop # didn´t filter ARP Broadcast}}  

I also tried to use the hostapd function ap_isolate=1. Same result.

I use Raspberry Pi OS with kernel version 5.10.17-v7+, hostapd version 2.8-devel, nft version 0.9.6, dnsmasq version 2.80. ip_forward is active and NAT aswell. I wasn´t using a bridge but to be thoroughly: I tried table bridge with similar rules, no success. I then changed the whole setup to bridged access point instead of routed. I tried all rulesets again. Didn´t work either.

Could it be, that Hostapd forwards packets to the local network before packetfilter like Nftables are enforced? Or is there something wrong with my ruleset? Or is it something else altogether?

how to use awk for 'AND' and 'OR' condition together?

Posted: 27 Jul 2021 10:39 AM PDT

I have 2 column file like:

$ cat data  a4 b1  a4 c2  a4 b4  z4 c2  

I want to match both columns such as if (column1 = a4 and column2 = b1) OR (column1 = a4 and column2 = c2) then the output in column3 should be

(DESIRED OUTPUT):

a4 b1 matched  a4 c2 matched  a4 b4 -  z4 c2 -  

so I tried to incorporate my logic into 1 liner awk:

$ awk '{print $1, $2, (($1 = a4 && $2 = b1) || ($1 = a4 && $2 = c2) ? "a4-matched" : "-")}' data  

and I'm getting - for whole column3, I guess I have wrong awk syntax in place, or something else missing -- below is result:

a4 b1 -  a4 c2 -  a4 b4 -  z4 c2 -  

cannot sniff the packet going through openwrt network bridge

Posted: 27 Jul 2021 08:54 AM PDT

What I am doing is setting up a spare openwrt as a packet sniffer.

I have setup like this:

Target board -> openwrt bridge -> my home router <- My PC.  

From MY PC, I am using wireshark to capture any packet going through the target board. Currently, my home router IP is X.X.X.1, my PC is X.X.X.50 and the openwrt bridge is X.X.X.80 and my target board is up and has the X.X.X.28

Using wireshark to observe the openwrt, I can see packet of the X.X.X.80 but not anything from X.X.X.28. I have tried using my PC to ping the X.X.X.28, and I can see that there is the traffic going from my pc to X.X.X.28 while there is not any captured traffic from X.X.X.28. Do I setup the OpenWRT wrongly?

I can confirm that the Target device is up and running smoothly, I have run application on it. I just cannot sniff the packet from it for debugging. All the setup is wired network.

How to use socat to implement a base64 decoding proxy?

Posted: 27 Jul 2021 10:36 AM PDT

The goal: bidirectional communication while decode in a unidirectional way the incoming data

Theory: suppose to have a proxy/ server that listens on port 8080 which needs to handle multiple clients at once. The data coming in is base64 encoded, it should be decoded and forwarded to another port ( 80 ).

Practice: I would like to use socat because of all its features ( and also because it is the only one I know that can do all these things, if you know something else could be fine too ):

  • tcp to tcp
  • udp to tcp
  • fork and reuseaddr
  • exec commands

I'm looking for something like that:

socat tcp-listen:8080,reuseaddr,fork exec:/path/to/myscript.sh  

with /path/to/myscript.sh:

#!/bin/sh  exec base64 -d | socat - tcp:localhost:80  

But this sadly does not fit my case because is not completely bidirectional

Changing words using sed

Posted: 27 Jul 2021 09:08 AM PDT

How do I change multiple words using sed? For example, I have a .txt file with the contents being

Var_A = 1  Var_B = 2  Var_C = 3  

how do I change 1,2,3 to AAA,BBB,CCC so I have this

Var_A = AAA  Var_B = BBB  Var_C = CCC  

I've tried using this sed -i 's/Var_A = 1\nVar_B = 2\nVar_C = 3/Var_A = AAA\nVar_B = BBB\nVar_C = CCC' file.txt but this does not work at all

clamd changing owner/permissons of /tmp

Posted: 27 Jul 2021 08:35 AM PDT

I installed the clamav antivirus package today on Arch Linux. It is the first time I have used it and I am curious to try it out. I have set up and enabled the clamd daemon (I use openrc); however, it seems that whenever the clamd daemon is started (or restarted), it is changing the owner and permissions of my /tmp folder as follows:

drwxr-xr-x   6 clamav clamav  4096 Jul 27 11:23 tmp  

Previously I had this set to (what I believe to be standard):

drwxrwxrwt   6 root root  4096 Jul 27 11:23 tmp  

If I change the folder settings back and then restart clamd, it changes the owner/permissions back again. I have tried changing the TemporaryDirectory setting in /etc/clamav/clamd.conf to:

# Optional path to the global temporary directory.  # Default: system specific (usually /tmp or /var/tmp).  TemporaryDirectory /tmp/clamav  

to try to give it its own folder, but it doesn't seem to help.

Does anyone know if I am doing something wrong with the setup, or could this be a bug in clamav?

how to get the version of a loaded kernel module in docker container

Posted: 27 Jul 2021 07:31 AM PDT

lsmod can list the loaded modules inside the container.

Module                  Size  Used by  pci_hyperv_intf        16384  1 mlx5_core  igb_uio                20480  2  uio                    20480  5 igb_uio  

but if I want to check the version of the igb_uio module with modinfo I got this: modinfo: ERROR: Module alias igb_uio not found

there is a folder with /sys/module/igb_uio and the content is:

ls /sys/module/igb_uio/  coresize  drivers  holders  initsize  initstate  notes  parameters  refcnt  sections  srcversion  supported  taint  uevent   

but no *.ko file - so how can I get the version info of this loaded module?

Is it possible to use the escape codes used in shell prompts elsewhere, such as with echo?

Posted: 27 Jul 2021 07:37 AM PDT

Example:

  • When I run

    echo -e "\[\033[;33m\][\t \u (\#th) | \w]$\[\033[0m\]"  

    the printed response is

    \[\][    \u (\#th) | \w]$\[\]  

    where everything after the first \[ and before the last \] is an orangey-brown.

  • However when I set the command prompt to

    \[\033[;33m\][\t \u (\#th) | \w]$\[\033[0m\]  

    the command prompt is printed as

    [21:55:17 {username} (89th) | {current directory path}]$  

    were the whole command prompt is the orangy-brown.

In conclusion, my question is: Can I have a command prompt design printed (with echo, cat, less, etc.) as if it were the command prompt?

Linux in Active Directory: Persistent users

Posted: 27 Jul 2021 07:24 AM PDT

I was able to successfully join my Ubuntu 18.04 machine into AD.

For this I'm using SSSD and Kerberos.

I can ssh into in using AD domain credentials. Everything is fine except that those domain users are not persistent.

When a domain user enters a Windows machine, then a home directory is created automatically and the user is added into the users list. This allows the domain user to log into Windows even if there's no network connection.

But on my Ubuntu machine no home directory is created and no users are added into /etc/shadow and /etc/passwd. It means that if AD was down or the network was down, then there's no way for the domain users to login.

Where can I find information on how to configure this properly? What files I need to look into? Or maybe Linux's AD stack does not allow it?

How to install GRUB2 on shrunken RAID1 disks?

Posted: 27 Jul 2021 10:44 AM PDT

TL;DR: Trying to install GRUB2 on block devices that are in RAID1. Stuck at installing bootloader.

Goal

to replace HDD-s with smaller SSD-s. Here are the steps that I've taken:

# Booted into rescue mode   # failed and removed the partition from md array  mdadm --manage /dev/md1 -f /dev/sdb2  mdadm --manage /dev/md1 -r /dev/sdb2    # took out the HDD  # shrunk the filesystem and then the md  resize2fs -f /dev/md1 85G  mdadm --grow /dev/md1 -z 88G    # md1 mounted fine, no issues there. Didn't try to mount /dev/sdd2, as it's Linux RAID type  # recreated partitions on SSD as they are on HDD    # added to array  mdadm --add /dev/md1 /dev/sdb2    # waited for the sync to finish.  # recreated partitions on second SSD  # removed remaining HDD once synced, added SSD to array  

Problem

How to install bootloader on the SSD-s? Errors that I'm facing:

grub2-install --directory /mnt/sysimage/boot/grub2/i386-pc /dev/sdd  Installing for i386-pc platform.  grub2-install error: cannot open `/mnt/sysimage/boot/grub2/i386-pc/kernel.img': No such file or directory.  

Specs

  • CentOS 7
  • mdadm v4.1
  • No LVM

When you SSH a remote login to another computer can you change permissions on a file or directory? If so how?

Posted: 27 Jul 2021 07:28 AM PDT

I SSH a remote login to a computer but found that even with administrator privileges I could not change permissions on a directory I wanted to copy.

I tried sudo chmod -R 777 directory

It prompted for a password which i then entered but it said you don't have permission.

This was on Mac Os Unix.

Bluetooth error after upgrading to Ubuntu 21.04 (Hirsute Hippo)

Posted: 27 Jul 2021 08:42 AM PDT

After upgrading to Ubuntu 21.04 my computer displays the following error on resume from suspend: Bluetooth: hci0: Reading supported features failed (-16) The computer does not respond after this is printed and I have to reboot it to get it working. Other than that, Bluetooth is working normally. This issue prevents me from using suspend since the computer has to be rebooted after resume.

The PC has the ID 8087:0a2b Intel Corp. Bluetooth wireless interface

running umount on HFS filesystem gets stuck in D state, preventing suspend to RAM

Posted: 27 Jul 2021 07:34 AM PDT

I have mounted an HFS file system from a disk image and proceeded to umount it. upon doing so, the umount process entered D state and did not leave. the filesystem is unmounted, but the process remains in D state.

now that it is in D state, I am completely unable to suspend my system to RAM.

a solution to this problem would either be to find a way to suspend regardless of the D state process or to find a way to take the process out of D state.

dmesg says:

[3157428.258176] INFO: task umount:2459 blocked for more than 120 seconds.  [3157428.258177]       Tainted: G           OE     4.19.0-16-amd64 #1 Debian 4.19.181-1  [3157428.258178] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.  [3157428.258179] umount          D    0  2459   2458 0x00000000  [3157428.258180] Call Trace:  [3157428.258181]  __schedule+0x29f/0x840  [3157428.258182]  ? bit_wait_timeout+0x90/0x90  [3157428.258183]  schedule+0x28/0x80  [3157428.258184]  io_schedule+0x12/0x40  [3157428.258185]  bit_wait_io+0xd/0x50  [3157428.258186]  __wait_on_bit_lock+0x5d/0xa0  [3157428.258187]  out_of_line_wait_on_bit_lock+0x91/0xb0  [3157428.258189]  ? init_wait_var_entry+0x40/0x40  [3157428.258191]  hfs_mdb_commit+0x326/0x340 [hfs]  [3157428.258192]  hfs_sync_fs+0xa/0x10 [hfs]  [3157428.258195]  __sync_filesystem+0x2c/0x50  [3157428.258196]  sync_filesystem+0x2a/0x40  [3157428.258198]  generic_shutdown_super+0x22/0x100  [3157428.258199]  kill_block_super+0x21/0x50  [3157428.258201]  deactivate_locked_super+0x2f/0x70  [3157428.258203]  cleanup_mnt+0x3f/0x70  [3157428.258205]  task_work_run+0x8a/0xb0  [3157428.258208]  exit_to_usermode_loop+0xeb/0xf0  [3157428.258210]  do_syscall_64+0x10d/0x110  [3157428.258211]  entry_SYSCALL_64_after_hwframe+0x44/0xa9  

Screen flickers when playing sound - Solved w/ Solution

Posted: 27 Jul 2021 08:34 AM PDT

I made the switch from OpenSuse TW to Arch, instead of installing arch from scratch I decided this time to try Arco Linux.

Now, the flickering problem isn't new to me, it happened on Fedora 33 and 34 then on OpenSuse - Leap and Tumbleweed - and now on Arco Linux.

It happens if any sound is played. If a video starts the flickering happens. If I go to spotify web, for example, it will happen, etc.

The flickering takes about 2s. The laptop screen goes first getting completly black and then the second monitor does the same. Then both blink, geting back to normal. I can then pause the music or video and press play again that it won't blink again, only after awhile.

It was hard to find the solution on fedora - gnome - but I then found it, and, it was because of wayland, changing the gdm conf to disable wayland made the trick. On OpenSuse - gnome and i3 - it was the same thing with the same solution - I installed OpenSuse with gnome first, so on i3 the problem was the same.

Now on ArcoLinux I didn't installed it with gnome, I went straight ahead and choose i3. Downloaded my config files, restarted i3 and everything was okay. Opened up brave, went to youtube and played a random video, bam, flickering starts like it always did. I like the other times, went to edit the gdm file, but there wasn't any. I didn't select gdm or any other to be installed. Arco Linux comes with sddm so I tried that but there was nothing there to disable wayland - which yes, it was running. I googled it and it has now been 5 hours since that. I changed kernel from lts to stable, but nothing changed. I then installed gdm, disabled sddm and enabled gdm. Rebooted the system, gnome login screen shows up, I login, everything went fine, just needed to move my edits from .bash_profile to .bashrc. Opened up youtube and it still flickers the screen. I seriously don't know what else to do.

Resume:

  • Screen flickers when playing sounds. It as happened 2 times before and the same solution dind't work this time.

  • Changed kernel from lts to stable (5.13.5-arch1-1). Didn't work.

  • Changed from sddm to gdm. This belongs to the - "old" - same
    solution.

Any help is appreciated. Thanks in advance!

Edit:

After running the command dmesg -l err, I got this output:

[ 0.181632] x86/cpu: SGX disabled by BIOS. [ 17.961054] snd_hda_intel 0000:00:0e.0: azx_get_response timeout, switching to single_cmd mode: last cmd=0x20bf8100 [ 18.235440] snd_hda_codec_hdmi hdaudioC0D2: Unable to sync register 0x2f0d00. -5 [ 18.871455] snd_hda_codec_realtek hdaudioC0D0: Unable to sync register 0x2b8000. -5 [ 18.871790] snd_hda_codec_realtek hdaudioC0D0: Unable to sync register 0x2b8000. -5 [ 36.231326] snd_hda_codec_hdmi hdaudioC0D2: Unable to sync register 0x2f0d00. -5 [ 37.008073] snd_hda_codec_realtek hdaudioC0D0: Unable to sync register 0x2b8000. -5 [ 37.008419] snd_hda_codec_realtek hdaudioC0D0: Unable to sync register 0x2b8000. -5

Edit 2:

Checked for updates again, there was an update to change " Jack " to " extra/Jack ". It updated alsa and pulseaudio libraries - I think. Rebooted, still the same flickering.

Edit 3: SOLVED!

Here's what made it for me.

After running:

$ cat /sys/module/snd_hda_intel/parameters/power_save*

and getting " 1 Y " as a return value, I tried to change the values with:

sudo echo 1 > /sys/module/snd_hda_intel/parameters/power_save && sudo echo 1 > /sys/module/snd_hda_intel/parameters/power_save_controller

This didn't work since I didn't have the permissions. What I had to do was to create /etc/modprobe.d/audio_disable_powersave.conf and add options snd_hda_intel power_save=0 to it. Rebooted the system and all works well now.

How to run remote server shell script with environment parameters on Jenkins pipeline

Posted: 27 Jul 2021 08:52 AM PDT

I am attempting to run a shell script on a remote server in jenkins scripted pipeline using the sshScript remote: remote, script: command. This line of code currently looks like this:

sshScript remote: remote, script: './bash.sh' "$env.gitTag" "$env.Version"  

However, it keeps saying that the parameters are null there is an error being thrown. I have tried everything and cannot find an answer. I echo the parameters before they are thrown and they contain strings which I expect.

15:56:35  WARNING: Unknown parameter(s) found for class type 'org.jenkinsci.plugins.sshsteps.steps.CommandStep': script  [Pipeline] }  [Pipeline] // stage  [Pipeline] }  [Pipeline] // node  [Pipeline] }  [Pipeline] // timestamps  [Pipeline] End of Pipeline  java.lang.IllegalArgumentException: command is null or empty      at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:69)      at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution.lambda$start$0(SSHStepExecution.java:84)      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)      at java.base/java.lang.Thread.run(Thread.java:829)  Finished: FAILURE  

These are the errors being published at the end.

Encode a FILE to QR Code. Current Problem: When decoding the QR the output becomes different

Posted: 27 Jul 2021 08:40 AM PDT

Main Objective:

I want to encode the GNU GPL version 3.0 from [https://www.gnu.org/licenses/gpl-3.0.txt.][1] in QR Code format.

My Way:

  • First, by compressing the file in 7Z format with LZMA2 and maximum compression using ark.
  • Second, by splitting the compressed file using split in several files because it cannot be encoded as a whole.
  • Third, by encoding the split files into QR Code.

What I did:

I will use "file" as placeholder for the actual filename gpl-3.0.txt

  • Compressed the file by using ark with LZMA2 and maximum compression.

  • Split the file to several files each one containing 2953 bytes.

    split -d -b 2953 file.7z  

    resulting in output files x00, x01, x02, x03. The limit 2953 bytes is chosen because QR Code version 40 can encode 2953 bytes in raw format but in a LOW Error Correction Level.

  • Encoded the split files using the command:

    qrencode -l L -8 -r x00 -o 0.jpg  

    (the same for x01 etc.)

  • Decoded the files using zbarimg:

    zbarimg --raw 0.jpg > 0  

    (again, the same for 1.jpg etc.)

  • Concatenated the files using cat:

    cat 0 1 2 3 4 > gpl-3.0.txt.7z  
  • Tried to extract the file with no success:

    7z x gpl-3.0.txt.7z  

Problem:

I will use "files" as placeholder for the files encoded in QR Code.

When I try to decode the QR Code encoded files using zbarimg, the output becomes different.

Example file x00:

  • Original x00 hexdump
    hexdump -C -n 32 x00    00000000  37 7a bc af 27 1c 00 04  57 7d fc 55 65 2c 00 00  |7z..'...W}.Ue,..|  00000010  00 00 00 00 62 00 00 00  00 00 00 00 36 86 8f e5  |....b.......6...|  
  • Decoded JPG file 0.jpg (corresponding to x00 file) using zbarimg.
    zbarimg --raw 0.jpg > 0  
    Resulting hexdump:
    00000000  37 7a c2 bc c2 af 27 1c  00 04 57 7d c3 bc 55 65  |7z....'...W}..Ue|  00000010  2c 00 00 00 00 00 00 62  00 00 00 00 00 00 00 36  |,......b.......6|  

What I request

Are there any ways I can achieve my main Objective and also to solve the problem stated?

Utilities/Softwares Used (All are CLI Utilities Except ark) :

  • zbarimg: from zbar-tools, Author of utility by Jeff Brown
  • qrencode: from [https://www.gnu.org/licenses/gpl-3.0.txt][1]
  • split: by Torbjorn Granlund and Richard M. Stallman
  • ark: ark 18.8.3 (KDE GUI Program for Compressing and Decompressing Files)
  • cat: by Torbjorn Granlund and Richard M. Stallman
  • 7z: Info: ritten for Debian by Mohammed Adnene Trojette. Updated by Robert Luberda.

Laptop screen and monitor go blank for a few seconds whenever playing sound

Posted: 27 Jul 2021 08:39 AM PDT

I'm using Debian Bullseye on an Acer Swift laptop (I also had this issue when I was on Debian Buster).

When I have an external monitor connected via HDMI, frequently both displays (the laptop screen and external monitor) will go black for a few seconds (maybe 4 seconds), and then come back on. This behaviour is reliably reproducible any time that a website I'm on plays sounds, or I open the pulseaudio mixer dialog, and certain other options involving apps that play or control sound. When it's in response to a sound playing, the sound doesn't start until both monitors have come back on after going black.

I've read a number of questions and other discussions about similar problems, and the suggested solutions haven't worked. The only things, so far, I have found that stop this occurring, also stop sound from working.

  • Leaving headphones plugged into the audio jack don't stop this happening
  • rmmod -f snd_hda_codec_hdmi stops it happening but also disables all sound
  • Selecting a different profile in the pulseaudio (eg, to one with HDMI out and analog in) stops sound from working

It does look like it's something to do with HDMI audio. I don't want to use audio over HDMI now and would be happy disabling that if I could still have sound, if that could fix my problem.

There aren't any syslog or dmesg entries that are reliably coming up when this happens. I have a recollection that you could increase logging verbosity of the intel HDA codec, but I haven't discovered how.

Edit: pastebin of dmesg lines referring to snd_hda* https://pastebin.ubuntu.com/p/jZ3dM33PFg/

rpl error "TypeError: encode() argument 1 must be str, not None"

Posted: 27 Jul 2021 08:33 AM PDT

Maybe I should use a different tool, but rpl has always worked for me like this...

rpl -Ris "oldname.com" "newname.com" *  

(If you're wondering, R = recursive, i = ignore case, s = dry-run simulation)

The error is...

The files listed below would be modified in a replace operation.  Traceback (most recent call last):    File "/usr/bin/rpl", line 314, in <module>  main()    File "/usr/bin/rpl", line 246, in main  matches = blockrepl(f, o, regex, old_str, new_str, 1024)    File "/usr/bin/rpl", line 92, in blockrepl  parts = (after.join(parts)).encode(encoding=encoding, errors='ignore')  TypeError: encode() argument 1 must be str, not None  

Installing a .rpm package on a Unix VM - root unable to see the file

Posted: 27 Jul 2021 09:07 AM PDT

I am working on an AngularJS app, and want to get Protractor up and running with it, to use for testing the front end user interaction automatically.

The way my development environment is set up, is that I am doing the front-end development on my local Windows desktop, and running grunt on a CentOS 7 VM to serve the front-end of the application.

I have used Unix systems a bit in the past, but predominantly just for a couple of modules I took at university a few years ago, so don't have that much experience with them.

When I joined this company, I started working with the practises that they already had in place. Day-to-day, my use of the Unix VM is simply:

  1. Start it up
  2. Open a couple of terminals
  3. Become root (su -)
  4. Run python (python3.4 -m myApp start)
  5. Run grunt serve from the appropriate location, to serve the front end

I am following the tutorial at: http://www.protractortest.org/#/tutorial to try and get Protractor up and running to use it as a testing framework within my development environment, and have done the first couple of steps of the setup without any problems:

npm install -g protractor    webdriver-manager update  

When I then try to run the next command: webdriver-manager start, I get an error that says:

'java' is not recognized as an internal or external command, operable program or batch file.

[11:24:04] I/start - Selenium Standalone has exited with code 1

I assume that this means that Java is not installed on the VM, and will need to be in order to run the command webdriver-manager start?

I downloaded the JRE for linux x64 (.rpm file) from Oracle, and copied it to the desktop of my VM. I am now following the instructions at Linux Java installation to install Java on the VM, but am having a bit of trouble doing so...

I have followed the steps:

  1. Become root
  2. Change to the directory in which you want to install
  3. Install the package: `rpm -ivh jre-8u144-linux-x64.rpm

but when I run this last command, to install the package, the console shows an error that says:

open of jre-8u144-linux-x64.rpm failed: No such file or directory

If I run ls from the terminal where I am logged in as root, I can't see any of the files on the Desktop (which is my current location), but if I run ls from another terminal where I'm not logged in as root, I can see all of the files on the desktop, including the jre-8u144-linux-x64.rpm file that I'm trying to install...

So why is it that the root user can't see the .rpm file that I want to install, even though the 'normal' user can...? I tried installing the JRE from the 'normal' user by running the command in that terminal, but obviously got an error stating that I didn't have the permissions to do this:

error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)

How can I install the JRE that I need in order to use this testing framework on my VM?

kill background while loop

Posted: 27 Jul 2021 08:17 AM PDT

i have a while loop to act as stopwatch and i want to implment it in script to count the time taken by command to run and i want to kill it after command finish

date1=`date +%s`; while true; do      echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";  done &  

i need to kill this loop inside the script

i tried

    1-jobs but it gives me no output      2-kill $! but give me erro  

but the loop is keep running

Microphone volume on USB soundcard very low, snd_usb_audio options?

Posted: 27 Jul 2021 08:23 AM PDT

I have a C-Media USB soundcard installed on my Raspberry Pi: Bus 001 Device 004: ID 0d8c:0008 C-Media Electronics, Inc.. It is a USB cable with an XLR end on the other side, to which I have an XLR Microphone (a Sennheiser MD 427 if anyone is interested) connected: this is what it looks like

Connecting it to my Mac I can turn up the recording volume (it says "settings for selected device" and "input volume" in german) mac settings and I get a fairly ok recording from it (it's actually a stereo recording, but this shows the volume level): mac recording

Now, the same under Linux looks quite differently. The device is recognized ok, snd_usb_audio is loaded and alsamixer shows the new recording device and lets me turn up the "recording volume" all the way: alsamixer

Yet, the volume of what I can record using # AUDIODEV=hw:1 rec tmp.wav is abysmal at best: Linux recording

Now, is there a way to change the kernel module settings so that I can "crank the recording volume up" any more then what I am presented with? Or maybe any other settings I have forgotten about?

I can "soft-up" the recording using # AUDIODEV=hw:1 rec tmp.wav gain 20, but that also increases the noise and it is still below what the Mac records.


Before you ask:

# arecord -L  null      Discard all samples (playback) or generate zero samples (capture)  default:CARD=Device      C-Media USB Audio Device, USB Audio      Default Audio Device  sysdefault:CARD=Device      C-Media USB Audio Device, USB Audio      Default Audio Device  front:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Front speakers  surround21:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      2.1 Surround output to Front and Subwoofer speakers  surround40:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      4.0 Surround output to Front and Rear speakers  surround41:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      4.1 Surround output to Front, Rear and Subwoofer speakers  surround50:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      5.0 Surround output to Front, Center and Rear speakers  surround51:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      5.1 Surround output to Front, Center, Rear and Subwoofer speakers  surround71:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      7.1 Surround output to Front, Center, Side, Rear and Woofer speakers  iec958:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      IEC958 (S/PDIF) Digital Audio Output  dmix:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Direct sample mixing device  dsnoop:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Direct sample snooping device  hw:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Direct hardware device without any conversions  plughw:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Hardware device with all software conversions  #    # lsusb  Bus 001 Device 005: ID 0d8c:0008 C-Media Electronics, Inc.  Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter  Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  #    # arecord -l  **** List of CAPTURE Hardware Devices ****  card 1: Device [C-Media USB Audio Device], device 0: USB Audio [USB Audio]    Subdevices: 1/1    Subdevice #0: subdevice #0  #    # amixer -c 1 scontrols  Simple mixer control 'PCM',0  Simple mixer control 'Mic',0  Simple mixer control 'Auto Gain Control',0  #    # uname -ra  Linux xxx 4.4.16+ #899 Thu Jul 28 12:36:19 BST 2016 armv6l GNU/Linux  #    # aplay -l -L  null      Discard all samples (playback) or generate zero samples (capture)  default:CARD=ALSA      bcm2835 ALSA, bcm2835 ALSA      Default Audio Device  sysdefault:CARD=ALSA      bcm2835 ALSA, bcm2835 ALSA      Default Audio Device  dmix:CARD=ALSA,DEV=0      bcm2835 ALSA, bcm2835 ALSA      Direct sample mixing device  dmix:CARD=ALSA,DEV=1      bcm2835 ALSA, bcm2835 IEC958/HDMI      Direct sample mixing device  dsnoop:CARD=ALSA,DEV=0      bcm2835 ALSA, bcm2835 ALSA      Direct sample snooping device  dsnoop:CARD=ALSA,DEV=1      bcm2835 ALSA, bcm2835 IEC958/HDMI      Direct sample snooping device  hw:CARD=ALSA,DEV=0      bcm2835 ALSA, bcm2835 ALSA      Direct hardware device without any conversions  hw:CARD=ALSA,DEV=1      bcm2835 ALSA, bcm2835 IEC958/HDMI      Direct hardware device without any conversions  plughw:CARD=ALSA,DEV=0      bcm2835 ALSA, bcm2835 ALSA      Hardware device with all software conversions  plughw:CARD=ALSA,DEV=1      bcm2835 ALSA, bcm2835 IEC958/HDMI      Hardware device with all software conversions  default:CARD=Device      C-Media USB Audio Device, USB Audio      Default Audio Device  sysdefault:CARD=Device      C-Media USB Audio Device, USB Audio      Default Audio Device  front:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Front speakers  surround21:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      2.1 Surround output to Front and Subwoofer speakers  surround40:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      4.0 Surround output to Front and Rear speakers  surround41:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      4.1 Surround output to Front, Rear and Subwoofer speakers  surround50:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      5.0 Surround output to Front, Center and Rear speakers  surround51:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      5.1 Surround output to Front, Center, Rear and Subwoofer speakers  surround71:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      7.1 Surround output to Front, Center, Side, Rear and Woofer speakers  iec958:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      IEC958 (S/PDIF) Digital Audio Output  dmix:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Direct sample mixing device  dsnoop:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Direct sample snooping device  hw:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Direct hardware device without any conversions  plughw:CARD=Device,DEV=0      C-Media USB Audio Device, USB Audio      Hardware device with all software conversions  **** List of PLAYBACK Hardware Devices ****  card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]    Subdevices: 8/8    Subdevice #0: subdevice #0    Subdevice #1: subdevice #1    Subdevice #2: subdevice #2    Subdevice #3: subdevice #3    Subdevice #4: subdevice #4    Subdevice #5: subdevice #5    Subdevice #6: subdevice #6    Subdevice #7: subdevice #7  card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 1: Device [C-Media USB Audio Device], device 0: USB Audio [USB Audio]    Subdevices: 1/1    Subdevice #0: subdevice #0  #    # lsusb -v -d 0d8c:0008    Bus 001 Device 004: ID 0d8c:0008 C-Media Electronics, Inc.  Device Descriptor:    bLength                18    bDescriptorType         1    bcdUSB               1.10    bDeviceClass            0 (Defined at Interface level)    bDeviceSubClass         0    bDeviceProtocol         0    bMaxPacketSize0        64    idVendor           0x0d8c C-Media Electronics, Inc.    idProduct          0x0008    bcdDevice            1.00    iManufacturer           0    iProduct                1 C-Media USB Audio Device    iSerial                 0    bNumConfigurations      1    Configuration Descriptor:      bLength                 9      bDescriptorType         2      wTotalLength          224      bNumInterfaces          4      bConfigurationValue     1      iConfiguration          0      bmAttributes         0xa0        (Bus Powered)        Remote Wakeup      MaxPower              100mA      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        0        bAlternateSetting       0        bNumEndpoints           0        bInterfaceClass         1 Audio        bInterfaceSubClass      1 Control Device        bInterfaceProtocol      0        iInterface              0        AudioControl Interface Descriptor:          bLength                10          bDescriptorType        36          bDescriptorSubtype      1 (HEADER)          bcdADC               1.00          wTotalLength           71          bInCollection           2          baInterfaceNr( 0)       1          baInterfaceNr( 1)       2        AudioControl Interface Descriptor:          bLength                12          bDescriptorType        36          bDescriptorSubtype      2 (INPUT_TERMINAL)          bTerminalID             1          wTerminalType      0x0101 USB Streaming          bAssocTerminal          0          bNrChannels             2          wChannelConfig     0x0003            Left Front (L)            Right Front (R)          iChannelNames           0          iTerminal               0        AudioControl Interface Descriptor:          bLength                12          bDescriptorType        36          bDescriptorSubtype      2 (INPUT_TERMINAL)          bTerminalID             2          wTerminalType      0x0201 Microphone          bAssocTerminal          0          bNrChannels             1          wChannelConfig     0x0001            Left Front (L)          iChannelNames           0          iTerminal               0        AudioControl Interface Descriptor:          bLength                 9          bDescriptorType        36          bDescriptorSubtype      3 (OUTPUT_TERMINAL)          bTerminalID             6          wTerminalType      0x0301 Speaker          bAssocTerminal          0          bSourceID               9          iTerminal               0        AudioControl Interface Descriptor:          bLength                 9          bDescriptorType        36          bDescriptorSubtype      3 (OUTPUT_TERMINAL)          bTerminalID             7          wTerminalType      0x0101 USB Streaming          bAssocTerminal          0          bSourceID              10          iTerminal               0        AudioControl Interface Descriptor:          bLength                10          bDescriptorType        36          bDescriptorSubtype      6 (FEATURE_UNIT)          bUnitID                 9          bSourceID               1          bControlSize            1          bmaControls( 0)      0x01            Mute Control          bmaControls( 1)      0x02            Volume Control          bmaControls( 2)      0x02            Volume Control          iFeature                0        AudioControl Interface Descriptor:          bLength                 9          bDescriptorType        36          bDescriptorSubtype      6 (FEATURE_UNIT)          bUnitID                10          bSourceID               2          bControlSize            1          bmaControls( 0)      0x43            Mute Control            Volume Control            Automatic Gain Control          bmaControls( 1)      0x00          iFeature                0      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        1        bAlternateSetting       0        bNumEndpoints           0        bInterfaceClass         1 Audio        bInterfaceSubClass      2 Streaming        bInterfaceProtocol      0        iInterface              0      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        1        bAlternateSetting       1        bNumEndpoints           1        bInterfaceClass         1 Audio        bInterfaceSubClass      2 Streaming        bInterfaceProtocol      0        iInterface              0        AudioStreaming Interface Descriptor:          bLength                 7          bDescriptorType        36          bDescriptorSubtype      1 (AS_GENERAL)          bTerminalLink           1          bDelay                  1 frames          wFormatTag              1 PCM        AudioStreaming Interface Descriptor:          bLength                14          bDescriptorType        36          bDescriptorSubtype      2 (FORMAT_TYPE)          bFormatType             1 (FORMAT_TYPE_I)          bNrChannels             2          bSubframeSize           2          bBitResolution         16          bSamFreqType            2 Discrete          tSamFreq[ 0]        48000          tSamFreq[ 1]        44100        Endpoint Descriptor:          bLength                 9          bDescriptorType         5          bEndpointAddress     0x01  EP 1 OUT          bmAttributes            9            Transfer Type            Isochronous            Synch Type               Adaptive            Usage Type               Data          wMaxPacketSize     0x00c8  1x 200 bytes          bInterval               1          bRefresh                0          bSynchAddress           0          AudioControl Endpoint Descriptor:            bLength                 7            bDescriptorType        37            bDescriptorSubtype      1 (EP_GENERAL)            bmAttributes         0x01              Sampling Frequency            bLockDelayUnits         1 Milliseconds            wLockDelay              1 Milliseconds      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        2        bAlternateSetting       0        bNumEndpoints           0        bInterfaceClass         1 Audio        bInterfaceSubClass      2 Streaming        bInterfaceProtocol      0        iInterface              0      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        2        bAlternateSetting       1        bNumEndpoints           1        bInterfaceClass         1 Audio        bInterfaceSubClass      2 Streaming        bInterfaceProtocol      0        iInterface              0        AudioStreaming Interface Descriptor:          bLength                 7          bDescriptorType        36          bDescriptorSubtype      1 (AS_GENERAL)          bTerminalLink           7          bDelay                  1 frames          wFormatTag              1 PCM        AudioStreaming Interface Descriptor:          bLength                14          bDescriptorType        36          bDescriptorSubtype      2 (FORMAT_TYPE)          bFormatType             1 (FORMAT_TYPE_I)          bNrChannels             1          bSubframeSize           2          bBitResolution         16          bSamFreqType            2 Discrete          tSamFreq[ 0]        48000          tSamFreq[ 1]        44100        Endpoint Descriptor:          bLength                 9          bDescriptorType         5          bEndpointAddress     0x82  EP 2 IN          bmAttributes            5            Transfer Type            Isochronous            Synch Type               Asynchronous            Usage Type               Data          wMaxPacketSize     0x0064  1x 100 bytes          bInterval               1          bRefresh                0          bSynchAddress           0          AudioControl Endpoint Descriptor:            bLength                 7            bDescriptorType        37            bDescriptorSubtype      1 (EP_GENERAL)            bmAttributes         0x01              Sampling Frequency            bLockDelayUnits         0 Undefined            wLockDelay              0 Undefined      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        3        bAlternateSetting       0        bNumEndpoints           1        bInterfaceClass         3 Human Interface Device        bInterfaceSubClass      0 No Subclass        bInterfaceProtocol      0 None        iInterface              0          HID Device Descriptor:            bLength                 9            bDescriptorType        33            bcdHID               1.00            bCountryCode            0 Not supported            bNumDescriptors         1            bDescriptorType        34 Report            wDescriptorLength      50           Report Descriptors:             ** UNAVAILABLE **        Endpoint Descriptor:          bLength                 7          bDescriptorType         5          bEndpointAddress     0x83  EP 3 IN          bmAttributes            3            Transfer Type            Interrupt            Synch Type               None            Usage Type               Data          wMaxPacketSize     0x0004  1x 4 bytes          bInterval              32  Device Status:     0x0000    (Bus Powered)  #  

How could we allow non-root users to control a systemd service?

Posted: 27 Jul 2021 09:35 AM PDT

With sysvinit, a sudoers entry like this would suffice:

%webteam cms051=/sbin/service httpd *  

This would allow for commands such as:

  • sudo service httpd status
  • sudo service httpd restart

Now, with systemd, the service name is the final argument. I.e., the service restart would be done with:

systemctl restart httpd.service  

Naturally, I thought defining the command as systemctl * httpd.service would work but that would allow something like systemctl restart puppet.service httpd.service which is not the desired effect.

With that being considered, what would be the best way allow non-root users to control a systemd service then? This doesn't need to be sudoers; perhaps a file permission change may be sufficient?

No comments:

Post a Comment