Thursday, February 17, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to convert a multiple choice text file into a json file with indents

Posted: 17 Feb 2022 10:51 AM PST

How can i convert a text file into a json output like below? Text file: Question:'Which of the following commands can be used to perform a full text search on all available packages on a Debian system? a.opt1 b.opt2 c.opt3 d.opt4 e.opt5

{ type:'radio', question:'Which of the following commands can be used to perform a full text search on all available packages on a Debian system?', correct answer:'dpkg', options:[ {a:'apt', correct:false, selected:false}, {a:'apt-cache', correct:false, selected:false}, {a:'apt-get', correct:false, selected:false}, {a:'apt-search', correct:false, selected:false}, {a:'dpkg',correct:true, selected:false}, ],

},.  

Does a physical volume need filesystem before extending logical volume with it?

Posted: 17 Feb 2022 10:43 AM PST

I have an existing logical volume and I want to extend it with newly added physical volume (from separate disk) in the volume group. Before extending the logical volume, is it required to make filesystem for the physical volume or not?

I know the logical volume itself has a filesystem, but I don't exactly understand how the extending process works in practice.

Cannot install Debian when CSM is disabled

Posted: 17 Feb 2022 10:54 AM PST

I am trying to install Debian 11.2.0 (debian-11.2.0-amd64-netinst.iso) on an old Lenovo ThinkCentre M92p (Intel Core i5-3470).

I upgraded BIOS to latest version (9SKT9CA, released on December 24th 2018) and disabled CSM.

Installer works fine until following two errors are thrown.

Failed to create a file system

When I select continue…

This machine's firmware has started in UEFI mode but it looks like there may be an existing operating system already installed using "BIOS compatibility mode".

I am installing Debian on an empty exFAT-formatted Samsung T7 Touch SSD… no other operating system is present besides live installer.

What am I missing? Thanks for helping out!

Error 1

Error 2

Startup config

Whats the difference of the available memory shown by using sar (system activity report) command and /proc/meminfo?

Posted: 17 Feb 2022 10:01 AM PST

On the same machine, entering "sar -r ALL" shows:

kbmemfree kbavail kbmemused %memused ...

157096 232380 561828 56.48 ...

Then, entering "cat /proc/meminfo" shows:

MemTotal: 994824 kB

MemFree: 135700 kB

MemAvailable: 212988 kB

...

What is the difference between the available memory shown by the above two commands?

Can these two values be seen as the same?

Neither of them includes swap?

Trouble to get a ipv6 address with dhclient/console lines

Posted: 17 Feb 2022 09:52 AM PST

I have issues to get an ipv6 address when using the command dhclient -6 to connect my PC to gateway by wifi.

I have those logs when I use dhclient -6 -v

sudo dhclient -v -6  Internet Systems Consortium DHCP Client 4.4.1  Copyright 2004-2018 Internet Systems Consortium.  All rights reserved.  For info, please visit https://www.isc.org/software/dhcp/  no link-local IPv6 address for wlan0  If you think you have received this message due to a bug rather  than a configuration issue please read the section on submitting  bugs on either our web page at www.isc.org or in the README file  before submitting a bug.  These pages explain the proper  process and the information we find helpful for debugging.  exiting.  

I don't have the same issue when using the non ipv6 command to renew my computer address by dhcp. Also when I connect my PC to Gateway manually (with the graphical interface) I can see that I have an inet6 local and global address, so the issue only happens with command lines.

I also can set a static address IPV6 with the following command

sudo ip -6 addr add 2001:0db8:0:f101::1/64 dev wlan0       ~$ ifconfig wlan0  wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500          inet 192.168.101.207  netmask 255.255.255.0  broadcast 192.168.101.255          inet6 2001:db8:0:f101::1  prefixlen 64  scopeid 0x0<global>          ether 9e:9c:ef:d1:d3:0a  txqueuelen 1000  (Ethernet)          RX packets 1011  bytes 105257 (102.7 KiB)          RX errors 0  dropped 0  overruns 0  frame 0          TX packets 1775  bytes 219313 (214.1 KiB)          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

Any idea how to solve the issue, i am opened to the idea of using other command than dhclient provided it can works with command lines.

Invoke a program in a Bash script with command line parameters stored in a variable

Posted: 17 Feb 2022 09:37 AM PST

Is it possible to invoke some program in a Bash script with complete command line parameters (both the key and the value) stored in variables?

I use the following scanimage call in a script:

scanimage -p --mode "True Gray" --resolution 150 -l 0 -t 0 -x 210 -y 297 --format=png  -o scan.png  

I want to store some of the parameters in variables. I tried this, concerning the --mode switch:

options="--mode \"True Gray\""  scanimage -p $options --resolution 150 -l 0 -t 0 -x 210 -y 297 --format=png  -o scan.png  

but this doesn't work, scanimage says:

scanimage: setting of option --mode failed (Invalid argument)  

Storing only the value for the --mode switch does work:

mode="True Gray"  scanimage -p --mode "$mode" --resolution 150 -l 0 -t 0 -x 210 -y 297 --format=png  -o scan.png  

but I'd like to be variable about the switches, and I'd also like to customize multiple switches without knowing which will be set.

So is it possible to store not only the values for command line options in a variable, but also the option switch(es) along with the value(s)?

run command on and in subfolders which contain files of specific extension

Posted: 17 Feb 2022 10:55 AM PST

Good day all,

I'm trying to run commands on subfolders which contain files with specific extension(s). I want to run the commands inside the folders themselves, and have whatever output be generated inside the folders themselves.

Here is an illustration of what I'm trying to accomplish. I have this to start:

.  └── folder      ├── subfolder 1      │    ├── file.abc      │    └── file2.abc      ├── subfolder 2      │    └── file.xyz      ├── subfolder 3      │    └── file.def      └── subfolder 4  

I want to find subfolder 1 and 3 in this case, and have commands run inside them, and have the outputs of said commands also be within their respective folders as so

.  └── folder      ├── subfolder 1      │    ├── file.abc      │    ├── file.out      │    ├── file2.abc      │    ├── file2.out      │    └── subfolder.out      ├── subfolder 2      │    └── file.xyz      ├── subfolder 3      │    ├── file.def      │    ├── file.out      │    └── subfolder.out      └── subfolder 4  

This code works, ran inside folder:

if ()(($#)) */*.(abc|def|ghi)(NY1-.); then            for file (*/*.(abc|def|ghi)) command1 $file && command2 ${file} > $file.out && command3 * > subfolder.out      else echo "No appropriate files found"  fi  

But when command3 on * or also *.(abc|def|ghi) inside the folders to try to generate a single subfolder.out per subfolder, I want it to generate a single file inside said folder with the results. What I get is that the file will be generated and overwritten wherever I run the script, and not inside the folder as I want it to. So if I run this script inside the top folder, I get this:

.  └── folder      ├── subfolder.out      ├── subfolder 1      │    ├── file.abc      │    ├── file.out      │    ├── file2.abc      │    └── file2.out      ├── subfolder 2      │    └── file.xyz      ├── subfolder 3      │    ├── file.def      │    └── file.out      └── subfolder 4  

I would want it to generate as follows

.  └── folder      ├── subfolder 1      │    ├── file.abc      │    ├── file.out      │    ├── file2.abc      │    ├── file2.out      │    └── subfolder.out      ├── subfolder 2      │    └── file.xyz      ├── subfolder 3      │    ├── file.def      │    ├── file.out      │    └── subfolder.out      └── subfolder 4  

So to recap: I want to test subfolders for the presence of files with specific extensions, and then I want to run commands inside the folders that have them, and have the generated outputs all be inside the folders in which they were created. I want to run commands on every file of specific extension it finds inside the folder, but also on a wildcard *.(abc|def|ghi). I would want to run command3 on all files of whatever extension it finds, rather than on every individual files of whatever extension it finds.

I'm basically trying to cd into folders which contain files that are of the right extension, then command3 * > subfolder.out . The file subfolder.out has to be created and remain in the correct subfolder.

How can I accomplish this? Thanks in advance.

Append checksum value in trailer

Posted: 17 Feb 2022 10:50 AM PST

I want to append SHA256 checksum hash value to trailer record of a file

file1.txt

H this is a test   D 1  D 2  D 3  T checksum  

Used below command to obtain 64 digit alpha numeric hash value

sha256sum file1.txt >file2.txt

file2.txt

<64digituniquealphanumvalue> file1.txt  

My expected output file would be

file3.txt

H this is a test  D 1  D 2  D 3  T checksum <64digituniquealphanum>  

But I got the below output using below command

cat file1.txt file2.txt > file3.txt  

file3.txt

H this is a test  D 1  D 2  D 3  T checksum  <64digituniquealphanum> file1.txt  

file1 has a new line and my requirement is to append the 64 digit unique checksum hash value in T record type that is last line of file in unix without filename as given in expected file format. Kindly advise me with the commands how to achieve it in unix

How to retrive information like PID, PPID, Level in bash of all processes which have descendant processes more than six?

Posted: 17 Feb 2022 08:51 AM PST

I will trigger seven dummy descendant processes using below code:

#!/bin/bash    if [[ "$#" -ne 1 ]]; then      set -- 7 #To set command line argument to 7 when arguments aren't provided  fi    if [[ "$1" -gt 2 ]]; then      "$0" "$(($1 - 1))" #Execute same script by passing a number(decrementing)  else      sleep 120  fi  

Thus pstree -pc 101 (assuming 101 is pid of first process of above script) will display:

dummy(101)──dummy(102)──dummy(103)──dummy(104)──dummy(105)──dummy(106)──sleep(107)

How do I display the information of the dummy process in below format, actually for a particular user($USER) I want to display every process information who have descendants more than six in below format.

PID PPID Level
107 106 1 (indicates child)
106 105 2 (indicates parent)
105 104 3 (indicates grand parent)
104 103 4
103 102 5
102 101 6
101 100 7

Frankly I do not know Bash scripting. I have just learned how to to display PID'S of a user processes using below command:

ps -u $USER -o user,pid,ppid,lstart,cmd

Tilde and angle bracket keys are swapped

Posted: 17 Feb 2022 07:59 AM PST

I have looked for solutions to this problem quite a bit now, and I haven't found any good answers to it.

This is the layout I am using Image of keyboard layout

When pressing the tilde key (the one to the left of 1), it instead outputs an angle bracket, and the layout screen shows that the button to the left of Z is pressed. The same goes for the opposite, when pressing the angle bracket key (left of Z), it shows that the tilde key is pressed instead.

I have no clue when this started to happen, nor do I know why this happened. I would love for some tips or directions on how to fix this issue as it is quite annoying.

System information:

OS: Debian Bookworm

DE: Cinnamon/GNOME (issue is present on both)

Physical keyboard layout is Norwegian

Sync files only by changed modification time

Posted: 17 Feb 2022 07:42 AM PST

Is there a way to sync files only by changed modification time? I back up my data to a archive system that moves files to tape after some amount of time. The moved files leave a symbolic link with the same modification time, but size and checksum are different, so rsync will recopy the file. I tried rclone with --ignore-size but it didn't do what I wanted.

Cannot shutdown the host when QEMU/KVM is installed

Posted: 17 Feb 2022 07:42 AM PST

I have a problem with LIBVIRT or something. The host is Linux Fedora 34 on AMD and the guest VM is Windows 10. Virt-manager is connected through user session. I am fairly new to Linux, but I recently switched to QEMU/KVM from Virtualbox and guest VM itself is working fine.

My problem is that every time I want to reboot or shutdown my host system, first stop job for Virtualization daemon is running for about 6 minutes and then shutdown sequence finishes but my host computer does not power down or reboots itself as used to and I have to hold down the power button to turn off host machine.

I tried to shutdown the guest VM before host shutdown but with no luck. Secondly, whenever I stop libvirtd.service in linux I just cannot restart it without completely rebooting my host computer.

What to do?

Can't create a bootable SD card for Gumstix Overo because i can't partition the sd card correctly

Posted: 17 Feb 2022 07:36 AM PST

So i was trying to create a bootable SD card, for Gumstix Overo, through this link https://www.gumstix.com/community/support/getting-started/create-bootable-microsd-card/

but every time i try to partition the sd card using the command sudo ./mk2partsd /dev/sdc it doesn't work correctly because the SD card changes it's name in devices, but it was supposed to create 2 partitions boot and roofts, images of code before the command:SD card in devices Through command lsblk we can see SD card in sdc1

after the command sudo ./mk2partsd /dev/sdc: The result of the previous command The continuation result of the previous command

And we can that it didn't create another partition: Didn't create another partition

But changed it's name in devices:

The name changed

i'm using VirtualBox with Ubuntu 14.04 in case you are wondering.

WARNING ** : bad d-i Packages file (time distortion or clock problem)

Posted: 17 Feb 2022 07:28 AM PST

I install a linux archive via an old NAS in flash kernel boot, and after struggling with the packages, apt fires me on that:

Jan 1 01:08:26 main-menu[209] : INFO : The menu item 'download-installer' is selected  Jan 1 01:08:26 net-retriever: gpgv :   Jan 1 01:08:26 net-retriever: Signature made on Sat Apr 25 11:01:30 2015 UTC using RSA key ID 473041FA  Jan 1 01:08:26 net-retriever: gpgv:   Jan 1 01:08:26 net-retriever: key 473041FA was created 1282936517 seconds in the future (time distortion or clock problem)  Jan 1 01:08:26 net-retriever: gpgv :   Jan 1 01:08:26 net-retriever: WRONG signature of "Debian Archive Automatic Signing Key (6.0/squeeze) <ftpmaster@debian.org>"  Jan 1 01:08:26 net-retriever:   Jan 1 01:08:26 net-retriever: error: Bad signature on /tmp/net-retriever-2952-Release.  Jan 1 01:08:32 anna [2948] : WARNING ** : bad d-i Packages file  Jan 1 01:08:32 net-retriever: gpgv :   Jan 1 01:08:32 net-retriever: Signature made on Sat Apr 25 11:01:30 2015 UTC using RSA key ID 473041FA  Jan 1 01:08:32 net-retriever: gpgv:   Jan 1 01:08:32 net-retriever: key 473041FA was created 1282936511 seconds in the future (time distortion or clock problem)  Jan 1 01:08:32 net-retriever: gpgv :   Jan 1 01:08:32 net-retriever: WRONG signature of "Debian Archive Automatic Signing Key (6.0/squeeze) <ftpmaster@debian.org>"  Jan 1 01:08:32 net-retriever:   Jan 1 01:08:32 net-retriever: error: Bad signature on /tmp/net-retriever-2973-Release.  Jan 1 01:08:35 anna [2948] : WARNING ** : bad d-i Packages file  Jan 1 01:08:35 main-menu[209]: INFO: The menu item 'download-installer' succeeded but asked to be left unconfigured.  

Any idea ? knowing that ntp/date/timedatectl doesn't exist obviously

Source tuto : https://github.com/Dees7/openstora/blob/master/pages/How_to_install_Debian_Linux_on_NETGEAR_Stora.md

Step #Running the installer

Bash using variables within variables within command

Posted: 17 Feb 2022 07:17 AM PST

I have a couple of curl commands, one to fetch an authentication key and then another that needs to use that key, currently i have the below bash script.

#!/bin/bash    ACCESS_TOKEN=$(curl -XPOST -H "Content-type: application/json" -d '{"client_id":"XXX", "client_secret":"XXX", "grant_type":"client_credentials"}' 'https://url.com' | ./jq '.access_token')    echo $ACCESS_TOKEN    UPLOADARRAY=$(curl -v -XGET -H 'Authorization: Bearer "$ACCESS_TOKEN"' -H 'client_id:XXX' -H "Content-type:application/json" 'https://otherurl.com' | ./jq '{authCode: .authCode, name: .uploadUrl}')    echo $UPLOADARRAY  

The issue is looking at the verbose output of the second curl command i see:

> User-Agent: curl/7.77.0  > Accept: */*  > Authorization: Bearer "$ACCESS_TOKEN"  

So the content of the variable access content (which the test echo statement shows does contain the right value) isn't being used and instead the string "$ACCESS_TOKEN" is used.

I did have a look at Quoting within $(command substitution) in Bash and wrapping the command with the additional double quotes but this made no difference.

Can anyone spot whats wrong here?

Recent files and locations listed in Dolphin and other applications are very old, date is false

Posted: 17 Feb 2022 08:04 AM PST

I have noticed that files and locations shown in Dolphin (and thus in KDE file dialog too) under 'Recent files' and 'Recent locations' are not recent at all. All I see is files (in 'Recent Files') and folders (in 'Recent Locations') from my system but that I am 100% sure I have not accessed in months, while the system seems to think that happened a few minutes ago.

But I have also noticed that recent files and recent applications are also askew in the Application Dashboard launcher too: they are too old, 'recent files' there are those from the list in Dolphin, the 'recent applications' have not been used at all in weeks or even months!

It is as if those lists are stuck in time, at a certain date when I've looked at those foobar2000 icons and files:

enter image description here

That time information saying number of minutes or some hour "today" is completely false: I had nothing to do with those files in months!

The same incorrect "recent" files and folders are listed by recentlyused:/files/ and recentlyused:/locations/.

Discussing here I see that recentdocuments:/ as path in Dolphin or the files in ~/.local/share/RecentDocuments include the real "recent files", related to my activity during last days and hours.

Surely, these are the ones that should be listed in Dolphin panel "Recent" too.

Could this be a bug or is it a problem with my system?

This is in Kubuntu 22.04 (updated from 20.04, where I had the same problem), Plasma 5.24., Dolphin 21.12.2.)

How can I best track agrs in the environment without using ps?

Posted: 17 Feb 2022 09:19 AM PST

I am working with a customer BusyBox v1.23.2 container, trying to track args being passed in the environment. I wanted to use pslogger to show when foo is sent in the environment.

However, the ps tool has all control options restricted and so the best thing I have come up with is:

watch -n 1 'ps | grep foo'  

where

  • -n 1 is the time in seconds to rewatch

Is 1 second a wide enough window for env args? Is there a better solution to this problem?

Maybe there is something to be done with top ?

Thanks :-)

why cannot bash map CTRL^C to intr signal if invoked as init?

Posted: 17 Feb 2022 07:22 AM PST

If I make the bash as the first process invoked (i.e as init), as a result it will display the following:

init: cannot set terminal process group (-1): Inappropriate ioctl for device  init: no job control in this shell  

and any signal doesn't work.(e.g CTRL^C).

Through reading the source code of bash-5.1.12, the problem is located at the expression in job.c line 4501:

(t = tcgetpgrp (shell_tty)) == -1  

and the error value is ENOTTY, which mean that the calling process does not have a controlling terminal.

So what are the relations between a controlling termial and signals and why is the bash invoked as init without a controlling terminal ?

Which process is responsible for mapping Ctr+C to intr signal in systemd+agetty+login+bash?

Posted: 17 Feb 2022 07:23 AM PST

I am trying to read source code to understand which process is reponsible for these mapping, but I can't still figure it out. Can anyone give me a hint about which code is relative to it ?

source code: agetty+login(util-linux project), systemd

Boot taking forever with a 106 JBOD attached. - WARNING: Device /dev/xxx not initialized in udev database even after waiting 10000000 microseconds

Posted: 17 Feb 2022 08:09 AM PST

When attaching a 106 JBOD enclsoures (106 18TB drives via HBA card) to a Debian Bullseye server, i get spammed with the following for each path to any of the 106 drives.

It makes a reboot take a huge amount of time.

Example:

WARNING: Device /dev/sdcf not initialized in udev database even after waiting 10000000 microseconds  

enter image description here

What is causing this? I seem unable to figure out.

Script to set screen resolution by providing X and Y co-ordinates in redhat

Posted: 17 Feb 2022 08:14 AM PST

Goal is to provide resolution X and Y as arguments to the script (./res_set.sh 1920 1080) and gtf, xrandr newmode and addmode will be executed according to the script.

#!/usr/bin/env bash  if [ "$1" == "-h" ] ; then  echo "Usage: `basename $0` [X co-ordinate] [Y co-ordinate]"  exit 0  fi    echo "X Co-ordinate";  echo $1;  echo "Y Co-ordinate";  echo $2;  echo "Are you sure ? [Y/N]";  read input;  if [ $input == "y" ];  then  gtf $1 $2 60 > kar1.txt                                             #To get modeline  sed -n '3 p' kar1.txt > kar2.txt                                    #Select Line 2  grep -o -E '["_x.0-9 ]+' kar2.txt > kar3.txt                        #Filter result  wo_filter=$(perl -p -e 's/(?:_60.00)//g' kar3.txt | grep "\S");       filter=$(grep "\S" kar3.txt);  fil_resolution=$(grep -o -P '(?<=").*(?=")' <<< $wo_filter)  resolution=$(grep -o -P '(?<=").*(?=")' kar3.txt)  echo "Filter: $filter";  echo "Wo_filter: $wo_filter";  echo "Resolution: $resolution";  echo "Filted_Resolution: $fil_resolution";  var=$(xrandr --newmode $wo_filter)  xrandr --addmode default $fil_resolution  #rm -v kar*  else  exit;  fi  

This creates xrandr newmode but fails to add the mode (addmode) in the resolution list while using this script. I get xrandr:Cannot find mode. But it works and adds to the mode list if xrandr newmode and addmode commands are executed individually.

Input

Output

Xrandr output

This is output of xrandr | tail

My thoughts are : Are $variables are in different datatype and spoiling my result ? How will I able to verify the datatype of variables here or in bash (does it matter) ?

Automate Alpine Linux installation

Posted: 17 Feb 2022 07:13 AM PST

I am trying to achieve unattended Alpine Linux installation. I went through the Alpine automatic installation guide but many manual interventions are still needed during the installation! For example providing the root user name, creating the answer file (setup-alpine -c answerfileName), editing the answer file, calling the actual installation command (setup-alpine -f answerfileName) and resetting the root password.

Is there any way to include the answer file inside the ISO image, select the root user by default before starting the installation and set its password after the installation is done. In CentOS we can provide kickstart file in isolinux.cfg:

label MyMENU2    menu label ^Deploy Manager Node    kernel vmlinuz    append initrd=initrd.img inst.stage2=hd:LABEL=MYISO inst.ks=hd:LABEL=MYISO:/ks/ks1.cfg quiet  

Is there something similar in Alpine Linux ?

Why the LESS_TERMCAP settings does not work when put it into ~/.profile

Posted: 17 Feb 2022 07:32 AM PST

I have the following LESS_TERMCAP settings:

# less config  export LESS=-R           export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking  export LESS_TERMCAP_md=$'\E[01;31m' # begin bold      export LESS_TERMCAP_me=$'\E[0m' # end mode            export LESS_TERMCAP_se=$'\E[0m' # end standout-mode  export LESS_TERMCAP_so=$'\E[01;44;37m' # begin standout-mode  export LESS_TERMCAP_ue=$'\E[0m' # end underline  export LESS_TERMCAP_us=$'\E[01;33m' # begin underline  export LESSOPEN='| /usr/bin/highlight -O ansi %s 2>/dev/null'  

When I put into ~/.profile, the less viewer gets absolutely messy. On the other hand, when I put into ~/.zshrc (I am using zsh), it works, why?

Since I was taught to keep the environment variables into non-login shell config files, such as ~/.profile, I want to do so.

Further information:

 tapyu@tapyu-ThinkPad-P73   OS: Ubuntu 20.04 focal   Kernel: x86_64 Linux 5.13.0-28-generic   Uptime: 2h 25m   Packages: 2559   Shell: zsh 5.8   Resolution: 2048x1152   DE: GNOME 3.36.5   WM: Mutter   WM Theme: Adwaita   GTK Theme: Yaru-dark [GTK2/3]   Icon Theme: Yaru   Font: Ubuntu 11   Disk: 123G / 217G (60%)   CPU: Intel Core i7-9750H @ 12x 4.5GHz [43.0°C]   GPU: Intel Corporation UHD Graphics 630 (Mobile)  NVIDIA Corporation GP107GLM [Quadro P620] (rev a1)   RAM: 4740MiB / 23681MiB  

Best regards.

dd command ruining files [closed]

Posted: 17 Feb 2022 09:25 AM PST

I recently was trying to flash from an IMG file with dd, and it took a lot shorter than normal, and when I checked the drive, it had names like

\u2584\u00bc\u2591+\u03c6\u256bv\u2559.|  

I don't know if I'm being stupid, or if it's a drive error. This is the code I used:

sudo dd if=~/Downloads/tails-amd64-4.20.img of=/dev/sdd1 bs=1M  

Suspend laptop when closing lid

Posted: 17 Feb 2022 07:24 AM PST

My laptop does not suspend when I close the lid. I have the default settings in /etc/systemd/logind.conf, i.e. everything is commented out (uncommenting does not have an effect, as expected):

$ grep -i lid /etc/systemd/logind.conf  > #HandleLidSwitch=suspend  > #HandleLidSwitchExternalPower=suspend  > #HandleLidSwitchDocked=ignore  > #LidSwitchIgnoreInhibited=yes  

Suspicious to me is, that when I look at journalctl, and close the lid, I do not see any event message.

Suspending from the command line works just fine.

How can I suspend my laptop when the lid is closed?

Edit: I am on Arch Linux with i3.

$ systemd-inhibit --list  > WHO            UID USER PID COMM           WHAT  WHY                                       MODE   > NetworkManager 0   root 314 NetworkManager sleep NetworkManager needs to turn off networks delay  >   > 1 inhibitors listed.  

Edit2: I checked the state of the lid like this:

while true; do      cat /proc/acpi/button/lid/LID0/state      sleep 1  done  

Then closed the lid for a while, opened it again. I always got the same output:

state:     open  

Edit 3:

$ dmesg | grep -i lid  > [    1.131805] input: Lid Switch as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00/input/input0  > [    1.131837] ACPI: Lid Switch [LID0]  

This system is currently not set up to build kernel modules

Posted: 17 Feb 2022 10:07 AM PST

I'm trying to install VirtualBox 6.1.16 on a LinuxMint 19.3 host which is based on Ubuntu 18.04 bionic. I have checked all other answers and tried all possibilities, but to no avail.

Previously I had VirtualBox 6.0 which I uninstalled before installing 6.1 .

I'm getting the following error message:

sudo dpkg -i virtualbox-6.1_6.1.16-140961~Ubuntu~bionic_amd64.deb

(Reading database ... 455695 files and directories currently installed.)  Preparing to unpack virtualbox-6.1_6.1.16-140961~Ubuntu~bionic_amd64.deb ...  Unpacking virtualbox-6.1 (6.1.16-140961~Ubuntu~bionic) ...  Setting up virtualbox-6.1 (6.1.16-140961~Ubuntu~bionic) ...  addgroup: The group `vboxusers' already exists as a system group. Exiting.  This system is currently not set up to build kernel modules.  Please install the gcc make perl packages from your distribution.  This system is currently not set up to build kernel modules.  Please install the gcc make perl packages from your distribution.    There were problems setting up VirtualBox.  To re-start the set-up process, run    /sbin/vboxconfig  as root.  If your system is using EFI Secure Boot you may need to sign the  kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load  them. Please see your Linux system's documentation for more information.  

So far I've tried:

  • install all dependencies with sudo apt-get install build-essential gcc make perl dkms linux-headers-$(uname -r)
Building dependency tree         Reading state information... Done  build-essential is already the newest version (12.4ubuntu1).  make is already the newest version (4.1-9.1ubuntu1).  dkms is already the newest version (2.3-3ubuntu9.7).  gcc is already the newest version (4:7.4.0-1ubuntu2.3).  linux-headers-5.4.0-53-generic is already the newest version (5.4.0-53.59~18.04.1).  perl is already the newest version (5.26.1-6ubuntu0.5).  0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.  
  • checking for previously installed versions sudo dpkg -l *virtualbox* and sudo dkms status
dpkg-query: no packages found matching virtualbox-6.1_6.1.16-140961~Ubuntu~bionic_amd64.deb  
  • Checked SecureBoot was already disabled.

  • Tried booting to a 4.15 kernel

  • Tried installing using the "All distributions" link:

sudo ./VirtualBox-6.1.16-140961-Linux_amd64.run   Verifying archive integrity... All good.  Uncompressing VirtualBox for Linux installation.............  VirtualBox Version 6.1.16 r140961 (2020-10-15T15:03:02Z) installer  Installing VirtualBox to /opt/VirtualBox  Python found: python, installing bindings...  This system is currently not set up to build kernel modules.  Please install the gcc make perl packages from your distribution.  This system is currently not set up to build kernel modules.  Please install the gcc make perl packages from your distribution.    There were problems setting up VirtualBox.  To re-start the set-up process, run    /sbin/vboxconfig  as root.  If your system is using EFI Secure Boot you may need to sign the  kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load  them. Please see your Linux system's documentation for more information.    VirtualBox has been installed successfully.    You will find useful information about using VirtualBox in the user manual    /opt/VirtualBox/UserManual.pdf  and in the user FAQ    http://www.virtualbox.org/wiki/User_FAQ    We hope that you enjoy using VirtualBox.    The installation log file is at /var/log/vbox-install.log.  

This is the log file:

VirtualBox 6.1.16 r140961 installer, built 2020-10-15T15:03:02Z.    Testing system setup...  Removing previous installation of VirtualBox 6.1.16 r140961 from /opt/VirtualBox    vboxdrv.sh: Stopping VirtualBox services.  vboxdrv.sh: Starting VirtualBox services.  vboxdrv.sh: Building VirtualBox kernel modules.  

but nothing is helping. I'm really at a loss here. Many thanks in advance.

python easy_install or pip errors about sysconfig

Posted: 17 Feb 2022 09:04 AM PST

somehow the installation of python is broken in my linux OEL 6.9.

pip or easy_install are broken and I cannot do anything.

i get the same error on both sides:

# easy_install  Traceback (most recent call last):    File "/usr/bin/easy_install", line 5, in <module>      from pkg_resources import load_entry_point    File "/usr/lib/python2.6/site-packages/setuptools-39.2.0-py2.6.egg/pkg_resources/__init__.py", line 947, in <module>      class Environment(object):    File "/usr/lib/python2.6/site-packages/setuptools-39.2.0-py2.6.egg/pkg_resources/__init__.py", line 951, in Environment      self, search_path=None, platform=get_supported_platform(),    File "/usr/lib/python2.6/site-packages/setuptools-39.2.0-py2.6.egg/pkg_resources/__init__.py", line 180, in get_supported_platform      plat = get_build_platform()    File "/usr/lib/python2.6/site-packages/setuptools-39.2.0-py2.6.egg/pkg_resources/__init__.py", line 380, in get_build_platform      from sysconfig import get_platform  ImportError: No module named sysconfig  

I removed python-setuptools to no avail.

I think i was trying to update latest version of pyOpenSSL and it crashed and cannot fix.

we are running Oracle enterprise Linux 6.6 in a VM.

how to fix it without resorting to installing python 2.7 which is not included in the official repos

thank you

How to check easily the munin alert-email-notification?

Posted: 17 Feb 2022 08:05 AM PST

I run the munin monitoring application on my debian Wheezy server and I would like to test the alert-email-notification procedure. To do that, I add in munin.conf the following line:

df._home.warning 25  

I set 25 because the df command returns 30 for /home.

I also defined one contact:

contacts me  contact.me.command mail "munin test ${var:host}" my_email@my_isp.com  

Unfortunately I don't receive any mails.

There are no errors in the logs. Note that I use exim4 to send emails and that I can send emails from a terminal.

What could be wrong in my configuration ?

Note also I ckecked manually the df plugin:

munin-run df  

returns 30 for /home

How to exit a git merge asking for commit message?

Posted: 17 Feb 2022 09:43 AM PST

I'm using git. I did a normal merge, but it keeps asking this:

# Please enter a commit message to explain why this merge is necessary,  # especially if it merges an updated upstream into a topic branch.  

And even if I write something, I can't exit from here. I can't find docs explaining this. How should I do?

Mac OS X: Terminal Prompt Username

Posted: 17 Feb 2022 09:38 AM PST

I'm using Mac OS Snow Leopard (v10.6.8). I've changed the account name under System Preferences > System > Accounts > Full Name. However, that does not change the username on the terminal prompt. That is, by changing the export PS1 to, for example, \u, the username remains the old one.

I did not rename the home directory under /Users/username, but I was hoping it would be possible just to change that particular username on the terminal (I think it is called short name).

No comments:

Post a Comment