Thursday, November 11, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Samsung 204TS monitor LED blinks, no display, no OSD : How to do a hardware reset?

Posted: 11 Nov 2021 11:21 AM PST

I'm running Linux on a laptop with a resolution of 1600x900 at 60Hz.

I tried both connecting the HDMI and VGA output (one at a time) to my Samsung 204TS monitor but nothing show up.

I checked, all the cable are fine.

But the Samsung display is black, only the LED of the monitor is blinking.

Neither the "Source" nor the "Auto" button show anything.

There's no OSD shown when I press the "Menu" key.

How can I do a hardware reset of that monitor ?

Is there a key combination to press when the OSD Menu does not appear ?

Errors from nouveau display driver on Debian - firmware: failed to load nouveau/nvc1_fuc084 (-2)

Posted: 11 Nov 2021 11:07 AM PST

I've installed Debian 11 with dual boot on a laptop of mine lately. I installed the official image, so no non-free drivers got installed.

I had some driver issues reported when using dmesg (I think one was the bluetooth) and I seemed to have fixed them by installing some packages (I copied the failing driver name from dmesg, searched it with apt, and installed the best match).

At some point I've decided to add the contrib and non-free sources to my sources list, to see if getting non-free drivers would improve anything: https://www.xmodulo.com/install-nonfree-packages-debian.html

I was getting errors from the nouveau driver before that too (despite the fact that my screen was using the full resolution), so I was just trying to make the errors go away.

I've tried the nvidia-detect utility and after installing its suggestion my resolution dropped and wouldn't be set to a higher one. So, I've uninstalled that.

I've also tried the instructions here: https://wiki.debian.org/NvidiaGraphicsDrivers#Debian_11_.22Bullseye.22 Again, my resolution dropped.

I think that, in both cases I've installed a legacy driver (most likely nvidia-legacy-390xx-driver).

My graphics card seem to be a GA compatible controller: NVIDIA Corporation GF108M [GeForce GT 540M] (rev a1).

Eventually, I have uninstalled what I had installed (hopefully - not sure if anything stayed behind...) and my resolution is now restored, but I still get the same errors in dmesg:

[   14.913827] Bluetooth: Can't change to loading configuration err  [   14.913943] ath3k: probe of 1-1.5:1.0 failed with error -110  [   37.345865] nouveau 0000:01:00.0: firmware: failed to load nouveau/nvc1_fuc084 (-2)  [   37.345872] firmware_class: See https://wiki.debian.org/Firmware for information about missing firmware  [   37.345876] nouveau 0000:01:00.0: Direct firmware load for nouveau/nvc1_fuc084 failed with error -2  [   37.345892] nouveau 0000:01:00.0: firmware: failed to load nouveau/nvc1_fuc084d (-2)  [   37.345895] nouveau 0000:01:00.0: Direct firmware load for nouveau/nvc1_fuc084d failed with error -2  [   37.345898] nouveau 0000:01:00.0: msvld: unable to load firmware data  [   37.345901] nouveau 0000:01:00.0: msvld: init failed, -19  

These seem to be the only remaining errors.

If we exclude the bluetooth one at the top (which I have no idea why it happens), you see the failing nouveau driver afterwards.

And I am a bit confused by it really, because (from my understanding) the nouveau driver is supposed to be shipped with the kernel. So, why would it fail? How could there be a missing dependency to it or anything like that?

I think I also tried installing it (nouveau) with apt, but nothing got installed. Not sure what would happen if one of its dependencies was the wrong version (if it would be replaced or not). I guess it would be replaced if the existing binary is an older version, but I am not sure about that.

So, if anyone has any idea what I could do, feel free to drop his ideas. This is my first time dealing with Linux drivers, so I am a bit clueless.

For sure, I could just ignore the problem, since my screen seems to work fine.

Just, I can't unsterstand what is going on here... If the driver doesn't load, why is my screen working OK?

How to use big-cursor in Ubuntu?

Posted: 11 Nov 2021 11:05 AM PST

I've installed the big-cursor package in Ubuntu 20.04.3 LTS, but it doesn't show up on the update-alternatives list, and I can't find any instructions on how to use it.

I use the dwm window manager and the command line (i.e., no Gnome, etc.). How do I use the cursor theme?

Apache virtualhost configuration issue

Posted: 11 Nov 2021 11:13 AM PST

I'm developing a symfony application and in trying to remove index.php from the url, I used the following virtualhost configuration:

<VirtualHost *:80>            ServerAdmin webmaster@localhost          DocumentRoot "/var/www/html/experiments-1/public"            ErrorLog ${APACHE_LOG_DIR}/error.log          CustomLog ${APACHE_LOG_DIR}/access.log combined    </VirtualHost>  

The localtion of the site is confirmed as /var/www/html/experiments-1/public/index.php.

But when I visit http://localhost:81/ I just get the default symfony page.

I would appreciate some insight into what I'm missing or doing wrong.

how to update /dev/mapper entries after unplugging hotswap disk

Posted: 11 Nov 2021 10:47 AM PST

My backup disks use lvm. Ltwo et's assume they have the following lv's on them:

They are both inserted into the same cage, so only one of them can be present in the system at any one time. When I remove a disk, the entry in /dev/mapper usually doesn't go away, misleading to be interpreted as if the disk was present. I want to run a command, that updates /dev/mapper entirely, to be sure that available disks show up and unavailable disk do not. Ho can I do that?

How to get voicemail from call-in service onto computer

Posted: 11 Nov 2021 10:04 AM PST

I am using an Android phone without visual voicemail.

Is there any way I can download the voicemails onto my linux computer?

Seeking the linux solution to this question.

Extract last n lines and prepend chars with sed one-liner

Posted: 11 Nov 2021 10:39 AM PST

Considering this file:

1  2  3  4  5  

I can extract the last 3 lines with this sed one-liner:

$ /bin/sed input.txt -e ':a;$q;N;4,$D;ba'  

But I would also like to add some characters (# ) in front of each line, so that the output will be like so:

# 3  # 4  # 5  

How can I modify the one-liner to do that? I mean, without adding another sed invocation (with | /bin/sed -e 's/^/# /').

I would prefer to use sed only for the same reasons of the original question, i.e. I have a system with limited binaries available.

Stuck in initramfs after reboot

Posted: 11 Nov 2021 09:30 AM PST

So i got that error already twice while having my laptop, and i previously were able to fix it after them google search and switching to ahci in bios. But this time it seems to be another problem because even though sata-mode is ahci it kicks me back to initramfs. I tried this: https://askubuntu.com/questions/976071/how-to-switch-from-ide-to-ahci with the hope to not get that error in the future. After that i sadly got the error i am now stuck on. Original error message | the output i get from cat /proc/modules and ls dev . Help is greatly appreciated.

Dell G5 SE fans not working in debian 11

Posted: 11 Nov 2021 09:11 AM PST

Dell g5 5505 SE - Ryzen 5 4600H and RX5600M GPU, I tried installing debian 11 (kernel 5.10), after a few minutes of usage, my laptop got so hot and noticed that both my laptop fans are not working, I tried i8kutils it makes only the CPU fan work , I tired i8kfanctl to run both the fans, but no use. Is there any way to fix this?

How do I bypass "This operation is not permitted because it will break the system. Abort." on Pop!_OS?

Posted: 11 Nov 2021 09:01 AM PST

On Pop!_OS, I'm trying to remove an apt package that's marked as "essential". I understand the consequences and know how to make sure I'll still be able to use my system afterward. In examples and documentation about this online, it says all I'd have to do is type Yes, do as I say! into apt, but instead of getting prompted to do that, I just get this message:

This operation is not permitted because it will break the system.  Abort.  

This is my own system, so I shouldn't need permission to remove whatever packages I want and then deal with the consequences myself. How can I bypass this?

netplan not configuring network

Posted: 11 Nov 2021 08:38 AM PST

I'm trying to configure a static IP on a freshly installed, fleshly upgraded Ubuntu 20.04.03 system.

This is my /etc/netplan/00-installer-config.yaml:

network:    ethernets:      enp4s0:          dhcp4: no          addresses: [192.168.178.91/24]    version: 2  

This is what I get from ip a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00      inet 127.0.0.1/8 scope host lo         valid_lft forever preferred_lft forever      inet6 ::1/128 scope host          valid_lft forever preferred_lft forever  2: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000      link/ether 7c:10:c9:3f:8c:e2 brd ff:ff:ff:ff:ff:ff    ... plus lots of docker ifs.  

When I

  • run netplan apply,
  • run netplan generate ; netplan apply
  • run netplan apply, then reboot,

I don't get any errors, but ip a still gives me the same results and the system isn't reachable via the static address I'm trying to configure. Also, the system is taking forever to start because it is waiting for dhcp.

When I introduce an error into the config file, netplan complains, so it's reading the right file. When I run netplan get, the output is different from the config file, but equivalent:

network:    ethernets:      enp4s0:        addresses:        - 192.168.178.91/24        dhcp4: false    version: 2  

What am I doing wrong? How can I check what netplan is doing, if anything?

BTW: I don't think it's related, but when I run netplan try, I get "An error occurred: 'NetplanApply' object has no attribute 'state'".

I've seen others complain about that problem, but they were still able to apply their network configuration.

Bit comparison between two files

Posted: 11 Nov 2021 09:58 AM PST

I am in the process of learning bash, and I need to compare two almost identical text files (only a few bits are flipped) and output the amount of bits that are the same. In other words, I need to compare bits, not characters. Reading through the bash documentation, I came across the comm and diff commands, but they seem to compare the files line by line and not bit by bit. Any help would be greatly appreciated.

How to undo fdisk new partition on ext4 file system?

Posted: 11 Nov 2021 11:32 AM PST

I have a LVM called /dev/data/files on a VM of mine. I allocated 50 GB on it and wanted to extend this LVM...

So, instead of using lvextend command which i forgot to use i did the following:

fdisk /dev/data/files  Used N option to create a partition  Writed changes...  

So then i restarted the server but the size didnt change. I didnt know how fdisk worked so i believe that i created a new partition on that file system...

My question is: Is it safe to delete this partition i created and then use lvextend to extend the LVM disk the correct way? Like if i enter fdisk again and choose to delete the partition, will i lose any files? Or is it ok to remove it?

Thanks!

How to add empty new lines in less (log viewer)?

Posted: 11 Nov 2021 09:52 AM PST

When I monitor some log file with tail -F file.log, I can press enter to add some space between actual log lines and the new ones, for example:

some log 1  some log 2  some log 3      some log 4  some log 5  

But when I monitor some file with less file.log, I cannot add such space when I press the enter key. How could I add this tail -F file.log behavior to less file.log?

Update

I would not like to edit the log file, I just need to add some spacing on the output while I am reviewing them in realtime (while I run tests on the application). Whether the file is going to be edited or not is irrelevant.

I just would like to use less instead of tail because less is more feature rich as find in buffer, etc.

scp over bash script doesn't accept omit command

Posted: 11 Nov 2021 09:38 AM PST

Consider this scp command to send all files and directories in the current directory except the shell scripts.

scp -r ./!(*.sh) debian@192.168.0.50:~/  

When this command is ran from the terminal, it works fine. I am trying to run the same command in a bash script, and for that I had to change it this way

scp -r ./!\(*.sh\) debian@192.168.0.50:~/  

but it returns this error

./!(*.sh): No such file or directory  

EDIT 1 Using the full quote as follow

scp -r './!(*.sh)' debian@192.168.0.50:~/  

return the same error

EDIT 2 The full script looks like this

#!/bin/bash    SOURCE="${BASH_SOURCE[0]}"  while [ -h "$SOURCE" ]; do    DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"    SOURCE="$(readlink "$SOURCE")"    [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"  done  DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"  cd "${DIR}" || exit    echo -e "Sending all scripts to $1."  shopt -s extglob  scp -r -P $1 ./!\(*.sh\) debian@192.168.0.50:$2  
  • Making scp as a separate function fixed the issue with Regex as follow:
#!/bin/bash    SOURCE="${BASH_SOURCE[0]}"  while [ -h "$SOURCE" ]; do    DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"    SOURCE="$(readlink "$SOURCE")"    [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"  done  DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"  cd "${DIR}" || exit    run_scp() {      scp -r -P $PORT $1 debian@192.168.0.50:$TARGET_DIR  }    PORT=$1  TARGET_DIR=$2    echo -e "Sending all scripts to $PORT."  shopt -s extglob  run_scp ./!\(*.sh\)  

How to grab variables from a txt file needed for processing in a bash script?

Posted: 11 Nov 2021 08:12 AM PST

I have a txt file named setup.txt that contains the following data:

DSN=ZXP.SOURCE  PATH=/z/zxp/20211015  SCHEMA=ZXP  URL=https://zxp-support.mybluemix.net/contest/4q21/contact-sheet  OUTPUT=OUTPUT(RESULT)  REPORT=q421report  

I need to pass this file as a parameter to my script but as a novice in shell scripting I get errors when using source setup.txt which seems like it executes anything in the file.

input="$1"  source $1    if [ $# -ne 1 ]    then      printf "Usage Example: ./executor.sh setup.txt \n\n"        exit 1  fi  if test -f "$input"; then      echo "$input exists."      content=$(cat $input  fi  echo $DSN  echo $SCHEMA #echoing the variables give me errors  

How can I access the variables?

Run a terminal command when device connects to a WiFi network

Posted: 11 Nov 2021 11:17 AM PST

I spoof my MAC address on a public WiFi network that I use often, but I do not want to have my MAC spoofed on my home network. I was thinking that a way to automate this is to have the computer automatically reset its MAC address with

sudo spoof-mac reset wi-fi

using SpoofMAC. How could I automate this, so that every time my computer connects to x network, that command gets run, and my MAC address gets set back to normal?

I am on MacOS Monterey.

Enclosing the value of a variable in single quotes in BASH

Posted: 11 Nov 2021 10:27 AM PST

I'm trying to adapt some Perl scripts to Bash to run them in Nagios XI.

The problem is that Nagios expects the values of the variables to arrive between single quotes, but I can't manage to escape the variables correctly.

For example, in the top area where I declare variables and/or constants, I have this:

status='OK'  

And when I replace it in the value to return to Nagios, I put it like this and it works correctly:

output="[$status]"  output_msg="Voting disks status check succeeded"  

Which when printed, returns that [OK] Voting disks status check succeeded.

However, I have other variables that I build from executed commands, like this:

command=`/oracle/app/grid/19300/bin/crsctl query css votedisk | grep asm`  output1=`echo $command | cut -d " " -f4`  output2=`echo $command | cut -d " " -f5`  

If I run this script locally, the result is as expected:

[OK] Voting disks status check succeeded - (/dev/mapper/asm_ocr1) [OCR].  

But when I launch it from the Nagios server, the $output1 and $output2 variables always arrive empty:

[OK] Voting disks status check succeeded -  

I know it's because of the single quotes because when I try to declare a third variable with a literal text, it comes out correctly:

output3='Test'  output="[$status] $output_msg - $output3  

This paints on the Nagios server:

[OK] Voting disks status check succeeded - Test  

Any idea how to put the text contained in $output1 and $output2 in single quotes so Nagios will interpret it?

EDIT

To corroborate that the content of the variable must be in single quotes, I have made the following test:

#Add the path that $output1 should return  test='/dev/mapper/asm_ocr1'  #Paint in the output the variable $test  output="[$status] $output_msg - $test $output1 $output2"    ########    #On the Nagios server, the $test variable send correctly:  [OK] Voting disks status check succeeded - /dev/mapper/asm_ocr1 ''  

EDIT 2

I found out that the error does not come from the quotation marks, but from the Nagios communication with the node where the DB is running.

The complete script, so far, is this one:

. /home/oracle/.profile_RAC  ORACLE_HOME=/oracle/app/grid/19300  ORACLE_BASE=/oracle/app/base  nagios_exit_codes=('UNKNOWN', 3, 'OK', 0, 'WARNING', 1, 'CRITICAL', 2)  status='OK'  ok=1  action=$1    case $action in          "votedisk")                  #command=`/oracle/app/grid/19300/bin/crsctl query css votedisk | grep asm`                  #command=$(/oracle/app/grid/19300/bin/crsctl query css votedisk)                  command=`/oracle/app/grid/19300/bin/crsctl query css votedisk`                    case $comando in                          *"failed"*|*"OFFLINE"*|*"PROC"*)                                  status='CRITICAL'                                  output_msg="Voting disk status check failed!"                          ;;                            * )                                  output_msg="Voting disks status check succeeded"                          ;;                  esac                    output="[$status] $output_msg - $command"            ;;            "clusterstatus")                  comando=`/oracle/app/grid/19300/bin/crsctl query crs releaseversion`                  output_msg="All clusterware services are up (clusterware version: $comando)"                  output="$output_msg"            ;;  esac      echo -e $output  exit 0  

Running this script locally, the result is this:

[root@bbddmachine plugins]# sh ./script_prueba.sh votedisk  [OK] Voting disks status check succeeded - ## STATE File Universal Id File Name Disk group -- ----- ----------------- --------- --------- 1. ONLINE 8dfc2a9528244f95bf87bb394e793995 (/dev/mapper/asm_ocr1) [OCR] Located 1 voting disk(s).  

But on the Nagios machine, the result is wrong:

[nagios@ng1esp libexec]$ ./check_nrpe -2 -H 172.27.68.132 -t 60 -c check_crs_votedisk  [OK] Voting disks status check succeeded - Unable to communicate with the Cluster Synchronization Services daemon.  

However, if I launch the other option in the script called ```clusterstatus`` everything works fine:

[nagios@ng1esp libexec]$ ./check_nrpe -2 -H 172.27.68.132 -t 60 -c check_crs_clusterstatus  All clusterware services are up (clusterware version: Oracle High Availability Services release version on the local node is [19.0.0.0.0])  

rsync : Copy symlinks as regular files

Posted: 11 Nov 2021 11:18 AM PST

I need to copy a large directory containing all kinds of files onto a drive that already has a lot of important data.

I'd like to be able to copy munged symlinks but the drive is exfat and symlinks are not supported. Because the file already has a lot of data on it, I'd like to avoid having to transfer that data in order to format it to something that does support symlinks.

Is there a way that rsync could read a symlink such as this:

/etc/apache2/sites-enabled/mysite.conf -> ../sites-available/mysite.conf  

and generate a regular file like

<rsync-destination>/etc/apache2/sites-enabled/mysite.conf.rsync-munged  

containing the text

../sites-available/mysite.conf  

I would prefer if the solution was something built into rsync or done in bash pipeline, or at least part of the basic tools found on any linux, but I'm willing to accept an other software that offers what rsync does + this functionnality

Edit:

I see that rsync can not do such a thing. I think I found a way to do it manually:

rsync everything but the symlinks, then seperately run a 'find' operation to identify all symlinks in the destination, and manually create them with a bash script.

I'd have to manually extract the symlink data from stdio and I'm not sure how to do that. ls -l has a lot more data that would get in the way

VNC: has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing

Posted: 11 Nov 2021 08:56 AM PST

Trying to set up a VNCServer for first time and allow user netizen be able to log onto the server and we can work together.

So looks like there is two exec starts here so do I need to remove one?

[root@orcacomputers conf]# systemctl status vncserver@:1.service -l  ● vncserver@:1.service - Remote desktop service (VNC)     Loaded: error (Reason: Invalid argument)     Active: inactive (dead)    Nov 10 18:34:25 orcacomputers systemd[1]: vncserver@:1.service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.        [Unit]  Description=Remote desktop service (VNC)  After=syslog.target network.target    [Service]  Type=simple    # Clean any existing files in /tmp/.X11-unix environment  ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  ExecStart=/usr/bin/vncserver_wrapper **netizen** %i  ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'    [Install]  WantedBy=multi-user.target        vim /etc/systemd/system/vncserver@\:1.service      [Unit]  Description=Remote desktop service (VNC)  After=syslog.target network.target    [Service]  Type=forking  ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  ExecStart=/sbin/runuser -l **netizen** -c "/usr/bin/vncserver %i -geometry 1280x1024"  PIDFile=/home/**netizen**/.vnc/%H%i.pid  ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'    [Install]  WantedBy=multi-user.target    [root@orcacomputers conf]# systemctl start vncserver@:1  Failed to start vncserver@:1.service: Unit is not loaded properly: Invalid argument.  See system logs and 'systemctl status vncserver@:1.service' for details.  

How can I extract some values that fall within a range

Posted: 11 Nov 2021 08:13 AM PST

I have about 4500 lines of aminoacid variations that look like this:

S1437T  H1266Y  T2662A  E1397A  E626K  S1538T  E3021K  

Briefly, the letters flanking the numbers are the amino acid residues and the numbers represent the residue position. I would like to retrieve only those variations that fall within the range 2400 to 3100.

I tried using grep but wasn't so successful in doing that. Also, I know that awk might be better for this kind of operation but I'm a total noob when it comes to awk. Any help would be appreciated.

linux D state processes reboot still remain? how can i close it?

Posted: 11 Nov 2021 10:22 AM PST

I have a 2cpu 4G server. Recently I found that the load is relatively high. I found a D states process after troubleshooting. I checked some information and said that only restarting can solve the problem.

But I restarted several times and the process is still there.

May I ask everyone, what is this process? process? How can this problem be solved?

Linux 5.10.60-9.al8.x86_64 #1 SMP Mon Sep 6 21:30:37 CST 2021 x86_64 x86_64 x86_64 GNU/Linux

[root@test ~]# cat /proc/137/status   Name:   load_calc  Umask:  0000  State:  D (disk sleep)  Tgid:   137  Ngid:   0  Pid:    137  PPid:   2  TracerPid:  0  Uid:    0   0   0   0  Gid:    0   0   0   0  FDSize: 64  Groups:    NStgid: 137  NSpid:  137  NSpgid: 0  NSsid:  0  Threads:    1  SigQ:   1/14009  SigPnd: 0000000000000000  ShdPnd: 0000000000000000  SigBlk: 0000000000000000  SigIgn: ffffffffffffffff  SigCgt: 0000000000000000  CapInh: 0000000000000000  CapPrm: 000001ffffffffff  CapEff: 000001ffffffffff  CapBnd: 000001ffffffffff  CapAmb: 0000000000000000  NoNewPrivs: 0  Seccomp:    0  Seccomp_filters:    0  Speculation_Store_Bypass:   vulnerable  Cpus_allowed:   3  Cpus_allowed_list:  0-1  Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001  Mems_allowed_list:  0  voluntary_ctxt_switches:    59154  nonvoluntary_ctxt_switches: 0    [root@test ~]# cat /proc/137/stack   [<0>] load_calc_func+0x55/0x1a0  [<0>] kthread+0x11b/0x140  [<0>] ret_from_fork+0x22/0x30    [root@test ~]# ps -ef |grep load  root         137       2  0 15:34 ?        00:00:00 [load_calc]  root       11317    1645  0 19:01 pts/0    00:00:00 grep --color=auto load    top - 19:03:10 up  3:28,  1 user,  load average: 1.00, 1.00, 1.00  Tasks: 143 total,   1 running, 141 sleeping,   0 stopped,   1 zombie  %Cpu(s):  3.2 us,  0.0 sy,  0.0 ni, 96.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st  MiB Mem :   3538.5 total,    200.4 free,    774.7 used,   2563.3 buff/cache  MiB Swap:      0.0 total,      0.0 free,      0.0 used.   2461.8 avail Mem       

Where is sudo hiding my root's .Xauthority data?

Posted: 11 Nov 2021 09:20 AM PST

I just noticed something peculiar about how sudo handles the .Xauthority file:

sudo xauth add $(xauth list | tail -1)    user@server: sudo xauth info  Authority file:       /root/.xauthYZ21Nt  File new:             no  File locked:          no  Number of entries:    1  Changes honored:      yes  Changes made:         no  Current input:        (argv):1    user@server:  sudo xauth info  Authority file:       /root/.xauth3BFy5d  File new:             no  File locked:          no  Number of entries:    1  Changes honored:      yes  Changes made:         no  Current input:        (argv):1    user@server:  sudo xauth list  server/unix:10  MIT-MAGIC-COOKIE-1  c922ab48defdf43b1092dffb86c06eed    user@server: sudo ls -la /root | grep auth  -rw-r--r--  1 root root    0 Nov  9 14:40 .Xauthority  -rw-------  1 root root   57 Nov  9 15:23 .xauthsrxzxl    user@server:  pkexec xauth info  Authority file:       /root/.Xauthority  File new:             no  File locked:          no  Number of entries:    0  Changes honored:      yes  Changes made:         no  Current input:        (argv):1  

So, $XAUTHORITY value is different in every new sudo, and it points to a temporary file which disappears when sudo quits. Because of this, the last command (which uses pkexec instead of sudo and expects it to be in /root/.Xauthority) fails to see the cookie. For instance, sudo gedit runs fine, but pkexec env DISPLAY=$DISPLAY gedit fails.

Why is it done in such a complicated way, where is the data stored, and more importantly, how can I access .Xauthority data with pkexec?

Count and return how many replacements were done with sed in a file

Posted: 11 Nov 2021 11:27 AM PST

I have a large JSON file in which I want to replace one string with another. It should not, but it might happen that this string would be used in a context where I do not want to replace it.

I know how many times it is in the file in the right context so I would like to also print how many occurrences of the string were replaced with sed. How can I do that?

For finding and replacing the string I use:

sed -i "" "s/my_string/new_string/g" my_file.json  

Note that I'm on mac but I would need it for Linux too, like:

sed -i "s/my_string/new_string/g" my_file.json  

I know I could just run a grep to find the string in the file and return the count like this:

grep -o my_string my_file.json | wc -l  

but that's not what I'm asking. I am asking if there is a way how to do the same as any text editor (word, notepad, geany, ...) does -- if I give a string, it tells me how many times it saw this string and replaced it with another.

More information -- it will run in a Bash script so if there would be another better way, I am open to that.

Fedora 31 drops wifi connection after some time

Posted: 11 Nov 2021 11:01 AM PST

I'm using Fedora 31 on my Notebook. Everything works well, except for Fedora dropping the wifi connection after a while, making it necessary to reconnect to the network. Every few minutes after reconnecting the behaviour repeats itself. I have no idea whats the reasons for that. It often happens when I downlaod files (putting "load" on the network) but sometimes also without any obvious reason. The problem first appeared under Fedora 30 and stayed after the upgrade to Fedora 31.

Output for journalctl -b -u NetworkManager:

-- Logs begin at Sun 2019-07-14 01:05:47 CEST, end at Sat 2019-11-16 23:42:15 CET. --  Nov 16 23:35:19 localhost.localdomain systemd[1]: Starting Network Manager...  Nov 16 23:35:19 localhost.localdomain NetworkManager[1073]: <info>  [1573943719.8189] NetworkManager (version 1.20.6-1.fc31) is starting... (after a restart)  Nov 16 23:35:19 localhost.localdomain NetworkManager[1073]: <info>  [1573943719.8191] Read config: /etc/NetworkManager/NetworkManager.conf (lib: 20-connectivity-fedora.conf)  Nov 16 23:35:19 localhost.localdomain systemd[1]: Started Network Manager.  Nov 16 23:35:19 localhost.localdomain NetworkManager[1073]: <info>  [1573943719.8260] bus-manager: acquired D-Bus service "org.freedesktop.NetworkManager"  Nov 16 23:35:19 localhost.localdomain NetworkManager[1073]: <info>  [1573943719.8355] manager[0x5559cd8e80f0]: monitoring kernel firmware directory '/lib/firmware'.  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3382] hostname: hostname: using hostnamed  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3385] hostname: hostname changed from (none) to "localhost.localdomain"  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3390] dns-mgr[0x5559cd8cd240]: init: dns=default,systemd-resolved rc-manager=symlink  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3401] rfkill2: found Wi-Fi radio killswitch (at /sys/devices/pci0000:00/0000:00:1d.3/0000:05:00.0/ieee80211/phy0/rfkill2) (driver ath10k_pci)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3403] manager[0x5559cd8e80f0]: rfkill: Wi-Fi hardware radio set enabled  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3403] manager[0x5559cd8e80f0]: rfkill: WWAN hardware radio set enabled  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3479] Loaded device plugin: NMWifiFactory (/usr/lib64/NetworkManager/1.20.6-1.fc31/libnm-device-plugin-wifi.so)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3486] Loaded device plugin: NMAtmManager (/usr/lib64/NetworkManager/1.20.6-1.fc31/libnm-device-plugin-adsl.so)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3511] Loaded device plugin: NMTeamFactory (/usr/lib64/NetworkManager/1.20.6-1.fc31/libnm-device-plugin-team.so)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3553] Loaded device plugin: NMBluezManager (/usr/lib64/NetworkManager/1.20.6-1.fc31/libnm-device-plugin-bluetooth.so)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3559] Loaded device plugin: NMWwanFactory (/usr/lib64/NetworkManager/1.20.6-1.fc31/libnm-device-plugin-wwan.so)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3561] manager: rfkill: Wi-Fi enabled by radio killswitch; enabled by state file  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3563] manager: rfkill: WWAN enabled by radio killswitch; enabled by state file  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3565] manager: Networking is enabled by state file  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3567] dhcp-init: Using DHCP client 'internal'  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3644] settings: Loaded settings plugin: ifcfg-rh ("/usr/lib64/NetworkManager/1.20.6-1.fc31/libnm-settings-plugin-ifcfg-rh.so")  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3644] settings: Loaded settings plugin: keyfile (internal)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3838] device (lo): carrier: link connected  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3845] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3886] manager: (enp4s0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3951] settings: (enp4s0): created default wired connection 'Kabelgebundene Verbindung 1'  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.3986] device (enp4s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.4067] device (wlp5s0): driver supports Access Point (AP) mode  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.4079] manager: (wlp5s0): new 802.11 Wi-Fi device (/org/freedesktop/NetworkManager/Devices/3)  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.4127] device (wlp5s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')  Nov 16 23:35:20 localhost.localdomain NetworkManager[1073]: <info>  [1573943720.7252] device (wlp5s0): set-hw-addr: set MAC address to 96:1B:95:D7:6D:B2 (scanning)  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0023] modem-manager: ModemManager available  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0103] manager: (virbr0): new Bridge device (/org/freedesktop/NetworkManager/Devices/4)  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0157] supplicant: wpa_supplicant running  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0157] device (wlp5s0): supplicant interface state: init -> starting  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0323] manager: (virbr0-nic): new Tun device (/org/freedesktop/NetworkManager/Devices/5)  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0446] device (virbr0-nic): state change: unmanaged -> unavailable (reason 'connection-assumed', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0458] device (virbr0-nic): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0583] sup-iface[0x5559cd8fe130,wlp5s0]: supports 5 scan SSIDs  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0596] device (wlp5s0): supplicant interface state: starting -> ready  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0597] Wi-Fi P2P device controlled by interface wlp5s0 created  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0599] manager: (p2p-dev-wlp5s0): new 802.11 Wi-Fi P2P device (/org/freedesktop/NetworkManager/Devices/6)  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0602] device (p2p-dev-wlp5s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0610] device (p2p-dev-wlp5s0): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.0613] device (wlp5s0): state change: unavailable -> disconnected (reason 'supplicant-available', sys-iface-state: 'managed')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <warn>  [1573943721.0631] sup-iface: failed to cancel p2p connect: P2P cancel failed  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3859] device (virbr0): state change: unmanaged -> unavailable (reason 'connection-assumed', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3906] device (virbr0): state change: unavailable -> disconnected (reason 'connection-assumed', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3924] device (virbr0): Activation: starting connection 'virbr0' (dc059138-81a5-4d0a-bb5e-725c891ae6bf)  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3935] device (virbr0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3947] device (virbr0): state change: prepare -> config (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3976] device (virbr0-nic): Activation: starting connection 'virbr0-nic' (d3fd587b-3b1e-418f-9fa9-dc52709be3e1)  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3980] device (virbr0): state change: config -> ip-config (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.3991] device (virbr0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4045] device (virbr0-nic): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4060] device (virbr0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4066] device (virbr0-nic): state change: prepare -> config (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4073] device (virbr0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4083] manager: NetworkManager state is now CONNECTED_LOCAL  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4108] device (virbr0): Activation: successful, device activated.  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4127] device (virbr0-nic): state change: config -> ip-config (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4203] device (virbr0): bridge port virbr0-nic was attached  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4203] device (virbr0-nic): Activation: connection 'virbr0-nic' enslaved, continuing activation  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4214] device (virbr0-nic): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4270] device (virbr0-nic): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4274] device (virbr0-nic): state change: secondaries -> activated (reason 'none', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4291] device (virbr0-nic): Activation: successful, device activated.  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4363] device (virbr0-nic): state change: activated -> unmanaged (reason 'connection-assumed', sys-iface-state: 'external')  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4374] device (virbr0): bridge port virbr0-nic was detached  Nov 16 23:35:21 localhost.localdomain NetworkManager[1073]: <info>  [1573943721.4374] device (virbr0-nic): released from master device virbr0  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7709] policy: auto-activating connection 'Wifi-SSID' (b11eeab9-1cd2-40cf-b02e-719ac7a2cbcb)  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7722] device (wlp5s0): Activation: starting connection 'Wifi-SSID' (b11eeab9-1cd2-40cf-b02e-719ac7a2cbcb)  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7731] device (wlp5s0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7741] manager: NetworkManager state is now CONNECTING  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7777] device (wlp5s0): set-hw-addr: reset MAC address to 58:00:E3:D0:B5:0F (preserve)  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7887] device (wlp5s0): supplicant interface state: ready -> disabled  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7889] device (p2p-dev-wlp5s0): supplicant management interface state: ready -> disabled  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7892] device (wlp5s0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7897] device (wlp5s0): Activation: (wifi) access point 'Wifi-SSID' has security, but secrets are required.  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7898] device (wlp5s0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7901] sup-iface[0x5559cd8fe130,wlp5s0]: wps: type pbc start...  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7939] device (wlp5s0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7946] device (wlp5s0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7950] device (wlp5s0): Activation: (wifi) connection 'Wifi-SSID' has security, and secrets exist.  No new secrets needed.  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7952] Config: added 'ssid' value 'Wifi-SSID'  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7952] Config: added 'scan_ssid' value '1'  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7953] Config: added 'bssid' value '54:67:51:B8:29:2A'  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7954] Config: added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256 FT-PSK'  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7955] Config: added 'psk' value '<hidden>'  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7982] device (wlp5s0): supplicant interface state: disabled -> inactive  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.7982] device (p2p-dev-wlp5s0): supplicant management interface state: disabled -> inactive  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.8098] device (wlp5s0): supplicant interface state: inactive -> scanning  Nov 16 23:35:25 localhost.localdomain NetworkManager[1073]: <info>  [1573943725.8099] device (p2p-dev-wlp5s0): supplicant management interface state: inactive -> scanning  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.5410] device (wlp5s0): supplicant interface state: scanning -> authenticating  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.5412] device (p2p-dev-wlp5s0): supplicant management interface state: scanning -> authenticating  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.5617] device (wlp5s0): supplicant interface state: authenticating -> associating  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.5618] device (p2p-dev-wlp5s0): supplicant management interface state: authenticating -> associating  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.6162] device (wlp5s0): supplicant interface state: associating -> associated  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.6162] device (p2p-dev-wlp5s0): supplicant management interface state: associating -> associated  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.6367] device (wlp5s0): supplicant interface state: associated -> 4-way handshake  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.6367] device (p2p-dev-wlp5s0): supplicant management interface state: associated -> 4-way handshake  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.7563] device (wlp5s0): supplicant interface state: 4-way handshake -> completed  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.7564] device (wlp5s0): Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to wireless network "Wifi-SSID"  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.7564] device (p2p-dev-wlp5s0): supplicant management interface state: 4-way handshake -> completed  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.7651] device (wlp5s0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.7656] dhcp4 (wlp5s0): activation: beginning transaction (timeout in 45 seconds)  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.8962] dhcp4 (wlp5s0): state changed unknown -> bound  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.8970] device (wlp5s0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.8993] device (wlp5s0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.8995] device (wlp5s0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.9002] manager: NetworkManager state is now CONNECTED_LOCAL  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.9017] manager: NetworkManager state is now CONNECTED_SITE  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.9018] policy: set 'Wifi-SSID' (wlp5s0) as default for IPv4 routing and DNS  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.9062] device (wlp5s0): Activation: successful, device activated.  Nov 16 23:35:30 localhost.localdomain NetworkManager[1073]: <info>  [1573943730.9069] manager: startup complete  Nov 16 23:35:31 localhost.localdomain NetworkManager[1073]: <info>  [1573943731.0336] manager: NetworkManager state is now CONNECTED_GLOBAL  Nov 16 23:35:32 localhost.localdomain NetworkManager[1073]: <info>  [1573943732.0747] policy: set 'Wifi-SSID' (wlp5s0) as default for IPv6 routing and DNS  Nov 16 23:35:34 localhost.localdomain NetworkManager[1073]: <info>  [1573943734.5034] agent-manager: req[0x5559cd9eb540, :1.201/org.gnome.Shell.NetworkAgent/1000]: agent registered  Nov 16 23:40:47 localhost.localdomain NetworkManager[1073]: <info>  [1573944047.5176] manager: NetworkManager state is now CONNECTED_SITE  

The general journal shows the following before dropping the connection:

Nov 16 23:40:40 localhost.localdomain systemd[1626]: Starting Tracker metadata database store and lookup manager...  Nov 16 23:40:40 localhost.localdomain systemd[1626]: Started Tracker metadata database store and lookup manager.  Nov 16 23:40:47 localhost.localdomain NetworkManager[1073]: <info>  [1573944047.5176] manager: NetworkManager state is now CONNECTED_SITE  Nov 16 23:40:47 localhost.localdomain systemd[1]: Starting Network Manager Script Dispatcher Service...  Nov 16 23:40:47 localhost.localdomain systemd[1]: Started Network Manager Script Dispatcher Service.  Nov 16 23:40:47 localhost.localdomain audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'  Nov 16 23:40:57 localhost.localdomain systemd[1]: NetworkManager-dispatcher.service: Succeeded.  Nov 16 23:40:57 localhost.localdomain audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'  Nov 16 23:41:11 localhost.localdomain tracker-store[3088]: OK  Nov 16 23:41:11 localhost.localdomain systemd[1626]: tracker-store.service: Succeeded.  

I also get the following error during the creation-phase of the connection:

    Nov 16 23:43:08 localhost.localdomain systemd[1]: Started Network Manager Script Dispatcher Service.  Nov 16 23:43:08 localhost.localdomain kernel: wlp5s0: deauthenticating from 54:67:51:b8:29:2a by local choice (Reason: 3=DEAUTH_LEAVING)  Nov 16 23:43:08 localhost.localdomain wpa_supplicant[1183]: wlp5s0: CTRL-EVENT-DISCONNECTED bssid=54:67:51:b8:29:2a reason=3 locally_generated=1  Nov 16 23:43:08 localhost.localdomain wpa_supplicant[1183]: dbus: wpa_dbus_property_changed: no property SessionLength in object /fi/w1/wpa_supplicant1/Interfaces/0  Nov 16 23:43:08 localhost.localdomain NetworkManager[1073]: <warn>  [1573944188.6104] sup-iface[0x5559cd8fe130,wlp5s0]: connection disconnected (reason -3)  Nov 16 23:43:08 localhost.localdomain NetworkManager[1073]: <info>  [1573944188.6110] device (wlp5s0): state change: deactivating -> disconnected (reason 'new-activation', sys-iface-state: 'managed')  Nov 16 23:43:08 localhost.localdomain wpa_supplicant[1183]: wlp5s0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD  Nov 16 23:43:08 localhost.localdomain NetworkManager[1073]: <info>  [1573944188.6136] dhcp4 (wlp5s0): canceled DHCP transaction  Nov 16 23:43:08 localhost.localdomain NetworkManager[1073]: <info>  [1573944188.6136] dhcp4 (wlp5s0): state changed bound -> done  Nov 16 23:43:08 localhost.localdomain wpa_supplicant[1183]: wlp5s0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=DE  

Output terminal not being displayed in KDbg

Posted: 11 Nov 2021 08:31 AM PST

I am using Linux Mint 18 and KDbg 4.14.16.

I have a problem with the output terminal of KDbg - when I run a program, I am supposed to input some data, but the Program output window is not being displayed, so I am not able to input my data.

I have already tried turning it on by selecting Settings->This program->Output->Full terminal emulation, but it did not work.

If anyone has another idea on how to solve this, please help. Thanks

mv file/folder with blank-spaces in its name doesn't work - LFTP

Posted: 11 Nov 2021 09:00 AM PST

I have 2 spaces:
My Synology NAS. And my FTP.

If we assume that some files on my local NAS are also in my FTP repository, I want to move some files on my local NAS AND on my FTP on different folders.

eg: After downloading files from FTP to NAS
NAS:
- Move from /volume1/Downloading/file001 to /volume1/Downloaded/file001

FTP:
- Move from /downloads/file001 to /downloads/Finished/file001

Every files on the NAS are moved at the right path : OK
On my FTP, only files/folders that doesn't contain blank spaces are moved : KO

So here is a part of the script we need to know:

#!/bin/sh  # Inits  ficLog=/volume1/ScriptsAndOutputs/logFTPSeedibox.txt  downloadingFolderPath=/volume1/Downloading  downloadedFolderPath=/volume1/Downloaded  ftpDestinationPath=FinishedTmp    # Configuration : ftp / user / pass  servFTP=server  userFTP=user  passFTP=password    for filePath in "${downloadingFolderPath}"/* ; do        # As filePath is the complete path of the file we need to get the file NAME      fileName=`basename "${filePath}"`      #Try to move it on FTP      lftp ftp://${userFTP}:${passFTP}@${servFTP} -e 'set ssl:verify-certificate false;set file:charset utf8;set ftp:charset utf8;cd downloads;mv "${fileName}" "${ftpDestinationPath}"'      res2=$?        #Then we move file on the NAS      mv "${filePath}" "${downloadedFolderPath}"  done  exit 0  

Here is the output :

+ ficLog=/volume1/ScriptsAndOutputs/logFTPSeedibox.txt  + downloadingFolderPath=/volume1/Downloading  + downloadedFolderPath=/volume1/Downloaded  + ftpDestinationPath=FinishedTmp  + servFTP=server  + userFTP=user  + passFTP=password  + for filePath in '"${downloadingFolderPath}"/*'  ++ basename /volume1/Downloading/@eaDir  + fileName=@eaDir  + lftp ftp://user:password@server -e 'set ssl:verify-certificate false;set file:charset utf8;set ftp:charset utf8;cd downloads;mv "${fileName}" "${ftpDestinationPath}"'  cd ok, cwd=/downloads             mv ${fileName}=>${ftpDestinationPath} [Waiting for response...]  mv: Access failed: 550 RNFR command failed. (${fileName})           + res2=1  + mv /volume1/Downloading/@eaDir /volume1/Downloaded  mv: inter-device move failed: '/volume1/Downloading/@eaDir' to '/volume1/Downloaded/@eaDir'; unable to remove target: Directory not empty  + for filePath in '"${downloadingFolderPath}"/*'  ++ basename '/volume1/Downloading/Folder With Files'  + fileName='Folder With Files'  + lftp ftp://user:password@server -e 'set ssl:verify-certificate false;set file:charset utf8;set ftp:charset utf8;cd downloads;mv "${fileName}" "${ftpDestinationPath}"'  cd ok, cwd=/downloads             mv ${fileName}=>${ftpDestinationPath} [Waiting for response...]  mv: Access failed: 550 RNFR command failed. (${fileName})           + res2=1  + mv '/volume1/Downloading/Folder With Files' /volume1/Downloaded  + for filePath in '"${downloadingFolderPath}"/*'  ++ basename /volume1/Downloading/Test_no_spaces.txt  + fileName=Test_no_spaces.txt  + lftp ftp://user:password@server -e 'set ssl:verify-certificate false;set file:charset utf8;set ftp:charset utf8;cd downloads;mv "${fileName}" "${ftpDestinationPath}"'  cd ok, cwd=/downloads             mv ${fileName}=>${ftpDestinationPath} [Waiting for response...]  mv: Access failed: 550 RNFR command failed. (${fileName})           + res2=1  + mv /volume1/Downloading/Test_no_spaces.txt /volume1/Downloaded  + for filePath in '"${downloadingFolderPath}"/*'  ++ basename '/volume1/Downloading/test_under et espaces.txt'  + fileName='test_under et espaces.txt'  + lftp ftp://user:password@server -e 'set ssl:verify-certificate false;set file:charset utf8;set ftp:charset utf8;cd downloads;mv "${fileName}" "${ftpDestinationPath}"'  cd ok, cwd=/downloads             mv ${fileName}=>${ftpDestinationPath} [Waiting for response...]  mv: Access failed: 550 RNFR command failed. (${fileName})           + res2=1  + mv '/volume1/Downloading/test_under et espaces.txt' /volume1/Downloaded  + exit 0  

As you can see, it's working for any folder/file on the NAS but only for files/folders names without blank-spaces on the FTP.

Can someone help me? Thanks.

How can I replace the stock driver module inside a Linux ISO?

Posted: 11 Nov 2021 10:04 AM PST

In particular, I want to replace the stock network drivers (r8169) with something else (r8168) in the installation ISO. Is this possible?

Currently, I have to install Ubuntu/Debian/CentOS (same problem with the driver in all distros) first, and then install the correct network driver, add it to the kernel and then blacklist the old one. I would like to avoid this long winded process if possible. Hopefully, there's a way to do this on Windows (Understandably, I don't want to boot into the Linux installation without a working internet connection).

Isn't there a way to do this from within Windows? For example, by opening up the iso files and replacing the stock driver module... Where are the network drivers located within the ISO?

How do I run GUI applications as root by using pkexec?

Posted: 11 Nov 2021 10:01 AM PST

I am using Trisquel GNU/Linux-Libre which comes with Gnome3 Flashback Desktop Environment.

I know that I can run GUI application as root by sudo & gksudo but I want to know that How do I run GUI applications as root with the help of pkexec?

When I tries to run gedit (or any other application like:nautilus) by pkexec gedit then It prompts for password for authentication:-

screenshot

After entering password it exit with error:-

$ pkexec gedit  error: XDG_RUNTIME_DIR not set in the environment.    (gedit:6135): Gtk-WARNING **: cannot open display:  

So, It seems something is going wrong with display environment.

I've also tried with DISPLAY=:0 pkexec gedit but doesn't work.


Following information is available from man pkexec:-

The environment that PROGRAM will run it, will be set to a minimal known and safe environment in order to avoid injecting code through LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID environment variable is set to the user id of the process invoking pkexec. As a result, pkexec will not allow you to run X11 applications as another user since the $DISPLAY and $XAUTHORITY environment variables are not set. These two variables will be retained if the org.freedesktop.policykit.exec.allow_gui annotation on an action is set to a nonempty value; this is discouraged, though, and should only be used for legacy programs.

Now I don't know What to do in order to accomplish this.

Thus, Help me to find out How to run GUI applications as root by means of pkexec. Or Is this possible or not?


BTW, Inspired by gparted-pkexeccommand which works fine. How gparted use pkexec?

Convince grep to output all lines, not just those with matches

Posted: 11 Nov 2021 10:08 AM PST

Say I have the following file:

$ cat test    test line 1  test line 2  line without the search word  another line without it  test line 3 with two test words  test line 4  

By default, grep returns each line that contains the search term:

$ grep test test    test line 1  test line 2  test line 3 with two test words  test line 4  

Passing the --color parameter to grep will make it highlight the portion of the line that matches the search expression, but it still only returns lines that contain the expression. Is there a way to get grep to output every line in the source file, but highlight the matches?

My current terrible hack to accomplish this (at least on files that don't have 10000+ consecutive lines with no matches) is:

$ grep -B 9999 -A 9999 test test  

Screenshot of the two commands

If grep can't accomplish this, is there another command-line tool that offers the same functionality? I've fiddled with ack, but it doesn't seem to have an option for it either.

No comments:

Post a Comment