Saturday, July 17, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Suddenly unable to ssh into CentOS 8 server with error "Server refused our key"

Posted: 17 Jul 2021 10:56 AM PDT

I have a CentOS 8 server set up with a few users with SSH keys, and I haven't had any problems logging in with any of the users as of a few days ago. (Password authentication is disabled, so is root login.)

I go to log in today using PuTTY and WinSCP and get a chilling

Server refused our key

This happens for ALL users. sshd seems to be functioning obviously since it gets up to the point of refusing a key. When I dig through the logs I see:

Server offered these authentication methods: publickey,gssapi-keyex,gssapi-with-mic

This indicates that sshd seems to be operating normally.

I tried logging in using keys loaded in Pageant, and I also tried bypassing Pageant and loading the keys directly in PuTTY and WinSCP, the key is still refused. And yes, it's the correct key, and it hasn't changed.

I happen to have a backup application running so I am able to see what changes to the files may have taken place on the server. I can confirm that the .ssh/authorized_keys files have not been modified. Nor has sshd_config, which I downloaded and looked at.

The last time I logged in was a few days ago and I did a dnf update, but I don't see how that can affect any of this.

Any ideas what may be causing this?

Is it possible to use `df` when some of the NFS disks are unresponsive?

Posted: 17 Jul 2021 10:48 AM PDT

I have some Ubuntu file server that is connected to several NFS disks. Due to some earthquake, some NFS disks became unresponsive. This results in the df command hanging forever. Is it possible to use df when some of the NFS disks are unresponsive? E.g., by specifying some timeout (such as: "if disk x doesn't respond within y second, skip").

How to keep width format in printf when saving to a variable?

Posted: 17 Jul 2021 10:06 AM PDT

I have the following code

printf "%8s.%s\n" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM"  

That produces the expected output

   24756.22971      9910.13045      7701.30924     22972.27622  

I would like to save this output with leading spaces in a variable for later uses like this

printf -v output "%8s.%s\n" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM"  

However, if i try to print/echo the variable $output, leading spaces are gone:

24756.22971  9910.13045  7701.30924  22972.27622  

How do I combine two "devices" so that I can expand a partition that I want to span both on Ubuntu 20 LTS without a GUI / GParted. (SSH only.)

Posted: 17 Jul 2021 08:10 AM PDT

I have been looking all over to figure out how to expand a partition on one "device" to use space on another "device". I am putting quotes around device because that is what it calls it. (I know it basically just means another drive.)

Here is the output of fdisk -l on my system (also on the picture below):

Disk /dev/sda: 360 GiB, 386547056640 bytes, 754974720 sectors  Disk model: QEMU HARDDISK     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: 0xe857882a    Device     Boot   Start       End   Sectors   Size Id Type  /dev/sda1  *       2048   1953791   1951744   953M 83 Linux  /dev/sda2       1953792 754972671 753018880 359.1G 83 Linux      Disk /dev/sdb: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors  Disk model: QEMU HARDDISK     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/loop0: 1.13 GiB, 1216450560 bytes, 2375880 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/vg1-lvol0: 1.26 TiB, 1384053211136 bytes, 2703228928 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  

The output of "fdisk -l"

As you can probably tell, I have already tried to use lvm, but I don't think I did anything correctly because I could not find anyone explaining how to use it for what I want to do.

I do see that there is a new "1.26TiB" Disk, but how do I use that without wiping the data on said disk?

Any help would be very appreciated as our servers have been down for a while now due to this issue.

Thanks!

How to install glib 1.2 on new system?

Posted: 17 Jul 2021 08:46 AM PDT

I try to install glib 1.2 on Ubiuntu 21.04 to run old c program

After succesfull

./configure --build=i386-linux-gnu --host=i386-linux-gnu  

I try

make  

with error :

 make check  Making check in .  make[1]: Wejście do katalogu '/home/a/Pobrane/glib-1.2.0'  /bin/sh ./libtool --mode=link gcc  -g -O2 -Wall  -D_REENTRANT  -o libglib.la -rpath /usr/local/lib -version-info 0:0:0  -release 1.2 garray.lo gcache.lo gcompletion.lo gdataset.lo gdate.lo gerror.lo ghash.lo ghook.lo giochannel.lo giounix.lo glist.lo gmain.lo gmem.lo gmessages.lo gmutex.lo gnode.lo gprimes.lo grel.lo gscanner.lo gslist.lo gstrfuncs.lo gstring.lo gtimer.lo gtree.lo gutils.lo    rm -fr .libs/libglib.la .libs/libglib.* .libs/libglib-1.2.*    *** Warning: This library needs some functionality provided by -lc.  *** I have the capability to make that library automatically link in when  *** you link to this library.  But I can only do this if you have a  *** shared version of the library, which you do not appear to have.  gcc -shared -Wl,-soname -Wl,libglib-1.2.so.0 -o .libs/libglib-1.2.so.0.0.0 garray.lo gcache.lo gcompletion.lo gdataset.lo gdate.lo gerror.lo ghash.lo ghook.lo giochannel.lo giounix.lo glist.lo gmain.lo gmem.lo gmessages.lo gmutex.lo gnode.lo gprimes.lo grel.lo gscanner.lo gslist.lo gstrfuncs.lo gstring.lo gtimer.lo gtree.lo gutils.lo  /usr/bin/ld: gcache.lo: in function `g_bit_nth_lsf':  ...    /home/a/Pobrane/glib-1.2.0/glib.h:1560: multiple definition of `g_bit_nth_msf'; garray.lo:/home/a/Pobrane/glib-1.2.0/glib.h:1560: first defined here  /usr/bin/ld: gutils.lo: in function `g_bit_storage':  /home/a/Pobrane/glib-1.2.0/glib.h:1578: multiple definition of `g_bit_storage'; garray.lo:/home/a/Pobrane/glib-1.2.0/glib.h:1578: first defined here  collect2: error: ld returned 1 exit status  make[1]: *** [Makefile:296: libglib.la] Błąd 1  make[1]: Opuszczenie katalogu '/home/a/Pobrane/glib-1.2.0'  make: *** [Makefile:403: check-recursive] Błąd 1    

I have googled the error info without result. Is the solution for this ?

========edit===

After glib installation:

 make  cc -ansi -Wall -g -I /usr/include/glib-1.2 -I /usr/include/gtk-1.2 -I /usr/lib/glib/include  -c julia2.c  julia2.c:8:10: fatal error: gtk/gtk.h: Nie ma takiego pliku ani katalogu      8 | #include <gtk/gtk.h>        |          ^~~~~~~~~~~  compilation terminated.  make: *** [makefile:16: julia2.o] Błąd 1  

how do I undelete my Python3 symlink to Python3.8?

Posted: 17 Jul 2021 10:40 AM PDT

I've run into an issue where I've lost the ability to use apt on my Debian: I get "No module named 'apt_pkg'" despite uninstalling it and reinstalling it.

Another person while looking at the following output, suggested I had deleted the symlink to Python3.8.

screenshot of the output of ls on /usr/bin

So how do I get it back?

This all started when I changed Python3 versions. As a person says in this query Change the Python3 default version in Ubuntu - apparently this can break apt? They say: "This answer will probably break apt.".

How to kill an application that thrashes hdd?

Posted: 17 Jul 2021 06:51 AM PDT

Is there a known way/application to kill applications that thrash HDD, like early-oom does for RAM?

Would rotating BTRFS snapshots too frequently cause slowdown?

Posted: 17 Jul 2021 05:03 AM PDT

I've Debian Buster with swaps disabled (only enabled before hibernation) and zram installed. I do track the RAM and swap usage all the time by the widgets. Swap is full nearly all the time but RAM stays 80-90% at most, mostly. I also have Early OOM Killer installed, so I'm never out of RAM, I guess. My VBox virtual machines are located inside a folder whose CoW is disabled.

I also have a script that takes a BTRFS snapshot of the rootfs every hour and deletes the older ones, so I guarantee keeping a limited amount of snapshots.

Problem is that my system becomes unresponsive sometimes. I'm out of ideas what to check for the responsible parameter. Could it be the rotation of BTRFS snapshots? How frequent rotation is too frequent? Can I log/trace the total CPU time and disk read/write amount of btrfs-cleaner?

How to find what packages are added in a new Debian release

Posted: 17 Jul 2021 09:18 AM PDT

I am updating my Debian system to a new major release and as Debian is famous for having one of the largest software repositories among Linux distros, I am interested to see what packages have been added since the last release. Currently I am updating from Debian 10 "Buster" to Debian 11 "Bullseye".

Is such a list maintained by the Debian project people or else how is it possible to build it, probably using an APT query?

Obviously packages that have only seen version updates should not be counted. It would also be interesting to see what packages have been removed.

Using 'screen', open few tabs

Posted: 17 Jul 2021 03:11 AM PDT

I need to do a script which runs 2 servers.

I know that screen -S my-servers create screen with this name. How I can write a command which does 1 screen with 2 tabs?

So I need a command. (I know keyboard binds but i don't need to use it often)

  1. What command must do: Create screen > create tab1 >run script ; create tab2 > run script

  2. What command i can use if i want to do CTRL+C than run script in some tab of this screen

Unable to start plasmashell in Arch Linux

Posted: 17 Jul 2021 03:24 AM PDT

KWin is displaying windows, but the background, panel et cetera are missing. I tried starting plasmashell from Konsole using

kstart5 plasmashell  

But it returns an error message:

starting invalid corona "org.kde.plasma.desktop"  

I've tried reinstalling plasma, but it did not work. Any help would be much appreciated

KDE/xorg: How to prevent windows from being only almost fullscreen?

Posted: 17 Jul 2021 03:21 AM PDT

The Problem:

Strangely enough, I've had this problem on every operating system I've used, including Windows.

Sometimes windows open not-quite-fullscreen. I don't know why they do that, I certainly didn't leave the app like that last time I closed it. There's usually like a pixel or two between the top edge of the window and the edge of the screen, as well as at the bottom.

This is extremely annoying because I don't usually look that closely, and then more often than not, when I try to click the "X" in the top right corner, I actually miss the window and click whatever is behind it - usually the "X" of another window that I didn't want to close.

The most recent case of this was Yakuake's keyboard shortcut config window. I ended up closing my browser instead, with lots of open tabs.

This shouldn't be possible to happen at all. I see zero legitimate use cases for windows doing that. Sure, there is snapping, but that only applies when I'm moving the window myself, not when a new window opens.

Question:

Is there some way to configure xorg/kwin to prevent windows from opening only almost fullscreen? Say, a 10px margin at the screen edges (except at the bottom because of the task bar) where if the window is within all of them, it automatically gets properly maximized? Again, KDE's built-in snapping doesn't work because I'm not moving the window myself.

How to use official Nix Docker image to test configuration?

Posted: 17 Jul 2021 08:21 AM PDT

I'm trying to build my Nix configuration in GitLab CI, to make sure any changes have at least a chance of working in NixOS. The official Nix Docker image has a very different structure from NixOS (being based on Alpine), and I keep getting an error I've no idea how to resolve:

$ docker run --volume=$(pwd):/etc/nixos --interactive --rm --tty nixos/nix  5cc8dad8d887:/# nix-build /etc/nixos/configuration.nix  error: cannot auto-call a function that has an argument without a default value ('config')  

Even the file generated by nixos-generate-config has the same problem:

$ cd "$(mktemp --directory)"  $ nixos-generate-config --root .  $ nix-build etc/nixos/configuration.nix  error: cannot auto-call a function that has an argument without a default value ('config')  

The only other repo I've found to do something similar is much more complex than what I was hoping to do here.

How to specify the BusIDs for all framebuffer devices in freebsd?

Posted: 17 Jul 2021 05:20 AM PDT

I installed lxde this way:

sudo pkg install xf86-video-intel  sudo pkg install lxde-mate  cd /usr/home/freebsd  vi .xinitrc  ck-launch-session dbus-launch --exit-with-session  exec startlxde  

It doesn't matter to write the two lines

ck-launch-session dbus-launch --exit-with-session  exec startlxde  

into one line.

exec ck-launch-session dbus-launch --exit-with-session  startlxde  

And the rc.conf file setting:
vi /etc/rc.conf dbus_enable="YES"

vi /etc/fstab  proc /proc procfs rw 0 0  

It is time to start lxde to enter into gui.

startx  cannot run in framebuffer mode, please specify busIDs for all framebuffer devices.  

I deleted my swap partition and ended up with longer boot times and no RESUME file

Posted: 17 Jul 2021 04:18 AM PDT

I am running Ubuntu 20.04, dual-booted with my Win10. I initially made a 32GB swap partition while installing Ubuntu, but now, I wanted to utilize that space somewhere else. So, this is what I did. But ended up with longer boot times now. As suggested in the comments, I had to do RESUME=none in my /etc/initramfs-tools/conf.d/resume file. Also here, the same thing is given. But, I can't find a resume file there! I didn't delete it ever. How to solve this now? Edit for clarification: I don't want to hibernate!!! I just shut down my computer, and then when I turn it ON, it is taking around a minute to boot up.

Execute root Node Module with www-data user

Posted: 17 Jul 2021 04:38 AM PDT

I have a video creator plugin called editly made in node. When i run the command on my ubuntu:

editly file.json  

it creates the video normaly. But then i run the bash tha runs this code on browser (nginx server using www-data user) it doesnt run.

I think is about permission.

Can anyone help me out, please?

Thanks in advance

How to add freebsd in grub.cfg properly?

Posted: 17 Jul 2021 10:47 AM PDT

Show all my disks and partitions.

sudo fdisk -l  Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors  Disk model: ST1000VX000       Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes  Disklabel type: gpt  Disk identifier: BF20422A-7E3A-4CA2-B249-61BB4A5D42B7    Device         Start        End    Sectors   Size Type  /dev/sda1       2048     923647     921600   450M Windows recovery environment  /dev/sda2     923648    1128447     204800   100M EFI System  /dev/sda3    1128448    1161215      32768    16M Microsoft reserved  /dev/sda4    1161216  314069245  312908030 149.2G Microsoft basic data  /dev/sda5  314071040  315117567    1046528   511M Windows recovery environment  /dev/sda6  315119616  346370047   31250432  14.9G Linux swap  /dev/sda7  346370048 1953523711 1607153664 766.4G Linux filesystem      Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors  Disk model: ST500DM002-1SB10  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes  Disklabel type: gpt  Disk identifier: 4635826C-E544-11EB-AD01-48F31700362D    Device         Start       End   Sectors   Size Type  /dev/sdb1         40    532519    532480   260M EFI System  /dev/sdb2     532520 968884255 968351736 461.8G FreeBSD UFS  /dev/sdb3  968884256 976773127   7888872   3.8G FreeBSD swap  

FreeBSD is already installed in /dev/sdb2,i can enter it after selecting in bios. enter image description here

I want to add it in the grub menu.

sudo vim  /boot/grub/grub.cfg  ### BEGIN /etc/grub.d/40_custom ###  menuentry "FreeBSD" {      insmod ufs2      insmod bsd      set root=(hd1,gpt2)      kfreebsd /boot/loader      kfreebsd /boot/kernel      set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada1p2      set kFreeBSD.vfs.root.mountfrom.options=rw      set kFreeBSD.hw.psm.synaptics_support=1  }  ### END /etc/grub.d/40_custom ###   

Reboot,the FreeBSD added in grub menu. enter image description here

Click it to boot,it encounter "invalid a.out header".

enter image description here
If i simply set the grub.cfg as below:

sudo vim  /boot/grub/grub.cfg  ### BEGIN /etc/grub.d/40_custom ###  menuentry "FreeBSD" {      insmod ufs2      insmod bsd      set root=(hd1,gpt2)      kfreebsd /boot/loader  }  ### END /etc/grub.d/40_custom ###   

Nothing output ,it seems boot load get stuck there.

Mount /dev/sdb2 in debian and list all files related boot.

debian@debian:~$ sudo mkdir  /mnt/freebsd  debian@debian:~$ sudo mount -r -t ufs -o ufstype=ufs2 /dev/sdb2  /mnt/freebsd  debian@debian:~$ ls  /mnt/freebsd  bin   COPYRIGHT  entropy  home  libexec  mnt  proc    root  sys  usr  boot  dev        etc      lib   media    net  rescue  sbin  tmp  var  debian@debian:~$ ls  /mnt/freebsd/boot  beastie.4th         efi.4th         loader.efi          modules  boot                entropy         loader_lua          pmbr  boot0               firmware        loader_lua.efi      pxeboot  boot0sio            fonts           loader.rc           screen.4th  boot1               frames.4th      loader_simp         shortcuts.4th  boot1.efi           gptboot         loader_simp.efi     support.4th  boot2               gptboot.efi     logo-beastie.4th    uboot  brand.4th           gptzfsboot      logo-beastiebw.4th  userboot_4th.so  brand-fbsd.4th      images          logo-fbsdbw.4th     userboot_lua.so  cdboot              isoboot         logo-orb.4th        userboot.so  check-password.4th  kernel          logo-orbbw.4th      version.4th  color.4th           loader          lua                 zfs  defaults            loader.4th      mbr                 zfsboot  delay.4th           loader_4th      menu.4th            zfsloader  device.hints        loader_4th.efi  menu-commands.4th  dtb                 loader.conf     menu.rc  efi                 loader.conf.d   menusets.4th  

Search the a.out file with :

tree  /mnt/freebsd/boot/ | grep  a.out  

No file named a.out in /dev/sdb2!
How to fix grub.cfg file then ?
Why don't write it with grub-mkconfig ?

debian@debian:~$ sudo grub-mkconfig -o /boot/grub/grub.cfg  Generating grub configuration file ...  Found background image: /usr/share/images/desktop-base/desktop-grub.png  Found linux image: /boot/vmlinuz-4.19.0-17-amd64  Found initrd image: /boot/initrd.img-4.19.0-17-amd64  Found linux image: /boot/vmlinuz-4.19.0-16-amd64  Found initrd image: /boot/initrd.img-4.19.0-16-amd64  Found Windows Boot Manager on /dev/sda2@/efi/Microsoft/Boot/bootmgfw.efi  Found FreeBSD 13.0-RELEASE on /dev/sdb2  Adding boot menu entry for EFI firmware configuration  done  

windows was recognized and written into grub.cfg.

debian@debian:~$ cat  /boot/grub/grub.cfg  | grep  -i  window  menuentry 'Windows Boot Manager (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-efi-4A44-FBE5' {  

FreeBSD was recognized too and not to be written into grub.cfg.

debian@debian:~$ cat  /boot/grub/grub.cfg  | grep  -i  freebsd  debian@debian:~$ cat  /boot/grub/grub.cfg  | grep  BSD  

How to fix then ?

I have issues with installing Lubuntu 20.04 on my Lenovo g2 laptop

Posted: 17 Jul 2021 07:29 AM PDT

I am trying to install lubuntu and getting following error message:

Command apt-cdrom add -m -d=/media/cdrom/ ended with a code 100.  Output: Using CD-ROM mount point /media/cdrom/  Identifying... [3a5b628dae090a8f953f7235a13ce1b8-2]  Scanning disc for index files...  Found 8 package indexes, 0 source indexes, 0 translation indexes and 2 signatures  Found label 'Lubuntu 20.04.2 LTS _Focal Fossa_ - Release amd64 (20210204)'  This disc is called: 'Lubuntu 20.04.2 LTS _Focal Fossa_ - Release amd64 (20210204)'  Copying package lists...  gpgv: Signature made Fri Aug 7 01:58:55 2020 MSK gpgv: using RSA key 843938DF228D22F7B3742BC0D94AA3F0EFE21092  gpgv: BAD signature from "Ubuntu CD Image Automatic Signing Key (2012) "  Sub-process apt-key returned an error code (1)  gpgv: Signature made Thu Feb 4 05:49:35 2021 MSK  gpgv: using RSA key 843938DF228D22F7B3742BC0D94AA3F0EFE21092  gpgv: Good signature from "Ubuntu CD Image Automatic Signing Key (2012) "  Reading Package Indexes... 0% Reading Package Indexes... 2% Reading Package Indexes...Error! Writing new source list    Source list entries for this disc are:  deb cdrom:[Lubuntu 20.04.2 LTS _Focal Fossa_ - Release amd64 (20210204)]/ bionic contrib main non-free restricted  deb cdrom:[Lubuntu 20.04.2 LTS _Focal Fossa_ - Release amd64 (20210204)]/ focal main multiverse restricted universe    Repeat this process for the rest of the CDs in your set.  E: Sub-process gpgv returned an error code (1)  W: Signature verification failed for: /media/cdrom/dists/bionic/Release.gpg  

Before that every other distributive wouldn't finish installing except for Ubuntu 21.04, but I had certain sound issues and every time I tried to get drivers after the reboot there would be some "kernel incompatibility" issues appearing on a grub during reboot that wouldn't get me anywhere from that point.

What can i try to do in order to fix that?

Also i don't currently have a stable OS on this PC so the only interactions are either USB OS on this PC or to install a new package using other one and a flash drive. I disabled secure boot, pretty sure the disk image of the OS is just fine too.

"device disconnected or multiple access on port" error

Posted: 17 Jul 2021 06:16 AM PDT

I'm programming in Python 3 on a Raspberry PI 4 running current Debian. My program uses serial port /dev/ttyS0 to send binary requests to a MP3 player board. The documentation about the MP3 player board says it will respond to queries about the playing status. The program loops after an MP3 is started playing to know when it is finished playing.

The program works well after a reboot of the RPi but gets an "device disconnected or multiple access on port" error on the second and later attempts to run. The error still occurs if the MP3 player is restarted but not the RPi. Changing timeout doesn't seem to prevent it.

What program or utility can I run to see what is accessing the port or what to do to prevent disconnect?

I think the problem is an OS issue and not a program problem but that is why I'm asking here.

"""Sends a  message via serial & receives back information via serial."""     import serial  import time     PLAYING_DONE = bytearray([0, 0, 0])     def write_command(port, command):      """Write command to serial port"""      command = [170] + command  # Command packet starts with 0xAA      command.append(sum(command) % 256)  # Append checksum      print(command)      port.write(bytearray(command))     def read_status(port):      """Read status?  Returns 3L bytearray"""      write_command(port, [1, 0])      bytes = port.read(5)      if bytes[0] != 0xAA:          raise ValueError('Serial sentinel error')      if bytes[4] != (sum(bytes[:-1]) % 256):          raise ValueError('Serial read checksum error')      return bytes[1:-1]     def play_track(port, track_info):      """Start playing track.  Track is??"""      write_command(port, [7] + track_info)     with serial.Serial(          '/dev/ttyS0',  #'COM3:',          baudrate=9600,          parity=serial.PARITY_NONE,          stopbits=serial.STOPBITS_ONE,          bytesize=serial.EIGHTBITS,          timeout=2) as ser:      # Start of serial context      play_track(ser, [2, 0, 4])  # Track info?      playing = None      while playing != PLAYING_DONE:          time.sleep(4)           playing = read_status(ser)          print(f'Status = {playing}')      # end of serial context  print("I am done")  

Using sed to change all contents of a file except a particular line number (the header)?

Posted: 17 Jul 2021 09:30 AM PDT

I want to use sed on Linux to change all the second fields in a CSV file for all rows except the first row (which is the header). I'm aware that I can just loop this and go line by line using sed -i '{$LINE_NUMBER ....' and not using this on that line, but I'm wondering if there is a way to do this without a loop which is slower.

I guess I could also just change all contents. Then in the next line change it back for this one particular line.

| Q1 | Q2 | Q3 |  | Name    | Resource_ID | Key |  | Joseph | 343433| AGFD |  | Mary | 242355 | AREW |  

dash and local keyword not resetting shell

Posted: 17 Jul 2021 07:03 AM PDT

dash shell (unlike bash and busybox ash implementation where both examples print foo: '') takes value of previously defined variable, i.e. guarding with local does not work:

$ foo=ee; bar() { local foo; echo "foo: '$foo'"; }; bar  foo: 'ee'  

It requires declare it as empty:

$ foo=ee; bar() { local foo=; echo "foo: '$foo'"; }; bar  foo: ''  

Is it a dash bug (worth of reporting) or local expect to initialize variable? The problem with local is that it's not POSIX, although there was an attempt (source which shows how different are local implementations in various shells).

Can Linux use a CPU core as a micro-controller?

Posted: 17 Jul 2021 04:11 AM PDT

Correct me if I'm wrong:

As far as I searched around the web, the main difference between a micro-controller (like Arduino) and a SBC (like Raspberry Pi) is that the micro-controller is atomic which means it runs your code line by line and does nothing else, no delay. But a SBC (RPi for example) runs an OS, and the OS is not atomic, which means it will schedule your code for running, because the OS has to do other works too, your code may run with a delay, depending on how busy the OS is.

Therefore, for some projects like a flight controller for example, we should use a micro-controller so the drone would react to our commands and sensors' data immediately without any delay.

There are some boards like the BeagleBone that have a CPU capable of running an OS, and one or more micro-controllers capable of doing something atomic. which means you get both worlds with one board.

Now here's my question:

On a multi-core CPU that is running a Linux OS, can we tell the Linux kernel to reserve one core for only one process? Say I have a Python program that controls a drone on a Raspberry Pi, can I tell Linux to use three of four cores for itself and use one core just for my flight controller program? Am I making any sense?

I am aware of Linux job priority and some real-time Linux kernels, but I haven't looked into those options in detail. I would appreciate any guidance regarding this topic, thanks.

NVMe performance hit when using LUKS encryption

Posted: 17 Jul 2021 06:03 AM PDT

I'm running all the commands on the Proxmox host, when I LUKS encrypt a disk I get about a 28% hit in read speeds and 66% hit in write speeds. I have aes-ni enabled and I should be getting good enough performance from hardware acceleration so I don't really know whats going on... Also it doesn't make sense the write speed is faster on an unencrypted drive.

root@red:/dev/mapper# lsblk  NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT  sda       8:0    0 111.8G  0 disk  ├─sda1    8:1    0  1007K  0 part  ├─sda2    8:2    0   512M  0 part  └─sda3    8:3    0 111.3G  0 part  sdb       8:16   0 111.8G  0 disk  ├─sdb1    8:17   0  1007K  0 part  ├─sdb2    8:18   0   512M  0 part  └─sdb3    8:19   0 111.3G  0 part  sdc       8:32   0  12.8T  0 disk  sdd       8:48   0  12.8T  0 disk  nvme0n1 259:0    0 465.8G  0 disk    root@red:/dev/mapper# hdparm -t /dev/nvme0n1    /dev/nvme0n1:   HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device   Timing buffered disk reads: 4774 MB in  3.00 seconds = 1591.14 MB/sec    root@red:/dev/mapper# dd if=/dev/zero of=/dev/nvme0n1 oflag=direct bs=128k count=32k  32768+0 records in  32768+0 records out  4294967296 bytes (4.3 GB, 4.0 GiB) copied, 2.39636 s, 1.8 GB/s  

Then I LUKS encrypt as follows:

root@red:~# cryptsetup luksFormat /dev/nvme0n1    WARNING!  ========  This will overwrite data on /dev/nvme0n1 irrevocably.    Are you sure? (Type uppercase yes): YES  Enter passphrase for /dev/nvme0n1:  Verify passphrase:    root@red:~# cryptsetup luksOpen /dev/nvme0n1 Test  Enter passphrase for /dev/nvme0n1:    root@red:~# lsblk  NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT  sda       8:0    0 111.8G  0 disk  ├─sda1    8:1    0  1007K  0 part  ├─sda2    8:2    0   512M  0 part  └─sda3    8:3    0 111.3G  0 part  sdb       8:16   0 111.8G  0 disk  ├─sdb1    8:17   0  1007K  0 part  ├─sdb2    8:18   0   512M  0 part  └─sdb3    8:19   0 111.3G  0 part  sdc       8:32   0  12.8T  0 disk  sdd       8:48   0  12.8T  0 disk  nvme0n1 259:0    0 465.8G  0 disk  └─Test  253:0    0 465.8G  0 crypt      root@red:~# hdparm -t /dev/mapper/Test    /dev/mapper/Test:   HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device   Timing buffered disk reads: 3450 MB in  3.00 seconds = 1149.84 MB/sec    root@red:~# dd if=/dev/zero of=/dev/mapper/Test oflag=direct bs=128k count=32k  32768+0 records in  32768+0 records out  4294967296 bytes (4.3 GB, 4.0 GiB) copied, 6.83405 s, 628 MB/s  root@red:~#  

Here is the a benchmark of cryptsetup

root@red:~# cryptsetup benchmark  #     Algorithm |       Key |      Encryption |      Decryption          aes-cbc        128b      1011.6 MiB/s      3031.2 MiB/s      serpent-cbc        128b        85.2 MiB/s       646.1 MiB/s      twofish-cbc        128b       192.3 MiB/s       354.1 MiB/s          aes-cbc        256b       792.4 MiB/s      2475.1 MiB/s      serpent-cbc        256b        87.2 MiB/s       648.4 MiB/s      twofish-cbc        256b       193.2 MiB/s       355.4 MiB/s          aes-xts        256b      1921.2 MiB/s      1919.5 MiB/s      serpent-xts        256b       626.2 MiB/s       634.2 MiB/s      twofish-xts        256b       349.9 MiB/s       353.1 MiB/s          aes-xts        512b      1780.3 MiB/s      1768.5 MiB/s      serpent-xts        512b       614.3 MiB/s       637.7 MiB/s      twofish-xts        512b       353.2 MiB/s       352.5 MiB/s    root@red:~# root@red:~# cryptsetup luksDump /dev/nvme0n1  LUKS header information  Version:        2  Epoch:          3  Metadata area:  16384 [bytes]  Keyslots area:  16744448 [bytes]  UUID:           XXXX  Label:          (no label)  Subsystem:      (no subsystem)  Flags:          (no flags)    Data segments:    0: crypt      offset: 16777216 [bytes]      length: (whole device)      cipher: aes-xts-plain64      sector: 512 [bytes]    root@red:~# sort -u /proc/crypto | grep module  module       : aesni_intel  module       : crc32_pclmul  module       : crct10dif_pclmul  module       : cryptd  module       : ghash_clmulni_intel  module       : kernel  module       : serpent_avx2  module       : serpent_avx_x86_64  module       : serpent_generic  module       : serpent_sse2_x86_64  module       : twofish_avx_x86_64  module       : twofish_generic  module       : twofish_x86_64  module       : twofish_x86_64_3way  root@red:~#  

I'm getting around 1700MB/s on the benchmark using aes-xts so I'm wondering why the drive speed is taking such a hit? Any help would be greatly appreciated!

create a folder from dynamic path location

Posted: 17 Jul 2021 05:01 AM PDT

I would like to create a folder which location is available in abc.csv file. abc.scv content the following fields id,path and file name we should read the file name and move the file in the path directory if directory is not available we should create then move the directory i have try simply this

    echo "Enter directory name"  read dirname        if [ ! -d "$dirname" ]      then          echo "File doesn't exist. Creating now"          mkdir "/home/test"/$dirname          echo "File created"      else          echo "File exists"      fi  

sudo command not found

Posted: 17 Jul 2021 04:06 AM PDT

I got my init.sh file for installing seafile. When calling:

if  [ ! -f /config/init_completed ]; then      ...  else    # start seafile    sudo bash ${INSTALLPATH}seafile.sh start    sudo bash ${INSTALLPATH}seahub.sh start    # keep seafile running in foreground to prevent docker container shutting down    while true; do      sudo tail -f /opt/seafile/logs/seafile.log      sleep 10    done    fi  

I got the error: /scripts/init.sh: line 44: sudo: command not found

Install Path is a environmental Variable set in the Dockerfile:

ENV SEAFILE_VERSION seafile-server-6.3.4  ENV INSTALLPATH /opt/seafile/${SEAFILE_VERSION}/  

whoami output is root

Without the sudo command the error is (guess it's cause I don't have permissions without sudo):

bash: /opt/seafile/seafile-server-6.3.4/seafile.sh: No such file or   directory  

Could not find libmount

Posted: 17 Jul 2021 07:09 AM PDT

During compilation of customized distribution (using buildroot v. 11.2018) I have problem with libmount library (the problem appeared after I had included efl package in buildroot menuconfig - Target packages -> Graphic lib... -> efl ). I have additionaly installed package libmount-dev with no results.

checking for getxattr in -lc... yes  checking sys/xattr.h usability... yes  checking sys/xattr.h presence... yes  checking for sys/xattr.h... yes  checking for XATTR_NOFOLLOW... no  checking for LIBMOUNT... no  configure: error: *** Could not find libmount  

How to include this library to obtain succesful compilation?

libreadline dependency related Error while installing an app, “seedsync”

Posted: 17 Jul 2021 09:04 AM PDT

I was trying to install Seedsync.
I followed the instructions on their github

    Download the deb package from the latest release        Install the deb package:        sudo dpkg -i <deb file>  

When I try to install the deb package I get this error

Selecting previously unselected package seedsync.  (Reading database ... 276845 files and directories currently installed.)  Preparing to unpack seedsync_0.6-0_amd64.deb ...  Unpacking seedsync (0.6-0) ...  dpkg: dependency problems prevent configuration of seedsync:   seedsync depends on libreadline6 (>= 6.0); however:    Package libreadline6 is not installed.    dpkg: error processing package seedsync (--install):   dependency problems - leaving unconfigured  Processing triggers for libc-bin (2.27-3ubuntu1) ...  Errors were encountered while processing:   seedsync      

Trying to install libreadline6 tell me that it's either moved somewhere else or obsolete.

Edit:

sudo apt-get install libreadline6   

gives me

Reading package lists... Done  Building dependency tree         Reading state information... Done  Package libreadline6 is not available, but is referred to by another package.  This may mean that the package is missing, has been obsoleted, or  is only available from another source    E: Package 'libreadline6' has no installation candidate  

Edit2:

Tring to install libc-bin or libreadline7 shows that it's already the newest version, 0 upgraded,0 newly installed and 0 not upgraded.

The seedsync package asks for libreadline6 (>=6.0) and I think I have libreadline7

apt-get install libreadline7  Reading package lists... Done  Building dependency tree         Reading state information... Done  libreadline7 is already the newest version (7.0-3).  0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.      

Bind9 socket.c unexpected error

Posted: 17 Jul 2021 10:04 AM PDT

The named process is giving this kind of error the whole day:

Jun 17 12:50:43 s named[24479]: socket.c:5274: unexpected error:  Jun 17 12:50:43 s named[24479]: connect(198.41.0.4#53) 22/Invalid argument  

What is this error?

Named (BIND 9.8.4-rpz2+rl005.12-P1) runs on Debian GNU/Linux squeeze/sid x32. From machine I can telnet to this address (a.root-servers.net.), also I can resolve IP address to name with nslookup

Is there any tool to view live statistics about a Radeon GPU?

Posted: 17 Jul 2021 05:21 AM PDT

I've checked out GPU usage monitoring (CUDA), but are there similar tools for AMD/ATI cards? Or kind of universal tools? I want to check out if my applications use the 256 MB of RAM of the video card at all, since I've seen applications that uses lots system memory, while they should rather use the video cards.

glxinfo does not provide the information I'm looking for, but maybe you will ask if I have HW Acceleration:

$ glxinfo | grep render  direct rendering: Yes  OpenGL renderer string: Gallium 0.4 on ATI RV515  

The info about the card:

03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV515 [Radeon X1300/X1550] (prog-if 00 [VGA controller])      Subsystem: VISIONTEK Device 2352      Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-      Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-      Latency: 0, Cache Line Size: 16 bytes      Interrupt: pin A routed to IRQ 19      Region 0: Memory at d0000000 (64-bit, prefetchable) [size=256M]      Region 2: Memory at bffe0000 (64-bit, non-prefetchable) [size=64K]      Region 4: I/O ports at e000 [size=256]      Expansion ROM at bffc0000 [disabled] [size=128K]      Capabilities: [50] Power Management version 2          Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)          Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-      Capabilities: [58] Express (v1) Endpoint, MSI 00          DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited              ExtTag+ AttnBtn- AttnInd- PwrInd- RBE- FLReset-          DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-              RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+              MaxPayload 128 bytes, MaxReadReq 128 bytes          DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-          LnkCap: Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, L1 <1us              ClockPM- Surprise- LLActRep- BwNot-          LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-              ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-          LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-      Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit+          Address: 0000000000000000  Data: 0000      Kernel driver in use: radeon  

I know there is Process Explorer in Windows, and it works with my card so the thing is Linux Kernel - driver/module - tool.

No comments:

Post a Comment