Sunday, April 10, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


rite a script using linux for each one of the following commands

Posted: 10 Apr 2022 11:57 AM PDT

write a script using linux for each one of the following commands

  1. Count the common lines between two files.

  2. For all files in the current directory, replace any spaces in file names with underscores. If performing the rename would clash with an existing file, do not rename the file and print a warning on stderr.

  3. Find the five largest subdirectories of the current directory:

  4. Search all subdirectories of the current subdirectory. If there are two (or more) files with identical file contents both named **.mp3, print the path to each of them.

To do this efficiently, you may want to use md5sum.

IMPORTANT NOTE: make the code on a .sh or .txt file write this in one code please

Why pipe doesn't work with upower -e

Posted: 10 Apr 2022 11:58 AM PDT

I've just found this command:

upower -e  

that displays a list of files that can be used with upower -i to display plugged device status.

So my first try was using:

upower -e | xargs upower -i  

but it doesn't work. So I've tried:

$ upower -e | xargs echo  /org/freedesktop/UPower/devices/line_power_AC /org/freedesktop/UPower/devices/battery_BAT0 /org/freedesktop/UPower/devices/line_power_ucsi_source_psy_USBC000o001 /org/freedesktop/UPower/devices/DisplayDevice  

and it display all files in single line. So I've used:

$ upower -e | xargs -0 echo  /org/freedesktop/UPower/devices/line_power_AC  /org/freedesktop/UPower/devices/battery_BAT0  /org/freedesktop/UPower/devices/line_power_ucsi_source_psy_USBC000o001  /org/freedesktop/UPower/devices/DisplayDevice    

it works but displays one empty line, but this doesn't work:

$ upower -e | xargs -0 upower -i  failed to set path: Object path invalid: /org/freedesktop/UPower/devices/line_power_AC  /org/freedesktop/UPower/devices/battery_BAT0  /org/freedesktop/UPower/devices/line_power_ucsi_source_psy_USBC000o001  /org/freedesktop/UPower/devices/DisplayDevice    

Why upower -e | xargs upower -i doesn't work? I'm using Bash on Fedora.

Is there something I'm missing here?

EDIT:

This seems to work:

upower -e | xargs -I {} upower -i "{}"  

But I'm wondering: why a quote is needed if the filename doesn't have spaces?

When to clean up /var/tmp?

Posted: 10 Apr 2022 11:47 AM PDT

/var/tmp is not defined in POSIX, but is defined in FHS:

5.15. /var/tmp : Temporary files preserved between system reboots  5.15.1. Purpose  The /var/tmp directory is made available for programs that   require temporary files or directories that are preserved between   system reboots. Therefore, data stored in /var/tmp is more   persistent than data in /tmp.    Files and directories located in /var/tmp must not be deleted  when the system is booted. Although data stored in /var/tmp is   typically deleted in a site-specific manner, it is recommended   that deletions occur at a less frequent interval than /tmp.  

This is a very difficult definition for real life situations. A package does not use /tmp, because the files should not be deleted on reboot for some reason.

If a package fails to cleanup its remains in /tmp the distribution/admin can safely clean at reboot.

When and how should we clean up /var/tmp? What can packages and software developers expect from /var/tmp?

Do we have to clean /var/tmp after n reboots?

(see also What can go wrong if /var/tmp is on a temporary filesystem? and What is the difference between /tmp and /var/tmp?)

Cinnamon - cursor blocked at end of panel

Posted: 10 Apr 2022 08:10 AM PDT

When I move my cursor along a panel, it eventually is blocked at the end of it. I have two panels, one on the left and one at the top, so I'd like to be able to click the top-left corner. Although, this is not that much of an issue on the desktop, it is still active when I am playing a full-screen game!

picture of the problem

My cursor (represented by the ugly arrow) cannot go any further than the red line when it is in the blue area. How can I deactivate this?

Run an API service on Linux

Posted: 10 Apr 2022 09:32 AM PDT

I'm ssh'ing into an AWS EC2 instance and starting my API. I want the API to keep running and accepting requests.

So, is tmux a good way to do this? Or is there a better way? I was under the impression tmux and screen was more for really long tasks. Wasn't sure if they would be good for running an API indefinitely.

match value2 in 2 files if value 1 is exact match

Posted: 10 Apr 2022 10:38 AM PDT

I have 2 files containing list. Column 1 is userIds & column 2 is associated values

# cat file1  e3001 75  n5244 30  w1453 500    #cat file2  d1128 30  w1453 515  n5244 30  e3001 55  

Things to consider.

  1. userIds may not be sorted exactly in both files
  2. Number of userIds may vary in files

REQUIRED

  • firstly, userId from file1:column1 must match UserId in file2:column1
  • next compare their values in file1:column2 with file2:column2
  • print where values has variance. also extra userIds if any

OUTPUT:

e3001 has differnece, file1 value: 75 & file2 value: 55  w1453 has differnece, file1 value: 500 & file2 value: 515  d1128 is only present in filename: file1|file2  

solution with 1liner-awk or bash loop is welcome

I'm trying to loop, but it's spitting garbage, guess there's some mislogic

#!/usr/bin/env bash    ## VARIABLES  FILE1=file1  FILE2=file2  USERID1=(`awk -F'\t' '{ print $1 }' ${FILE1}`)  USERID2=(`awk -F'\t' '{ print $1 }' ${FILE2}`)  USERDON1=(`awk -F'\t' '{ print $2 }' ${FILE1}`)  USERDON2=(`awk -F'\t' '{ print $2 }' ${FILE2}`)    for user in ${USERID1[@]}  do      for (( i = 0; i < "${#USERID2[@]}"; i++ ))      #for user in ${USERID2[@]}      do          if [[ ${USERID1[$user]} == ${USERID2[i]} ]]          then              echo ${USERID1[$user]} MATCHES BALANCE FROM ${FILE1}: ${USERDON1[$i]} WITH BALANCE FROM ${FILE2}: ${USERDON2[$i]}          else              echo ${USERID1[$user]}           fi      done  done  

Below is copied file right from linux box. It's tab separated, but awk works with tab also, as far as I know.

#cat file1  e3001   55  n5244   30  w1453   515  

What's the difference between structures "cdev" and "inode" in the context of device driver programming?

Posted: 10 Apr 2022 09:28 AM PDT

I am currently studying device drivers in an operating systems course and am getting confused regarding the difference between the "inode" structs and "cdev" structs. Could someone clarify the differences between these two structures and what they're meant to achieve?

Execv with arguments starting from second element [migrated]

Posted: 10 Apr 2022 06:41 AM PDT

I am making a program that can take another program as an argument and run it.

I am using execv() to run the second program, but how can I use argv[] (that comes from the main program, is a char*) as arguments for execv()?

The first element of argv[] is the name of the main program, so I need to start at the second element where the name of the next program is located.

I am thinking there might be different solutions, for example:

  • Tell execv() to start from the second argument
  • copy the content of argv[] (except first element) to another array and use that
  • Something with pointers so maybe I can point to the second element and start there

What is the best way to do this? And can I get an example of how to do it as I am really new to C?

Thank you

No such file or directory, but file is present?

Posted: 10 Apr 2022 05:47 AM PDT

I'm trying to gcc the following project from Azure on Ubuntu 20.04: https://github.com/Azure/azure-umqtt-c

When I've installed the project through cmake, I attempt to gcc mqtt_client.c, but get met with the following error:

omic@omic-virtual-machine:~/azure-umqtt-c/src$ gcc mqtt_client.c  mqtt_client.c:18:10: fatal error: azure_umqtt_c/mqtt_client.h: No such file or directory     18 | #include <azure_umqtt_c/mqtt_client.h>        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~  compilation terminated.  

However, when I go to azure-umqtt-c/inc/azure-umqtt-c, the file mqtt_client.h is present. Can someone assist me and make me understand why this is happening?

Thanks!

tar invalid transform expression error due to whitespaces over ssh call

Posted: 10 Apr 2022 09:40 AM PDT

I am using tar --transform over SSH call to rename the documents during archiving based on array DOCUMENTNAMES.

    tar -uvf /tmp/$TARGET''TVL_document.tgz'' --transform='s|'\${doc}'|'\$docname'|' -C /appl-doc/a-mc-acc-dms/DATA \${doc}  

I am able to get the tar output if DOCUMENTNAMES contain no space (e.g. "application.pdf"). For DOCUMENTNAMES with spaces (e.g. "project form.pdf"), the shell does not expand it correctly and I get the error tar invalid transform expression

How can I escape the --transform='s|'\${doc}'|'\$docname'|' sequence in a way that spaces in DOCUMENTNAMES get escaped correctly?

Full code:

DOCUMENTNAMES=("project form.pdf" "application.pdf")    # SSH to Linux fileshare to create tar  sshpass -p $IPA_PASS ssh -tt -o StrictHostKeyChecking=no $IPA_NAME@$TARGET "sudo su - jboss <<'EOF'    # create an empty tar  tar -cvf /tmp/$TARGET''TVL_document.tgz'' -T /dev/null    # transfer local array to remote  eval `typeset -p DOCUMENTNAMES`    index=0  for doc in "${DOCUMENTIDS[@]}"  do        docname=\${DOCUMENTNAMES[\$index]}        # Update tar with one document at a time and update name using transform      tar -uvf /tmp/$TARGET''TVL_document.tgz'' --transform='s|'\${doc}'|'\$docname'|' -C /appl-doc/a-mc-acc-dms/DATA \${doc}      index=$((index+1))  done  EOF  "  

How can I allow only specific users to use my repository?

Posted: 10 Apr 2022 05:32 AM PDT

I have an apt repository server. Is there a way to allow only specific users / machines to connect to my repository? Through crednetials, certificates or any other way? It can't be IP or some other device agnostic parameter.

Thanks

ps aux --headers problem on openSUSE Leap 15.3 when redirect output

Posted: 10 Apr 2022 10:37 AM PDT

The following works ok on openSUSE Leap 15.3. As in the header line is repeated for each screen of output when I scroll the screen back with the scroll bar on the terminal:

ps aux --headers  

But when I redirect the output to either a file or another command I only get the initial header line on the first line of output. The expected header lines for each screen of output are missing. The output for the actual processes show ok. 2 commands to recreate the issue:

ps aux --headers | less  

or

ps aux --headers  >> ps.out  

Same problem when use the tee command for screen and file output:

ps aux --headers | tee ps-tee.out  

I used the following to see if could get any errors, but the error file is empty:

ps aux --headers 1>>ps.out 2>>ps.error  

When grep for the header line, it only matches once:

dave@localhost:~> ps aux --headers | egrep RSS | egrep -v grep  USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  dave@localhost:~>   

I was using bash, but also tried ksh, csh and zsh and get the same problem.

The problem exists when launch the terminal (KDE/Konsole) from the gui desktop and also when ssh onto the box using Putty.

In addition to openSUSE Leap 15.3, the same problem happens on SUSE Linux Enterprise 15.3 and the older release of SUSE Linux Enterprise 11.4 (only tried ssh session via Putty).

CentOS 6/7 and Mint 19 (using bash) work as expected when redirect the output to either a command or a file, as in I can see the header line for every screen of output.

When grep from CentOS/Mint can see multiple header lines and this is what I would expect from openSUSE:

[dave@centos1 ~]$ ps aux --headers | egrep RSS    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  dave      3682  0.0  0.0   4424   816 pts/0    S+   11:58   0:00 egrep RSS  [dave@centos1 ~]$  

Any tips/explanations on why redirection is causing the additional/subsequent header lines to disappear from the redirected output would be greatly appreciated.

How to install gcc-5 on Debian 8.10?

Posted: 10 Apr 2022 06:55 AM PDT

I am trying to install gcc-5 on debian 8.10 on a beaglebone green.

I have looked at many threads, of which the following was the most promising. How to install GCC 5 on debian jessie 8.1

When I try to follow the instruction of

echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list  

I get an error, similarly when I try the same with sudo.

If I elevate the user, using sudo su -, It seems I am successful.

debian@beaglebone:~$ echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list  -bash: /etc/apt/sources.list.d/unstable.list: Permission denied  debian@beaglebone:~$ sudo echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list  -bash: /etc/apt/sources.list.d/unstable.list: Permission denied  debian@beaglebone:~$ sudo su -  root@beaglebone:~# echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list  root@beaglebone:~# cat /etc/apt/sources.list.d/unstable.list     deb http://ftp.us.debian.org/debian unstable main contrib non-free  root@beaglebone:~# exit  logout  debian@beaglebone:~$ sudo cat /etc/apt/sources.list.d/unstable.list    deb http://ftp.us.debian.org/debian unstable main contrib non-free  debian@beaglebone:~$   

Continuing, sudo apt-get update all seems fine.

debian@beaglebone:~$ sudo apt-get update  Ign http://deb.debian.org jessie InRelease  Hit http://repos.rcn-ee.com jessie InRelease                                                              Hit http://deb.debian.org jessie-updates InRelease                                                        Hit http://deb.debian.org jessie/updates InRelease  Hit https://deb.nodesource.com jessie InRelease  Hit https://deb.nodesource.com jessie InRelease  Hit http://ftp.us.debian.org unstable InRelease  Hit http://deb.debian.org jessie Release.gpg     Hit http://deb.debian.org jessie Release  Get:1 http://repos.rcn-ee.com jessie/main armhf Packages [987 kB]  Get:2 http://deb.debian.org jessie-updates/main armhf Packages [20 B]              Get:3 http://deb.debian.org jessie-updates/contrib armhf Packages [20 B]                             Get:4 https://deb.nodesource.com jessie/main armhf Packages [980 B]                      Get:5 http://deb.debian.org jessie-updates/non-free armhf Packages [20 B]                                 Get:6 http://deb.debian.org jessie/updates/main armhf Packages [961 kB]                  Get:7 https://deb.nodesource.com jessie/main Sources [20 B]                            Get:8 https://deb.nodesource.com jessie/main armhf Packages [765 B]                                       Get:9 http://ftp.us.debian.org unstable/main armhf Packages [11.9 MB]                                     Get:10 http://deb.debian.org jessie/updates/contrib armhf Packages [994 B]                                Get:11 http://deb.debian.org jessie/updates/non-free armhf Packages [4,393 B]                             Get:12 http://deb.debian.org jessie/main armhf Packages [8,898 kB]                                        Get:13 http://ftp.us.debian.org unstable/contrib armhf Packages [61.4 kB]                                 Get:14 http://ftp.us.debian.org unstable/non-free armhf Packages [78.7 kB]                                Get:15 http://deb.debian.org jessie/contrib armhf Packages [44.3 kB]                                      Get:16 http://deb.debian.org jessie/non-free armhf Packages [74.9 kB]                                     Fetched 23.0 MB in 1min 22s (281 kB/s)                                                                    Reading package lists... Done  debian@beaglebone:~$   

But when I try the last instruction of:

apt-get install -t unstable gcc-5  

It does not work: as default user:

debian@beaglebone:~$ sudo apt-get install -t unstable gcc-5  Reading package lists... Done  Building dependency tree         Reading state information... Done  E: Unable to locate package gcc-5  debian@beaglebone:~$   

The same happens if I elevate user:

root@beaglebone:~# apt-get install -t unstable gcc-5  Reading package lists... Done  Building dependency tree         Reading state information... Done  E: Unable to locate package gcc-5  root@beaglebone:~#  

I am using this kernel image Debian 8.10 2018-02-01 4GB SD SeeedStudio IoT

I need to run this specific image because it is the most recent image that supports the HDMI Cape.

I am trying to run a node.js server as well as C/C++ code. Being unable to run the node.js server and the app boiled down to not having the correct version of gcc because:

whenever I run node server.js, I get the following error:

My host has gcc version 9.4, and node js version 10.19

Yes I ran,

sudo npm cache clean -f  sudo npm install -g n  sudo n stable  

on both host and target.

I also followed the debian 8 guide to install different versions of nodejs, the same issue persists.

https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-debian-8

Any help would be appreciated.

lspci command doesn't detect monitor through mini dvi port

Posted: 10 Apr 2022 06:39 AM PDT

I just wired a just received 2005 Toshiba TDP S25 Projector VGA to the mini dvi port of my GP66 Leopard via an adapter. However, when I select "Computer 1" on the toshiba menu I have a mere "no signal" displayed.

Here is the output of the lspci command:

bash-5.1$ lspci  00:00.0 Host bridge: Intel Corporation 11th Gen Core Processor Host Bridge/DRAM Registers (rev 05)  00:01.0 PCI bridge: Intel Corporation 11th Gen Core Processor PCIe Controller #1 (rev 05)  00:02.0 VGA compatible controller: Intel Corporation TigerLake-H GT1 [UHD Graphics] (rev 01)  00:04.0 Signal processing controller: Intel Corporation TigerLake-LP Dynamic Tuning Processor Participant (rev 05)  00:06.0 PCI bridge: Intel Corporation 11th Gen Core Processor PCIe Controller #0 (rev 05)  00:0a.0 Signal processing controller: Intel Corporation Tigerlake Telemetry Aggregator Driver (rev 01)  00:0d.0 USB controller: Intel Corporation Tiger Lake-H Thunderbolt 4 USB Controller (rev 05)  00:14.0 USB controller: Intel Corporation Tiger Lake-H USB 3.2 Gen 2x1 xHCI Host Controller (rev 11)  00:14.2 RAM memory: Intel Corporation Tiger Lake-H Shared SRAM (rev 11)  00:15.0 Serial bus controller: Intel Corporation Tiger Lake-H Serial IO I2C Controller #0 (rev 11)  00:16.0 Communication controller: Intel Corporation Tiger Lake-H Management Engine Interface (rev 11)  00:1c.0 PCI bridge: Intel Corporation Tiger Lake-H PCI Express Root Port #5 (rev 11)  00:1d.0 PCI bridge: Intel Corporation Tiger Lake-H PCI Express Root Port #9 (rev 11)  00:1d.4 PCI bridge: Intel Corporation Device 43b4 (rev 11)  00:1f.0 ISA bridge: Intel Corporation Tiger Lake-H LPC/eSPI Controller (rev 11)  00:1f.3 Multimedia audio controller: Intel Corporation Tiger Lake-H HD Audio Controller (rev 11)  00:1f.4 SMBus: Intel Corporation Tiger Lake-H SMBus Controller (rev 11)  00:1f.5 Serial bus controller: Intel Corporation Tiger Lake-H SPI Controller (rev 11)  01:00.0 VGA compatible controller: NVIDIA Corporation GA104M [GeForce RTX 3080 Mobile / Max-Q 8GB/16GB] (rev a1)  01:00.1 Audio device: NVIDIA Corporation GA104 High Definition Audio Controller (rev a1)  02:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller 980  03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)  05:00.0 Network controller: Intel Corporation Wi-Fi 6 AX210/AX211/AX411 160MHz (rev 1a)  

I can't find it. Maybe I should find a VGA to HDMI adapter and retry from there?

And here is the same for xorg:

bash-5.1$ dnf list installed | grep xorg  abrt-addon-xorg.x86_64                           2.14.6-9.fc35                       @anaconda               xorg-x11-drv-amdgpu.x86_64                       21.0.0-1.fc35                       @anaconda               xorg-x11-drv-ati.x86_64                          19.1.0-6.fc35                       @anaconda               xorg-x11-drv-evdev.x86_64                        2.10.6-10.fc35                      @anaconda               xorg-x11-drv-fbdev.x86_64                        0.5.0-9.fc35                        @anaconda               xorg-x11-drv-intel.x86_64                        2.99.917-51.20200205.fc35           @anaconda               xorg-x11-drv-libinput.x86_64                     1.2.0-1.fc35                        @anaconda               xorg-x11-drv-nouveau.x86_64                      1:1.0.17-2.fc35                     @anaconda               xorg-x11-drv-openchrome.x86_64                   0.6.400-2.20210215git5dbad06.fc35   @anaconda               xorg-x11-drv-qxl.x86_64                          0.1.5-20.fc35                       @anaconda               xorg-x11-drv-vesa.x86_64                         2.4.0-12.fc35                       @anaconda               xorg-x11-drv-vmware.x86_64                       13.2.1-16.fc35                      @anaconda               xorg-x11-drv-wacom.x86_64                        0.40.0-2.fc35                       @anaconda               xorg-x11-drv-wacom-serial-support.x86_64         0.40.0-2.fc35                       @anaconda               xorg-x11-fonts-ISO8859-1-100dpi.noarch           7.5-32.fc35                         @fedora                 xorg-x11-server-Xorg.x86_64                      1.20.11-2.fc35                      @anaconda               xorg-x11-server-Xorg.x86_64                      1.20.14-3.fc35                      @updates                xorg-x11-server-Xwayland.x86_64                  21.1.3-1.fc35                       @updates                xorg-x11-server-Xwayland.x86_64                  21.1.4-1.fc35                       @updates                xorg-x11-server-common.x86_64                    1.20.11-2.fc35                      @anaconda               xorg-x11-server-common.x86_64                    1.20.14-3.fc35                      @updates                xorg-x11-xauth.x86_64                            1:1.1-9.fc35                        @anaconda               xorg-x11-xinit.x86_64                            1.4.0-12.fc35                       @anaconda         

Why aren't my audio devices recognized?

Posted: 10 Apr 2022 05:38 AM PDT

On my laptop, only Dummy Output appears in Sound Preferences. This is Mint 20.3, but similarly, nothing is found when running on with an Endeavor or Fedora live-USB-stick. Headphones in the AUX do not work either. With Windows, audio works. Apparently the sound card is HDA Intel PCH (see aplay -l below). arecord --list-devices gives an empty result (below). See also arecord --list-pcms and /sbin/lsmod | grep snd below.

How can I get this working?

$ aplay -l  **** List of PLAYBACK Hardware Devices ****  card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]    Subdevices: 1/1    Subdevice #0: subdevice #0  
arecord --list-devices      **** List of CAPTURE Hardware Devices ****  
$ arecord --list-pcms  default      Playback/recording through the PulseAudio sound server  surround21      2.1 Surround output to Front and Subwoofer speakers  surround40      4.0 Surround output to Front and Rear speakers  surround41      4.1 Surround output to Front, Rear and Subwoofer speakers  surround50      5.0 Surround output to Front, Center and Rear speakers  surround51      5.1 Surround output to Front, Center, Rear and Subwoofer speakers  surround71      7.1 Surround output to Front, Center, Side, Rear and Woofer speakers  null      Discard all samples (playback) or generate zero samples (capture)  samplerate      Rate Converter Plugin Using Samplerate Library  speexrate      Rate Converter Plugin Using Speex Resampler  jack      JACK Audio Connection Kit  oss      Open Sound System  pulse      PulseAudio Sound Server  upmix      Plugin for channel upmix (4,6,8)  vdownmix      Plugin for channel downmix (stereo) with a simple spacialization  usbstream:CARD=PCH      HDA Intel PCH      USB Stream Output  
$ /sbin/lsmod | grep snd  snd_sof_pci            20480  0  snd_sof_intel_hda_common    73728  1 snd_sof_pci  snd_soc_hdac_hda       24576  1 snd_sof_intel_hda_common  snd_sof_intel_hda      20480  1 snd_sof_intel_hda_common  snd_sof_intel_byt      20480  1 snd_sof_pci  snd_sof_intel_ipc      20480  1 snd_sof_intel_byt  snd_sof               106496  4 snd_sof_pci,snd_sof_intel_hda_common,snd_sof_intel_byt,snd_sof_intel_ipc  snd_sof_xtensa_dsp     16384  1 snd_sof_pci  snd_hda_ext_core       32768  3 snd_sof_intel_hda_common,snd_soc_hdac_hda,snd_sof_intel_hda  snd_soc_acpi_intel_match    32768  2 snd_sof_pci,snd_sof_intel_hda_common  snd_soc_acpi           16384  2 snd_sof_pci,snd_soc_acpi_intel_match  ledtrig_audio          16384  1 snd_sof  snd_soc_core          249856  3 snd_sof,snd_sof_intel_hda_common,snd_soc_hdac_hda  snd_compress           24576  1 snd_soc_core  ac97_bus               16384  1 snd_soc_core  snd_pcm_dmaengine      16384  1 snd_soc_core  snd_hda_codec_hdmi     61440  1  snd_hda_intel          53248  1  snd_intel_dspcfg       28672  3 snd_hda_intel,snd_sof_pci,snd_sof_intel_hda_common  snd_hda_codec         139264  3 snd_hda_codec_hdmi,snd_hda_intel,snd_soc_hdac_hda  snd_hda_core           90112  7 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_ext_core,snd_hda_codec,snd_sof_intel_hda_common,snd_soc_hdac_hda,snd_sof_intel_hda  snd_hwdep              20480  1 snd_hda_codec  snd_pcm               106496  8 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_sof,snd_sof_intel_hda_common,snd_soc_core,snd_hda_core,snd_pcm_dmaengine  snd_seq_midi           20480  0  snd_seq_midi_event     16384  1 snd_seq_midi  snd_rawmidi            36864  1 snd_seq_midi  snd_seq                69632  2 snd_seq_midi,snd_seq_midi_event  snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi  snd_timer              36864  2 snd_seq,snd_pcm  snd                    90112  13 snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_timer,snd_compress,snd_soc_core,snd_pcm,snd_rawmidi  soundcore              16384  1 snd  

Change color of a certain lines from an output bash

Posted: 10 Apr 2022 08:21 AM PDT

I have this output from a drive diag command.

Slot Number        : 0     Drive's position   : DiskGroup 0    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 447.130 GB [0x37e436b0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : PHYM813201FL480BGNSSDSC2KG480G7R SCV1DL58    Foreign State      : None     Media Type         : Solid State Device   Temperature        : 20C (68.00 F)   S.M.A.R.T alert    : No       Slot Number        : 1     Drive's position   : DiskGroup 0    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 447.130 GB [0x37e436b0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : PHYM81320058480BGNSSDSC2KG480G7R SCV1DL58    Foreign State      : None     Media Type         : Solid State Device   Temperature        : 21C (69.80 F)   S.M.A.R.T alert    : No       Slot Number        : 2     Drive's position   : DiskGroup 1    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 1.090 TB [0x8bba0cb0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : SEAGATE ST1200MM0099 ST31WFK0VEBK   Foreign State      : None     Media Type         : Hard Disk Device   Temperature        : 22C (71.60 F)   S.M.A.R.T alert    : No       Slot Number        : 3     Drive's position   : DiskGroup 1    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 1.090 TB [0x8bba0cb0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : SEAGATE ST1200MM0099 ST31WFK0T07T   Foreign State      : None     Media Type         : Hard Disk Device   Temperature        : 22C (71.60 F)   S.M.A.R.T alert    : No       Slot Number        : 4     Drive's position   : DiskGroup 1    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 1.090 TB [0x8bba0cb0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : SEAGATE ST1200MM0099 ST31WFK0VAJK   Foreign State      : None     Media Type         : Hard Disk Device   Temperature        : 22C (71.60 F)   S.M.A.R.T alert    : No       Slot Number        : 5     Drive's position   : DiskGroup 1    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 1.090 TB [0x8bba0cb0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : SEAGATE ST1200MM0099 ST31WFK0SYPC   Foreign State      : None     Media Type         : Hard Disk Device   Temperature        : 22C (71.60 F)   S.M.A.R.T alert    : No       Slot Number        : 6     Drive's position   : DiskGroup 1    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 1.090 TB [0x8bba0cb0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : SEAGATE ST1200MM0099 ST31WFK0MVN2   Foreign State      : None     Media Type         : Hard Disk Device   Temperature        : 22C (71.60 F)   S.M.A.R.T alert    : No       Slot Number        : 7     Drive's position   : DiskGroup 1    Media Error        : 0     Other Error        : 0     Predictive Failure : 0     Raw Size           : 1.090 TB [0x8bba0cb0 Sectors]  Firmware state     : Online, Spun Up   Inquiry Data       : SEAGATE ST1200MM0099 ST31WFK0SZ2L   Foreign State      : None     Media Type         : Hard Disk Device   Temperature        : 22C (71.60 F)   S.M.A.R.T alert    : No   

And I would like to only make changes on the 3,4,5,7,9 and 12th line of each drive after the ":" sign. Those results are the standards but I want to add some color if it says something different. For example:

Slot Number        : 7     Drive's position   : DiskGroup 1    Media Error        : 4  (I want the whole line in red)  Other Error        : 3  (I want the whole line in red)  Predictive Failure : 1  (I want the whole line in red)  Raw Size           : 1.090 TB [0x8bba0cb0 Sectors]  Firmware state     : Failed. (I want the whole line in red)  Inquiry Data       : SEAGATE ST1200MM0099 ST31WFK0SZ2L   Foreign State      : Unconfigured  (I want the whole line in red)  Media Type         : Hard Disk Device   Temperature        : 22C (71.60 F)   S.M.A.R.T alert    : Yes  (I want the whole line in red)  

I would like to make those changes for every drive, the drive quantity is variable, sometimes is more sometimes is less.

I already tried this but is not working.

awk -F ':' '$1~/^(Media Error|Other Error|Predictive Failure)$/ && $2 > 0 {print "\033[31m" $0 "\e[0m"; next} 1'  

Cpu frequency is too low due to faulty battery

Posted: 10 Apr 2022 09:30 AM PDT

I have a battery which apparently is dead (I've tried to re-calibrate it with power-calibrate, didn't work).

 $ acpi  Battery 0: Charging, 0%, charging at zero rate - will never fully charge.  Battery 1: Not charging, 0%  

As a result CPU frequency is set to the lowest value

 $ grep MHz /proc/cpuinfo   cpu MHz     : 399.999  cpu MHz     : 400.064  cpu MHz     : 400.001  cpu MHz     : 400.046   $ sudo cpupower frequency-info   analyzing CPU 0:    driver: intel_pstate    CPUs which run at the same hardware frequency: 0    CPUs which need to have their frequency coordinated by software: 0    maximum transition latency:  Cannot determine or is not supported.    hardware limits: 400 MHz - 2.60 GHz    available cpufreq governors: performance powersave    current policy: frequency should be within 400 MHz and 2.60 GHz.                    The governor "performance" may decide which speed to use                    within this range.    current CPU frequency: Unable to call hardware    current CPU frequency: 400 MHz (asserted by call to kernel)    boost state support:      Supported: no      Active: no     

I've tried to set the frequency manually but it fails

 $ sudo cpupower frequency-set -f 2000  Setting cpu: 0  Error setting new values. Common errors:  - Do you have proper administration rights? (super-user?)  - Is the governor you requested available and modprobed?  - Trying to set an invalid policy?  - Trying to set a specific frequency, but userspace governor is not available,     for example because of hardware which cannot be set to a specific frequency     or because the userspace governor isn't loaded?  

Rising it with sysfs didn't work also,

 $ echo "2000000" | sudo tee -a /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq   2000000   $ cat /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq   400000  

How can I disable CPU frequency scaling completely or set it to the maximum?

The problem occurs only on Linux, OpenBSD works on maximum CPU frequency

I'm also able to measure performance degradation with

dd if=/dev/zero bs=1M count=1024 | md5sum -  

where it gives me about ~50MB/s, almost 10 times less than expected.

Minecraft Input Bug(It's not glfw #1112)

Posted: 10 Apr 2022 10:53 AM PDT

I have a keyboard input bug in Minecraft 1.12 and below. When I open a world I can use only number keys, arrows and special keys(functional keys, escape etc). I wrote a mod that writes the name and code of the button when it is pressed and it does not respond to press on buttons with letters on they. I think Minecraft response buttons wrong.

My system: Fedora 35, KDE Plasma 5.24.3, X11 1.20.14

find duplicate 1st field and concat its values in single line

Posted: 10 Apr 2022 12:08 PM PDT

I have a file that has entries in key: value format like the below:

cat data.txt

name: 'tom'  tom_age: '31'  status_tom_mar: 'yes'  school: 'anne'  fd_year_anne: '1987'  name: 'hmz'  hmz_age: '21'  status_hmz_mar: 'no'  school: 'svp'  fd_year_svp: '1982'  name: 'toli'  toli_age: '41'  

and likewise ...

I need to find and print only those key: value that have duplicate keys as a single entry.

The below code gets me the duplicate keys

cat data.txt | awk '{ print $1 }' | sort  | uniq -d  name:  school:  

However, I want the output where I wish to concatenate the values of duplicate keys in one line.

Expected output:

name: ['tom', 'hmz', 'toli']  school: ['anne', 'svp']  tom_age: '31'  status_tom_mar: 'yes'  fd_year_anne: '1987'  hmz_age: '21'  status_hmz_mar: 'no'  fd_year_svp: '1982'  toli_age: '41'  

Can you please suggest?

vscode doesn't open as root in debian

Posted: 10 Apr 2022 06:28 AM PDT

In the new update, vscode doesn't open as root in debian. Even after specifying an alternative directory using --user-data-dir

Has anyone ever faced this issue in the new update of vscode or is there any way to fix this? The terminal doesn't output any errors after executing the command (it just doesn't open as root). I couldn't find any solution online either because most of the vscode and root account related problems are associated with the person failing to specify path using --user-data-dir and in my case it doesn't open at all.

Operating system: Debian 10

Vscode version: 1.58.2-1626302803

[NOTE: I didn't face this issue until I updated to version 1.58.2-1626302803. The old versions of vscode was working fine in the root account.]

Gnome does not wake up the monitor anymore on keypress

Posted: 10 Apr 2022 10:41 AM PDT

Since around the middle of October 2020, my Arch Linux machines don't wake up the monitor anymore when I press any key in the Gnome login screen. However the machine itself is woken up, as I see my keypresses as password entries or am even locked if I press enter due to too many login attempts once I wake the monitor up by switching to another console via CTRL+ALT+Fx and back.

What has changed and how can I restore the original functionality?

What can I do to fix occasional lagging of terminal emulator?

Posted: 10 Apr 2022 08:05 AM PDT

My terminal emulators are lagging occasionally. It's not heavy a lag. May be once in 20-30 mins( I think). The terminal becomes unresponsive and all the characters I typed during lag appears suddenly. It's not happening in any other app (even in SMPLAYER during 1080p video playback). The lag occurs even during low memory usage(nearly 1 GB free). I thought there might be a problem in xterm and switched to xfce4-terminal emulator. problem still persisted. Then thought there might be a bug in bash and switched to zsh . still no luck. What's happening ? How can I narrow the down problem?
system info : Arch + i3 + compton
Update1: I thought my history size(1000) might be causing the problem and changed it to 100. And this doesn't seem to work either.
Update2: My ~/.bashrc

  #  # ~/.bashrc  #    # If not running interactively, don't do anything  [[ $- != *i* ]] && return    alias ls='ls --color=auto'  alias grep='grep --color=auto'    PS1='\[\033[32m\]\u\[\033[33m\]@\[\033[36m\]\h \[\033[31m\]\W\[\033[33m\]\$\[\033[00m\]'      ## my settings  alias vi='vim'  alias vi_i3='vim ~/.config/i3/config'  alias pacs='sudo pacman -S'  alias pacss='pacman -Ss'  alias pacsyu='sudo pacman -Syu'  export TERMINAL='xfce4-terminal'  HISTSIZE=100  

Update3: But in zsh I used very simple Prompt string without any color. Still it was lagging.

How do I set a cmake policy?

Posted: 10 Apr 2022 09:36 AM PDT

I'm trying to compile the Paraview graphical visualization software for my ARM-based laptop; however, I am getting a few configuration warnings that seem to relate to cmake 'policies'. The warning text and the cmake man page suggest that I should be able to run the command cmake_policy() to set a particular policy; however, I can't figure out how or where to run it.

How can I set a particular cmake policy?

Grub Rescue Mode - /boot/grub directory does not exist

Posted: 10 Apr 2022 07:43 AM PDT

I have gone through a lot of questions and answers related to grub rescue but I am having a different problem which I am not able to understand.

As per some of the answers, I tried following steps to resolve this problem -

  1. First of all I used ls command to get all the partitions which in my case were (hd0), (hd0,msdos5), (hdo,msdos1), (hd1) & (hd1,msdos1)

  2. Out of the above 5 partitions, I got Filesystem is ext2 message for (hd0,msdos1) drive.

  3. As per some of the answers provided in ask ubuntu & stack exchange I tried to set the root & prefix using (hd0,msdos1) drive (which I found using ls command)

  4. While setting prefix I realised that the /boot/grub directory does not exist in selected drive (hd0,msdos1).

  5. As a result of this when I try to fire insmod normal command, grub rescue gives an error saying /boot/grub/i386-pc/normal.mod not found

  6. Apart from this, I tried using bootable USB drive with ubuntu 14, 16, 17, 18 & even windows OS but I always ended up in grub rescue window.

This leaves me with following questions -

  1. Am I setting a wrong drive as root drive (provided this is the only ext2 drive among 5 enlisted drives) ?

  2. Is there a way of including the /boot/grub folder in the root directory so that I can run `insmod normal command ?

How to prevent 'grub rescue' from ever happening?

Posted: 10 Apr 2022 07:37 AM PDT

I already know how to recover from 'grub rescue' and I'm not asking about it.

I barely have one HDD and I change its partitions for multiple purpose. But everytime I do so, I got 'grub rescue', I can handle but it is annoying. Is there any way to prevent grub rescue ? (e.g. replace grub with another loader, install my own script, etc.)

UPDATE: Add a few more details

  • I don't use a partition as /boot but only /

  • My root partition is a part of a bigger extended partition

  • My root partition is not /dev/sda1 but /dev/sda5. I use dual-boot (Windows is in /dev/sda1)

  • I guess when I change a part of extended partition, its address/name (i.e. (hd0,msdosX), I don't know what this is) changes, so avoiding 'grub rescue' while still use grub is perhaps impossible. May be change boot loader is the only solution

  • In 'grub rescue', I saw that grub know how many partition and whether a partition is ext2/3/4 or not (by ls and ls (hdX,msdosY)), so if I could let grub scan for partition and boot the first found ext partition, problem solved!

libpam-pwquality not working in Ubuntu 16.04

Posted: 10 Apr 2022 06:08 AM PDT

I installed libpam-pwquality:

sudo apt-get install libpam-pwquality  

And configured /etc/pam.d/common-password:

password        requisite                       pam_pwquality.so retry=3 minlen=10    password        [success=1 default=ignore]      pam_unix.so obscure use_authtok try_first_pass sha512  password        required                        pam_deny.so  password        required                        pam_permit.so  

Then when I ran passwd, I could still set a password of 2 or 3 characters. What was missing?

Shell script - creating and assign to groups advice needed on my script

Posted: 10 Apr 2022 11:08 AM PDT

Where could I include man useradd and -g and G i'm not sure where to include these commands above. The current shell script doesn't successly create the user but does run.

#!/usr/bin/env bash    anotherUser() {     read -p "Add another user? [y/n] yn"     if [[ $yn = *[yY]* ]]; then        checkUser     fi     exit  }  checkUser() {  while :     do        read -p "Enter user: " userName        read -s -p "Enter password : " userPass        if id "$userName" >/dev/null; then           echo "User exists"           anotherUser        else           echo adduser "$userName"           printf "User %s has been added\n" "$userName"           exit        fi     done  }  checkUser  

Find all .php files inside directories with writable permissions

Posted: 10 Apr 2022 10:04 AM PDT

I'm looking for a linux command to scan through all writable directories on the server and show ones with .php and .html files inside them.

Something like:

find -type d -writable -exec find {} -iname '*.php' -o -iname '*.html' \;  

10x!

Two mice pointers (xinput stuff) issue (logs me off)

Posted: 10 Apr 2022 09:07 AM PDT

I'm trying to use two mice (mouse pointers) on my laptop (Linux Mint 16) so I've been following some tutorials that I found: the idea is to work with the xinput command. I have two mice (Touchpad and a wireless one).

So I create a new master

xinput --create-master secondmice  

it seems to work since a new pointer appears on the screen (I can't move it though).

Then I "bind" it to a mouse (the wireless one):

xinput reattach ID_WIRELESS ID_SECONDMICE  

it looks ok for no error occurs.

Once it's done I start moving the mice (wireless) to test. But it immediately crashes and logs me off. When I log back in, everything's alright, but I still have only my one unique pointer. Why does it crashes?

I checked log files and I couldn't find anything "weird" or that might helped me (/var/log/Xorg.0.log, /var/log/messages, ~/.xsessions-errors...)

EDIT: When it crashes a black-screen shows up (tty), right before I got on the "Log-in page", here's what we can read:
Linux Mint 16 Petra AslComp tty1 AslComp: [ 24.263867] brcmsmac bcms0:0: brcmsmac: brcms_ops_bss_info_changed: associated [ 24.264035] brcmsmac brcms0:0: brcms_ops_bss_info_changed: qos enabled: true (implement)
"AslComp" is computer name.
I've searched those terms with Google but it's more related to Wifi than xinput.

Read/Write to a Serial Port Without Root?

Posted: 10 Apr 2022 07:34 AM PDT

I'm writing an application to read/write to/from a serial port in Fedora14, and it works great when I run it as root. But when I run it as a normal user I'm unable to obtain the privileges required to access the device (/dev/ttySx). That's kind of crappy because now I can't actually debug the damn thing using Eclipse.

I've tried running Eclipse with sudo but it corrupts my workspace and I can't even open the project. So I'd like to know if it's possible to lower the access requirements to write to /dev/ttySx so that any normal user can access it. Is this possible?

No comments:

Post a Comment