Thursday, April 29, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to use Wi-Fi bridged adapter on Kali Linux Virtualbox

Posted: 29 Apr 2021 10:11 AM PDT

I have created a Kali Linux virtualbox and want to use my wifi card not wired connection. The standard NAT adapter gives me internet just fine, but when I change that to bridged adapter and select my wi-fi card "TP-LINK 802.11ac Network Adapter" with "promiscuous mode: Deny" and "Cable Connected" ticked. Kali does not change to wireless network and show me the available networks, it stays as ethernet network with wired connection 1. The network symbol is spinning and it cannot connect to the internet.

Hopefully this is a matter of turning off ethernet and turning on wifi but I don't know.

Thank you in advance.

Uncompressed files by content double gzipped by mistake

Posted: 29 Apr 2021 10:03 AM PDT

I have some files that I gzipped twice by mistake with no file extension

For example gzip -dc file outputs some binary gibberish for some of the files and for some other files it's okay

I would like to run a command to be able to find the double gzipped files in a folder (not all of them are double gzipped, but all of them are at least once) and automatically revert them to a single gzipping state

Incorrect selinux context for user's home dirs created durign ssh login

Posted: 29 Apr 2021 08:59 AM PDT

When new user's home folder is auto-created when I su - user from root shell, then context is correct:

[root@system ~]# su - user  Creating directory '/home/user'.  [user@system ~]$ ls -dZ .  drwx------. user user unconfined_u:object_r:user_home_dir_t:s0 .  

But the new user's home folder is created during ssh login, context is wrong:

[root@system ~]# ssh system -l user  Password:  Creating directory '/home/user'.  [user@system ~]$ ls -dZ .  drwx------. user user unconfined_u:object_r:home_root_t:s0 .  [user@system ~]$  

It is leading to problems with ssh functionality because of wrong context for .ssh stuff afterwards and Selinux complains about it (login with public key does not work because of this)

[user@system ~]$ mkdir .ssh  [user@system ~]$ ls -dZ .ssh .  drwx------. user userunconfined_u:object_r:home_root_t:s0 .  drwxr-x---. user userunconfined_u:object_r:home_root_t:s0 .ssh  

Only after I run restorecon valid context is set for the user's home folder and then ssh stuff is created in correct context:

[user@system ~]$ rm -rf .ssh  [user@system ~]$ restorecon -v .  restorecon reset /home/user context unconfined_u:object_r:home_root_t:s0->unconfined_u:object_r:user_home_dir_t:s0  [user@system ~]$ mkdir .ssh  [user@system ~]$ ls -dZ .ssh .  drwx------. user userunconfined_u:object_r:user_home_dir_t:s0 .  drwxr-x---. user userunconfined_u:object_r:ssh_home_t:s0 .ssh  [user@system ~]$  

Why there is wrong selinux context set for home directory when a user logs in via ssh for the first time, when his home dir is auto-created?

ip netns exec cannot start ONLY mate-terminal and gnome-terminal?

Posted: 29 Apr 2021 08:43 AM PDT

I am using the newns script from here:

https://superuser.com/questions/983727/route-only-specific-traffic-through-vpn

... except on this system:

$ mate-about -v  MATE Desktop Environment 1.24.0    $ cat /etc/issue  Ubuntu 20.04.2 LTS \n \l    $ lsb_release -a  No LSB modules are available.  Distributor ID: Ubuntu  Description:    Ubuntu 20.04.2 LTS  Release:    20.04  Codename:   focal  

So, the thing is, I have changed to export XTERM=/usr/bin/mate-terminal in that script, and when I run newns MYNS start right after reboot, the "namespaced" terminal runs fine; then I run newns MYNS stop, and the "namespaced" terminal is shut down - all good, all as expected.

But then, when I want to repeat the procedure - the terminal does NOT start anymore, but there is no error either?! I have eventually reduced it to this line (once the network namespace MYNS is made):

$ sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/mate-terminal myusername    (mate-terminal:12410): dbind-WARNING **: 17:33:10.398: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-pRWfI7rzyW: Connection refused  

Every once in a while, it might run once, but 99% of the time, re-running this command results with nothing.

Here is the funny part - if I replace mate-terminal with xterm in the above command line:

sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/xterm myusername  

... it works every time! But I do not want to use xterm - I need a terminal with tabs ...

Just for fun, I tried running VLC here, too:

sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/vlc myusername  

... and at least it starts fine (though it complains "vlcpulse audio output error: PulseAudio server connection failure: Connection refused"; "dbus interface error: Failed to connect to the D-Bus session daemon: Failed to connect to socket /tmp/dbus-CRRGy7gvlN: Connection refused" etc ...)

So, finally I installed gnome-terminal and tried with it - and it will not start either, just like mate-terminal, except with different messages:

$ sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/gnome-terminal myusername  # Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-pRWfI7rzyW: Connection refused  # Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Could not connect: Connection refused  

This file /tmp/dbus-pRWfI7rzyW keeps on repeating for starts of both terminals, but:

$ sudo ls -la /tmp/dbus*  ls: cannot access '/tmp/dbus*': No such file or directory  

... it is most definitely not present on the system.

So, my guess is, this might have something to do with DBUS - unfortunately, I do not really know or understand dbus.

My question is - is there a workaround I could do, so mate-terminal or gnome-terminal could start in this context every time?

grep Output Multiple Files in .bashrc Function

Posted: 29 Apr 2021 08:58 AM PDT

I was trying to create a function in my bash profile that would pass in a variable (mainly a directory), and run two different programs. The variable would typically be something like ~/logdirectory/*.log. I've got ~25 files in the /logdirectory/. When I run each line of the function on the command line, it functions as expected.

The first line runs a python script, which on the command line will return the results for all 25 files, but when I run it within the function, it only returns the results for 1 file (the very first in the directory)

The second line is supposed to grep through that same set of log files in /logsdirectory/, and look for a value that should be in all of the log files, and then pipe all of the results into awk to do some maths on the returning values. However, much like the first line, it's only returning the results for the very first file in the directory. Does anyone know what I'm missing or might need to do? I've tried subfunctions with for/do loops to try and get it to work, but no luck. Below is the function I'm working with. Any guidance would greatly be appreciated. Thanks!

plotstats() {      #take log directory and run plotman analyze      plotman analyze $1      grep -i "total time" $1 |awk '{sum=sum+$4} {avg=sum/NR} {tday=86400/avg*6*101.366/1024} END {printf "%d K32 plots, avg %0.1f seconds, %0.2f TiB/day \n", NR, avg, tday}'   }  

sed replace multiple matches per line

Posted: 29 Apr 2021 07:41 AM PDT

I am trying to replace some html links such that they open in a new tab (Except links that point to the same page).

Here is a dummy html page to illustrate my issue. I call it test.html.

<p>  This is the <a href="https://www.google.com/">Google link</a>  </p>    <p>  And these are <a href="https://twitter.com/">Twitter link</a> and <a href="https://www.instagram.com/">Instagram link</a>.  </p>  

I am using this code to find and replace links with some addition.

sed -E 's/(<a href="[^#]+[-a-zA-Z0-9@:%._\+~#=/?&]+")(>)/\1 target="_blank">/g' test.html  

The result looks like this:

<p>  This is the <a href="https://www.google.com/" target="_blank">Google link</a>  </p>    <p>  And these are <a href="https://twitter.com/">Twitter link</a> and <a href="https://www.instagram.com/" target="_blank">Instagram link</a>.  </p>  

Note the addition of target="_blank". It works as expected, except when there are multiple matches. In case of multiple matches per line, only the rightmost one is replaced. It seems to be detecting the whole line as a block.

Looking into this a bit, I found a suggestion to add a negation to split the detection blocks. So I added a negation for closing tag > like ^> so the code looks like

sed -E 's/(<a href="[^#]+[-a-zA-Z0-9@:%._\+~#=/?&^>]+")(>)/\1 target="_blank">/g' test.html  

But this doesn't seem to do anything. Perhaps, I am doing this wrong.

Running/testing now on sed 4.7. Intended to be run on sed 4.4.

Installation of "darling" on Debian 10 is failing

Posted: 29 Apr 2021 08:44 AM PDT

I'm trying to install darling to Debian 10, but it is failing.

I've got two .deb files from here, the first is just darling, and the second is darling-dkms.

Trying to install the first one, I get the following dependency error:

dpkg: dependency problems prevent configurtion of darling:    darling depends on libc6 (>= 2.32); however:      Version of libc6:amd64 on system is 2.28-10.    darling depends on libc6-i386 (>= 2.32); however:      Version of libc6-i386 on system is 2.28-10    darling depends on darling-dkms; however:      Package darling-dkms is not installed  

I tried running sudo apt --fix-broken install, but it didn't fix the issue

The second package is no better: trying to download it, I get a build error:

'make' -C lkm/ MIGDIR=/usr/src/darling-mach=0.1/miggen MIGDIR_REL=../miggen....(bad exit status: 2)  Error! Bad return status for module build on kernel 4.19.0-16-amd64 (x86_64)  Consult /var/lib/dkms/darling-mach/0.1/build/make.log for more information.  

(the log file)

I've tried stright away compilling the githup repo, but it was not any better.

I have gcc, clang, make and cmake installed, I'm not sure what is wrong thou. Any help with resolving this issue will be greatly appreciated!

P. s. I am very new to Unix-like systems, so just have that in mind

Sort and Join with letters and numbers

Posted: 29 Apr 2021 07:24 AM PDT

I have two files (file1 and file2) and I would like to mount a third (file3) containing a column that the two do not have. I usually do the sort and then together with the join. But it is not working, because it has values with letters and numbers from the example below:

File1:

ARS-BFGL-BAC-1180 14 20574088  ARS-BFGL-BAC-11805 12 14897445  ARS-BFGL-BAC-11852 1 34309921  ARS-BFGL-BAC-11867 13 12616676   

File2

AC16359 ARS-BFGL-BAC-11798 B B  AC16359 ARS-BFGL-BAC-11805 B B  AC16359 ARS-BFGL-BAC-1180 B B  AC16359 ARS-BFGL-BAC-11852 A A  AC16359 ARS-BFGL-BAC-11867 B B   

I notice that I use the same sort command for both and note that the final SNP_Name 11805 is above 1180 and the other is not.

Combine multiple awk functions

Posted: 29 Apr 2021 09:48 AM PDT

I'm very new to awk, I'm trying to do the following in an environment that doesn't support grep -P and doesn't have Perl installed either.

Given I have a list of env variables starting with a prefix, I want to generate an argument list based on those variables, without using the prefix.

So, for example, if I have

PREFIX_VARIABLE_1=100  PREFIX_VARIABLE_2=500  

I'd like to generate

 --set service.VARIABLE_1=100 --set service.VARIABLE_2=500  

I've came up with

 env | awk 'match($0, /PREFIX_.*/) { substr($0, RSTART+8, RLENGTH) ; split($0, parts, "=") ; printf "--set service.%s=%s ", parts[1], parts[2] }'    

but this doesn't strip the prefix, substr is not being used I guess

With grep -P I can do it:

 env | grep -oP '(?<=PREFIX_)(.*)' | awk 'split($0, parts, "=") { printf "--set service.%s=%s ", parts[1], parts[2] }'  

Any idea how to chain/pipe multiple awk functions properly? Thanks

EFI USB install

Posted: 29 Apr 2021 07:57 AM PDT

I am having some issues installing a ubuntu on a USB.

Well installing it is the easy part, making the partitions and getting it to boot is ok (following this) https://ubuntuforums.org/showthread.php?t=2338836

The problem however is only one ever wants to boot. if the USB boots, the grub on the main system needs repairing, if the main system boots or is restored the USB grub needs repairing.

I honestly have no idea why im having so many issues with this. any help? THIS IS NOT ABOUT A LIVE USB

My goal is to have a usb with dev op tools on that I can plug into a system, it boots without interaction and configures the main system.

the usb is ubuntu 20 and the main system 18

No Wifi Adapter found using externel wifi dongle

Posted: 29 Apr 2021 07:36 AM PDT

Im using linux Ubuntu 20.04. My computer has only enthernet but I needed also wi-fi, so I bought wifi dongle 8188eu. First i tried installing drivers and maybe I succedded(or maybe not). Now it is is showing me the wifi to turn it on but also that 'No wifi adapter is found". Can someone help me? Thanks in advance!

Sort the data to plot a sphere

Posted: 29 Apr 2021 09:50 AM PDT

Here I have a data which I would to plot with line using gnuplot. Using the code

pl 'Sphere_ISOTEST_data.txt' w p  

I get below figure

this

but, using

pl 'Sphere_ISOTEST_data.txt' w l  

I get the following:

enter image description here

Can anyone suggest as to how to sort the data such that I can plot w l and get only the circumference of the sphere.

How to convert a CSV with multiple sub-row items (from a column) to new columns in Awk?

Posted: 29 Apr 2021 10:11 AM PDT

I have a CSV file with the general format shown in the picture below.

In that CSV there are multiple rows that belong to a certain column (desc) and I would like to to extract those items and add them to new columns called name, size, weight, glass, respectively. I have highlighted (in red) those sub-row items for the entries.

Original Structure:

enter image description here

Expected Structure:

enter image description here


The original CSV:

page,item,id,desc,price  1,2,F1,Alpha,111.11  1,,,380 x 2280 mm (size),  1,,,Weight: 33.0 kg,  1,,,Glass: AAA,  1,,,XXX,  1,3,F2,Beta,222.22  1,,,880 x 2280 mm (size),  1,,,Weight: 68.4 kg,  1,,,Glass: BBB,  1,,,YYY,  1,4,F3,Gamma,333.33  1,,,1980 x 1580 mm (size),  1,,,Weight: 78.2 kg,  1,,,Glass: CCC,  1,,,XXX,  1,,,YYY,  1,,,ZZZ,  

Expected resulting CSV:

page,item,id,name,size,weight,glass,price  1,2,F1,Alpha,380 x 2280,33.0,AAA,111.11  1,3,F2,Beta,880 x 2280,68.4,BBB,222.22  1,4,F3,Gamma,1980 x 1580,78.2,CCC,333.33  

where name would take the place of the first row in desc.


UPDATE:

I might not have been clear, but the number of sub-rows in the desc column may vary. The already accepted answer fails when you add another item.

Adding the following item to the above,

1,7,F4,Delta,111.11  1,,,11 x 22 mm (size),  1,,,Weight: 33.0 kg,  1,,,Glass: DDD,  1,,,Random-1,  

...you will see the problem:

page,item,id,name,size,weight,glass,price  1,2,F1,Alpha,380 x 2280,33.0,AAA,111.11  1,3,F2,Beta,880 x 2280,68.4,BBB,222.22  1,4,F3,Gamma,1980 x 1580,78.2,CCC,333.33  1,7,F4,Delta,YYY,ZZZ,11 x 22,111.11  

So two important points:

  • Any sub-rows after Glass:... should be ignored.
  • There may be items that doesn't have any sub-rows in the desc column, they should also be ignored.

Q: How can I remap those sub-rows into new columns, using Awk?
(Or are there more suitable tools for doing this in bash?)

Possibly related (but not very helful) Questions:

Exiftool on WSL cannot write

Posted: 29 Apr 2021 09:40 AM PDT

Using exiftool on Windows Subsystem for Linux (WSL, Ubuntu) I can print exif data:

# exiftool test.pdf    ExifTool Version Number         : 10.80  File Name                       : test.pdf  Directory                       : .  File Size                       : 279 kB  File Modification Date/Time     : 2020:04:28 23:00:41+02:00  File Access Date/Time           : 2020:04:28 23:08:51+02:00  File Inode Change Date/Time     : 2020:04:28 23:00:41+02:00  File Permissions                : rwxrwxrwx  File Type                       : PDF  File Type Extension             : pdf  MIME Type                       : application/pdf  PDF Version                     : 1.7  Linearized                      : No  Warning                         : Info object (11 0 obj) not found at 285226  

However, I cannot change or delete them, e.g. the following command throws an error which I do not understand.

# exiftool -all= test.pdf    Error: Info object (11 0 obj) not found at 285226 - test.pdf      0 image files updated      1 files weren't updated due to errors  

I was not sure about write privileges, so I copied (duplicated, from within WSL) the (Windows-created) original file and renamed it to test.pdf, but this did not solve the problem.
I found the following suggestions, but they did not solve the issue either:

Jq --- converting nested json to csv

Posted: 29 Apr 2021 08:31 AM PDT

I have sample JSON like below

{    "data": [      {        "name": "city",        "LIST": {          "ID": [            {              "value": "ny",              "name": "US"            },            {              "value": "lon",              "name": "GB"            },            {              "value": "Toronto",              "name": "CA"            }          ]        }      },      {        "name": "city1"      }    ]  }  

I was to get value as below

city,ny    city1,  

I want only value where name="US" in jq.

There will be maximum of 1 name = "US" for each element of the data array. If there is no name = "US" then I want it as blank or NULL. In above example, if 2nd record doesn't have name = "US" then output will be city1,blank or city1,.

How to run subsequent commands after invoking a shell

Posted: 29 Apr 2021 09:14 AM PDT

I have a script called myscript.sh with multiple commands within it

#!/bin/sh/    singularity shell -B /home/user/Desktop/ /home/user/image/some_image.simg  /home/user/miniconda/activate my_env  cd /app/app_folder/scripts  ls -ash  

The first command (line 3) invokes a shell and I want the subsequent commands to run within the invoked shell.

How do I get this to work properly.

Are data compression algorithms in *nix systems modular?

Posted: 29 Apr 2021 09:30 AM PDT

I find the term "data compression" as can mean different operations without a necessary common denominator:

  1. Smallscaling: Making a data piece smaller in a way that won't miss its main designation
  2. Reducing redundancy: Removing anything which is considered "redundant" from a data piece
  • I assume that each one of these operations could be described with the saying "storing data more efficiently"
  • I assume that each one of these operations can be lossless or non lossless depending on the method utilized to achieve the "compression"

Are data compression algorithms in *nix systems modular (in accordance with Unix philosophy)?

Linux installation not able to find the first partition of the disk during the boot up

Posted: 29 Apr 2021 09:43 AM PDT

I have an hard disk image of an openSUSE installation from a x86-64 machine which I no longer have access to. I'm trying to boot from this raw disk using quemu. If I start the virtual machine with for example qemu-system-x86_64 -m 4096 -curses -hda srv.sda -enable-kvm or qemu-system-x86_64 -m 4096 -curses -drive id=disk,file=srv.sda,if=none,format=raw -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -enable-kvm, then I end up in the GRUB 2.02 shell, where I can specify the Linux kernel and initial ramdisk with commands below:

grub> linux (hd0,msdos1)/boot/vmlinuz  grub> initrd (hd0,msdos1)/boot/initrd  grub> boot  

This starts the boot process which always ends here:

              [    0.234732] NET: Registered protocol family 10                [    0.235188] lo: Disabled Privacy Extensions                [    0.235592] lib80211: common routines for IEEE802.11 drivers                [    0.236014] registered taskstats version 1                [    0.236439]   Magic number: 1:617:774                [    0.236774] mem zero: hash matches                [    0.237151] rtc_cmos 00:01: setting system clock to 2021-04-22 07:46:24 UTC (                1619077584)                [    0.237802] Freeing unused kernel memory: 896k freed                [    0.238330] Write protecting the kernel read-only data: 10240k                [    0.238762] Freeing unused kernel memory: 1616k freed                [    0.239578] Freeing unused kernel memory: 748k freed                doing fast boot                Creating device nodes with udev                [    0.255337] udev: starting version 157                mount: devpts already mounted or /dev/pts busy                mount: according to mtab, devpts is already mounted on /dev/pts                Boot logging started on /dev/char/../tty1(/dev/console) at Thu Apr 22 10:46:24 2                021                resume device  not found (ignoring)                Waiting for device /dev/sda1 to appear: [    1.072809] input: ImExPS/2 Generic E                xplorer Mouse as /devices/platform/i8042/serio1/input/input1                ..............................Could not find /dev/sda1.                Want me to fall back to /dev/sda1? (Y/n)  

Can I modify the disk settings of the qemu in some way that the first and only partition of the disk becomes available for Linux? For example, looks like GRUB is able to access it as it successfully reads the /boot/vmlinuz and /boot/initrd.

EDIT: After recreating the initial ramdisk and including the ata_piix kernel module the qemu-system-x86_64 boot process is following:

              [    0.244118] rtc_cmos 00:01: setting system clock to 2021-04-27 15:31:52 UTC (                1619537512)                [    0.244762] Freeing unused kernel memory: 896k freed                [    0.245284] Write protecting the kernel read-only data: 10240k                [    0.245716] Freeing unused kernel memory: 1616k freed                [    0.246529] Freeing unused kernel memory: 748k freed                doing fast boot                [    0.266568] SCSI subsystem initialized                [    0.267653] megasas: 00.00.04.17.1-rc1 Thu. Oct. 29, 11:41:51 PST 2009                [    0.278467] scsi0 : ata_piix                [    0.278833] scsi1 : ata_piix                [    0.279164] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc060 irq 14                [    0.279562] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc068 irq 15                Creating device nodes with udev                [    0.444780] udev: starting version 157                mount: devpts already mounted or /dev/pts busy                mount: according to mtab, devpts is already mounted on /dev/pts                Boot logging started on /dev/char/../tty1(/dev/console) at Tue Apr 27 18:31:52 2                021                resume device  not found (ignoring)                Waiting for device /dev/sda1 to appear: [    1.080811] input: ImExPS/2 Generic E                xplorer Mouse as /devices/platform/i8042/serio1/input/input1                ..............................Could not find /dev/sda1.                Want me to fall back to sda1? (Y/n)    

As seen above, the ata_piix module seems to be loaded, but /dev/sda1 is still not found.

Mopidy with pipewire-pulse

Posted: 29 Apr 2021 08:00 AM PDT

I run Mopidy as a service for my mpd because of the nice Spotify integration. I've followed the documentation's instructions to use it with pulseaudio by setting

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1`  

in my /etc/pulse/default.pa and

[audio]  output = pulsesink server=127.0.0.1  

in my /etc/mopidy/modipy.conf.
All of this was working perfectly, however recently I've started using Pipewire as a replacement for PulseAudio on Arch Linux by following this and installing pipewire,pipewire-alsa, pipewire-pulse and pipewire-media-session. But now I've noticed that whenever I try to play any music nothing happens. I checked the journalctl for Mopidy and found this

ERROR ... [536:MainThread] mopidy.audio.gst  ... mopidy[536]:   GStreamer error: Failed to connect: Connection refused  ... mopidy[536]: WARNING ... [536:Audio-2] mopidy.audio.actor  ... mopidy[536]:   Setting GStreamer state to GST_STATE_PLAYING failed  ... mopidy[536]: WARNING ... [536:Core-11] mopidy.core.tracklist  ... mopidy[536]:   Track is not playable: local:track:...  

I searched around and found the gst-plugin-pipewire package, but installing it didn't help at all. Apart from Mopidy, everything else audio-wise is working perfectly. If I could get some help with this I'd be thankful.

Camera stops working on Ubuntu 20.04

Posted: 29 Apr 2021 08:40 AM PDT

I have a USB camera and it's behaviour is really weird. I test it on the webcam testing website, and after giving priviliges to the website everything goes well, the camera works just fine. But I found out that after several refreshes of the website my camera just stops working (I can't see the output on my screen, earlier it was there). The only solution I managed to find is unplug & plug the USB again, then the whole thing repeats - camera works for a few website refreshes, then it stops again. Does somebody know what's happening? It seems really weird to me

EDIT: If it'd help, my camera model is "A4Tech Co., Ltd. A4tech FHD 1080P PC Camera".

EDIT 2: journalctl output:

when camera works:

apr 25 14:59:37 my-desktop-name firefox[2787]: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)' failed apr 25 14:59:37 my-desktop-name firefox[2787]: gtk_widget_get_window: assertion 'GTK_IS_WIDGET (widget)'   

when camera stops working:

apr 25 14:56:38 my-desktop-name kernel: xhci_hcd 0000:02:00.0: WARN Set TR Deq Ptr cmd failed due to incorrect slot or ep state.  

also output from ls -l /dev/video;id (in my case /dev/video0)

crw-rw----+ 1 root video 81, 0 04-29 17:39 /dev/video0  

Running Android Emulator sets audio volume to 100%

Posted: 29 Apr 2021 09:42 AM PDT

I working with Android Studio now, and when I test my app on real device connected to PC, everything is OK. But if I run Android Emulator (Pixel 2, level 29 API), sound volume of my PC is being set to maximum somewhy, which can deliver little problems if u work at Night.

I tried either to download 30th API level or use Nexus emulator instead of Pixel one, but nothing of that helps.

My application doesnt deal with audio for now, and error occurs even before any activity starts. My DE is Cinnamon, OS is Void-linux if it does matter. Any help is appreciated, thank you.

What is /dev/mapper/cachedev1?

Posted: 29 Apr 2021 07:22 AM PDT

I just got my first QNAP NAS, used to work mostly with Synology before, and I'm currently trying to figure out how the system uses LVM. Mostly out of curiosity.

In my specific case, it's a 2 bay NAS that I'm setting up as RAID 1 "storage pool". Within that pool, I created a "thick volume".

These naming conventions do seem a bit confusing. When the "storage pool" gets created, QNAP seems to immediately create a LVM thin pool (i.e. a volume) across all of the free space. Any "thick" or "thin" volumes are then created within that pool.

Here is the output of vgs and lvs right after the creation of the storage pool and one 250GB thick volume:

 # vgs    VG   #PV #LV #SN Attr   VSize VFree    vg1    1   3   0 wz--n- 1.81t    0     # lvs    LV    VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert    lv1   vg1  Vwi-aot--- 250.00g tp1         100.00    lv544 vg1  -wi-------  18.54g    tp1   vg1  twi-aot---   1.73t             14.13  0.03  

After I created the volume, I tried to find out where it was mounted but neither mount nor df -h would show that lv1 was mounted. From the web interface, you could already interact with the shared folder in the lv, so clearly it had to be somewhere.

dmsetup ls --tree gives more info:

# dmsetup ls --tree  cachedev1 (252:8)   └─vg1-lv1 (252:7)      └─vg1-tp1-tpool (252:4)         ├─vg1-tp1_tmeta (252:0)         │  └─ (9:1)         ├─vg1-tp1_tierdata_2 (252:3)         │  └─vg1-tp1_tierdata_2_fcorig (252:6)         │     └─ (9:1)         ├─vg1-tp1_tierdata_1 (252:2)         └─vg1-tp1_tierdata_0 (252:1)  

So, there is a device called cachedev1 in /dev/mapper and it's mounted on /share/CACHEDEV1_DATA. And within here, any "shared folders" will appear.

I don't have the knowledge to make sense of this configuration. What is /dev/mapper/cachedev1 exactly? How did lv1 become part of it? And what is the benefit of using it over just mounting the LVM volume directly?

Delete all folders inside a folder except one with specific name

Posted: 29 Apr 2021 08:40 AM PDT

I need to delete all folders inside a folder using a daily script. The folder for that day needs to be left.

Folder 'myfolder' has 3 sub folder: 'test1', 'test2' and 'test3' I need to delete all except 'test2'.

I am trying to match exact name here:

find /home/myfolder -type d ! -name 'test2' | xargs rm -rf  

OR

find /home/myfolder -type d ! -name 'test2' -delete  

This command always tries to delete the main folder 'myfolder' also ! Is there a way to avoid this ?

ssh remote file execution is not working

Posted: 29 Apr 2021 09:09 AM PDT

I have a bash script test.sh that contains the following commands

#!/bin/bash    PASSWORD=""  USERNAME=""  REM_HOSTNAME='localhost'    FILES_TO_COPY="remote_exec.sh"      function scptmp {      exec sshpass -p $PASSWORD scp -o "ConnectTimeout 3" \          -o "StrictHostKeyChecking no" \          -o "UserKnownHostsFile /dev/null" \          "$@"  }    echo -e "\tCopying files to remote host..."  scptmp -r -q $FILES_TO_COPY $USERNAME@$REM_HOSTNAME:/tmp    echo -e "\tSet execution privs on remote file..."  sshpass -p "$PASSWORD" ssh -t -oStrictHostKeyChecking=no $USERNAME@$REM_HOSTNAME "echo $PASSWORD | sudo -S chmod +x /tmp/$FILES_TO_COPY"    echo -e "\Execute..."  sshpass -p "$PASSWORD" ssh -oStrictHostKeyChecking=no -t $USERNAME@$REM_HOSTNAME "echo $PASSWORD | sudo -S bash /tmp/$FILES_TO_COPY"  

And the remote_exec.sh with the following content:

#!/bin/bash    hostname=`hostname`  mkdir $hostname  

When I execute the script with

bash test.sh  

I don't receive any error, but the remote_exec.sh doesn't seem to be executed on the host since no directory is created.

Does anyone have an idea what the problem might be?

What happens to a multithreaded Linux process if it gets a signal?

Posted: 29 Apr 2021 07:46 AM PDT

If a Unix (Posix) process receives a signal, a signal handler will run.

What will happen to it in a multithreaded process? Which thread receives the signal?

In my opinion, the signal API should be extended to handle that (i.e. the thread of the signal handler should be able to be determined), but hunting for infos on the net I only found year long flames on the linux kernel mailing list and on different forums. As I understood, Linus' concept differed from the Posix standard, and first some compat layer was built, but now the Linux follows the posix model.

What is the current state?

Old ATI Video Card on Debian 8 - Xpress 200 - model: 1150

Posted: 29 Apr 2021 08:08 AM PDT

Well, my problem is very complicated, I've an old machine (Dell Vostro 1000) where I'm using Debian 8 with XFCE. This machine have an integrated video card (ATI MOBILITY RADEON XPRESS 200 - Model: 1150), and it doesn't work with Debian default configuration.

Let's see what I already have tried:

  • To turn on my laptop without it shows the notorious colored stripes I need use the "nomodeset" code on grub.cfg.
  • The Debian 8 appears don't have the xorg.conf (???), I made a Xorg.conf following the instructions at https://wiki.debian.org/AtiHowTo , without success.
  • I tried already tried follow the procedures in the page above, cause the current proprietary driver is not compatible with my old video card. and the older version (legacy) can't be installed and shows some conflicts with "X". This way I have to use the generic linux driver.
  • I tried set the display resolution using XRANDR, but it fails and when I made the insertion of another resolution, I just can't select this.
  • Thinking about modules, maybe I can see a little ligth in the end of tunnel. I find a blacklist file into "/etc/modprobe.d" and removed the module "radeonfb" of blacklist, but when I tried to restart, the machine only shows a black screen with the mouse pointer only. to fix this I changed the "quiet" entry of boot line and changed it with "single" to show the command line and I can see that when the module "radeonfb" is loaded, the letters of command line become small (like it have made a resolution adjustment) but I need understand why only a black screen and the mouse pointer is showed.

NOTE: The xorgs and firmware-linux are installed but doesn't work. I really don't need 3d acceleration, but I need to resize my screen. Actually it's 1024x768 but the hardware can show 1280x800.

No output from locate command

Posted: 29 Apr 2021 09:35 AM PDT

I usually find the answers to all my Unix related problems already posted as questions and answers. However, this particular issue has had me stumped for the past hour so I thought I'd ask my first question on this site.

Problem

I have a development / staging server server running CentOS 5.11. Running locate as a regular user results in no output (not even an error message):

locate readdir  

However, running the command as the superuser prints a list of valid results:

$ sudo locate readdir  /home/anthony/repos/php-src/TSRM/readdir.h  /home/anthony/repos/php-src/ext/standard/tests/dir/readdir_basic.phpt  ... etc.  

strace usually helps me debug any such issues and running strace locate readdir shows:

stat64("/var/lib/mlocate/mlocate.db", 0xbff65398) = -1 EACCES (Permission denied)  access("/", R_OK|X_OK)                  = -1 EACCES (Permission denied)  exit_group(1)                           = ?  

Check permissions

I checked the ownership and permissions of the locate binary and its default database. As expected the command is setgid with slocate as the group owner while the database has the appropriate ownership and permissions.

$ ls -l /usr/bin/locate  -rwx--s--x 1 root slocate 22280 Sep  3  2009 /usr/bin/locate    $ sudo ls -l /var/lib/mlocate/mlocate.db  -rw-r----- 1 root slocate 78395703 May  8 04:02 /var/lib/mlocate/mlocate.db    $ sudo ls -ld /var/lib/mlocate/  drwxr-x--- 2 root slocate 4096 Sep  3  2009 /var/lib/mlocate/  

There are also no unusual file attributes:

$ sudo lsattr /usr/bin/locate /var/lib/mlocate/mlocate.db  ------------- /usr/bin/locate  ------------- /var/lib/mlocate/mlocate.db  

Compare with working system

Meanwhile, everything works as expected on the Production server. Running locate readdir as a regular (non-root) user returns a list of results as it should:

$ locate readdir  /usr/include/php/TSRM/readdir.h  /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/POSIX/readdir.al  /usr/share/man/man2/readdir.2.gz  

For comparison, I also ran this command through strace but I then got the same permission denied error as on the staging server. I was wondering how this could be until I read the manual page for sudo. Listed in the Bugs section:

Programs that use the setuid bit do not have effective user ID privileges while being traced.

So, unfortunately, I can't use strace for debugging.

I compared the results of all the above commands between the Staging and Production servers and there's no difference between them. Both systems have the mlocate-0.15-1.el5.2 RPM with no modifications to their files as shown by rpm -V mlocate.

Other considerations

I thought it might be related to the fact that on the problematic staging server, my login is authenticated using Winbind but I created a regular local user on the same box and I still have the same issue. There's obviously something else that I'm missing but I simply don't know what it is.

I suspect it is related to the setgid file permission, maybe PAM or possibly SELinux. I don't know much about either PAM or SELinux: I've only ever looked at PAM when configuring Winbind authentication while SELinux was installed with the OS but I've never used it.

Note: the production server has been subject to far fewer modifications than the development server which has had some experimentation.

Gnome, nautilus copy files to USB stops at 100% or near

Posted: 29 Apr 2021 07:58 AM PDT

I had similar issues before but i don't remember how i solved it.

When i try to copy something to USB stick, with FAT, it stops near the end, sometimes at 100%. And of course, when i transfer the memory stick somewhere else, it doesn't contain complete file. (file is a movie!)

I tried to mount device with mount -o flush, but i get same issue.

Also, i did format the USB stick with new FAT partition...

Any idea what cold i do?

p.s. I believe it's not related to OS, which is Debian, and i believe that coping from SSD drive doesn't make it stuck.

Print the string between two parentheses

Posted: 29 Apr 2021 09:10 AM PDT

I have file with these lines

G8 = P(G1,G3)  G9 = P(G3,G4)  G12 = P(G2,G9)  G15 = P(G9,G5)  G16 = P(G8,G12)  G17 = P(G12,G15)  

I need the output as

G1,G3  G3,G4  .....  

How can I do it with sed/grep command or using perl?

How to print certain columns by name?

Posted: 29 Apr 2021 07:47 AM PDT

I have the following file:

id  name  age  1   ed    50  2   joe   70     

I want to print just the id and age columns. Right now I just use awk:

cat file.tsv | awk '{ print $1, $3 }'  

However, this requires knowing the column numbers. Is there a way to do it where I can use the name of the column (specified on the first row), instead of the column number?

No comments:

Post a Comment