Thursday, August 12, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to write NGINX configuration for wordpress and legacy files

Posted: 12 Aug 2021 10:48 AM PDT

I want to serve files from wordpress and legacy static files from a directory.

For example I want to serve wordpress home page / and wordpress files such as wp-login.php and newly created wordpress articles with permalink /articles/ and I want to serve legacy .html files from /legacy directory.

So if nginx finds wordpress files serve them, if not found then check legacy directory ..

The config file shown below will do all of the above except will not serve the images and javascript etc from legacy files .. It will serve the html files from the /legacy directory and the home page from / but does not serve files like myserver.com/image/image.png or myserver.com/image.jpg (or any other images for example) -- I have tried numerous config alternations with no luck. Thanks for any help.

server_name myserver.com www.myserver.com;  access_log /var/log/nginx/myserver.com.access.log rt_cache_redis;  error_log /var/log/nginx/myserver.com.error.log;    root /var/www/myserver.com/htdocs;  index index.php;  location ^~ .php$ {  tryfiles $uri =404;  include fastcgiparams;  fastcgi_pass php74;  }    location / {  try_files $uri $uri/ /legacy$uri /index.php$args;  }    include common/redis-php74.conf;  include common/wpcommon-php74.conf;  include common/locations-wo.conf;    

What type of buffering does stderr use by default (in linux)?

Posted: 12 Aug 2021 10:32 AM PDT

What type of buffering does stderr use by default (in linux)? What type of buffering does stderr use by default (in linux)? What type of buffering does stderr use by default (in linux)? What type of buffering does stderr use by default (in linux)? What type of buffering does stderr use by default (in linux)?

Using SCP in a Bastion VM setup with an established SSH tunnel

Posted: 12 Aug 2021 10:31 AM PDT

I am looking at ways to mitigate the potential for using scp commands within GCE VMs that are running CentOS 8.

Current setup is a bastion VM being able to SSH into a secondary VM (instance-1). I have not been able to SSH back from the secondary VM into the bastion VM after establishing the first SSH connection and I am assuming this is due to not having a SSH keypair in the opposite direction (someone correct me if I am wrong there). Error when running ssh <BASTION_IP> is ``Permission denied (publickey,gssapi-keyex,gssapi-with-mic)`

I am attempting to SCP from instance-1 to the bastion and that does not work either with an error of Permission denied (publickey,gssapi-keyex,gssapi-with-mic). This is due to the SSH keypair not being present correct?

Is there a way to work around this? I want to see what potential approaches can be used for running SCP commands from instance-1 to the bastion. Would any form of TCP forwarding or establishing a different SSH tunnel allow for files to be transferred out?

Awk regex pattern matching with space

Posted: 12 Aug 2021 10:31 AM PDT

I have a file fruits:

ap ple   ora nge   pe ar  gra pes  bro ccoli  tom ato  ap ache  

I'd like to make an awk script to check how many fruits are there in the file.

I have tried

awk -F: '/ap|ora|pe|gra ple|nge|ar|pes/ {sum+=1} END {print sum+0}' fruits  

and it should return 4, since 4 of their pairs are exact match, but they're returning 5 I think due to ap ache. Does the space not register in this case?

Programmatically Trigger Drag&Drop Events on Linux

Posted: 12 Aug 2021 10:19 AM PDT

I currently working on an interactive video stream application (implemented in PyQt5) which allows viewers of the stream to interact with the streamer's system, for example by moving the mouse cursor or opening programs.

I would also want to allow Drag&Drop through the stream from one device to the other. I was able to implement the drag part as well as transferring the data by using QWidget's dropEvent()-Function and a web server. However, I am struggling with triggering a drop event at certain coordinates on the streamer's system. I had a look at xdnd as well as some applications such as xcopy already, but all of those seem to require the mouse for drag and drop.

Is there any way to tell X11 to invoke a drop event with a certain payload at given coordinates without having to use the mouse?

Thank you in advance!

Re-run multiple commands without pressing up a lot

Posted: 12 Aug 2021 10:32 AM PDT

I embarrassingly often find myself repeating a lot of previous commands. I go Up Up Up to find the first command. Enter. Then Up Up Up again for the second command. And so on.

Is there a way to step to the next command in history after re-running one? Like it would be great to do Up Up Up Shift+Enter Shift+Enter Shift+Enter to re-run the last three commands.

I know about fc, but it's not just about the shell. I hit this in the Python interpreter and basically everywhere I type any commands.

Why does lspci in an Azure VM show only a NIC card?

Posted: 12 Aug 2021 09:54 AM PDT

Normally in a Linux system a bunch of things show up, but in an Azure VM it shows only a single NIC card. Why is that?

Make scp skip downloading a file when "Permission denied" occure and instead try the next one

Posted: 12 Aug 2021 09:51 AM PDT

After transferring 2TB of 3TB using scp my internet died. I try to resolve this matter by setting all the files I have downloaded as read only with the hope of scp trying to copy over the file, realizing that a file with that name exist and it does not have premission to overwrite it and thus skip it. However, does not work as I had hoped. Instead scp terminate, saying "Permission Denied", which is accurate but I would like it to then just give up and look at the next file.

Is this possible to do? I have not found any such flags in the manual so do not really know. Is there maybe a better way of doing it?

Error using glib2 from yum: "libgio-2.0.so.0: undefined symbol: g_free"

Posted: 12 Aug 2021 09:48 AM PDT

I am trying to build all of the dependencies for Weasyprint 52.5 for AWS Lambda. Despite being a python library, Weasyprint has a large number of OS dependencies.

I'm creating a lambda layer by downloading all of the necessary rpms from yum and extracting the shared libraries. It nearly works but I can't seem to get around this error with libgio.

The OS is Amazon Linux 2, which uses yum for package management and seems to match up with CentOS 7.

This is the yum call command:

yumdownloader libffi pixman freetype fontconfig libglvnd libglvnd-glx libglvnd-egl mesa-libglapi libpng libxcb libXrender libX11 libXext libXau libXdamage libXfixes libXxf86vm expat libuuid libxshmfence libdrm libwayland-client libwayland-server glib2 fribidi libthai harfbuzz graphite2 gdk-pixbuf2 cairo pango  

Which pulls these package versions:

cairo-1.15.12-4.amzn2.x86_64  expat-2.1.0-12.amzn2.x86_64  fontconfig-2.13.0-4.3.amzn2.x86_64  freetype-2.8-14.amzn2.1.x86_64  fribidi-1.0.2-1.amzn2.1.x86_64  gdk-pixbuf2-2.36.12-3.amzn2.x86_64  glib2-2.56.1-9.amzn2.0.1.x86_64  graphite2-1.3.10-1.amzn2.0.2.x86_64  harfbuzz-1.7.5-2.amzn2.x86_64  libdrm-2.4.97-2.amzn2.x86_64  libffi-3.0.13-18.amzn2.0.2.x86_64  libglvnd-1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64  libglvnd-egl-1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64  libglvnd-glx-1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64  libpng-1.5.13-8.amzn2.x86_64  libthai-0.1.14-9.amzn2.0.2.x86_64  libuuid-2.30.2-2.amzn2.0.4.x86_64  libwayland-client-1.17.0-1.amzn2.x86_64  libwayland-server-1.17.0-1.amzn2.x86_64  libX11-1.6.7-3.amzn2.0.2.x86_64  libXau-1.0.8-2.1.amzn2.0.2.x86_64  libxcb-1.12-1.amzn2.0.2.x86_64  libXdamage-1.1.4-4.1.amzn2.0.2.x86_64  libXext-1.3.3-3.amzn2.0.2.x86_64  libXfixes-5.0.3-1.amzn2.0.2.x86_64  libXrender-0.9.10-1.amzn2.0.2.x86_64  libxshmfence-1.2-1.amzn2.0.2.x86_64  libXxf86vm-1.1.4-1.amzn2.0.2.x86_64  mesa-libglapi-18.3.4-5.amzn2.0.1.x86_64  pango-1.42.4-4.amzn2.x86_64  pixman-0.34.0-1.amzn2.0.2.x86_64  

Running rpmdev-extract to extract the rpms results in these shared libraries:

libcairo-script-interpreter.so.2.11512.0  libcairo.so.2.11512.0  libdrm_amdgpu.so.1.0.0  libdrm_intel.so.1.0.0  libdrm_nouveau.so.2.0.0  libdrm_radeon.so.1.0.1  libdrm.so.2.4.0  libEGL.so.1.1.0  libexpat.so.1.6.0  libffi.so.6.0.1  libfontconfig.so.1.11.1  libfreetype.so.6.14.0  libfribidi.so.0.4.0  libgdk_pixbuf-2.0.so.0.3612.0  libgdk_pixbuf_xlib-2.0.so.0.3612.0  libgio-2.0.so.0.5600.1  libglapi.so.0.0.0  libGLdispatch.so.0.0.0  libglib-2.0.so.0.5600.1  libGL.so.1.7.0  libGLX.so.0.0.0  libgmodule-2.0.so.0.5600.1  libgobject-2.0.so.0.5600.1  libgraphite2.so.3.0.1  libgthread-2.0.so.0.5600.1  libharfbuzz.so.0.10705.0  libkms.so.1.0.0  libpango-1.0.so.0.4200.3  libpangocairo-1.0.so.0.4200.3  libpangoft2-1.0.so.0.4200.3  libpangoxft-1.0.so.0.4200.3  libpixman-1.so.0.34.0  libpng15.so.15  libpng15.so.15.13.0  libthai.so.0.1.6  libuuid.so.1.3.0  libwayland-client.so.0.3.0  libwayland-server.so.0.1.0  libX11.so.6.3.0  libX11-xcb.so.1.0.0  libXau.so.6.0.0  libxcb-composite.so.0.0.0  libxcb-damage.so.0.0.0  libxcb-dpms.so.0.0.0  libxcb-dri2.so.0.0.0  libxcb-dri3.so.0.0.0  libxcb-glx.so.0.0.0  libxcb-present.so.0.0.0  libxcb-randr.so.0.1.0  libxcb-record.so.0.0.0  libxcb-render.so.0.0.0  libxcb-res.so.0.0.0  libxcb-screensaver.so.0.0.0  libxcb-shape.so.0.0.0  libxcb-shm.so.0.0.0  libxcb.so.1.1.0  libxcb-sync.so.1.0.0  libxcb-xevie.so.0.0.0  libxcb-xf86dri.so.0.0.0  libxcb-xfixes.so.0.0.0  libxcb-xinerama.so.0.0.0  libxcb-xinput.so.0.1.0  libxcb-xkb.so.1.0.0  libxcb-xselinux.so.0.0.0  libxcb-xtest.so.0.0.0  libxcb-xvmc.so.0.0.0  libxcb-xv.so.0.0.0  libXdamage.so.1.1.0  libXext.so.6.4.0  libXfixes.so.3.1.0  libXrender.so.1.3.0  libxshmfence.so.1.0.0  libXxf86vm.so.1.0.0  

When Weasyprint calls ffi.dlopen("libfontconfig.so.1"), I get an OSError:

cannot load library 'libfontconfig.so.1': /opt/lib/libgio-2.0.so.0: undefined symbol: g_free

I have tried downgrading some of the key packages to the other versions available on yum, but with no success. Specifically, I have tried downgrading the following:

fontconfig-2.10.95  glib2-2.50.3  cairo-1.14.8  pango-1.40.4  

but this results in the same error.

What is causing the undefined symbol error? Is there any workaround that will resolve this error?

Deleting lines of a series of ASCII (.csv) files having a certain row number

Posted: 12 Aug 2021 09:12 AM PDT

I have a series of 297 directories named as "dir000', 'dir001' and so on, each of which contains a text file called "config", which is a csv file with 3 columns and 256 rows. I have generated 25 random numbers in the range 1 to 256, and from all these files in each directory, I am required to remove those exact 25 rows. For instance, if my generator gave me a series of random numbers a = [145,11,140,119,183,178,225,131,1,65,213,115,207,41,194,221,10,205,6,57,224,108,44,85,211], I want to delete exactly these rows from each of the ASCII files("config") in each directory. Can anyone let me know how this can be achieved using command line? I am using Ubuntu 16.04 distribution.

Transform csv multiple columns to single column

Posted: 12 Aug 2021 09:39 AM PDT

I have 1 csv data with multiple column, without header:

5,-3,0  3,2,5  -2,4,4  0,2,1  2,-1,-2  

Then I would like to transpose it into single column, starting from first column. The expected output is below:

 5   3  -2   0   2  -3   2   4   2  -1   0   5   4   1  -2  

Anyone have a clue how to solve this problem?

What I have done is using excel formula: =INDEX($A$1:$C$4,1+INT((ROW(A1)-1)/COLUMNS($A$1:$C$4)),MOD(ROW(A1)-1+COLUMNS($A$1:$C$4),COLUMNS($A$1:$C4))+1) and ending with single column but start from first row.

I am looking for faster way to do this, using script for example.

Why is it possible to "loop" a filesystem by mounting it to one of its folders?

Posted: 12 Aug 2021 09:58 AM PDT

/dev/sda5 is mounted at / and it's my filesystem

piotr@thinkpad:~$ sudo mkdir /home/mpoint  piotr@thinkpad:~$ sudo mount /dev/sda5 /home/mpoint  

so now I can do:

piotr@thinkpad:~$ cd /home/mpoint/home/mpoint  

and when I'm in second mpoint directory, it's empty.

My questions are:

  1. Why is it possible to "loop" a filesystem by mounting it to one of its folders?

  2. Why this second mpoint dir is empty?

Removing single quotes from double-quoted variable element in array and run a command

Posted: 12 Aug 2021 10:17 AM PDT

I have a script where I dinamically change the arguments which must be passed to a command (mkvpropedit in this case). Consider the example script below:

#!/bin/bash    LANG_NAME="eng lish"    MYSETTINGS=()  MYSETTINGS+=("--edit 1")  MYSETTINGS+=("--set \"language=${LANG_NAME}\"")    echo "Count = ${#MYSETTINGS[@]}" # should be 2  set -x # enable to see the invoked command  mkvpropedit ${MYSETTINGS[@]}  

When I run this, I get in the console:

[~] # ./test.sh  Count = 2  + mkvpropedit --edit 1 --set '"language=eng' 'lish"'  

But I would like not having the single quotes on the final invocation of mkvpropedit, like so:

+ mkvpropedit --edit 1 --set "language=eng lish"  

I tried also echoing the array into a variable, and echo removes the single quote, but then I'm not able to use the variable as an argument of mkvpropedit because the single quotes appear again...

Of course the script has to work also if the variable is a single word, such as LANG_NAME="eng" . My Bash version is 3.2 (Busybox, actually).

Updated question

Probably the example below better explains what I'm trying to do. I've changed some names to be replicable.

#!/bin/bash    TITLE_NAME="my title"    MYSETTINGS=()  MYSETTINGS+=("--edit track:2")  MYSETTINGS+=("--set \"name=${TITLE_NAME}\"")    set -x  mkvpropedit file.mkv ${MYSETTINGS[@]}   

If I run this script, I get (due to the wrong quote):

# ./test.sh  + mkvpropedit file.mkv --edit track:2 --set '"name=my' 'title"'  Error: More than one file name has been given ('file.mkv' and 'title"').  

While if I run, manually:

# mkvpropedit file.mkv --edit track:2 --set "name=my title"  The file is being analyzed.  The changes are written to the file.  Done.  

So it's definitely a quoting issue; I would like to invoke mkvpropedit using the array in the script.

Using eval

What seems to work, at the moment, is inserting mkvpropedit and file.mkv into the array and eventually call eval "${MYSETTINGS[@]}", but is it worth and safe? Isn't eval evil (pun intended)?

TITLE_NAME="my title"    MYSETTINGS=(mkvpropedit file.mkv)  MYSETTINGS+=("--edit track:2")  MYSETTINGS+=("--set \"name=${TITLE_NAME}\"")    set -x  eval "${MYSETTINGS[@]}"  

Returns:

# ./test.sh  + eval mkvpropedit file.mkv '--edit track:2' '--set "name=my title"'  ++ mkvpropedit file.mkv --edit track:2 --set 'name=my title'  The file is being analyzed.  The changes are written to the file.  Done.  

Start program in virtual console

Posted: 12 Aug 2021 09:47 AM PDT

I am trying to create a desktop shortcut to start kodi on my Raspberry Pi running Raspberry Pi OS. My problem is:

  • If I create a desktop shortcut with kodi as the command, nothing happens.
  • If I run kodi from a normal terminal I get ERROR: Unable to create GUI. Exiting.

To actually start kodi, I need to switch to a TTY1 virtual console (Ctrl + Alt + F1) and then type kodi. It starts and runs perfectly fine.

I am wondering if I could somehow change my shortcut command to start and switch to kodi on TTY1 virtual console? Or any other way to make it work?


I have tried (from normal terminal on TTY7):

  • kodi > /dev/tty1 just prints ERROR: Unable to create GUI. Exiting in terminal.
  • setsid sh -c 'exec kodi <> /dev/tty1 >&0 2>&1' I get ERROR: Unable to create GUI. Exiting on TTY1
  • sudo openvt -s -c 2 kodi which opens a black screen with ERROR: Unable to create GUI. Exiting on default TTY7
  • /usr/bin/xinit /usr/local/bin/kodi -- :1 which opens a black screen with blinking _ in top left corner on default TTY7

How to grep below match criteria

Posted: 12 Aug 2021 09:17 AM PDT

I have a challenging task that requires some logic in on order to grep to grep for lines between a section:

I have in a file the below contents:

1856 /dev/informix/chunkbig10_1039    eppix:'informix'.lsc_ix1 212995  eppix:'informix'.api_valid_token 213201  eppix:'informix'.leads_reasons 213841  eppix:'informix'.epx_vas_sms 214481  eppix:'informix'.lsc_ix1 215121  eppix:'informix'.lsc_ix1 287926  eppix:'informix'.cn_clawback_idx 288750  eppix:'informix'.consent_types_idx 288782  eppix:'informix'.lsc_ix1 288850        1936 /dev/informix/chunkbig10_1119          1937 /dev/informix/chunkbig10_1120          1981 /dev/informix/chunkbig10_1164          1982 /dev/informix/chunkbig10_1165  

What I need to extract from the file is if I grep for chunkbig10_1039, I would like to print all the lines eppix* and I do not even know where to begin on how to achieve this. The problem is I cannot grep for eppix for example, because that can be anything but is an example if it were straight forward

awk case insensitive with gsub

Posted: 12 Aug 2021 10:01 AM PDT

I have text data, and want to transform a column values

$ cat infile  Mark father  Jason SOn  Jose son  Steffy daugHter  

I want to search for (father|son|daughter) case insensitively and substitute any father combination to Father, any case of son to Son, any case of daughter to Daughter

So outfile should look like this

$ cat outfile  Mark Father  Jason Son  Jose Son  Steffy Daughter  

I'm trying different combination of IGNORECASE with sub or gsub, but it prints all entries as is in infile

Can't write tildes on konsole and certain console emulators

Posted: 12 Aug 2021 09:52 AM PDT

So im completely bewildered on this problem, initially two years ago i remember being able to use tildes(~) easily on terminal emulators, but for some reason it suddenly stopped working for this and other small characters on certain terminal emulators(like konsole and kitty but strangely not alacritty where at least for tildes it seems to work). I would like to provide more data but the only thing that journalctl provides is this which seems to be related to my keyboard somehow:

ago 11 21:53:10 micron konsole[57951]: qt.xkb.compose: failed to create compose table  ago 12 00:05:32 micron yakuake[6053]: qt.xkb.compose: failed to create compose table  ago 12 00:41:43 micron konsole[230660]: qt.xkb.compose: failed to create compose table  ago 12 00:42:17 micron konsole[231203]: qt.xkb.compose: failed to create compose table  xkbcommon: ERROR: couldn't find a Compose file for locale "pt_PT.UTF8"  [224 00:46:09.943101] [glfw error 65544]: Failed to create XKB compose table for locale pt_PT.UTF8  

I forgot to add but i run two keyboards typically however every time i unplug my external keyboard(im working on a laptop and the embedded one has some few physical keys missing) i run to set my portuguese layout

setxkbmap pt

I work on arch linux, and althought its a bit outdated, ive updated it for months, and the problem persisted so not being updated doesnt seem to be the problem.

I kinda suck at writting and will divulge to much so feel free to offer criticism on text i can cut from this question

Update: i now know why it stopped working in general, although i don't know precisely how to fix it, apparently konsole when i use kde as the desktop manager instead of openbox makes it work, i've attemted to manually fill out the enviroment variables on .zshrc that are unset namely these:

export LANGUAGE="pt:en"  export XDG_SESSION_DESKTOP="KDE"  export XDG_CURRENT_DESKTOP="KDE"  

ive tried changing this to autostart file on /etc/xdg/openbox/autostart but for some reason both set and export get ignored

If using while read loops for text processing in bash is bad...what should I do, then?

Posted: 12 Aug 2021 09:35 AM PDT

I guess this may be a naive question but I can't get my head around so I felt like asking... I was searching for some solution to a problem, when I found this very interesting post about why is using [while|for] loops in bash considered bad practice. There is a very good explanation in the post (see the chosen answer) but I can't find anything that solves the issues that are discussed.

I searched extensively: I googled (or duckduckgo-ed) how to read a file in bash and all the results I am getting point towards a solution that, according to the above-mentioned post, is absolutely non-bash style and something that should be avoided. In particular, we have this:

while read line; do    echo $line | cut -c3  done  

and this:

for line in `cat file`; do    foo=`echo $line | awk '{print $2}'`    echo whatever $foo  done  

that are indicated as very bad examples of shell scripting. At this point I am wondering, and this is the actual question: if the posted while loops should be avoided because they are bad practice and whatever...what am I supposed to do, instead?

EDIT: I see that I am already having comments/questions addressing the exact issue with the while loop, so I feel like to widen the question a bit. Basically, what I am understanding is that I need to dig deeper into bash commands, and that is the real thing that I should do. But, when one searches around, it looks like people are, in the general case, using and teaching bash in an improper way (as per my google-ing).

Opera is unable to play videos in MX Linux KDE version

Posted: 12 Aug 2021 09:02 AM PDT

I recently installed and started to use the Opera browser as it offers a wide range of functionality and the workspace feature: it seems very viable for me. But when it comes to playing videos, this browser is giving me lots of trouble. So let me add a screenshot to show what actually is happening here.

enter image description here

The same goes for Netflix; here is the screenshot.

enter image description here

Are there any workarounds to this problem? I really love this browser; I want to use it for this purpose.

No wi-fi on Linux Mint 19.3 Tricia

Posted: 12 Aug 2021 09:47 AM PDT

I know there is a lot of posts about this problem, but i tried to find a solution every where my problem persist.. So when i want to use my wi-fi, it say: Not available, so i can use ethernet connexion only..

Here is some details of my configuration :

nmcli general status :

STATE                  CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN  connected (site only)  limited       enabled  enabled  enabled  enabled  

nmcli device wifi : (It show nothing)

inxi -Fxz :

System:    Host: lol Kernel: 5.4.0-73-generic x86_64 bits: 64 compiler: gcc v: 7.5.0     Desktop: Cinnamon 4.4.8 Distro: Linux Mint 19.3 Tricia     base: Ubuntu 18.04 bionic   Machine:    Type: Laptop System: HP product: HP Pavilion Gaming Laptop 16-a0xxx v: N/A     serial: <filter>     Mobo: HP model: 87AD v: 32.30 serial: <filter> UEFI: AMI v: F.10     date: 06/23/2020   Battery:    ID-1: BAT0 charge: 45.6 Wh condition: 45.6/45.6 Wh (100%)     model: HP Primary status: Full   CPU:    Topology: Quad Core model: Intel Core i5-10300H bits: 64 type: MT MCP     arch: N/A L2 cache: 8192 KiB     flags: lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 39999     Speed: 899 MHz min/max: 800/4500 MHz Core speeds (MHz): 1: 900 2: 900     3: 900 4: 900 5: 899 6: 899 7: 882 8: 898   Graphics:    Device-1: Intel vendor: Hewlett-Packard driver: i915 v: kernel     bus ID: 00:02.0     Device-2: NVIDIA vendor: Hewlett-Packard driver: nouveau v: kernel     bus ID: 01:00.0     Display: x11 server: X.Org 1.20.8 driver: modesetting unloaded: fbdev,vesa     resolution: 1920x1080~60Hz     OpenGL: renderer: Mesa DRI Intel UHD Graphics (CML GT2) v: 4.6 Mesa 20.0.8     direct render: Yes   Audio:    Device-1: Intel vendor: Hewlett-Packard driver: sof-audio-pci     bus ID: 00:1f.3     Device-2: NVIDIA vendor: Hewlett-Packard driver: snd_hda_intel v: kernel     bus ID: 01:00.1     Sound Server: ALSA v: k5.4.0-73-generic   Network:    Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet     vendor: Hewlett-Packard driver: r8168 v: 8.045.08-NAPI port: 4000     bus ID: 03:00.0     IF: eno1 state: up speed: 100 Mbps duplex: full mac: <filter>     Device-2: Realtek vendor: Hewlett-Packard driver: rtw_pci v: N/A     port: 3000 bus ID: 04:00.0     IF: wlo1 state: down mac: <filter>     IF-ID-1: enp0s20f0u2c4i2 state: down mac: <filter>     IF-ID-2: tun0 state: unknown speed: 10 Mbps duplex: full mac: N/A   Drives:    Local Storage: total: 1.38 TiB used: 229.81 GiB (16.3%)     ID-1: /dev/nvme0n1 vendor: Western Digital     model: PC SN520 SDAPNUW-512G-1014 size: 476.94 GiB     ID-2: /dev/sda vendor: Seagate model: ST1000LM049-2GH172 size: 931.51 GiB   RAID:    Hardware-1: Intel 82801 Mobile SATA Controller [RAID mode] driver: ahci     v: 3.0 bus ID: 00:17.0   Partition:    ID-1: / size: 466.31 GiB used: 114.37 GiB (24.5%) fs: ext4 dev: /dev/dm-1     ID-2: /boot size: 704.5 MiB used: 178.4 MiB (25.3%) fs: ext4     dev: /dev/nvme0n1p2     ID-3: swap-1 size: 979.5 MiB used: 906.6 MiB (92.6%) fs: swap     dev: /dev/dm-3   Sensors:    System Temperatures: cpu: 52.0 C mobo: N/A gpu: nouveau temp: 38 C     Fan Speeds (RPM): N/A   Info:    Processes: 341 Uptime: 4d 4h 20m Memory: 7.55 GiB used: 5.19 GiB (68.7%)     Init: systemd runlevel: 5 Compilers: gcc: 7.5.0 Shell: bash v: 4.4.20     inxi: 3.0.32   

iwconfig :

enp0s20f0u2c4i2  no wireless extensions.    eno1      no wireless extensions.    wlo1      IEEE 802.11  ESSID:off/any              Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm               Retry short limit:7   RTS thr:off   Fragment thr:off            Power Management:on              lo        no wireless extensions.    tun0      no wireless extensions.  

lsusb :

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub  Bus 001 Device 003: ID 0bda:b00c Realtek Semiconductor Corp.   Bus 001 Device 002: ID 04f2:b6f1 Chicony Electronics Co., Ltd   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  

Also, secure boot is disabled !

It's realy boring to stay in ethernet, i can't find out from where this problem come from, i tried to install drivers ect.. never worked..

Thank for your help guys !

What means the definition of path and leaf array in jq --stream man page

Posted: 12 Aug 2021 10:36 AM PDT

In the jq manual page, --stream option, says:

Parse the input in streaming fashion, outputing arrays of path and leaf values (scalars and empty arrays or empty objects). For example, "a" becomes [[],"a"], and [[],"a",["b"]] becomes [[0],[]], [[1],"a"], and [[1,0],"b"].

I want to know the meaning of "arrays of path and leaf values" and why the input representation is transformed like:

"a" -> [[],"a"]  

and

[[],"a",["b"]] ->  [[0],[]]  , [[1],"a"]  , [[1,0],"b"]  

I have been reviewing trees like list representation but it's not similar.

How to write udev rule that matches a device's interface attribute(s)

Posted: 12 Aug 2021 11:01 AM PDT

I have a USBTMC device that has a usbtmc interface. The interface has bInterfaceClass, bInterfaceSubClass, and bInterfaceProtocol attributes with values 'fe', '3', and '1' respectively. The question is how to write a udev rule that matches attributes on an interface of the device. It appears that matching starts the device level, and can only look "upward" at the device's parents, but cannot look "downward" (down the sysfs tree) into the device's interface(s).

I'm able to write a working rule that matches based on the VID/PID:

SUBSYSTEM=="usb", ATTR{idProduct}=="5c18", ATTR{idVendor}=="2a8d", MODE:="0660", GROUP="plugdev"  

but a rule like this does NOT work:

SUBSYSTEM=="usb", ATTR{bInterfaceClass}=="fe", ATTR{bInterfaceSubClass}=="03", MODE:="0660", GROUP="plugdev"  

The following shows a listing of the device, and shows the attributes of the interface found under 1-1:1.0:

me@box:/sys/bus/usb/devices/1-1$ ls  1-1:1.0            bcdDevice            bDeviceProtocol  bMaxPacketSize0     bNumInterfaces  descriptors  devpath  idProduct    manufacturer  power    removable  serial     tx_lanes  version  authorized         bConfigurationValue  bDeviceSubClass  bMaxPower           busnum          dev          driver   idVendor     maxchild      product  remove     speed      uevent  avoid_reset_quirk  bDeviceClass         bmAttributes     bNumConfigurations  configuration   devnum       ep_00    ltm_capable  port          quirks   rx_lanes   subsystem  urbnum  me@box:/sys/bus/usb/devices/1-1$ cat 1-1\:1.0/bInterfaceClass   fe  me@box:/sys/bus/usb/devices/1-1$ cat 1-1\:1.0/bInterfaceSubClass   03  me@box:/sys/bus/usb/devices/1-1$ cat 1-1\:1.0/bInterfaceProtocol   01  me@box:/sys/bus/usb/devices/1-1$  

The command: udevadm info -a -n

lists device ATTR that can be used, as well as parent ATTRS. None of these include the (child) interface attributes.

Any help would be appreciated.

DEAUTH_LEAVING error

Posted: 12 Aug 2021 10:00 AM PDT

I'm not able to manage this error

[  666.695694] wlan0: deauthenticating from xx:xx:xx:xx:xx:xx by local choice (Reason: 3=DEAUTH_LEAVING)  

I obtain the error only when I'm trying to connect to a WPA2-Enterprise network (EAP-MSCHAP2). Other connections work well without any error. This error has been obtained after a Linux upgrade, at now I'm using

Linux root 4.18.0-kali2-amd64 #1 SMP Debian 4.18.10-2kali1 (2018-10-09) x86_64 GNU/Linux   

Lurking I've seen a possible cause to this problem: the TLSv1.2 support has been disabled. I've seen several solutions with wpa_supplicant, but I'm using network manager. I've also tried to configure wpa_supplicant without any result. What can I do?

Accessing MTP mounted device in terminal

Posted: 12 Aug 2021 09:35 AM PDT

cd: /run/user/$UID/gvfs/mtp://%5Busb%3A001,010%5D/

gives the error :

cd: no such file or directory: /run/user/1000/gvfs/mtp://%5Busb%3A001,010%5D/   

Even though the device is mounted in the file manager and shows the same mtp path

I'd like to access it via terminal to able to copy data out of it as the File Manager just hangs when done via the GUI.

Distribution : Fedora 28

How to cleanup SSH reverse tunnel socket after connection closed?

Posted: 12 Aug 2021 10:57 AM PDT

If I run something like this:

ssh -4 -f -N -T -R "/home/dude/lol.socket:192.168.4.44:4444" dude@someserver -p 22 -i privatekey -o "ExitOnForwardFailure yes" -o ConnectTimeout=5 -o ConnectionAttempts=3 -o ServerAliveInterval=15 -o  

And then lets say the connection is closed or dies for whatever reason.. say the computer reboots due to maintenance or error or there's internet connectivity issues or whatever -> we have a big problem. The created socket file /home/dude/lol.socket on the someserver does not get deleted by sshd. So as the reverse tunnel initiator is recovering and tries to recreate the tunnel it can't because:

Error: remote port forwarding failed for listen path /home/dude/lol.socket  

On the server side you get something like:

error: bind: Address already in use  error: unix_listener: cannot bind to path: /home/dude/lol.socket  

What would be the supported way / best hack to cleanup the socket after disconnect? Is this a bug in sshd, shouldn't it do that automatically if/when disconnects are noticed?

Backstory:

The idea behind using the sockets is simply that the server is going to handle n "dudes" creating reverse tunnels for m "lol" services in whatever ports and using sockets makes it much easier to ensure that a "dude" can only access and bind to his own sockets, but not other dudes sockets. It also frees me from having to keep record of which dude is using which port to expose which service. And when dude wants to connect to the service on some other server all he needs to know is the name of the service and bind it to some random local port (or socket if he wants to) i.e.

ssh -v -i -4 -N -T -L "127.0.0.1:3334:/home/dude/lol.sock" -p 22 dude@someserver -o "ExitOnForwardFailure yes" -o ConnectTimeout=5 -o ConnectionAttempts=3 -o ServerAliveInterval=15 -o ServerAliveCountMax=3

There's no need to know some magic port number that the reverse tunnel on the server is suppose to be running on. So, if you have better ideas how to solve this issue I'm all ears.

Tested with client/server both running Debian 9 (client actually on mac inside docker container) using openssh-client/server version 7.4p1-10+deb9u2

How do you keep only the last n lines of a log file?

Posted: 12 Aug 2021 08:56 AM PDT

A script I wrote does something and, at the end, appends some lines to its own logfile. I'd like to keep only the last n lines (say, 1000 lines) of the logfile. This can be done at the end of the script in this way:

tail -n 1000 myscript.log > myscript.log.tmp  mv -f myscript.log.tmp myscript.log  

but is there a more clean and elegant solution? Perhaps accomplished via a single command?

Rows to column conversion of file

Posted: 12 Aug 2021 09:33 AM PDT

Suppose I have a file:

File1:

PAPER  TEAM  MANISH NISHA GARIMA JYOUTI ........etc   

File2 I want:

PAPER      TEAM  MANISH  NISHA  GARIMA      JYOUTI  

Rows to column conversion of File1.

How can I replace root / filesystem with another filesystem?

Posted: 12 Aug 2021 09:01 AM PDT

When the Linux kernel starts up, it uses initrd as the root / filesystem, then replaces that with a filesystem partition in fstab.

Based on a test in an early init script, I want to replace that root / filesystem with another filesystem partition. How to do that?

How to make nemo support compressing files by context menu?

Posted: 12 Aug 2021 09:01 AM PDT

I use Cinnamon on ArchLinux and Nemo is it's default file manager. I've tried 3 GUI file archivers (p7zip with WxGTK, peazip & file-roller), but none of them add a "compress option" in the context menu.

How can I add a "compress option" to Nemo's right click context menu?

How do I delete the first n lines of an ascii file using shell commands?

Posted: 12 Aug 2021 08:54 AM PDT

I have multiple files that contain ascii text information in the first 5-10 lines, followed by well-tabulated matrix information. In a shell script, I want to remove these first few lines of text so that I can use the pure matrix information in another program. How can I use bash shell commands to do this?

If it's any help, I'm using RedHat and an Ubuntu linux systems.

No comments:

Post a Comment