Tuesday, June 15, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


can't paste into Jshell Version 11.0.11 reproduced on two machines

Posted: 15 Jun 2021 09:53 AM PDT

I have a rather strange problem on two of my notebooks one running Manjaro Linux (Arch for children) and the other Ubuntu 20.10. When I use Jshell the read-eval-print loop tool for Java 11, I can't paste into Jshell, not with the mouse and not with ctrl+p I made a little video demonstrating the problem. It only happens in Jshell, normal bash isn't affected. (echo command at the beginning of the first video works fine)

http://www.filedropper.com/peek2021-06-1518-03 (under 1 MB big)

I made another recording that shows that in ether xfce4 terminal or st terminal after pasting a string of characters into jshell it freezes, until typing 17 characters into the seemingly frozen jshell, when the pasted text appears plus the typed in characters after the freeze. (if i use letters instead of numbers like in the video the output looks like this: jshell> System.out.println("This is a Test...")abcdefghijklmnopqrs in both st and xfce4 terminal

http://www.filedropper.com/peek2021-06-1518-36 (1.3 MB)

Used Java Version on both machines is: openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9) OpenJDK 64-Bit Server VM (build 11.0.11+9, mixed mode)

If this should be a question for a Java board, could you point one out to me?

How to repair linux after failed to start file system

Posted: 15 Jun 2021 09:52 AM PDT

I have problem with my linux. I always had small problem with my HHD but my PC always could works correctly but yesterday its stuck and I decided to reboot it. After rebooting I get this error.

[FAILED] Failed to start File System 6-53ec-49bb-8b46-0913583825fb.   [DEPEND] Dependency failed for /sysroot.   [DEPEND] Dependency failed for Initrd Root File System.  

The screen image here

However, I can boot my Windows, which is on the same HDD as Linux.

Please help me fix my computer.

I would really appreciate your help.

update xml parameter with ns using xmlstarlet

Posted: 15 Jun 2021 09:42 AM PDT

Long time consumer but first time poster :)

Thank you all for the awesome support here!!

My question:

I have this xml file:

<?xml version="1.0" encoding="UTF-8" ?>  <engineConfiguration xmlns="http://bla.com/engine/management/engineConfiguration">      <engineParameter>          <name>PORT_ID</name>          <value>47827</value>      </engineParameter>      <engineParameter>          <name>POS_PRINTER_PORT_ID</name>          <value>27001</value>      </engineParameter>      <engineParameter>          <name>PDS_WS_LOCATION</name>          <value>http://localhost:8080/pds-jbrain-ws/pdsservice?wsdl</value>      </engineParameter>  </engineConfiguration>  

im trying to update the POS_PRINTER_PORT_ID parameter but having a hard time...

i've tried bot below but nothing :(

xmlstarlet ed -u '/engineConfiguration/engineParameter/POS_PRINTER_PORT_ID' -v 9999 engineConfiguration.xml  
xmlstarlet ed -N s=http://bla.com/engine/management/engineConfiguration -u '/s:engineConfiguration/s:engineParameter[name = "POS_PRINTER_PORT_ID"]/value' -v 999 engineConfiguration.xml  

was also trying with xmllint but read that xmlstarlet is the way to go

Any input is much appreciated!!

Thank you,

Dave

What is a good mechanism for storing `jq` filters on disk?

Posted: 15 Jun 2021 09:41 AM PDT

The typical usage of jq

jq [options] <jq filter> [file...]  

means that, for example, to pretty-print a file one would write

jq -s '.' input.json output.json  

yet as the <filter> grows, it's cleaner to store it on disk, as a full-fledged program.

We might want to do that because:

  1. We're using the filter in multiple contexts/files, and do not want the risks of cutting-and-pasting.
  2. Storing the filter in a Makefile, means that we have to introduce trailing backslashes, which diminish the readability of the code.
  3. If we're lucky, we may have a mode in some editor that makes it easier to catch subtle mistakes in the code.

The best one can do with awk (which is to CSV files what jq is to JSON files) is to save a file with a .awk extension, make it executable and write on the first line:

#!/usr/bin/awk -f  

or

#! /opt/local/bin/gawk -f  

What is a good mechanism for storing jq filters on disk?

Kali VM no credentials

Posted: 15 Jun 2021 09:33 AM PDT

I got a problem with my Kali VM, running with VMWare Workstation player, on host win10.

It was working perfectly but I needed to give it more space, and obviously something got wrong in the process because after reboot I only got a "grub rescue" shell with the error "filesystem unknown". Most of the answers I found on how to repare that weren't working in my case, because none of my partition would give anything else that "filesystem unknown".

So, since I still had the installing ISO, I boot on it and asked for a repair, putting pretty much everything I could on automatic choice. It seems to me that it nearly reinstalled everything. I mean, it skipped the firsts steps but at some point it goes on downloading every needed packet which I already had...And indeed, after reboot, I got a GNOME access (I had only xfce before) and.... No login available. I mean, my login for my old account doesn't work anymore, and the default "kali/kali" credentials doesn't work either. So I got a beautiful login screen but no account to log in to. On top of that, I got a warning saying there's no more space on the vm. So It probably reinstalled a new kali like, next to the old one?

Any idea on how to sort this out? I'm okay with only getting back some files that were on my desktop and reinstall a brand new VM, think it would be cleaner that trying somehow to repair the shit I've done; but I really would like those files back.

Migrate from BTRFS to EXT4 using tar

Posted: 15 Jun 2021 09:14 AM PDT

I have a laptop with Fedora 33 with BTRFS file system.

BTRFS is not working out for me and I want to switch to EXT4.

Can I do this via a complete tar backup of my system ?

What I am planning to do this:

  1. Make a complete tar of root(/) and /home.(I have them in one single partition).
  2. Reinstall Fedora 33 with EXT4.
  3. Untar my backup in the new root partition.
  4. Adjust /etc/fstab.

The btrfs-convert -r option won't work since this was a fresh BTRFS install.

I will of course be preserving all the ACLs, extended attributes and numeric permissions while making the backup.

I don't want to reinstall my applications again.

I am using tar instead of rsync since my backup drive is NTFS formatted.

Does this sound feasible ?

Installing qsub on Ubuntu

Posted: 15 Jun 2021 09:11 AM PDT

I was wondering how to install qsub. I did this to install qstat

sudo apt-get install -y qstat

and it worked fine. But I did this to install qsub

sudo apt-get install -y qsub

and it didnt work.

Correct rEFInd stanza for emergency live ISO partition

Posted: 15 Jun 2021 09:05 AM PDT

It would be great to have the ability to chroot into in case of emergency when on the go without installation of the dual system. I'm unable to find out the right manual rEFInd stanza configuration so it could find Live OS loader.

Does anybody know how stanza should be setup for Live ISO?

I've created the sdb3 partition (iso9660) with ISO content:

├── arch  │   ├── boot  │   │   ├── amd-ucode.img  │   │   ├── intel-ucode.img  │   │   ├── licenses  │   │   ├── memtest  │   │   └── x86_64  │   ├── pkglist.x86_64.txt  │   └── x86_64  │       ├── airootfs.sfs  │       ├── airootfs.sfs.sig  │       └── airootfs.sha512  ├── EFI  │   └── BOOT  │       └── BOOTx64.EFI  ├── loader  │   ├── entries  │   │   ├── archiso-x86_64-linux.conf  │   │   └── archiso-x86_64-speech-linux.conf  │   └── loader.conf  ├── shellx64.efi  └── syslinux      ├── archiso_head.cfg      ├── archiso_pxe.cfg      ├── archiso_pxe-linux.cfg      ├── archiso_sys.cfg      ├── archiso_sys-linux.cfg      ├── archiso_tail.cfg  

The content of archiso-x86_64-linux.conf is:

title   Arch Linux install medium (x86_64, UEFI)  linux   /arch/boot/x86_64/vmlinuz-linux  initrd  /arch/boot/intel-ucode.img  initrd  /arch/boot/amd-ucode.img  initrd  /arch/boot/x86_64/initramfs-linux.img  options archisobasedir=arch archisolabel=ARCH_202101  

The setting of stanza in /boot/EFI/refind/refind.conf:

menuentry "Arch (ISO)" {      icon     /EFI/refind/theme/icons/settings.png      linux    /arch/boot/x86_64/vmlinuz-linux      initrd   /arch/boot/intel-ucode.img      options  "root=UUID=2021-01-01-09-18-56-00 ro"      submenuentry "Fallback initramfs" {           initrd   /arch/boot/x86_64/initramfs-linux.img                         }       enabled  }  

Finally /boot structure if needed:

├── EFI  │   ├── refind  │   │   ├── BOOT.CSV  │   │   ├── icons  │   │   ├── keys  │   │   ├── refind.conf  │   │   ├── refind_x64.efi  │   │   ├── theme  │   │   └── vars  │   └── tools  ├── initramfs-linux-fallback.img  ├── initramfs-linux.img  ├── intel-ucode.img  ├── refind_linux.conf  └── vmlinuz-linux  

rsync files across multiple user accounts

Posted: 15 Jun 2021 09:49 AM PDT

I am quite new to using rsync and I'm wondering if it is possible to rsync files across multiple user accounts on a single PC?

For the computers I want to apply the rsync command to, each user has to individually log in to their own user account.For example, if there are 20 users, there are 20 user accounts on that one PC. Is there a way to use rsync from the root account to access the directories and files of each user? I would only like to grab files in .csv format.

Thanks!

Commands where Export is Required to Persist Variables in Subshells

Posted: 15 Jun 2021 08:52 AM PDT

After reviewing this SO answer, my question is: Besides

$ ./your_script  $ ( exec /path/to/shell/bin -c 'some command(s)' )  $ exec /path/to/shell/bin -c 'some command(s)'  

are there any POSIX built-ins and/or command constructs that internally issue a "fork() + exec()" or "exec()" and would require the programmer to use export for variables they wish to persist in the new process?

I'm asking since I'm trying to prevent unintentional side-effects in my script and make it as portable as possible.

AFAIK, the above three command constructs are the only three (w.r.t to those defined in the POSIX standard) that would issue a "fork() + exec()". The first is subtle to the newcomer while the later two are quite explicit. Please let me know if this question is too broad (that is not my intent).

NB: It seems the book Shell Programming in Unix could use some updating. Pages 340-341 state

The export command tells the shell that the indicated variables are to be marked as exported; that is, their values are to be passed down to subshells.

which is a bit misleading and doesn't tell the full story. Per the SO answer, which I've matched in my own shell environments, variables (whether exported or not) are always passed down to a subshell and export is only needed for commands that issue exec. It seems the better definition would be

The export command tells the shell that the indicated variables are to be marked as exported; that is, their values are to be passed down to new processes issued from an exec call.

Fedora doesn't boot after installing over dual boot system

Posted: 15 Jun 2021 08:50 AM PDT

Long story short I have two SSD in my PC and one of them had Ubuntu and other Windows installed. I decided that I no longer need Windows and want to try out Fedora instead. So I installed Fedora on by deleting both drives in Anaconda and installed Fedora.

Now when I try to boot to Fedora I get a message Unknown TMP error and then you need to load the kernel first. Tried boot repair disk with no avail. So got the log from the tool with hope that someone might help cause I can't use the PC anymore.

http://paste.ubuntu.com/p/k278gKTXzS/

Shell: convert string to array

Posted: 15 Jun 2021 09:45 AM PDT

I am trying to convert string for example string=11111001 to array which I will be able to access by calling respective array index like arr[0]=1, arr[1]=0

I am new to shell scripting and from what I read, it doesn't have a separator I am stuck.

Can someone help me?

print nth column into a file.txt and set new headline

Posted: 15 Jun 2021 09:03 AM PDT

I have a main folder that includes 11 sub-folders named 0-degree to 10-degree.
this a schematic:

main.folder                       0-degree                                                 td.general                                 total_current                          

All folders have the same structure. now I want to print the third column of each total_current file into a file named jx.txt using a bash script. I tried this but it didn't make it. it just produce an empty jx.txt:

degree=degree                     declare -i a; for k in {0..9}; do a=15*$k; echo $a                  for param in $a; do                    folder="$param-$degree"                   cd $folder                      outfile="$jx.txt"                awk '{print $3}' */td.general/total_current > outfile                     cd ..                                           done                                      done                                                            

Script function call: function vs $(function)

Posted: 15 Jun 2021 08:43 AM PDT

Taking how reference the following code for simplicity

#!/bin/bash    number=7    function doSomething() {    number=8    echo "hello"  }    doSomething  echo "$number"    

It prints 8.

But with:

#!/bin/bash    number=7    function doSomething() {    number=8  }    $(doSomething)  echo "$number"  

It prints 7.

I have the following questions:

  • What are the technical names for each one?, I mean functioncall and $(functioncall)
  • How does work each approach? It seems the former considers (affects) the variables outside of the function itself, the latter not
  • When is mandatory use one approach over the other (it mostly about performance issues - of course - if there is any), if there are other reasons, they are welcome.

How does terminal in Linux actually work? [duplicate]

Posted: 15 Jun 2021 08:25 AM PDT

I'm using Linux console for years, but currently started thinking of how it actually works. Typing a command as a string and pressing Enter returns its output in the same terminal window.

Opening a new terminal window and executing tty shows the following result:

$ tty  /dev/pts/10  

Man page on pty defines that:

A process that expects to be connected to a terminal, can open the slave end of a pseudoterminal and then be driven by a program that has opened the master end. Anything that is written on the master end is provided to the process on the slave end as though it was input typed on a terminal. [...] Conversely, anything that is written to the slave end of the pseudoterminal can be read by the process that is connected to the master end

My understanding:

The actual terminal window is connected to a slave /dev/pts/10 and all the input I type into the terminal window is written on the slave end and then read on the master end. A process connected to the master end knows what to do with all the strings user type, executes them and write commands results on the master end which are then read on the slave end and displayed in the terminal window.

The question:

What is the process connected to the master end which knows how to execute commands which users type as strings?

regex pattern issue for digit validation in ksh

Posted: 15 Jun 2021 09:49 AM PDT

I was writing a ksh script to validate the column is numerical . the regex pattern is defined in a config file . like "\d+.\d+" .But this is not working when i use "d" pattern. However [0-9]{1,9} is working . any insights into this

here is the ksh i am using ksh

$ ksh --version    version         sh (AT&T Research) 93u+ 2012-08-01  

code snippet for the pattern comparison if i provide $col_patt as \d+ it would not work but [0-9]{1,} will work

val=$(awk -F "$sep" -v n="$col_pos" -v m="$col_patt" 'NR!=1 && $n !~ "^" m "$" {                           printf "%s:%s:%s\n", FILENAME, FNR, $n > "/dev/stderr"                           count++                         }                         END {print count+0}' "$cp_input" 2>> $script_path/errors_${file_name_patt}.log                         )  

here is the pattern used \d*.\d+

JBOD: How to Raid1 drives with different capacities? Btrfs, ZFS?

Posted: 15 Jun 2021 08:36 AM PDT

I have selection of hard drives, with capacities:

1 TB  500 GB  320 GB  250 GB  

I'd like to make Raid1 out of them, in the sense, that copy of any data will be always on two drives out of four I have. Problem is, that all drives have different capacities. In the past I've been running normal Raid1 mdadm 2x 2TB, Btrfs with 2x 2TB after I migrated from mdadm. I don't mind to use mdadm again, or Btrfs, or ZFS, although I know nothing about that one.

What would be best filesystem or utility for me, which fits this criteria:

  1. to have two copies of files at all times, so if one disk dies, I don't lose data
  2. have at much at possible available space with still meet criteria from point 1

What should I use? I have feeling Btrfs Raid1 will handle this, and story exactly two copies of every file across all four hard drives, but I am not sure. I have Linux on AMD64 computer, with 5.10 kernel.

Any advice welcome.

How to parse a particular ids from a text file?

Posted: 15 Jun 2021 08:35 AM PDT

I have a lengthy text file, partial file content is shown below,

[{"site":"1a2v_1","pfam":"Cu_amine_oxid","uniprot":"P12807"},{"site":"1a2v_2","pfam":"Cu_amine_oxid","uniprot":"P12807"},{"site":"1a2v_3","pfam":"Cu_amine_oxid","uniprot":"T12807"},{"site":"1a2v_4","pfam":"Cu_amine_oxid","uniprot":"P12808"},{"site":"1a2v_5","pfam":"Cu_amine_oxid","uniprot":"Z12809"},{"site":"1a2v_6","pfam":"Cu_amine_oxid","uniprot":"P12821"},{"site":"1a3z_1","pfam":"Copper-bind,SoxE","uniprot":"P0C918"},  

I need to parse uniprot ids from the above text file and the expected outcome is given below,

P12807  P12807  T12807  P12808  Z12809  P12821  P0C918  

In order to do the same, I have tried the following commands but nothing works for me,

sed -e 's/"uniprot":"\(.*\)"},{"site":"/\1/' file.txt  cat file.txt | sed 's/.*"uniprot":" //' | sed 's/"site":".*$//'  

Kindly help me to parse the ids as mentioned above.

Thanks in advance.

How to compare two column of a file and a list and print not matching pattern with awk

Posted: 15 Jun 2021 08:37 AM PDT

I have a data file A.tsv (field separator = \t) :

id  mutation  243 siti,toto,mumu  254       267 lala,siti,sojo  289 lala  

and a template file B.txt (field separator = not important because only one line and one column) :

lala,siti,mumu  

I want to create a new column in A.tsv(but in a new file C.tsv) named mutation_not were are printed only the mutation present in the mutation column of A.tsv that are not present in the list of B.txt.

C.tsv looks like this:

id  mutation    mutation_not  243 siti,toto,mumu  toto  254       267 lala,siti,sojo  sojo  289 lala  

I tried with exclude:

awk 'NR==FNR {exclude[$0];next} !($0 in exclude)' file2 file1  

but I don't have any good result. Do you have an idea? Thanks

Getting segmentation fault after ubuntu upgrade from 14.04 to 16.04

Posted: 15 Jun 2021 09:25 AM PDT

Our remote server has been recently upgraded, I used to use anaconda3 for the envs, now whatever command I type that has path anaconda bin folder gives a segmentation fault.

$ conda list  Segmentation fault  $ which conda  /home/user/anaconda3/bin/conda  

Update I ran the gdb debugger (gdb python), and this is the following error I have got.

Program received signal SIGSEGV, Segmentation fault.  0x00007ffff782ebbf in __libc_start_main () from /home/user/anaconda3/bin/../lib/libc.so.6  (gdb) bt  #0  0x00007ffff782ebbf in __libc_start_main () from /home/user/anaconda3/bin/../lib/libc.so.6  #1  0x000055555572f062 in _start () at ../sysdeps/x86_64/elf/start.S:103  

How to get information from "less" stream

Posted: 15 Jun 2021 08:33 AM PDT

How to get information about the stream displayed by "less", especially but not limited to number of lines?

Info: reading this answer list of less functions, I did not find out how to know how many lines there are in some command piped to a less, for example, "apt list --installed | less"

CPU fans not working on Dell laptop running Ubuntu

Posted: 15 Jun 2021 09:09 AM PDT

The CPU fans are not working at all on my DELL Inspiron 15R N5110, I am running Ubuntu 20.04.2 Server, and the laptop overheats quickly after a small duration of uptime.

I checked the hardware and the fans seems okay. Also before I uninstalled windows 7, the fans were working okay, so I know it is not a hardware problem.

This is the output of pwmwconfig from fancotrol:

# pwmconfig version 3.6.0  This program will search your sensors for pulse width modulation (pwm)  controls, and test each one to see if it controls a fan on  your motherboard. Note that many motherboards do not have pwm  circuitry installed, even if your sensor chip supports pwm.    We will attempt to briefly stop each fan using the pwm controls.  The program will attempt to restore each fan to full speed  after testing. However, it is ** very important ** that you  physically verify that the fans have been to full speed  after the program has completed.    Found the following devices:     hwmon0 is AC     hwmon1 is acpitz     hwmon2 is BAT0     hwmon3 is nouveau     hwmon4 is coretemp     hwmon5 is dell_smm    Found the following PWM controls:     hwmon5/pwm1           current value: 255    Giving the fans some time to reach full speed...  Found the following fan sensors:     hwmon5/fan1_input     current speed: 0 ... skipping!    There are no working fan sensors, all readings are 0.  Make sure you have a 3-wire fan connected.  You may also need to increase the fan divisors.  See doc/fan-divisors for more information.  

How does redirection to pv actually work?

Posted: 15 Jun 2021 09:07 AM PDT

I am trying to understand how the redirection is exactly working in this command

# tar -czf - ./Downloads/ | (pv -p --timer --rate --bytes > backup.tgz)  

What is the english translation ?

All the data of tar is redirected as input to pv and then pv redirects it to backup.tgz ?

Then why is the bracket around pv required ?

Then how does this redirection make sense ?

tar -czf - ./Documents/ | (pv -n > backup.tgz) 2>&1 | dialog --gauge "Progress" 10 70  

After pv what is the meaning of 2>&1 ?

Get Length of Function in Shell

Posted: 15 Jun 2021 08:24 AM PDT

UPDATE:

Some Background:

zsh returns the line number inside a function when $LINENO is called inside a function. I need a way to get the line number in the file and to differentiate when zsh is giving me a file line number vs. a function line number.

I couldn't find a zsh environment variable to change this behavior to match other Bourne shells (e.g. bash always gives the file line number), so I was trying to see if I could create a function with logic that could always output the file line number regardless of context. This is why I was trying to determine the length of the function.

If anyone knows of a good way to get the file line number with $LINENO in zsh in all contexts, I'd appreciate it!


QUESTION:

I've searched this and this, but can't seem to find an answer. Is there a portable way to write the number of lines a function definition has? (Please see "Some Background" above.)

My initial thought was to capture the function contents and pipe it to wc -l.

Consider the following test file:

Test File:

#! /bin/sh  #  # test_file.sh    func1() { echo 'A one-liner'; }  # With a nasty comment at the end  func2 (){    echo "A sneaky } included"    # Or an actual code block    {      echo 'hi'      echo 'there'    }  }    func3() { echo "I'm on a line."; }; echo 'And so am I'    func4(){ echo "But I'm a \"stand-alone\" one-liner."; }    func5() {    echo "I'm a nice function."    echo "And you can too!"      }    echo "Can we do this?"  

My initial attempt was to match corresponding pairs of {}'s with sed:

Solution Attempt:

#! /bin/sh  #  # function_length  #  # $1: string: absolute path to file  # $2: string: name of function (without ()'s)    fp=$(realpath "$1")  func_name="$2"    func_contents=$(cat "${fp}" |    sed -E -n '  /'"${func_name}"' ?[(][)]/{    :top    /[}]/!{      H      d    }    /[}]/{      x      s/[{]//      t next      G      b end    }    :next    x    b top    :end    p    q  }')    echo "${func_contents}"  echo    func_len=$(echo "${func_contents}" | wc -l)    echo "Function Length: ${func_len}"  

However, running this in zsh gives

$ ./function_length ./test_file.sh func1          func1() { echo 'A one-liner'; }  # With a nasty comment at the end    Function Length: 2  $ ./function_length ./test_file.sh func2      Function Length: 1  $ ./function_length ./test_file.sh func3    func3() { echo "I'm on a line."; }; echo 'And so am I'    Function Length: 2  $ ./function_length ./test_file.sh func4    func4(){ echo "But I'm a \"stand-alone\" one-liner."; }    Function Length: 2  $ ./function_length ./test_file.sh func5      Function Length: 1  

Does anyone know of a solution? Thank you!

Linux takes long time to boot after resizing and moving partitions

Posted: 15 Jun 2021 08:55 AM PDT

A while ago i installed a new NVME drive in my computer and installed Windows on it. I removed the old Windows installation from my old SSD so that my Linux installation could use all of it. I then moved the root Linux partition to the left and and expanded it to fill the space that Windows previously used. I also copied some files from the EFI partition on the NVME to the SSD to be able to use systemd-boot.

Now to the problem: after doing this Linux takes really long to boot (Windows works fine). Here is the output from systemd-analyze:

Startup finished in 18.338s (firmware) + 1.492s (loader) + 4.869s (kernel) + 1min 34.689s (userspace) = 1min 59.389s   graphical.target reached after 1min 34.684s in userspace  

systemd-analyze blame:

4.745s dev-sda6.device                                                                            4.291s plymouth-quit-wait.service                                                                  898ms mysql.service                                                                               740ms snapd.service                                                                               665ms systemd-logind.service                                                                      535ms accounts-daemon.service                                                                     517ms networkd-dispatcher.service                                                                 323ms udisks2.service                                                                             257ms system76-power.service                                                                      220ms snap-snapd-10492.mount                                                                      216ms fwupd.service                                                                               210ms dev-loop0.device                                                                            208ms snap-flutter-40.mount                                                                       199ms systemd-journal-flush.service                                                               182ms snap-core18-1944.mount                                                                      177ms snap-snapd-10238.mount                                                                      167ms ModemManager.service                                                                        144ms snap-flutter-36.mount                                                                       138ms teamviewerd.service                                                                         137ms polkit.service                                                                              136ms dev-loop1.device                                                                            135ms avahi-daemon.service                                                                        134ms NetworkManager.service                                                                      126ms systemd-resolved.service                                                                    123ms switcheroo-control.service                                                                  117ms thermald.service                                                                            116ms wpa_supplicant.service                                                                      116ms systemd-machined.service                                                                    115ms systemd-modules-load.service                                                                114ms upower.service                                                                              111ms snap-core18-1932.mount                                                                      107ms systemd-timesyncd.service                                                                    99ms user@1000.service                                                                            97ms lvm2-monitor.service                                                                         95ms dev-loop2.device                                                                             94ms dev-loop3.device                                                                             84ms apparmor.service                                                                             77ms gdm.service                                                                                  77ms gpu-manager.service                                                                          61ms systemd-udevd.service                                                                        60ms systemd-journald.service                                                                     55ms colord.service                                                                               55ms systemd-udev-trigger.service                                                                 52ms rsyslog.service                                                                              50ms dev-loop4.device                                                                             49ms libvirtd.service                                                                             47ms apport.service                                                                               42ms keyboard-setup.service                                                                       37ms update-notifier-download.service                                                             32ms e2scrub_reap.service                                                                         32ms dev-disk-by\x2duuid-ebb2d3f4\x2d5518\x2d4c00\x2d9298\x2dfb3a4b774f78.swap                    32ms qemu-kvm.service                                                                             29ms plymouth-start.service                                                                       28ms networking.service                                                                           24ms lm-sensors.service                                                                           22ms dev-loop5.device                                                                             20ms systemd-fsck@dev-disk-by\x2duuid-9d66c204\x2dfe76\x2d4fcb\x2d8ca3\x2d27acc6c41576.service    20ms snapd.seeded.service                                                                         18ms home.mount                                                                                   16ms alsa-restore.service                                                                         14ms snapd.apparmor.service                                                                       14ms systemd-tmpfiles-setup.service                                                               14ms systemd-sysctl.service                                                                       12ms resolvconf-pull-resolved.service                                                             12ms modprobe@drm.service                                                                         11ms plymouth-read-write.service                                                                  11ms systemd-sysusers.service                                                                     11ms nvidia-persistenced.service                                                                  10ms pppd-dns.service                                                                              9ms dev-hugepages.mount                                                                           9ms dev-mqueue.mount                                                                              9ms systemd-random-seed.service                                                                   9ms libvirt-guests.service                                                                        8ms sys-kernel-debug.mount                                                                        8ms sys-kernel-tracing.mount                                                                      8ms systemd-tmpfiles-clean.service                                                                7ms blk-availability.service                                                                      6ms systemd-tmpfiles-setup-dev.service                                                            6ms systemd-update-utmp.service                                                                   6ms systemd-remount-fs.service                                                                    6ms boot-efi.mount                                                                                6ms kmod-static-nodes.service                                                                     6ms user-runtime-dir@1000.service                                                                 5ms hddtemp.service                                                                               5ms sys-fs-fuse-connections.mount                                                                 4ms systemd-user-sessions.service                                                                 4ms tmp.mount                                                                                     4ms sys-kernel-config.mount                                                                       3ms ufw.service                                                                                   3ms rtkit-daemon.service                                                                          3ms systemd-update-utmp-runlevel.service                                                          2ms console-setup.service                                                                         2ms finalrd.service                                                                               2ms ifupdown-pre.service                                                                          1ms setvtrgb.service                                                                            955us libvirtd.socket                                                                             560us snapd.socket    

systemd-analyze critical-chain:

The time when unit became active or started is printed after the "@" character.  The time the unit took to start is printed after the "+" character.    graphical.target @1min 34.684s  └─multi-user.target @1min 34.684s    └─plymouth-quit-wait.service @1min 30.392s +4.291s      └─systemd-user-sessions.service @1min 30.385s +4ms        └─network.target @1min 30.380s          └─NetworkManager.service @1min 30.245s +134ms            └─dbus.service @1min 30.243s              └─basic.target @1min 30.239s                └─sockets.target @1min 30.239s                  └─libvirtd-ro.socket @1min 30.239s                    └─libvirtd.socket @1min 30.238s +955us                      └─sysinit.target @1min 30.233s                        └─systemd-timesyncd.service @5.040s +107ms                          └─systemd-tmpfiles-setup.service @5.024s +14ms                            └─local-fs.target @5.021s                              └─home.mount @5.002s +18ms                                └─systemd-fsck@dev-disk-by\x2duuid-9d66c204\x2dfe76\x2d4fcb\x2d8ca3\x2d27acc6c41576.service @4.981s +20ms                                  └─dev-disk-by\x2duuid-9d66c204\x2dfe76\x2d4fcb\x2d8ca3\x2d27acc6c41576.device @4.973s  

I see nothing in blame or critical-chain that takes unusually long time, but looking at boot.log from the last boot, i see the following:

[  OK  ] Finished Tell Plymouth To Write Out Runtime Data.  [  OK  ] Finished Create Volatile Files and Directories.           Starting Network Name Resolution...           Starting Network Time Synchronization...           Starting Update UTMP about System Boot/Shutdown...  [  OK  ] Finished Update UTMP about System Boot/Shutdown.  [  OK  ] Finished QEMU KVM preparation - module, ksm, hugepages.  [  OK  ] Finished Load AppArmor profiles.           Starting Raise network interfaces...           Starting Load AppArmor pro…managed internally by snapd...  [  OK  ] Finished Load AppArmor pro…s managed internally by snapd.  [  OK  ] Finished Raise network interfaces.  [  OK  ] Started Network Time Synchronization.  [  OK  ] Reached target System Time Set.  [  OK  ] Reached target System Time Synchronized.  [  OK  ] Started Network Name Resolution.  [  OK  ] Reached target Host and Network Name Lookups.  [ TIME ] Timed out waiting for device -1259-4770-ba01-32b86790a561.  [DEPEND] Dependency failed for Cryptography Setup for cryptswap.  [DEPEND] Dependency failed for Local Encrypted Volumes.  [  OK  ] Reached target Block Devic…ion for /dev/mapper/cryptswap.  [  OK  ] Reached target System Initialization.  [  OK  ] Started ACPI Events Check.  [  OK  ] Started CUPS Scheduler.  [  OK  ] Started resolvconf-pull-resolved.path.  [  OK  ] Started Daily apt download activities.  [  OK  ] Started Daily apt upgrade and clean activities.  [  OK  ] Started Periodic ext4 Onli…ata Check for All Filesystems.  [  OK  ] Started Discard unused blocks once a week.  [  OK  ] Started Refresh fwupd metadata regularly.  [  OK  ] Started Daily rotation of log files.  [  OK  ] Started Daily man-db regeneration.  [  OK  ] Started Message of the Day.  [  OK  ] Started Daily Cleanup of Temporary Directories.  [  OK  ] Reached target Paths.  [  OK  ] Listening on ACPID Listen Socket.  [  OK  ] Listening on Avahi mDNS/DNS-SD Stack Activation Socket.  [  OK  ] Listening on CUPS Scheduler.  [  OK  ] Listening on D-Bus System Message Bus Socket.           Starting Libvirt local socket.           Starting Socket activation for snappy daemon.  [  OK  ] Listening on UUID daemon activation socket.  [  OK  ] Listening on Virtual machine lock manager socket.  [  OK  ] Listening on Virtual machine lock manager admin socket.  [  OK  ] Listening on Virtual machine log manager socket.  [  OK  ] Listening on Virtual machine log manager socket.  [  OK  ] Listening on Libvirt local socket.  [  OK  ] Listening on Socket activation for snappy daemon.  [  OK  ] Stopped target Block Devic…ion for /dev/mapper/cryptswap.  [  OK  ] Listening on Libvirt admin socket.  [  OK  ] Listening on Libvirt local read-only socket.  [  OK  ] Reached target Sockets.  [  OK  ] Reached target Basic System.           Starting Accounts Service...  [  OK  ] Started ACPI event daemon.           Starting LSB: automatic crash report generation...           Starting Avahi mDNS/DNS-SD Stack...  [  OK  ] Started Regular background program processing daemon.  [  OK  ] Started CUPS Scheduler.  [  OK  ] Reached target Printer.  [  OK  ] Started D-Bus System Message Bus.           Starting Network Manager...  [  OK  ] Started Save initial kernel messages after boot.           Starting Remove Stale Onli…t4 Metadata Check Snapshots...  [  OK  ] Reached target Login Prompts.           Starting Detect the availa…eal with any system changes...  [  OK  ] Started irqbalance daemon.           Starting Initialize hardware monitoring sensors...           Starting Dispatcher daemon for systemd-networkd...           Starting NVIDIA Persistence Daemon...           Starting Authorization Manager...  [  OK  ] Started Pop Upgrade Daemon.           Starting Restore /etc/reso… the ppp link was shut down...           Starting resolvconf-pull-resolved.service...           Starting System Logging Service...           Starting Snap Daemon...           Starting Switcheroo Control Proxy service...           Starting System76 Power Daemon...           Starting User Login Management...           Starting Virtual Machine a…tainer Registration Service...           Starting Thermal Daemon Service...           Starting Disk Manager...           Starting WPA supplicant...  [  OK  ] Started NVIDIA Persistence Daemon.  [  OK  ] Finished Restore /etc/reso…re the ppp link was shut down.  [  OK  ] Finished Initialize hardware monitoring sensors.  [  OK  ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.  [  OK  ] Started LSB: automatic crash report generation.  [  OK  ] Finished resolvconf-pull-resolved.service.  [  OK  ] Started System Logging Service.  [  OK  ] Finished Detect the availa… deal with any system changes.  [  OK  ] Started Virtual Machine an…ontainer Registration Service.  [  OK  ] Started Avahi mDNS/DNS-SD Stack.  [  OK  ] Started WPA supplicant.  [  OK  ] Started Thermal Daemon Service.  [  OK  ] Started Make remote CUPS printers available locally.  [  OK  ] Started Switcheroo Control Proxy service.  [  OK  ] Started Network Manager.  [  OK  ] Reached target Network.  [  OK  ] Reached target Network is Online.  [  OK  ] Started Download data for …ailed at package install time.  [  OK  ] Started Check to see wheth…w version of Ubuntu available.  [  OK  ] Reached target Timers.           Starting Save/Restore Sound Card State...           Starting Manage, Install and Generate Color Profiles...           Starting LSB: disk temperature monitoring daemon...           Starting MySQL Community Server...  [  OK  ] Started Private Internet Access daemon.           Starting Permit User Sessions...           Starting TeamViewer remote control daemon...  [  OK  ] Started LSB: disk temperature monitoring daemon.  [  OK  ] Started Authorization Manager.  [  OK  ] Finished Permit User Sessions.           Starting Modem Manager...           Starting GNOME Display Manager...           Starting Hold until boot process finishes up...           Starting Hostname Service...  [  OK  ] Finished Save/Restore Sound Card State.  [  OK  ] Reached target Sound Card.  [  OK  ] Started Manage, Install and Generate Color Profiles.  [  OK  ] Started Hostname Service.  [  OK  ] Started GNOME Display Manager.  

I suspect this line could have something to do with the problem: [ TIME ] Timed out waiting for device -1259-4770-ba01-32b86790a561.

The device looks like the end of a UUID, so I suspected that there could be something wrong in my fstab file:

# /etc/fstab: static file system information.  #  # Use 'blkid' to print the universally unique identifier for a  # device; this may be used with UUID= as a more robust way to name devices  # that works even if disks are added and removed. See fstab(5).  #  # <file system>  <mount point>  <type>  <options>  <dump>  <pass>  UUID=de390d43-ceed-4756-82f9-e2af6908cb03       /tmp        ext4 noatime,errors=remount-ro  0   0  PARTUUID=c45be408-0645-4676-ad10-2faa239a802b   /boot/efi   vfat umask=0077                 0   0  UUID=ebb2d3f4-5518-4c00-9298-fb3a4b774f78       none        swap defaults                   0   0  UUID=a4a8fe1d-5017-4fed-9397-7c6463fe5d04       /           ext4 errors=remount-ro          0   0  UUID=9d66c204-fe76-4fcb-8ca3-27acc6c41576       /home       ext4 defaults                   0   2   

But there is no UUID that matches the one that gave the error, and that ID isn't in the output from sudo blkid either:

/dev/sda6: UUID="a4a8fe1d-5017-4fed-9397-7c6463fe5d04" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6dd08769-eae4-4a5a-a17c-776806c8c2d9"  /dev/loop0: TYPE="squashfs"  /dev/loop1: TYPE="squashfs"  /dev/loop2: TYPE="squashfs"  /dev/loop3: TYPE="squashfs"  /dev/loop4: TYPE="squashfs"  /dev/loop5: TYPE="squashfs"  /dev/nvme0n1p1: LABEL="SYSTEM" UUID="E6F4-51CF" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="M-dM-.M-.&" PARTUUID="cd2c4c5d-221d-425e-8125-db5e97aaf98b"  /dev/nvme0n1p2: BLOCK_SIZE="512" UUID="AEC02A49C02A17DB" TYPE="ntfs" PARTLABEL="[hmg checkos]:File not exist! filena" PARTUUID="9a34299d-bc2b-4ee5-8ca3-ef51c8662cf1"  /dev/sda1: UUID="ebb2d3f4-5518-4c00-9298-fb3a4b774f78" TYPE="swap" PARTUUID="b719b11d-e8b4-4232-b4a3-7ebb2884ca17"  /dev/sda2: LABEL="SYSTEM" UUID="E6F4-51CF" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="SYSTEM" PARTUUID="c45be408-0645-4676-ad10-2faa239a802b"  /dev/sda3: UUID="9d66c204-fe76-4fcb-8ca3-27acc6c41576" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="1b7287d0-725b-49f2-ab58-3cfb09eb349f"  /dev/sda4: UUID="de390d43-ceed-4756-82f9-e2af6908cb03" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="c6e2143d-3bc0-4c80-945e-fa7945933473"  /dev/sdb1: UUID="fb34963c-9b6d-42ca-acfb-1603eb003306" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="7fabbbe5-86c1-4b9d-be33-72b6fd1ac345"  /dev/sdc2: LABEL="Data" BLOCK_SIZE="512" UUID="A2038F931B0424E6" TYPE="ntfs"  

So now I don't know how I should proceed. I have also tried booting with all peripherals unplugged except one screen (including the NVME drive).

Simple command-line calculator

Posted: 15 Jun 2021 09:05 AM PDT

Issue:

Every now and then I need to do simple arithmetic in a command-line environment. E.G. given the following output:

Disk /dev/sdb: 256GB  Sector size (logical/physical): 512B/512B  Partition Table: gpt  Disk Flags:     Number  Start   End     Size    File system     Name  Flags   1      1049kB  106MB   105MB   fat32                 hidden, diag   2      106MB   64.1GB  64.0GB  ext4   3      64.1GB  192GB   128GB   ext4   5      236GB   256GB   20.0GB  linux-swap(v1)  

What's a simple way to calculate on the command line the size of the unallocated space between partition 3 and 5?

What I've tried already:

bc

bc  bc 1.06.95  Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.  This is free software with ABSOLUTELY NO WARRANTY.  For details type `warranty'.   236-192  44  quit

where the bold above is all the stuff I need to type to do a simple 236-192 as bc 1+1 echoes File 1+1 is unavailable.

expr

expr 236 - 192  

where I need to type spaces before and after the operator as expr 1+1 just echoes 1+1.

Bash script: split word on each letter

Posted: 15 Jun 2021 09:39 AM PDT

How can I split a word's letters, with each letter in a separate line?

For example, given "StackOver" I would like to see

S  t  a  c  k  O  v  e  r  

I'm new to bash so I have no clue where to start.

Setting console font in vconsole.conf does not work (systemd)

Posted: 15 Jun 2021 08:43 AM PDT

I am trying to set a different default console font for my new Arch Linux installation (using systemd).

I set up my vconsole.conf in /etc as so:

KEYMAP=us  FONT=Lat2-Terminus16  

I rebooted and saw my newly set console font appear, only for it to reset just before the login prompt.

Things to note:

  • running /usr/lib/systemd/systemd-vconsole-setup manually works fine
  • systemctl status systemd-vconsole-setup.service tells me that it has loaded and is "active (exited)"
  • I have indeed included the consolefont hook in mkinitcpio.conf

redirect web server with no-ip and port forwarding in livebox

Posted: 15 Jun 2021 09:01 AM PDT

I want my Apache web server running on a Livebox (home router appliance running Linux) to be accessible from the Internet (WAN).

I installed and configured the application noip2 on my Ubuntu PC. When I ping my hostname, it redirects me to my WAN ip, which is what I wanted. But I cannot access my Apache web server.

I tried this:

  • Disabling the iptables firewall configuration or the firewall of my Sagem modem.
  • Port forwarding on sagem modem (NAT).
  • Configuration of Apache.

What else can I try? How can I make my web server accessible from the WAN side?

Execute a command once per line of piped input?

Posted: 15 Jun 2021 09:08 AM PDT

I want to run a java command once for every match of ls | grep pattern -. In this case, I think I could do find pattern -exec java MyProg '{}' \; but I'm curious about the general case - is there an easy way to say "run a command once for every line of standard input"? (In fish or bash.)

No comments:

Post a Comment