Wednesday, December 22, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Create an LVM stripe with Puppet

Posted: 22 Dec 2021 04:25 AM PST

When I install a new server, it usually has 3-4 HDD disks. Puppet then automatically creates LVM from that.

Currently, it creates the default linear striped LVM whereas I'm looking into it being striped.

I know that when create a striped LVM from the command line, I need to pass in -i with the number of devices to stripe across. Thing is, sometimes it's 3 devices, and sometimes it's 4.

Here's the current init.pp:

class lvm_stripe {      $mydisks = $facts[company_disks]      $lvm_disks = split($mydisks, '\n')      each($lvm_disks) |$disk| {          exec { "part_${disk}":              command => "/sbin/parted -s /dev/${disk} mklabel gpt mkpart ext4 0% 100% ; /bin/sleep 2",              unless  => "/sbin/fdisk -l | grep /dev/${disk}1",          }      }      $mydevs = $facts[company_devs]      physical_volume { $mydevs: ensure => present, force => true }      volume_group { 'os':          ensure           => present,          physical_volumes => $mydevs,          # force            => true,      }      logical_volume { 'disk1':          ensure            => present,          volume_group => 'os',          stripes            => $mydevs.size(), # OR mydevs.length() - Both don't work      }      filesystem { '/dev/os/disk1':          ensure  => present,          fs_type => 'xfs',      }    }  

Thing is, it still makes it linear, and I couldn't find any additional parameters I needed in the docs.

So my question is, in puppet, how do create a striped LVM? And how to make it so it would use all the HDDs?

Thanks ahead!

How to change the color of this selected text of the gnome terminal?

Posted: 22 Dec 2021 04:21 AM PST

I'm trying to change the color of "[shark@Archshark ~]$" to blue in the terminal but It seems that I can't change it, please help.

enter image description here

WebCamoid Chorma-Key Green Screen Background Image Settings

Posted: 22 Dec 2021 04:04 AM PST

Can somebody please provide directions on HOW to set up WebCamoid to use a ChromaKey Green Screen to add a virtual background to my virtual camera? I have WebCamoid installed on MacOS Mojave 10.14 but cannot figure out how to do this and I cannot find directions anywhere. In theory I know you need to add an image, add a filter to process the video and then setup WebCamoid as a virtual webcam, but I can find no details on how this is done. Thank you.

How do I convert this script into an alias (MacOS, ZSH)

Posted: 22 Dec 2021 04:20 AM PST

This script works fine when directly typed into the console:

N | find . -type f -iname "*.aac" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -acodec libmp3lame "${FILE%.aac}.mp3";' _ '{}' \;  

But as I'm trying to add it as an alias into my ~/.zshrc file:

alias aac-to-mp3="N | find . -type f -iname \"*.aac\" -exec bash -c 'FILE=\"$1\"; ffmpeg -i \"${FILE}\" -acodec libmp3lame \"${FILE%.aac}.mp3\";' _ '{}' \;"  

It yields:

 ✔  aac-to-mp3  _: N: command not found  ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers    built with Apple clang version 13.0.0 (clang-1300.0.29.3)    configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox    libavutil      56. 70.100 / 56. 70.100    libavcodec     58.134.100 / 58.134.100    libavformat    58. 76.100 / 58. 76.100    libavdevice    58. 13.100 / 58. 13.100    libavfilter     7.110.100 /  7.110.100    libavresample   4.  0.  0 /  4.  0.  0    libswscale      5.  9.100 /  5.  9.100    libswresample   3.  9.100 /  3.  9.100    libpostproc    55.  9.100 / 55.  9.100  : No such file or directory  

I tried moving the N | into the command itself:

alias aac-to-mp3="find . -type f -iname \"*.aac\" -exec bash -c 'FILE=\"$1\"; N | ffmpeg -i \"${FILE}\" -acodec libmp3lame \"${FILE%.aac}.mp3\";' _ '{}' \;"  

But it generates the same output.

I did restart the shell between each alias change.

How do I make that script usable as an alias? I don't understand the issue.

what does (tr \\n \\0 <file.txt) mean?

Posted: 22 Dec 2021 04:20 AM PST

context: https://stackoverflow.com/a/13941223/15603477
I do understand xargs chmod 755 <file.txt

For bigger amount of files, or almost any number of lines in your input file...

For many binutils tools, like chown, chmod, rm, cp -t ...

xargs chmod 755 <file.txt  

If you have special chars and/or a lot of lines in file.txt.

xargs -0 chmod 755 < <(tr \\n \\0 <file.txt)  

I not sure (tr \\n \\0 <file.txt) meaning?
In man tr the following is what I found:

\\     backslash          \n     new line        

open() Syscall hooking x86_64

Posted: 22 Dec 2021 03:50 AM PST

I was trying to hook open() syscall. My open() does nothing but adds a couple of printk() before the actual syscall.

For hooking, I get the table from this command cat /boot/System.map-3.2.0-56-desktop | grep sys_call_table

This is the output

ffffffff81801360 R sys_call_table  ffffffff818052e8 r ia32_sys_call_table  

If I hook open() syscall for sys_call_table, my system crashes right after I load my LKM. If I hook for ia32_sys_call_table, it works properly. Why is this the behaviour if I am running x64 system?

Where in the filesystem can I get metadata about a socket?

Posted: 22 Dec 2021 03:12 AM PST

I know lsof and ss provide metadata about connections. Where do they get it from?

For example, this represents a connection:

ls -al /proc/102922/fd/98  lrwx------ 1 me me 64 dic 21 06:06 /proc/102922/fd/74 -> 'socket:[3803248]'  

With ss I can see more info:

tcp   ESTAB      0      0                192.168.68.108:33966      198.252.206.25:https  users:(("chrome",pid=102922,fd=98)) cubic wscale:9,7 rto:296 rtt:92.785/24.455 ato:40 mss:1448 pmtu:1500 rcvmss:536 advmss:1448 cwnd:10 bytes_sent:1463 bytes_acked:1464 bytes_received:336 segs_out:11 segs_in:7 data_segs_out:6 data_segs_in:2 send 1.25Mbps lastsnd:71284 lastrcv:71292 lastack:26068 pacing_rate 2.5Mbps delivery_rate 271kbps delivered:7 app_limited busy:308ms rcv_space:14480 rcv_ssthresh:64088 minrtt:86.996       

But, assume the system my app is running on does not have ss for some reason. How can I go from socket:[3803248] to the tcp stats that ss provides? I don't intend to fully rewrite ss :) but I'm curious about what exists in the filesystem.

Random log out of tty1 while typing

Posted: 22 Dec 2021 02:51 AM PST

I experienced a sudden log out from tty1 where I run the i3 window manager.

While typing stuff, the screen went black, and in a matter of seconds I was back to the login screen (I use no login manager):

Arch Linux 5.15.10-arch1-1 (tty1)    enrico login:   

It's actually the second time it happens. It happened a few days ago the first time, and I'm sure both then and now the log out happened while typing, but I have no idea what key combination might trigger a log out.

How can I troubleshoot this?

last -F | head -2 shows

enrico   tty1                          Wed Dec 22 11:34:38 2021   still logged in  enrico   tty1                          Wed Dec 22 06:39:30 2021 - Wed Dec 22 11:34:26 2021  (04:54)  

where the 11:34 event is when I logged back right after the strange log-out happened, whereas the previous event at 06:39 is when I originally logged in this morning.

Maybe I'm searching in the wrong place?

How can I replace a version number captured by regex with another one using SED?

Posted: 22 Dec 2021 03:23 AM PST

I am trying with the following sed command:

sed 's/shared:core:([0-9]{1,4}(\.[0-9a-z]{1,6}){1,5})/shared:core:1.1.1/' test.txt  

to replace the content of test.txt

shared:core:0.0.2  

I expect it to become

shared:core:1.1.1  

But nothing is happening. I think I need a little hint on how that works with sed

sudo crashes terminal but works from within a .sh file

Posted: 22 Dec 2021 02:48 AM PST

Something odd has started happening on my laptop running Ubuntu 20.04

When I open a terminal (either the default one or Terminator) and try to run any sudo command for example sudo ls it will hang, then just close/crash the terminal.

It is consistent and survives reboots etc.

It does not even get to the stage where it will ask for password.

However, if I create a test.sh file and run that e.g ./test.sh then any sudo command will work as expected. It will ask for password then work.

For example, this works:

Test.sh

#!/bin/bash  echo 'sudo will work from here and ask for password and list dir'  echo '----------------------------------------------------------'  echo ''  echo ''    sudo ls    

But in a terminal window, this crashes:

sudo ls  

I've Googled, and Stack Overflow'd everything I can think of, I've not installed anything new as the laptop hasn't been doing anything for a while.

I've run strace sudo which led me to a superuser post which I tried, but that did not work:

https://superuser.com/a/1580324    Hold space when booting Pop!_OS  Select Recovery, which brings up the OS installer  SUPER + T to bring up terminal  sudo -i to switch to root  mount -o remount,rw /  mount --all  chown root:root /usr/bin/sudo  chmod 4755 /usr/bin/sudo  Restart Pop!_OS and login normally  Now I am able to run sudo commands such as sudo apt install python3-virtualenv without issues... so far.  

So before I try anything else, I thought I would ask for some help or assistance as I'm not sure what to do next.

Any help would be appreciated.

OS Info

 solrevdev@hplaptop   OS: Ubuntu 20.04 focal   Kernel: x86_64 Linux 5.4.0-91-generic   Uptime: 11m   Packages: 3208   Shell: bash 5.0.17   Resolution: 1920x1080   DE: GNOME 3.36.5   WM: Mutter   WM Theme:    GTK Theme: Yaru [GTK2/3]   Icon Theme: Yaru   Font: Ubuntu 11   Disk: 148G / 249G (63%)   CPU: Intel Core i5-7200U @ 4x 3.1GHz [46.0°C]   GPU: Mesa Intel(R) HD Graphics 620 (KBL GT2)   RAM: 3632MiB / 15930MiB  

select lines in file with same string pattern

Posted: 22 Dec 2021 01:57 AM PST

Let´s suppose I have the following file.txt:

asiub  sj  abq  b aia  ainp oo  test = 123d  sub ,.  aiba 87ab  test = 129szs bq  test = aqua  ayqvq 133s   

I want to print only the lines of file.txt that contain the string test =.

desired output.txt:

test = 123d  test = 129szs bq  test = aqua  

Any suggestion?

Thanks

bash 2> >(command) > >(command) not getting it

Posted: 22 Dec 2021 02:41 AM PST

Been following this (https://stackoverflow.com/a/16283739/15603477) great answer. The following part I don't understand.

$ ls -ld /tmp /tnt 2> >(sed 's/^/E: /') > >(sed 's/^/O: /')  O: drwxrwxrwt 17 root root 28672 Nov  5 23:00 /tmp  E: ls: cannot access /tnt: No such file or directory  

and this also.

$ ((ls -ld /tmp /tnt |sed 's/^/O: /' >&9 ) 2>&1 |sed 's/^/E: /') 9>&1| cat -n       1  O: drwxrwxrwt 118 root root 196608 Jan  7 12:29 /tmp       2  E: ls: cannot access /tnt: No such file or directory  

https://www.gnu.org/software/sed/manual/sed.html#Introduction E: and O: part still not getting it.


The following is my interpretation

$ ls -ld /tmp /tnt 2> >(sed 's/^/E: /') > >(sed 's/^/O: /')  

2 refers to stderr, the command ls -ld /tmp /tnt 's error will be evaluated in (sed 's/^/E: /'), ^ refer to the beginning of the line, the beginning will be replaced with E:
>(sed 's/^/O: /') == 1>(sed 's/^/O: /')
1 refers to stdout, the normal output will be evaluated in (sed 's/^/O: /') The beginning will be replaced by O:

Reboot does not send "stop" to init.d scripts

Posted: 22 Dec 2021 02:57 AM PST

I have a script that I want to execute before a machine is either shut down or rebooted but it's only triggered with the start parameter, never with the stop parameter and it's driving me crazy.

Following symlinks exist on my system:

/etc/rc0.d/K01init.sh  /etc/rc1.d/K01init.sh  /etc/rc2.d/S99init.sh  /etc/rc3.d/S99init.sh  /etc/rc4.d/S99init.sh  /etc/rc5.d/S99init.sh  /etc/rc6.d/K01init.sh  

that all point to the same script /etc/init.d/init.sh. Based on another thread I also tried without the .sh suffix, which did not change anything.

/etc/init.d/init.sh

#!/bin/sh  ### BEGIN INIT INFO  # Provides:          init.sh  # Required-Start:    $all  # Required-Stop:  # Default-Start:     2 3 4 5  # Default-Stop:      0 1 6  # Short-Description: xxx  # Description:       xxx  ### END INIT INFO    if [ "$1" = "start" ]; then    echo "log message"    //do stuff  fi    echo "$1"    if [ "$1" = "stop" ]; then    echo "log message"    //do stuff  fi    exit 0  

The script runs fine during startup, but complains that the cleanup that should have happened in the stop block was not performed. When I echo the $1 to the logs, it only and always shows start, which means the OS apparently never sends the stop command to my script. Running the script from the command line (sudo /etc/init.d/init.sh stop) works like a charm with both start and stop parameters, so I'm confused as to why it does not work when I stop my machine.

Where am I going wrong here? I'm running Ubuntu 18.04 and my current runlevel is 5 (but that should not be relevant, as it should be about 0 & 6 here). Interesting enough, I tried to check for the actual runlevel at execution time by adding echo "$(who -r)" to the script, which does not output anything to the logs!

If relevant: I'm talking about reboots both via sudo reboot / sudo systemctl reboot and via Azure GUI (it's a virtual machine), not sure if Azures reboot mechanism differs, but neither way works.

Midnight Commander won't show if .env file is in a directory

Posted: 22 Dec 2021 02:55 AM PST

I'm on Ubuntu 20.04 latest, all updates included and I try to use Midnight Commander 4.8.24 from the distro's respository.

I want mc to display a directory's content so I type mc in the terminal. In a directory including a dot env (.env) file, mc will start, but the "GUI" of it will stop responding and won't show up.

You'll only see: "Hinweis: Das Setzen der Variablen CDPATH kann in cd-Kommandos Tastenschläge ersparen" (Translation is mine: "Hint: Setting of a CDPATH variable may save keystrokes.")

What I tried (bash and zsh, same behavior):

  1. mkdir stuff
  2. cd stuff
  3. mc -> works fine, then quit it.
  4. touch .env
  5. mc -> terminal stops responding, mentionened message from above appears.

To stop mc you must either 'kill' mc or the terminal itself. What can I do, so that mc ignores .env files or is it a bug/feature?

EDIT

$ mc -V    GNU Midnight Commander 4.8.24  Kompiliert mit GLib 2.63.3  Benutze die S-Lang-Bibliothek mit der terminfo-Datenbank  Mit eingebautem Editor und Aspell-Unterstützung  Mit optionaler Subshell-Unterstützung als Standard  Mit Unterstützung für Hintergrundtätigkeiten  Mit Maus-Unterstützung im xterm und der Linux-Konsole  Mit Unterstützung für X11-Ereignisse  Mit Internationalisierungs-Unterstützung  Mit Unterstützung mehrerer Codepages  Virtuelles Dateisystem: cpiofs, tarfs, sfs, extfs, ext2undelfs, ftpfs, sftpfs, fish  Datentyp: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;    $ echo $CDPATH  --empty--    

How to find DRM protected WMA files on Ubuntu Linux

Posted: 22 Dec 2021 01:35 AM PST

On my Ubuntu Linux 18.04 machine I have a whole bunch of WMA files (don't ask) which have gotten mixed up with several files from another computer that are DRM protected. The latter won't play and even crash some player software.

Is there a quick-and-easy way to recurse through the entire subdirectory tree and detect which WMA files are DRM protected? I've seen solutions based on Windows XP and Powershell, but nothing for *ix.

Mind you, I'm NOT looking for a (legally dubious) way to strip off the DRM protection; I just need to find out which ones are DRM protected without trying them out one by one so I can remove them.

Advise to discontinue the use of WMA and switch to more sensible formats instead is unnecessary; I never use WMA if I can possibly avoid it. However, the people who pay for my meal ticket require me to support this [censored] so I have little choice.

UTF-8 Decoding And Fonts

Posted: 22 Dec 2021 01:38 AM PST

I created an application that users write fancy texts. The only problem is that I don't know how to make command-line render this utf-8 charterer. It works well on every other charterers but it fails to render or show this: \xEF\xAE\xA9

Do I need to install specific font for this? or is there a bug? or is there any settings which i have to fix?

By the way I use Ubuntu 20.04 And it looks like an empty rectangle on the default Ubuntu terminal.

ScreenShot The Rectangle Unidentified Charterer

Verbose logging: howto save disk?

Posted: 22 Dec 2021 01:26 AM PST

Situation

I'm running a program on Linux, which produces a lot of verbose logs to stdout.

The program itself is put into background by using systemd.service facilities.

Until now, I have configured the program to store only the major loglevels to disk (to be read with syslog or journalctl), and keep printing the minor, verbose logs to stdout.

There was a pretty solid app called reredirect which could reattach me to the verbose-logging pty.

So, whenever some misbehaviour happened in the program, I could reattach myself to this pty, and investigate the verbose logs on what is going on.

Problem

I've changed the architecture to aarch64 and reredirect is not seem available on this platform.

Possible solutions

  1. Save all the verbose logs to disk and examine them just as usual: NOK, as verbose log is really huge, will stress the storage, or if I mount it into tmpfs, it might rotate (as it's huge), and I'll lose earlier, more important major logs.
  2. Starting it in pseudo-tty: wastes resources, thus I have no clue on the feasibility of a systemd.service usage along with screen or tmux.

Most of the time, I need only the major logs. I'm checking it once per week, or bi-weekly.

But when a strange behaviour happens, I need to deepdive right into the verbose logs. Restarting the application is not an option because I'd lose the misbehavior, so as the logs.

So, how can I reattach my current pty to a custom application's default one on aarch64?

Is there a way to decrypt the encrypted files (using ecryptFS) on Linux?

Posted: 22 Dec 2021 01:36 AM PST

I am using ecryptFS for encryption of data on Linux. Is there a way on Linux to decrypt the data without mounting the encrypted folder?

How to move files into subdirectories segregated by date

Posted: 22 Dec 2021 01:32 AM PST

I have a large directory of files last modified over the past several years through now. Is there an easy command or commands I can type one-time in an interactive bash shell that can create subdirectories with the name of each subdirectory being a four-digit year, and move respective files into each subdirectory when I cannot rely on any information in the file name regarding the age of the file, and finally verify everything I ran worked properly and I didn't lose any files or data?

For example given this completely fake example:

$ cd ~/Documents  $ ls -lhrt  ...  -rw-r--r--  4 user   user    4.0K Jun 29  2017 oldfile.txt  -rw-r--r--  4 user   user    4.0K May 15  2018 2018file.md  -rw-r--r--  4 user   user    4.0K Apr 14  2019 04.dat  -rw-r--r--  4 user   user    4.0K Jul 21  2019 somepage.html  drw-r--r--  4 user   user    4.0K Jul 21  2019 somepage_files  -rw-r--r--  4 user   user    4.0K Mar 13  2020 march.dat  -rw-r--r--  4 user   user    4.0K Feb 12 18:03 file02.dat  -rw-r--r--  4 user   user    4.0K Oct 11 18:03 OctReport.txt  

When I'm done, I want to end up with the following:

$ cd ~/Documents  $ find .  .  ./2017  ./2017/oldfile.txt  ./2018  ./2018/2018file.md  ./2019  ./2019/04.dat  ./2019/somepage.html  ./2019/somepage_files  ./2019/somepage_files/...  ./2020  ./2020/march.dat  ./2021  ./2021/file02.dat  ./2021/OctReport.txt  

How to force set (not subtract) permissions to future files?

Posted: 22 Dec 2021 01:14 AM PST

I have a program on Ubuntu Linux that creates a logs/error.log file with a permissions 660 (rw-rw----) or 640 (rw-r-----). But I want the file permissions always to be 666 (rw-rw-rw-) (including when the program creates the file).

Restrictions:

  1. I can't modify the program. Therefore, I can't change 660 mode using by the program for a new files.
  2. The program can recreate the file at any time. Therefore, the solution with a single manual execution of chmod is not suitable.
  3. I need to add a bits of permissions, but not subtract. Therefore, umask and setfacl are not suitable.

Ubuntu Azure Virtual Machine - No Space Left On Device

Posted: 22 Dec 2021 01:44 AM PST

I am a regular Windows user and from time to time I've developed things on Linux but space and machine was provided to me back then. Now I'm using Microsoft Azure and an Ubuntu Virtual Machine by myself and this error seems so strange to me. Why there are lots of mounts and not a combined memory like just /dev/ ? Can't I just merge them altogether? And is there some command from terminal to make free space re-distributed from the one's that have it to one's that not have it.

I typed df -i to see whats going on and the result is:

Filesystem      Inodes  IUsed   IFree IUse% Mounted on  /dev/root      3870720 396517 3474203   11% /  devtmpfs       2048512    464 2048048    1% /dev  tmpfs          2049470     63 2049407    1% /dev/shm  tmpfs          2049470   1051 2048419    1% /run  tmpfs          2049470      4 2049466    1% /run/lock  tmpfs          2049470     18 2049452    1% /sys/fs/cgroup  /dev/loop0       10833  10833       0  100% /snap/core18/2246  /dev/loop1       10836  10836       0  100% /snap/core18/2253  /dev/loop2       11736  11736       0  100% /snap/core20/1242  /dev/loop3       11776  11776       0  100% /snap/core20/1270  /dev/loop5         796    796       0  100% /snap/lxd/21835  /dev/sdb15           0      0       0     - /boot/efi  /dev/loop6         479    479       0  100% /snap/snapd/14295  /dev/loop7         479    479       0  100% /snap/snapd/14066  /dev/loop4        5777   5777       0  100% /snap/docker/1125  /dev/sda1      2097152     12 2097140    1% /mnt  tmpfs          2049470     37 2049433    1% /run/user/123  tmpfs          2049470     64 2049406    1% /run/user/1000  /dev/loop8        2268   2268       0  100% /snap/intellij-idea-community/337  /dev/loop9       40310  40310       0  100% /snap/postman/149  

df -h:

Filesystem      Size  Used Avail Use% Mounted on  /dev/root        29G   27G  2.2G  93% /  devtmpfs        7.9G     0  7.9G   0% /dev  tmpfs           7.9G   83M  7.8G   2% /dev/shm  tmpfs           1.6G  1.5M  1.6G   1% /run  tmpfs           5.0M     0  5.0M   0% /run/lock  tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup  /dev/loop1       56M   56M     0 100% /snap/core18/2253  /dev/loop0       56M   56M     0 100% /snap/core18/2246  /dev/loop2       62M   62M     0 100% /snap/core20/1242  /dev/loop3      818M  818M     0 100% /snap/intellij-idea-community/337  /dev/sdb15      105M  5.2M  100M   5% /boot/efi  /dev/loop4       62M   62M     0 100% /snap/core20/1270  /dev/loop5      169M  169M     0 100% /snap/postman/149  /dev/loop7       68M   68M     0 100% /snap/lxd/21835  /dev/loop6       44M   44M     0 100% /snap/snapd/14295  /dev/loop8      117M  117M     0 100% /snap/docker/1125  /dev/loop9       43M   43M     0 100% /snap/snapd/14066  /dev/sda1        32G   49M   30G   1% /mnt  tmpfs           1.6G   20K  1.6G   1% /run/user/123  tmpfs           1.6G   28K  1.6G   1% /run/user/1000  

Kali Linux - dpkg error while upgrading system. Error processing package powershell-empire (--configure):

Posted: 22 Dec 2021 04:20 AM PST

I was upgrading my Kali Linux VPS using standard sudo apt update and later sudo apt upgrade commands while I encountered an error: Sub-process /usr/bin/dpkg returned an error code (1).

I'm quite fresh Kali user, therefore I don't know why this error happened? Apart from standard Kali installation, I have XFCE desktop environment installed and POSTGRE SQL database. Nothing else. But for some time now I'm connecting to the server using SSH.

I was even more surprised, because I knew that Kali uses APT package manager, therefore I don't understand why there's DPKG error there.

(michal㉿kali)-[~]  └─$ sudo apt upgrade -y  Reading package lists... Done  Building dependency tree... Done  Reading state information... Done  Calculating upgrade... Done  The following packages were automatically installed and are no longer required:    baobab caribou cryptsetup-run folks-common gir1.2-caribou-1.0 gir1.2-clutter-1.0 gir1.2-cogl-1.0 gir1.2-coglpango-1.0 gir1.2-handy-0.0 gir1.2-mutter-8 gnom    gnome-contacts gnome-core gnome-font-viewer gnome-logs gnome-online-miners gnome-tweak-tool golang-1.16-go golang-1.16-src gstreamer1.0-packagekit kwin-sty    libamtk-5-0 libamtk-5-common libaom0 libavif12 libavif9 libcamel-1.2-62 libcaribou-common libcaribou0 libcbor0 libcodec2-0.9 libdap27 libdapclient6v5 libda    libedataserver-1.2-25 libedataserverui-1.2-2 libepsilon1 libextutils-pkgconfig-perl libfluidsynth2 libfolks-eds26 libfolks26 libgdal28 libgdal29 libgdk-pix    libgdk-pixbuf2.0-0 libgeos-3.9.0 libgeos-3.9.1 libgfbgraph-0.2-0 libgupnp-1.2-0 libhandy-0.0-0 libidn11 libkdecorations2private7 libkwineffects12a libkwing    libkwinxrenderutils12 libmusicbrainz5-2 libmusicbrainz5cc2v5 libmutter-8-0 libnetcdf18 libntfs-3g883 libomp-11-dev libomp5-11 libplacebo72 libproj19 libquv    libquvi-scripts-0.9 libstrictures-perl libtepl-5-0 libtracker-control-2.0-0 libtracker-miner-2.0-0 libtracker-sparql-2.0-0 liburcu6 liburing1 libvncclient1    libwireshark14 libwiretap11 libwsutil12 libx265-192 libxmlb1 libyara4 libzapojit-0.0-0 linux-image-5.10.0-kali7-amd64 lua-bitop lua-expat lua-json lua-sock    odbcinst1debian2 python3-editor python3-exif python3-gevent python3-gevent-websocket python3-ipython-genutils python3-jupyter-core python3-m2crypto python3    python3-orjson python3-parameterized python3-pbr python3-plotly python3-pylnk python3-stem python3-tenacity python3-zope.event vlc-bin vlc-l10n vlc-plugin-    vlc-plugin-notify vlc-plugin-qt vlc-plugin-samba vlc-plugin-skins2 vlc-plugin-video-splitter vlc-plugin-visualization  Use 'sudo apt autoremove' to remove them.  The following packages have been kept back:    breeze breeze-cursor-theme kde-cli-tools kde-cli-tools-data kde-config-gtk-style kde-config-screenlocker kde-plasma-desktop kde-style-breeze khotkeys khotk    kwin-common kwin-data kwin-style-breeze kwin-x11 libcolorcorrect5 libkdecorations2-5v5 libkdecorations2private9 libkf5sysguard-bin libkf5sysguard-data libk    libkfontinstui5 libkscreenlocker5 libksgrd9 libksignalplotter9 libksysguardformatter1 libksysguardsensorfaces1 libksysguardsensors1 libkwaylandserver5    libkwin4-effect-builtins1 libkwineffects13 libkwinglutils13 libkwinxrenderutils13 libkworkspace5-5 libnotificationmanager1 libplasma-geolocation-interface5    libpowerdevilcore2 libpowerdevilui5 libprocesscore9 libprocessui9 libsemanage-common libtaskmanager6abi1 libweather-ion7 passwd plasma-desktop plasma-deskt    plasma-workspace plasma-workspace-data powerdevil powerdevil-data qml-module-org-kde-ksysguard systemsettings  The following packages will be upgraded:    libdecor-0-0 libdecor-0-plugin-1-cairo libnet-pcap-perl  3 upgraded, 0 newly installed, 0 to remove and 51 not upgraded.  4 not fully installed or removed.  Need to get 92.4 kB of archives.  After this operation, 0 B of additional disk space will be used.  Get:1 http://mirror.serverius.net/kali kali-rolling/main amd64 libdecor-0-plugin-1-cairo amd64 0.1.0-3 [19.0 kB]  Get:2 http://mirror.neostrada.nl/kali kali-rolling/main amd64 libdecor-0-0 amd64 0.1.0-3 [13.2 kB]  Get:3 http://mirror.neostrada.nl/kali kali-rolling/main amd64 libnet-pcap-perl amd64 0.20-1 [60.2 kB]  Fetched 92.4 kB in 1s (130 kB/s)  (Reading database ... 468468 files and directories currently installed.)  Preparing to unpack .../libdecor-0-plugin-1-cairo_0.1.0-3_amd64.deb ...  Unpacking libdecor-0-plugin-1-cairo:amd64 (0.1.0-3) over (0.1.0-2) ...  Preparing to unpack .../libdecor-0-0_0.1.0-3_amd64.deb ...  Unpacking libdecor-0-0:amd64 (0.1.0-3) over (0.1.0-2) ...  Preparing to unpack .../libnet-pcap-perl_0.20-1_amd64.deb ...  Unpacking libnet-pcap-perl (0.20-1) over (0.19-1) ...  Setting up powershell-empire (4.2.0-0kali2) ...  Traceback (most recent call last):    File "/usr/share/powershell-empire/empire.py", line 11, in <module>      import empire.server.server as server    File "/usr/share/powershell-empire/empire/server/server.py", line 24, in <module>      import socketio    File "/usr/lib/python3/dist-packages/socketio/__init__.py", line 3, in <module>      from .client import Client    File "/usr/lib/python3/dist-packages/socketio/client.py", line 7, in <module>      import engineio    File "/usr/lib/python3/dist-packages/engineio/__init__.py", line 8, in <module>      from .asyncio_client import AsyncClient    File "/usr/lib/python3/dist-packages/engineio/asyncio_client.py", line 7, in <module>      import aiohttp    File "/usr/lib/python3/dist-packages/aiohttp/__init__.py", line 6, in <module>      from .client import (    File "/usr/lib/python3/dist-packages/aiohttp/client.py", line 35, in <module>      from . import hdrs, http, payload    File "/usr/lib/python3/dist-packages/aiohttp/http.py", line 7, in <module>      from .http_parser import (    File "/usr/lib/python3/dist-packages/aiohttp/http_parser.py", line 15, in <module>      from .helpers import NO_EXTENSIONS, BaseTimerContext    File "/usr/lib/python3/dist-packages/aiohttp/helpers.py", line 667, in <module>      class CeilTimeout(async_timeout.timeout):  TypeError: function() argument 'code' must be code, not str  dpkg: error processing package powershell-empire (--configure):   installed powershell-empire package post-installation script subprocess returned error exit status 1  dpkg: dependency problems prevent configuration of kali-linux-headless:   kali-linux-headless depends on powershell-empire; however:    Package powershell-empire is not configured yet.    dpkg: error processing package kali-linux-headless (--configure):   dependency problems - leaving unconfigured  Setting up libdecor-0-0:amd64 (0.1.0-3) ...  Setting up libnet-pcap-perl (0.20-1) ...  dpkg: dependency problems prevent configuration of kali-linux-default:   kali-linux-default depends on kali-linux-headless; however:    Package kali-linux-headless is not configured yet.    dpkg: error processing package kali-linux-default (--configure):   dependency problems - leaving unconfigured  Setting up libdecor-0-plugin-1-cairo:amd64 (0.1.0-3) ...  dpkg: dependency problems prevent configuration of kali-linux-large:   kali-linux-large depends on kali-linux-default; however:    Package kali-linux-default is not configured yet.    dpkg: error processing package kali-linux-large (--configure):   dependency problems - leaving unconfigured  Processing triggers for libc-bin (2.32-4) ...  Processing triggers for man-db (2.9.4-2) ...  Processing triggers for kali-menu (2021.4.2) ...  Errors were encountered while processing:   powershell-empire   kali-linux-headless   kali-linux-default   kali-linux-large  E: Sub-process /usr/bin/dpkg returned an error code (1)    ┌──(michal㉿kali)-[~]  └─$ ./setup/install.sh                                                                                                                                 100 ⨯  zsh: no such file or directory: ./setup/install.sh    
(michal㉿kali)-[~]  └─$ sudo dpkg --configure -a                                                                                                                           130 ⨯  Setting up powershell-empire (4.2.0-0kali2) ...  Traceback (most recent call last):    File "/usr/share/powershell-empire/empire.py", line 11, in <module>      import empire.server.server as server    File "/usr/share/powershell-empire/empire/server/server.py", line 24, in <module>      import socketio    File "/usr/lib/python3/dist-packages/socketio/__init__.py", line 3, in <module>      from .client import Client    File "/usr/lib/python3/dist-packages/socketio/client.py", line 7, in <module>      import engineio    File "/usr/lib/python3/dist-packages/engineio/__init__.py", line 8, in <module>      from .asyncio_client import AsyncClient    File "/usr/lib/python3/dist-packages/engineio/asyncio_client.py", line 7, in <module>      import aiohttp    File "/usr/lib/python3/dist-packages/aiohttp/__init__.py", line 6, in <module>      from .client import (    File "/usr/lib/python3/dist-packages/aiohttp/client.py", line 35, in <module>      from . import hdrs, http, payload    File "/usr/lib/python3/dist-packages/aiohttp/http.py", line 7, in <module>      from .http_parser import (    File "/usr/lib/python3/dist-packages/aiohttp/http_parser.py", line 15, in <module>      from .helpers import NO_EXTENSIONS, BaseTimerContext    File "/usr/lib/python3/dist-packages/aiohttp/helpers.py", line 667, in <module>      class CeilTimeout(async_timeout.timeout):  TypeError: function() argument 'code' must be code, not str  dpkg: error processing package powershell-empire (--configure):   installed powershell-empire package post-installation script subprocess returned error exit status 1  dpkg: dependency problems prevent configuration of kali-linux-headless:   kali-linux-headless depends on powershell-empire; however:    Package powershell-empire is not configured yet.    dpkg: error processing package kali-linux-headless (--configure):   dependency problems - leaving unconfigured  dpkg: dependency problems prevent configuration of kali-linux-default:   kali-linux-default depends on kali-linux-headless; however:    Package kali-linux-headless is not configured yet.    dpkg: error processing package kali-linux-default (--configure):   dependency problems - leaving unconfigured  dpkg: dependency problems prevent configuration of kali-linux-large:   kali-linux-large depends on kali-linux-default; however:    Package kali-linux-default is not configured yet.    dpkg: error processing package kali-linux-large (--configure):   dependency problems - leaving unconfigured  Errors were encountered while processing:   powershell-empire   kali-linux-headless   kali-linux-default   kali-linux-large    

I don't know where should I ask this question. I got a database there, which is pretty important for me - It's a part of my masters degree, so destroying the server and reinstalling Kali is not an option.

How can I check passphrase of gpg from a file?

Posted: 22 Dec 2021 03:31 AM PST

I want to check whether the passphrase of my user-id located inside a file is correct or not. I have stored my passphrase in a file (/home/user/.gpg_pass.txt), than I use it as:

gpg --verbose --batch --yes --pinentry-mode loopback \      --passphrase-file=/home/user/.gpg_pass.txt      --decrypt <file>  

Before using this command, I want to verify that the passphrase inside the file is correctly entered. I have tried, which did not help:

cat /home/user/.gpg_pass.txt | gpg --dry-run --passwd <key_id>


From man of gpg:

--passwd user-id         Change the passphrase of the secret key belonging to the certificate          specified as user-id.  This is a shortcut for the sub-command passwd           of  the edit  key  menu.  When using together with the option --dry-run          this will not actually change the passphrase but check that the current          passphrase is correct.  

When I enter:

$ gpg --dry-run --passwd <key_id>  

Two times following window show up I enter the passphrase, (if wrong passphrase is entered it says Bad Passphrase (try 2 of 3) in the GUI-console):

 ┌────────────────────────────────────────────────────────────────┐   │ Please enter the passphrase to unlock the OpenPGP secret key:  │   │ "Alper <alper@gmail.com>"                                      │   │ 3072-bit RSA key, ID 86B9E988681A51D1,                         │   │ created 2021-12-15.                                            │   │                                                                │   │                                                                │   │ Passphrase: __________________________________________________ │   │                                                                │   │         <OK>                                    <Cancel>       │   └────────────────────────────────────────────────────────────────┘  

Instead of manually entering passphrase into GUI inside console, can it be pipe in the gpg --dry-run --passwd <key_id> and can its output could be returned, verifying is the given passphrase correct or not?


Related: https://stackoverflow.com/q/11381123/2402577

Systemd log to file prepend timestamp

Posted: 22 Dec 2021 02:02 AM PST

I have a systemd service that logs to files:

[Unit]  Description=...    [Service]  ExecStart=/path/to/my_service  StandardOutput=append:/var/log/my_service/log.log  StandardError=append:/var/log/my_service/err_log.log    [Install]  WantedBy=multi-user.target  

I would like to prepend the current timestamp to each line as can be achieved in the terminal with the ts command from moreutils using:

/path/to/my_service | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]'  

I tried:

ExecStart=/path/to/my_service | /usr/bin/ts '[%%Y-%%m-%%d %%H:%%M:%%S]'  

but the log output still looks the same.

How can I prepend the timestamp to each line in both the StandardOutput and StandardError log files?

turn 1st row into + 3 columns in file txt

Posted: 22 Dec 2021 01:21 AM PST

enter image description hereI have a txt file, which looks like this:

#A9999999999999              012021I                                     0099999999    000000000099999999+000000000000000000-000000000000000000-    0099999999    000000000099999999+000000000000000000-000000000000000000-    0099999999    000000000099999999+000000000000000000-000000000000000000-    0099999999    000000000099999999+000000000000000000-000000000000000000-  

With the first row I want to create 3 more columns

9999999,012021,I,0099999999,000000000099999999+,000000000000000000-,000000000000000000-  9999999,012021,I,0099999999,000000000099999999+,000000000000000000-,000000000000000000-  9999999,012021,I,0099999999,000000000099999999+,000000000000000000-,000000000000000000-  9999999,012021,I,0099999999,000000000099999999+,000000000000000000-,000000000000000000-  

This example would include 3 columns with the value of the first row, first column with these positions 1st Column (08-15) 2nd column (30-35), 3rd column position 36 with the data of the 1st row.

During the insertion of the first part of the file the tab has changed the structure a little for some browsers. So I put a photo of what the layout of the file looks like.

I am currently using Debian. The first few attempts I was trying with cat and sed. As I'm not familiar with the syntax I came to ask for some examples.

Showing ImportError: cannot import name 'Message' from 'can' in my Ubuntu

Posted: 22 Dec 2021 01:55 AM PST

In my laptop Ubuntu 20, I am using TCP sockets for sending and receiving messages in Python and I am using can library. So the line in my python code here is:

from can import Message  

It was working fine but then I changed the folders and then I am getting the below error:

Traceback (most recent call last):    File "/home/rafi/PycharmProjects/Right Turn/CAN_simulator_Recv.py", line 12, in <module>      from can import Message  ImportError: cannot import name 'Message' from 'can' (/home/rafi/.local/lib/python3.8/site-packages/can/__init__.py)  

Can anyone help me with this error? Maybe it has something to do with directory or packages? The same can library is working fine in my Raspberry Pi Ubuntu 20. Will reinstalling the laptop's Ubuntu help?

I installed it with the below command

pip3 install python-can  

Tried uninstalling using the below command

pip3 uninstall python-can  

But after trying to uninstall, it showed below error

PermissionError: [Errno 13] Permission denied:  

LVM: df reports lots of free space, and no free space on PV

Posted: 22 Dec 2021 03:01 AM PST

I want to remove one partition from LVM. df -h reports a 46GB of free space:

Filesystem               Size  Used Avail Use% Mounted on  /dev/mapper/centos-root   58G   13G   46G  23% /  devtmpfs                 1.9G     0  1.9G   0% /dev  tmpfs                    1.9G     0  1.9G   0% /dev/shm  tmpfs                    1.9G  9.1M  1.9G   1% /run  tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup  /dev/sda1               1014M  261M  754M  26% /boot  VBoxShared               466G  278G  189G  60% /media/sf_VBoxShared  tmpfs                    379M  4.0K  379M   1% /run/user/42  tmpfs                    379M   48K  379M   1% /run/user/1000  

However for some reason all LVM thinks that I have no free space - here is output from pvs -o+pv_used:

  PV         VG     Fmt  Attr PSize   PFree Used       /dev/sda2  centos lvm2 a--   <9.00g    0   <9.00g    /dev/sda3  centos lvm2 a--  <20.00g    0  <20.00g    /dev/sda5  centos lvm2 a--  <30.00g    0  <30.00g  

Because of this pvmove /dev/sda5 fails with error "No extents available for allocation.". What happened with my system and how to fix this?

For reference, here is output of fdisk -l (I have resized physical volume in VirtualBox by adding extra 20GB there):

Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors  Units = sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disk label type: dos  Disk identifier: 0x000c178c       Device Boot      Start         End      Blocks   Id  System  /dev/sda1   *        2048     2099199     1048576   83  Linux  /dev/sda2         2099200    20971519     9436160   8e  Linux LVM  /dev/sda3        20971520    62914559    20971520   8e  Linux LVM  /dev/sda4        62914560   125829119    31457280    5  Extended  /dev/sda5        62916608   125829119    31456256   8e  Linux LVM    Disk /dev/mapper/centos-root: 62.3 GB, 62264442880 bytes, 121610240 sectors  Units = sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors  Units = sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  

I have CentOS 7.5.

ssh with rsa key asks for password

Posted: 22 Dec 2021 04:04 AM PST

I have a server with Ubuntu 14.04 x64 operation system.

Part of my sshd_config file (entire file):

Port 2202  Protocol 2  PermitRootLogin without-password  StrictModes yes  RSAAuthentication yes  PubkeyAuthentication yes  AuthorizedKeysFile      /etc/ssh/keys/%u/authorized_keys  RhostsRSAAuthentication no  PermitEmptyPasswords no  ChallengeResponseAuthentication no  #PasswordAuthentication yes  UsePAM yes  

In folder /etc/ssh/keys each system user has its own folder with authorized_keys file:

ls -l /etc/ssh/keys  drw------- 2 test.com  test.com   4096 Nov 20 06:53 test.com  drw------- 2 root      root       4096 Nov 20 02:29 root  

The permissions of these authorized_keys files are correct:

ls -l /etc/ssh/keys/*  /etc/ssh/keys/test.com:  total 4  -r-------- 1 test.com test.com 960 Nov 20 07:17 authorized_keys    /etc/ssh/keys/root:  total 4  -r-------- 1 root root 395 Nov 20 02:29 authorized_keys  

I have the same public id_rsa in root's and test.com's authorized_keys file.
I can login with root through ssh, but with test.com I am prompted for password.

Here is the debug info when trying to connect with test.com user:

debug1: Next authentication method: publickey  debug1: Offering RSA public key: /Users/Ivan/.ssh/id_rsa  debug1: Authentications that can continue: publickey,password  debug1: Trying private key: /Users/Ivan/.ssh/id_dsa  debug1: Next authentication method: password  

When I try to login with root I succeed:

debug1: Next authentication method: publickey  debug1: Offering RSA public key: /Users/Ivan/.ssh/id_rsa  debug1: Server accepts key: pkalg ssh-rsa blen 279  debug1: Authentication succeeded (publickey).  

I have Googled a lot of things. Couldn't find anything that solves my problem.

I have a script which creates system users using useradd command and these users are without passwords by default. I've found that system users without password may not login through ssh so I added password to test.com user. Didn't work.

I saw that UsePAM yes may be a problem. I set it to UsePAM no. Didn't work.

And yes, I did service ssh restart after each change to the sshd_config file.

I think I've tried everything and now I am clueless.

Any help will be appreciated!

Exim4 550-Verification failed - how to allow any sender?

Posted: 22 Dec 2021 02:04 AM PST

Mail sent from a daemon on my server connecting to exim4 daemon light using SMTP seems to be being frozen. In the exim4 log:

2014-10-01 09:52:19 1XZKKJ-00049R-8p <= noreply@example.com H=localhost (server.example.com) [127.0.0.1] P=esmtp S=9492  014-10-01 09:52:22 1XZKKJ-00049R-8p ** someone@somewhere.com R=dnslookup T=remote_smtp: SMTP error from remote mail server after RCPT TO:<someone@somewhere.com>: host somewhere.com [203.170.86.177]: 550-Verification failed for <noreply@example.com>  550-No Such User Here  550 Sender verify failed  

I think this is saying exim4 rejected the sender's, i.e. the from email address? Exim4 is running on server.example.com and I am using noreply@example.com as the sender which does not exist - it worked in the past. I had to recently re-do domain records on example.com but they are all OK now and have percolated out (they were done days ago).

I think I have the same issue as here: http://help.directadmin.com/item.php?id=59, but cannot try the solution as cannot find exim4 configuration file is - there are many under /etc/exim4/conf.d (I just ran dpkg-reconfigure exim4-config when I installed exim) and the documentation says there is just one? Also how was it working before?

I am prepared to allow any sender - the firewall blocks external access to exim and I am only using it to send mail from my own daemon.

UPDATE Sending to other email addresses works, just to particular one (that is certainly valid) does not - which is weird because exim says it is problem with sender not recipient?!

How to follow links in linux man pages?

Posted: 22 Dec 2021 01:10 AM PST

Is there a way to follow the links mentioned in a man page? For example, here's the man page for ps; how do I access the underlined link circled in red in the screenshot: top(1)?

Screenshot of the ps man page

No comments:

Post a Comment