Wednesday, October 27, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Move Files and Change Extension

Posted: 27 Oct 2021 10:27 AM PDT

I have a script I've been using for a couple years perfectly to find file names within a directory and adding a CR to each line as well as renaming the extension via MV. I've always had to execute this when the files are in their final directory but now I need to do it and actually move the file to a different directory (which I've added a constant labeled DESTINATION for). I don't use Linux a lot and had a lot of trial and error getting this original code so wanted to see if there was an easy way to do this with minimal changes to my existing code if possible, just not sure how to approach it since I'm feeding the directory/filename into a variable. Any suggestions are greatly appreciated!

#!/bin/bash  #Declare Constants:  DATESTAMP=$(date)  SOURCE=/folder1/  DESTINATION=/folder2/      #Find all .pux files in the source directory. Feed those files to a while read do to be processed  find "$SOURCE" -mindepth 1 -maxdepth 1 -type f -name "*.pux" -print0 | while IFS= read -r -d '' file; do      #Add carriage return to all lines in found files where there isn't a CR already      sed -i '/\r/! s/$/\r/' "${file}" &&      #Change .pux extension to .pun      mv "${file}" "${file/%pux/pun}" &&      #echo append actions performed with date stamp to a .x2n file in folder where pux/puns files sit      echo "$DATESTAMP" sed -i '/\r/! s/$/\r/' "${file}" >> "${file/%pux/x2n}" &&      echo "$DATESTAMP" mv "${file}" "${file/%pux/pun}" >> "${file/%pux/x2n}"      done  

udev rule for connecting external display not working

Posted: 27 Oct 2021 10:16 AM PDT

I have created my very first udev rule to automatically setup my external display when I plug in my laptop to docking station. As things turn out it's not working (what a suprise). First things first I checked what events are being sent when I unplug and plug in my external display to docking station (the same events happen when I connect and disconnect docking station itself from the laptop with external display connected to it). Here is the output from *udevadm monitor:

### CONNECTING EXTERNAL DISPLAY ###  KERNEL[12586.516063] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  UDEV  [12586.520032] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  KERNEL[12588.090123] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  UDEV  [12588.094088] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  
### DISCONNECTING EXTERNAL DISPLAY ###  KERNEL[12577.885860] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  KERNEL[12577.885951] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  UDEV  [12577.894562] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  UDEV  [12577.900236] change   /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1 (drm)  

Here is my udev rule:

KERNEL=="card1", SUBSYSTEM=="drm", ACTION=="change", RUN+="su vllblvck -c /usr/bin/setup-ext-display.sh"  

And here is the script that it is supposed to run:

#!/bin/sh                                                                                                                                                                                         # PLACE THIS SCRIPT INSIDE /usr/bin  # Automatically setup external monitor    xrandr_command="/usr/bin/xrandr"  sed_command="/bin/sed"    is_hdmi_connected=`DISPLAY=:0 $xrandr_command | $sed_command -n '/DP-1-2.3 connected/p'`  echo is_hdmi_connected: $is_hdmi_connected    if [ -n "$is_hdmi_connected" ]; then    DISPLAY=:0 xrandr --output DP-1-2.3 --auto --right-of eDP-1     echo connecting  else    DISPLAY=:0 $xrandr_command --output DP-1-2.3 --off    echo disconnecting  fi  

The script itself works just fine and does what I want it to do. I have even switched to the root user to check if su vllblvck -c part is working correctly and yes it is. I've run below command to check if the rule would even execute and supposedly it would but in reality it does not or malfunctions in some way and my external display is never set up .

udevadm test --action="change" /devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm/card1  

I would appreciate any tips on how to fix this or debug this further as udev rules topic is new to me and I've run out of ideas and google searches. And If that matters here I'm running ArcoLinux with 5.14.14-arch1-1 kernel.

How can I create a second root user on Kali Linux whose file contents cannot be viewed by the system admin?

Posted: 27 Oct 2021 10:02 AM PDT

I have 2 users on my Kali machine. One is root, the other is not. How can I change the second user to root so that the main root account cannot view the file contents of the other?

Wireless mouse not working on Arch Linux

Posted: 27 Oct 2021 09:44 AM PDT

A few months ago I bought a wireless mouse for my Linux machine. It was working on a few distros (for example elementary-os) fine, without the need of any drivers. After a few months, I stopped using it, but when I tried to use it again, it was not working. I tried almost everything but still it was not working. Right now I am using Arch Linux after changing a few distros, I bought another one. It was not working either. What can I do to make them work? Thanks in advance!

fish - Maximum recursion depth reached with tab-complete

Posted: 27 Oct 2021 09:36 AM PDT

With my fish shell, I have defined the alias

alias black='command black -l 110'  

When I type black in my shell and start to tab-complete, I get the error

complete: maximum recursion depth reached

The same thing happens with similar aliases such as

alias readelf='command readelf -W'  

Tool to detect and give info of compression method

Posted: 27 Oct 2021 10:22 AM PDT

What is utility tool to detect and give info of compression method (preferably more info) in any mean (CL or GUI) ?

IOW what windows 7z tool equivalent for Linux, giving info easily in GUI?

PPSSPP save folder can't be found anywhere

Posted: 27 Oct 2021 08:38 AM PDT

I can't find the PPSSPP saves folder anywhere. I searched online and many sources said that it could be found in .config/PPSSPP but i didn't found it there even when i viewed hidden files it wasn't there.If anyone can help it will be appreciated.I use linux mint 20.1.

Terminal Emulator Blinking Words in VIM

Posted: 27 Oct 2021 08:37 AM PDT

I am starting to write LaTeX documents in VIM and here is my code:

\documentclass{article}    \begin{document}  \frac{2x}{2} *  \end{document}  

For some reason, the following characters are blinking in the terminal:

  • {article}
  • {document}
  • {}{}
  • {document}

This forum seems to be related:

https://superuser.com/questions/449335/vi-editor-text-is-flashing-and-unusable/450302

There was another post from 2013 saying to do: export TERM=linux and I don't want that because text gets bolded and in vifm the selected file blinks.

I just want to turn blinking completely off - I can't see what I am typing when the screen is constantly blinking. It is very distracting.

  • OS: Arch Linux
  • Terminal emulator: xterm

Linux without bash

Posted: 27 Oct 2021 10:10 AM PDT

I'm not new in Linux world but I never liked Bash. Generally for me programming is an art and I'm very sensitive to the language syntax. When I have to work with bash, it feels like I'm writing in Stone Age people language.

Maybe Fish is not perfect shell, but it is a way better than Bash and I want to switch to it completely, but something tells me that removing Bash from the system is not a great idea.

So I decided to ask this crazy question, even though I have little faith that anyone will have an answer - is there existed some usable Linux distro that have no bash out of the box?

Allied Vision camera V4L2 drivers for linux

Posted: 27 Oct 2021 07:42 AM PDT

I've got USB camera (Allied Vision Mako Mako U-130B).

lsusb -v output (abbrev.):

idVendor           0x1ab2 Allied Vision  idProduct          0x0001 Vision device  iProduct                3 Mako Mako U-130B  

But when I connect this camera I can't see any /dev/video* files. Normal Web camera works, but not this above.

I found some driver for it, but this driver is not V4L2 compliant (Vimba) and doesn't create /dev/video* files, because it uses own api.

I want to have /dev/video* files, because I wrote application which uses v4l2 to access USB cameras and I don't want to change my code.

Do you know if exist such driver which will make that camera work like normal USB camera and creates /dev/video0 file?

Do I need to unbind driver on embedded device?

Posted: 27 Oct 2021 07:28 AM PDT

I've been having an issue reading from gpio devices on an embedded device(usrp n310). I2cdetect gives "UU" for the particular devices that I'm trying to reach indicating that the devices are already being occupied by a chip. /sys/bus/i2c/drivers shows that the driver linked to these devices is the pca953x. Previously, I was able to read and write from a gpio device(tca6416)on the zc706 platform, however, when doing a comparison of /sys/bus/i2c/drivers, I don't see any drivers associated with that chip. The code that I'm using is the following

#include "i2c_dev.hpp"       int main()    {     int i2cfd;     __s32 num;          //Opening i2c adapter 6    printf("Opening bus adapter\n");  i2cfd = open("/dev/i2c-6", O_RDWR);   if ( i2cfd <0 )     {       printf("Failed to open /dev/i2c-6: %s\n",strerror( errno ));       return (1);       }       //Instatiating three objects of IO_Expander class     IO_Expander dba;       //Reading data from the IO Expander     printf("Setting slave address of device\n");  if (ioctl(i2cfd, I2C_SLAVE, 0x20) < 0) {      printf("Error setting slave address:%s\n",strerror(errno));      return(1);    }    printf("Reading data from the IO Expander for DB-A Object\n");     num =dba.read_data(i2cfd, 0x00);     if (num<0){         printf("Error reading data: %s\n",strerror(errno));               }    else {            printf("The input value is %d: \n", num);             }          printf("Leaving DB-A Object \n\n\n");     //Closing the adapter     close(i2cfd);   }  

So, am I unable to read from the gpio devices on the n310 platform because of this pca953x driver? If so, would a correct approach be to "unbind" the pca953x driver the from the devices in order to read values from them?

Use a domain in a Plesk server for mail only

Posted: 27 Oct 2021 07:08 AM PDT

I have a server with Plesk Obsidian 18.0.35. This server hosts several domains including mail and everything works perfectly. Now I would like to use an external domain with this server but only for mail. Below my situation:

  1. the domain mydomain.com is pointed (with A records) to an IP address of another server (xxx.xxx.xxx.xxx) which hosts the website files but NOT the mail of domain;
  2. I want to use mydomain.com on plesk server but for mail ONLY and not for host website (alredy hosted on server xxx.xxx.xxx.xxx);
  3. I followed this tutorial (https://support.plesk.com/hc/en-us/...figure-domain-to-use-only-mail-functionality-) and also this (https://support.plesk.com/hc/en-us/articles/115000214973).

I also entered the MX record "mail.mydomain.com" in the DNS panel of mydomain.com, but the mail doesn't work.

If I try to log in with the webmail it tells me unable to log in.

Any help?

Thank you in advance!

Ignoring the SED encrypted drives until after booting is completed

Posted: 27 Oct 2021 06:53 AM PDT

I have an Ubuntu system which boots from a small NVME disk using software encryption, TPM, etc. to mitigate against data loss in case of theft. The system is interfaced with customised PCIe hardware to record data (possibly very large quantities of data).

The end-user interacts with the system via a web-interface and they are not intended to use any user accounts on the system or interact directly with it on keyboard/mouse/monitor. The system has several large drives which are intended to contain the data recorded by the system. These disks are able to be encrypted (or not) at the whim of the end-user.

The large disks are SED capable (not OPAL compliant). When the SED password is set (hdparm --user-master u --security-set-pass "$password" /dev/...) we see that the disks are not accessible without password (hdparm --user-master u --security-unlock "$password" /dev/...) after they are removed and re-inserted to the host system. Excellent, the encryption is working - our data is safe (OK, safer).

However, on power cycle the system pauses during the POST to prompt for a password for each drive (there are 12 of them!). This blocks the boot process. Obviously this is less than ideal for us as we have to connect a monitor and keyboard and tap in the authentication key for each disk. We don't need these disks to be unlocked at boot time. We can unlock them later (with the above unlock command) when the system is up and running and the system user asks for them to be mounted.

Does anyone have any ideas about how we can prevent the password prompt from blocking the boot process?

Scaling default xterm font to "Large"

Posted: 27 Oct 2021 06:45 AM PDT

In xterm, I would like to increase the default font size to the font5/Font5/"Large" option. I've managed to do this manually with my mouse via the control menu so far, which is brilliant, but it can become quite a burden whenever I open a new xterm window. Hence, I would like to achieve the same by setting it as my default in my .Xresources file, so that every new xterm window opens in the Large font size instead of using the manual control menu.

Reading the man page and doing some further research online, I tried, in separate attempts: xterm*font: font5, xterm*font: *-fixed-*-*-*-18-* and xterm*faceSize: 12.0 to achieve a similar outcome. Whilst the first try didn't work at all, in the latter two, the font is indeed increased but rather blurred when compared with what I can achieve through the control menu option. Surely, there must be a way!

Hardware accelerated lossless recording on a 6700 XT using ffmpeg

Posted: 27 Oct 2021 08:24 AM PDT

I'm trying to record my screen losslessly (or at near lossless quality) with hardware acceleration on a 6700 XT with ffmpeg. I'm running Linux Mint with the 5.14.14-051414-generic kernel.

I've tried:

ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -video_size 2560x1440 -i :0 -r 60 -vf 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi -qp 0 output.mp4

ffmpeg says it's recording at 60 fps, but the recording is choppy and slightly miscolored. I'm assuming the color issue is from the color format nv12, but rgb or rgb8 gives an error.

I've also tried using kmsgrab:

ffmpeg -device /dev/dri/card0 -f kmsgrab -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=2560:h=1440:format=nv12' -c:v h264_vaapi -qp 0 output.mp4

But it gives the error:

[kmsgrab @ 0x558f001c8d80] Using plane 65 to locate framebuffers.  [kmsgrab @ 0x558f001c8d80] Failed to get framebuffer 127: Invalid argument.  pipe:: Invalid argument  

The number after Failed to get framebuffer is usually 127 or somewhere from 134 to 136.

I got these commands here.

New keyboard layout variant not detected after reboot

Posted: 27 Oct 2021 06:38 AM PDT

I have added a new section to the /usr/share/X11/xkb/symbols/il file. I then added a reference of the section in /usr/share/X11/xkb/rules/base.lst and refreshed sudo dpkg-reconfigure xkb-data. However, even after rebooting the system (Kubuntu 20.04 LTS) the new keyboard layout is not available in KDE's System Settings.

Here is a summary of the system and the changes that I've made:

$ cat /etc/issue  Ubuntu 20.04.3 LTS \n \l    $ uname -a  Linux matrix-lenovo 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux    $ loginctl show-session $(loginctl|grep $(whoami) |awk '{print $1}') -p Type  Type=x11    $ ls -la /var/lib/xkb  total 12  drwxr-xr-x  2 root root 4096 Oct 27 12:31 .  drwxr-xr-x 89 root root 4096 Oct 26 08:19 ..  -rw-r--r--  1 root root  644 Jul  6 13:17 README.compiled    $ grep Hebrew /usr/share/X11/xkb/rules/base.lst    il              Hebrew    lyx             il: Hebrew (lyx)    phonetic        il: Hebrew (phonetic)    biblical        il: Hebrew (Biblical, Tiro)    potsatzi        il: Hebrew (Potsatzi)    $ diff /usr/share/X11/xkb/symbols/il.bak /usr/share/X11/xkb/symbols/il  140a141,205  > // Based on lyx, with additional useful directional characters  > // See table here: https://dotancohen.com/howto/rtl_right_to_left.html  > partial alphanumeric_keys  > xkb_symbols "potsatzi" {  >     name[Group1]= "Hebrew (Potsatzi)";  >   >     key <TLDE> { [ semicolon, asciitilde      ] };  >     // On some key (e.g. AD01, right below) there is not yet mapping for the  >     // second shift level. Since I could not figure a simple way to map this  >     // to "emit nothing", it is currently mapped to the same letter of the  >     // first shift level (avoiding mapping may risk it be used by a character  >     // from a different group).  >     key <AD01> { [ slash, slash                       ] };  >     key <AD02> { [ apostrophe, apostrophe     ] };  >     key <AD03> { [ hebrew_qoph, 0x10005b8     ] }; // Qamats  >     key <AD04> { [ hebrew_resh, 0x10005bc     ] }; // Dagesh/Shuruq  >     key <AD05> { [ hebrew_aleph, 0x100200e    ] }; // LRM  >     key <AD06> { [ hebrew_tet, 0x100200f      ] }; // RLM  >     key <AD07> { [ hebrew_waw, 0x10005b9      ] }; // Holam  >     key <AD08> { [ hebrew_finalnun, 0x100202a ] }; // ADDED by potsatzi LRE  >     key <AD09> { [ hebrew_finalmem, 0x100202b ] }; // ADDED by potsatzi RLE  >     key <AD10> { [ hebrew_pe, 0x10005b7               ] }; // Patah  >   >     key <AC01> { [ hebrew_shin, 0x10005b0     ] }; // Sheva  >     key <AC02> { [ hebrew_dalet, 0x10005bc    ] }; // Dagesh/Shuruq  >     key <AC03> { [ hebrew_gimel, hebrew_gimel ] };  >     key <AC04> { [ hebrew_kaph, hebrew_kaph   ] };  >     key <AC05> { [ hebrew_ayin, 0x10005c2     ] }; // Sin dot  >     key <AC06> { [ hebrew_yod, 0x10005c1      ] }; // Shin dot  >     key <AC07> { [ hebrew_chet, 0x10005b4     ] }; // Hiriq  >     key <AC08> { [ hebrew_lamed, 0x10020aa    ] }; // NIS  >     key <AC09> { [ hebrew_finalkaph, 0x100202c        ] }; // ADDED by potsatzi PDF  >     key <AC10> { [ hebrew_finalpe, colon      ] };  >     key <AC11> { [ comma, quotedbl            ] };  >   >     key <AB01> { [ hebrew_zain, hebrew_zain   ] };  >     key <AB02> { [ hebrew_samech,0x10005b6    ] }; // Segol  >     key <AB03> { [ hebrew_bet, 0x10005bb      ] }; // Qubuts  >     key <AB04> { [ hebrew_he, 0x10005b1               ] }; // H. Segol  >     key <AB05> { [ hebrew_nun, 0x10005b2      ] }; // H. Patah  >     key <AB06> { [ hebrew_mem, 0x10005b3      ] }; // H.  Qamats  >     key <AB07> { [ hebrew_zade, 0x10005b5     ] }; // Tsere  >     key <AB08> { [ hebrew_taw, greater                ] };  >     key <AB09> { [ hebrew_finalzade, less     ] };  >     key <AB10> { [ period, question           ] };  >   >     // Note the parens mirroring below:  >     key <AD11> { [ bracketright, braceright   ] };  >     key <AD12> { [ bracketleft, braceleft     ] };  >     key <AE01> { [ 1, exclam                  ] };  >     key <AE02> { [ 2, at                      ] };  >     key <AE03> { [ 3, numbersign              ] };  >     key <AE04> { [ 4, dollar                  ] };  >     key <AE05> { [ 5, percent                 ] };  >     key <AE06> { [ 6, asciicircum             ] };  >     key <AE07> { [ 7, ampersand                       ] };  >     key <AE08> { [ 8, asterisk                        ] };  >     key <AE09> { [ 9, parenright              ] };  >     key <AE10> { [ 0, parenleft                       ] };  >   >     key <AE11> { [ minus, 0x10005be           ] }; // H. Hiphen  >     key <AE12> { [ equal, plus                        ] };  > };  >   >   

The potsatzi section of the /usr/share/X11/xkb/symbols/il file is a copy-paste (well, a yank-paste in VIM) of the previous section, with the following changes:

  • The name was changed in two places from lyx to potsatzi.
  • Whitespace cleanup
  • I added three Unicode codepoints in the shift-char locations, those lines have the comment ADDED by potsatzi with the name of the character added.

Other than adding the alias to /usr/share/X11/xkb/rules/base.lst, removing cache files from /var/lib/xkb/, and rebooting the system, what else must I do to get the system to recognize the new layout variant?

Linux find <DOCKER_MOUNTED_DIR> -type d: how to list the deepest dirs, such as ./dir1/dir2 without ./dir1?

Posted: 27 Oct 2021 08:42 AM PDT

find . -type d  

normally will show

./dir1  ./dir1/dir2  ./dir3  ./dir3/dir4  ./dir3/dir4/dir5  ...  

I just want the

./dir1/dir2  ./dir3/dir4/dir5  

, without its parent ./dir1, ...

In other words, I only want to see directories that does not have any subdirectories in them.

Any idea?

EDIT: I found the -links 2 does work in a normal linux environment, e.g.,

docker run -it --rm ubuntu:bionic find /etc -type d -links 2  

works perfectly.

However, when I mount a dir (from MacOS or Windows) into the docker container, things changed, it does not work, you can try this:

docker run -it --rm -v /etc:/etc_of_host ubuntu:bionic find /etc_of_host -type d -links 2  

Simple find command will not run

Posted: 27 Oct 2021 08:05 AM PDT

I am fairly new to linux and I am currently trying to run the following command,

find ~ -name apt.no  

I'm looking for apt.no within another directory listed as montrose-files.

There is no response from the shell and it just creates a new line. Could anyone please explain to me why this does not produce even a result?

bbcharlieca@myvm:~$ find ~ -name apt.no  bbcharlieca@myvm:~$ █  

enter image description here

Find: Use regex to get all files with specific directory name in path, but without another specific directory name in path

Posted: 27 Oct 2021 09:06 AM PDT

I'm trying to use find to return all file names that have a specific directory in their path, but don't have another specific directory anywhere in the file path. Something like:

myRegex= <regex>   targetDir= <source directory>  find $targetDir -regex $myRegex -print  

I know I might also be able to do this by piping one find command into another, but I would like to know how to do this with a single regular expression.

For example, I want every file that has the directory "good" in it's path, but doesn't have the directory "bad" anywhere in its path no matter the combination. Some examples:

/good/file_I_want.txt #Captured  /good/bad/file_I_dont_want.txt #Not captured    /dir1/good/file_I_want.txt #Captured  /dir2/good/bad/file_I_dont_want.txt #Not captured    /dir1/good/dir2/file_I_want.txt #Captured  /dir1/good/dir2/bad/file_I_want.txt #Not captured    /bad/dir1/good/file_I_dont_want.txt #Not captured  

Keep in mind some file names might contain "good" or "bad", but I only want to account for directory names.

/good/bad.txt #Captured  /bad/good.txt #Not captured  

My research suggests I should use a Negative Lookahead and a Negative Lookbehind. However, nothing I have tried has worked so far. Some help would be appreciated. Thanks.

How to create a random complex password in SuSe 12

Posted: 27 Oct 2021 10:11 AM PDT

I need a way to generate a random password following this requirements:

  • Password at least 9 characters
  • at least 2 capital letters
  • at least 2 small letters
  • at least 2 digits
  • at least 2 special characters
  • must start with a letter

this is the command that I have:

{ shuf -r -n4 -e {A..Z}; shuf -r -n4 -e {a..z}; shuf -r -n4 -e {0..9}; } | shuf | tr -d $'\n'  

but is missing the special characters

OS is SuSE 12

I don't know how to download and install Dissenter Browser on Ubuntu 20.04

Posted: 27 Oct 2021 10:00 AM PDT

I just installed ubuntu desktop 21.04 on my raspberry pi 4b. I want to switch from mozilla firefox, the default browser, to Dissenter. I am trying to download and install Dissenter Browser on my computer but I don't know how. I've looked into it, and I found that the version I've tried only works on amd64 processors, but what I have is an arm64 procesor. Can anyone help?

how to print file name and total number of fasta sequences?

Posted: 27 Oct 2021 08:55 AM PDT

I have a fasta file namely test.fasta, pas.fasta, cel.fasta as shown below

test.fasta  >tile  ATGTC  >259  TGAT    pas.fasta  >ta  ATGCT    cel.fasta  >787  TGTAG  >yog  TGTAT  >In  NNTAG  

I need to print the file name and the total number of fasta sequences as shown below,

test,2  pas,1  cel,3  

I have used the following commands but failed to serve my purpose

grep ">" test.fasta | wc -l && ls test.fasta  

Please help me to do the same.

Thanks in advance.

Why this 'useless use of cat' with `detex` is 10x faster than the alternative?

Posted: 27 Oct 2021 07:01 AM PDT

I'm counting words in LaTeX files and intuitively used the command:

$ cat *tex | detex | wc -w  

I then immediately noticed he useless use of cat, and did the task again with:

$ detex *tex | wc -w  

Being proud of myself for avoiding an extra process, I wanted to check how many precious milliseconds I saved by not using cat. I was then very surprised to see that the version with cat was literally 10 times faster:

$ time cat *tex | detex | wc -w      5000    real    0m0.013s  user    0m0.005s  sys 0m0.007s  
$ time detex *tex | wc -w      5000    real    0m0.144s  user    0m0.124s  sys 0m0.014s  

What is the reason for this massive speed difference? Is cat just so much faster in reading files from a disk than detex?


I generated 5 example "LaTeX" files for benchmarking with:

$ for i in {1..5}; do shuf -n 1000 /usr/share/dict/words > "file${i}.tex"; done  

Problem after NVIDIA proprietary driver update - Linux Mint

Posted: 27 Oct 2021 07:03 AM PDT

I'm using a laptop in which I have both an NVIDIA graphic card and the Intel integrated one. Before I updated the NVIDIA driver through Linux Mint update manager, I used to have them both configured using NVIDIA settings and NVIDIA Prime.

After the update the driver manager marks the NVIDIA driver as installed, but the Intel graphic card has the following sentence written below "This device is not working" and the only option possible is "Do not use this device".
Both xserver-xorg-video-intel, mesa-utils and nvidia-settings are still installed (I've also tried to reinstall them) and I have SeureBoot disabled. When I try to run nvidia-settings it return an empty page and the following error is displayed:

ERROR: NVIDIA driver is not loaded    ERROR: Unable to load info from any available system  

How can I fix this situation? Thanks!

This is the output from lspci -nnk | grep "VGA\|'Kern'\|3D\|Display" -A2

00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:3e9b]      Subsystem: ASUSTeK Computer Inc. Device [1043:1fc0]      Kernel driver in use: i915  --  01:00.0 3D controller [0302]: NVIDIA Corporation GP107M [GeForce GTX 1050 Mobile] [10de:1c8d] (rev a1)      Subsystem: ASUSTeK Computer Inc. GP107M [GeForce GTX 1050 Mobile] [1043:1fc0]      Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia  

From ls /lib/modprobe.d/:

aliases.conf                             blacklist-nvidia.conf  blacklist_linux_4.15.0-106-generic.conf  fbdev-blacklist.conf  blacklist_linux_4.15.0-112-generic.conf  nvidia-graphics-drivers.conf  blacklist_linux_4.15.0-20-generic.conf   nvidia-kms.conf  blacklist_linux_4.15.0-54-generic.conf   systemd.conf  

From dpkg -l | grep -i nvidia:

ii  libnvidia-cfg1-440:amd64                   440.100-0ubuntu0.18.04.1                         amd64        NVIDIA binary OpenGL/GLX configuration library  ii  libnvidia-common-390                       390.138-0ubuntu0.18.04.1                         all          Shared files used by the NVIDIA libraries  ii  libnvidia-common-440                       440.100-0ubuntu0.18.04.1                         all          Shared files used by the NVIDIA libraries  rc  libnvidia-compute-390:amd64                390.138-0ubuntu0.18.04.1                         amd64        NVIDIA libcompute package  rc  libnvidia-compute-390:i386                 390.138-0ubuntu0.18.04.1                         i386         NVIDIA libcompute package  ii  libnvidia-compute-440:amd64                440.100-0ubuntu0.18.04.1                         amd64        NVIDIA libcompute package  ii  libnvidia-compute-440:i386                 440.100-0ubuntu0.18.04.1                         i386         NVIDIA libcompute package  ii  libnvidia-decode-440:amd64                 440.100-0ubuntu0.18.04.1                         amd64        NVIDIA Video Decoding runtime libraries  ii  libnvidia-decode-440:i386                  440.100-0ubuntu0.18.04.1                         i386         NVIDIA Video Decoding runtime libraries  ii  libnvidia-encode-440:amd64                 440.100-0ubuntu0.18.04.1                         amd64        NVENC Video Encoding runtime library  ii  libnvidia-encode-440:i386                  440.100-0ubuntu0.18.04.1                         i386         NVENC Video Encoding runtime library  ii  libnvidia-extra-440:amd64                  440.100-0ubuntu0.18.04.1                         amd64        Extra libraries for the NVIDIA driver  ii  libnvidia-fbc1-440:amd64                   440.100-0ubuntu0.18.04.1                         amd64        NVIDIA OpenGL-based Framebuffer Capture runtime library  ii  libnvidia-fbc1-440:i386                    440.100-0ubuntu0.18.04.1                         i386         NVIDIA OpenGL-based Framebuffer Capture runtime library  ii  libnvidia-gl-440:amd64                     440.100-0ubuntu0.18.04.1                         amd64        NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD  ii  libnvidia-gl-440:i386                      440.100-0ubuntu0.18.04.1                         i386         NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD  ii  libnvidia-ifr1-440:amd64                   440.100-0ubuntu0.18.04.1                         amd64        NVIDIA OpenGL-based Inband Frame Readback runtime library  ii  libnvidia-ifr1-440:i386                    440.100-0ubuntu0.18.04.1                         i386         NVIDIA OpenGL-based Inband Frame Readback runtime library  rc  nvidia-compute-utils-390                   390.138-0ubuntu0.18.04.1                         amd64        NVIDIA compute utilities  ii  nvidia-compute-utils-440                   440.100-0ubuntu0.18.04.1                         amd64        NVIDIA compute utilities  rc  nvidia-dkms-390                            390.138-0ubuntu0.18.04.1                         amd64        NVIDIA DKMS package  ii  nvidia-dkms-440                            440.100-0ubuntu0.18.04.1                         amd64        NVIDIA DKMS package  ii  nvidia-driver-440                          440.100-0ubuntu0.18.04.1                         amd64        NVIDIA driver metapackage  rc  nvidia-kernel-common-390                   390.138-0ubuntu0.18.04.1                         amd64        Shared files used with the kernel module  ii  nvidia-kernel-common-440                   440.100-0ubuntu0.18.04.1                         amd64        Shared files used with the kernel module  ii  nvidia-kernel-source-440                   440.100-0ubuntu0.18.04.1                         amd64        NVIDIA kernel source package  ii  nvidia-prime                               0.8.8.2                                          all          Tools to enable NVIDIA's Prime  ii  nvidia-prime-applet                        1.0.7                                            all          An applet for NVIDIA Prime  ii  nvidia-settings                            440.44-0ubuntu0.18.04.1                          amd64        Tool for configuring the NVIDIA graphics driver  ii  nvidia-utils-440                           440.100-0ubuntu0.18.04.1                         amd64        NVIDIA driver support binaries  ii  xserver-xorg-video-nvidia-440              440.100-0ubuntu0.18.04.1                         amd64        NVIDIA binary Xorg driver  

Here are my system info:

System:    Host: marco-ASUS Kernel: 4.15.0-112-generic x86_64 bits: 64 compiler: gcc v: 7.5.0              Desktop: Cinnamon 4.2.4 wm: marco dm: LightDM Distro: Linux Mint 19.2 Tina              base: Ubuntu 18.04 bionic   Machine:   Type: Laptop System: ASUSTeK product: VivoBook_ASUSLaptop X580GD_N580GD v: 1.0              serial: <filter>              Mobo: ASUSTeK model: X580GD v: 1.0 serial: <filter> UEFI: American Megatrends              v: X580GD.304 date: 05/17/2018   Battery:   ID-1: BAT0 charge: 29.1 Wh condition: 30.4/48.1 Wh (63%) volts: 11.6/11.6              model: ASUSTeK ASUS Battery serial: <filter> status: Discharging   CPU:       Topology: 6-Core model: Intel Core i7-8750H bits: 64 type: MT MCP arch: Kaby Lake              rev: A L2 cache: 9216 KiB              flags: lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 52799              Speed: 4004 MHz min/max: 800/4100 MHz Core speeds (MHz): 1: 3987 2: 4045 3: 4000              4: 4000 5: 4005 6: 4013 7: 3943 8: 4002 9: 4000 10: 4006 11: 3991 12: 4038   Graphics:  Device-1: Intel vendor: ASUSTeK driver: i915 v: kernel bus ID: 00:02.0              chip ID: 8086:3e9b              Device-2: NVIDIA GP107M [GeForce GTX 1050 Mobile] vendor: ASUSTeK driver: N/A              bus ID: 01:00.0 chip ID: 10de:1c8d              Display: x11 server: X.Org 1.19.6 driver: modesetting unloaded: fbdev,vesa              compositor: marco resolution: 1920x1080~60Hz              OpenGL: renderer: Mesa DRI Intel UHD Graphics 630 (CFL GT2) v: 4.6 Mesa 20.0.8              compat-v: 3.0 direct render: Yes   Audio:     Device-1: Intel Cannon Lake PCH cAVS vendor: ASUSTeK driver: snd_hda_intel v: kernel              bus ID: 00:1f.3 chip ID: 8086:a348              Sound Server: ALSA v: k4.15.0-112-generic   Network:   Device-1: Intel Wireless-AC 9560 [Jefferson Peak] driver: iwlwifi v: kernel port: 5000              bus ID: 00:14.3 chip ID: 8086:a370              IF: wlo1 state: up mac: <filter>              Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: ASUSTeK              driver: r8169 v: 2.3LK-NAPI port: 3000 bus ID: 03:00.0 chip ID: 10ec:8168              IF: eno2 state: down mac: <filter>   Drives:    Local Storage: total: 931.51 GiB used: 539.31 GiB (57.9%)              ID-1: /dev/sda vendor: Toshiba model: MQ04ABF100 size: 931.51 GiB speed: 6.0 Gb/s              serial: <filter>   RAID:      Hardware-1: Intel 82801 Mobile SATA Controller [RAID mode] driver: ahci v: 3.0              bus ID: 00:17.0 chip ID: 8086.282a   Partition: ID-1: / size: 136.93 GiB used: 111.72 GiB (81.6%) fs: ext4 dev: /dev/sda1              ID-2: swap-1 size: 31.25 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sda2   USB:       Hub: 1-0:1 info: Full speed (or root) Hub ports: 16 rev: 2.0 chip ID: 1d6b:0002              Device-1: 1-2:2 info: Microsoft Basic Optical Mouse type: Mouse              driver: hid-generic,usbhid rev: 1.1 chip ID: 045e:0084              Device-2: 1-6:3 info: IMC Networks type: Video driver: uvcvideo rev: 2.0              chip ID: 13d3:56a2              Device-3: 1-7:4 info: Realtek RTS5129 Card Reader Controller type: <vendor specific>              driver: rtsx_usb,rtsx_usb_ms,rtsx_usb_sdmmc rev: 2.0 chip ID: 0bda:0129              Device-4: 1-14:5 info: Intel type: Bluetooth driver: btusb rev: 2.0 chip ID: 8087:0aaa              Hub: 2-0:1 info: Full speed (or root) Hub ports: 8 rev: 3.1 chip ID: 1d6b:0003   Sensors:   System Temperatures: cpu: 68.0 C mobo: N/A              Fan Speeds (RPM): N/A   

Running multiple emulators with the same AVD is an experimental feature

Posted: 27 Oct 2021 10:06 AM PDT

I was able to get a remote viewer set up on my mac to remote view a Fedora server desktop. I run ~/android-studio/bin/studio.sh to launch Android Studio. I open AVD manager and try to boot up an emulator, but I get message

AVD is allready runing ...

enter image description here

and when I try to boot emulator device1 from command line

emulator -avd device1  

I get message

emulator: ERROR: Running multiple emulators with the same AVD is an experimental feature. Please use -read-only flag to enable this feature.

so overwhelming evidence is that device1 emulator is already running, and yet when I run command adb devices I get messages

List of devices attached

indicating no running devices ... so whats up?

edit

I delete all *.lock files, and press play; the dialog did not appear, however, the emulator also did not appear, but when I ran adb devices, no devices were shown, and then I pressed play again, I got the same dialog.

edit

I create new device and booted from command line and got    $ emulator -avd device3  Warning: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled ((null):0, (null))  emulator: INFO: QtLogger.cpp:66: Warning: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled ((null):0, (null))      failed to create drawable  failed to create drawable  failed to create drawable  failed to create drawable  failed to create drawable  failed to create drawable  failed to create drawable  failed to create drawable  getGLES2ExtensionString: Could not make GLES 2.x context current!  

Is there a way to make the local command work portably to dash ksh bash and zsh?

Posted: 27 Oct 2021 10:23 AM PDT

In dash (and in bash zsh and some other shells) the command local works to make a variable scope limited to that function (and descendants in some cases). That enable the possibility of making a variable limited to that function internals only (and descendant function calls in some cases).

For example:

testlocal(){                   local IFS                  IFS=123                  echo "internal  IFS = $IFS"                  testdescend  }    testdescend(){                  echo "descended IFS = $IFS"  }    IFS=abc  testlocal  echo "external  IFS = $IFS"  

Produce this output on execution in dash (and bash and zsh):

$ dash ./script  internal  IFS = 123  descended IFS = 123  external  IFS = abc  

Which means that the IFS remains local to the function (and descendants).

However, ksh is different, doesn't accept local:

$ ksh ./script  ./mt2[3]: local: not found [No such file or directory]  

Changing the word 'local' to 'typeset' makes the script (almost) work in ksh but dash doesn't recognize typeset.

And, to make the scope dynamic (descend to called functions) in ksh, the word function must be used to define functions:

function testlocal {                        typeset IFS                       IFS=123                       echo "internal IFS = $IFS"                       testdescend                     }  

Which further complicates portability to dash.

The question is: How to make the original script work also in ksh ? Is it possible to avoid a test for which shell is running the script?

MDADM - Stop Resync and Force Clean - Possible and/or Safe?

Posted: 27 Oct 2021 09:01 AM PDT

I have been having issues with my FileServer recently.

See "rcu_sched detected stalls on CPUs/tasks" - jiffies - ESXi Ubuntu 16 FileServer Guest

I just rebuilt it since I couldn't get any guidance on the issue. Unfortunatley, its resyncing my array again.

Seeing how this has been done multiple time in the last few days, I'm fairly confident that its "in sync".

I have a few questions to that regard.

  • When it resync's what is happening, is it just doing read operations on every piece of data? I feel i'm really abusing my HDD's at the moment
  • Can I cancel resync? (I still want to be able to use the MDADM Though!)
  • So Can I force it to "clean" state and remount?
  • Is resync automatic when you mount a new MDADM (This is a new VM), or is there an error in the metadata that is forcing a resync and I NEED to let it finish. (It takes about 24 Hours and my server is extremely slow during that time)

Thanks!

Update: There are 4x 5tb HDDs in raid5 passed through via mapped raw lun to a VM guest which then exports nfs and smb.

This question is mostly about if the commands i want exist for mdadm and what sync does.

Job for vsftpd.service failed because the control process exited with error code

Posted: 27 Oct 2021 08:01 AM PDT

I can not restart the vsftpd.

[root@localhost vsftpd]# service vsftpd restart   Redirecting to /bin/systemctl restart  vsftpd.service  Job for vsftpd.service failed because the control process exited with error code. See "systemctl status vsftpd.service" and "journalctl -xe" for details.  

I use the systemctl status vsftpd -l to check:

[root@localhost ~]# systemctl status vsftpd -l  ● vsftpd.service - Vsftpd ftp daemon     Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)     Active: failed (Result: exit-code) since Sun 2017-06-18 17:14:15 CST; 2h 49min ago    Process: 33103 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=1/FAILURE)    Jun 18 17:14:12 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...  Jun 18 17:14:15 localhost.localdomain systemd[1]: vsftpd.service: control process exited, code=exited status=1  Jun 18 17:14:15 localhost.localdomain systemd[1]: Failed to start Vsftpd ftp daemon.  Jun 18 17:14:15 localhost.localdomain systemd[1]: Unit vsftpd.service entered failed state.  Jun 18 17:14:15 localhost.localdomain systemd[1]: vsftpd.service failed.  

And be attention, in my /etc/vsftpd/vsftpd.conf, I have changed the :

listen=YES  listen_ipv6=NO  

I use the journalctl -xe, I get the below information:

[root@localhost vsftpd]# journalctl -xe                                                        (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                                          (pkla-check-authorization:                                                        '  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza  Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p                                              (pkla-check-authorization:                                                    '  

Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza Jun 18 20:09:46 localhost.localdomain polkitd[33643]: /etc/polkit-1/rules.d/49-p

                                                  (pkla-check-authorization:                                                    '  

Jun 18 20:09:46 localhost.localdomain polkitd[33643]: Error evaluating authoriza li

How to send a file using xmodem protocol from the command line

Posted: 27 Oct 2021 10:22 AM PDT

I have a scope attached to RX and TX lines of the serial port. If I do:

cat /dev/ttyS0  

I get a steady stream of 'C' characters so the remote side is up and sending. If I do:

cat {filename} > /dev/ttyS0  

I get a burst on TX line w/o any protocol. If I do the following:

/usr/bin/sx -vv -k -X -b -c send {filename}  

TX line remains inactive. File is binary and expecting xmodem 1K protocol. What am I doing wrong?

Is there a tool that allows logging of memory usage?

Posted: 27 Oct 2021 09:22 AM PDT

I want to monitor memory usage of a process, and I want this data to be logged. Does such a tool exist?

No comments:

Post a Comment