Tuesday, August 17, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Display Constantly "Fuzzy" with Nvidia Driver

Posted: 17 Aug 2021 12:33 PM PDT

I've been having this issue for at least 3 years where my display will be blurry while using the proprietary Nvidia driver. Nouveau doesn't fix anything either.

Any screenshots that I take using the monitor will show up crystal clear, but visually looking at it, everything seems fuzzy, blurry and sometimes even ghosts if I move a window around. I have a second monitor plugged in via a DP->VGA adaptor and, even when my main monitor is blurry, that looks perfectly fine. Sometimes my monitor will work flawlessly, but that's once in a blue moon.

I'm currently running Void Linux with the latest Linux kernel and KDE Plasma.

I am using an Nvidia RTX 2060, and the monitor is getting the signal via HDMI. I am unsure of the monitor's control board and anything like that as it's a seemingly random brand that have no official datasheets (and it doesn't even seem to be sold anymore). What I do know is it's a 32" 1080p@60Hz display, and it won't go higher than that.

I don't have this issue on Windows 10, and everything is displayed crisp and clear as day.

  • Tried GNOME, KDE Plasma and even XFCE - all produce the same output
  • Swapped the HDMI cable and even bought a whole new one
  • Tried changing the HDMI port that I use on the monitor
  • The issue has persisted across two GPUs now (I used to use a GTX1050)
  • Reinstalling the Nvidia Linux drivers (and reconfiguring them). They show up in lsmod and X11 is set to use them - nouveau is blacklisted and I confirmed this with lsmod
  • The issue has persisted over many distros, such as Ubuntu, Pop, Arch, Gentoo and Void.
  • I have looked in the monitor settings and found nothing relevant, and changing everything I can see does nothing to fix the clarity either
  • I've looked high and low in Plasma's and Nvidia's settings, and tried things such as forced anti-aliasing, text rendering, and even vsync changes. They make no difference even after a save + reboot.
  • I've installed every (even seemingly) relevant package across every Linux distribution that I've used, and none of them made a difference.
  • I re-tried POP_OS and ensured that I was using the Nvidia ISO and installs to root out any misconfiguration, to no avail.

I have looked around for others that have experienced something similar to me and all of the issues turned out to be misconfiguration or things that had nothing to do with what I'm experiencing (mostly anti-aliasing issues).

I find it hard to think of things that could be at fault as it works perfectly fine in Windows, which is baffling to me.

I'm completely out of ideas now, so any help or insight as to how I'd go about even debugging this would be greatly appreciated!

How to get the normal username as a variable

Posted: 17 Aug 2021 12:23 PM PDT

I'm trying to create a makefile script and I tried to automatically create multiple folders in a specific directory. However, I've had issues when trying to implement this: First, I tried doing it the normal route:

mkdir ~/Documents/testfolder  

However, it gave me this error: mkdir: cannot create directory '/root/Documents/testfolder': No such file or directory

I then tried using the $USER variable with this command:

mkdir /home/$USER/Documents/testfolder  

but then it'll be registered as /home/root/Documents/... and cause an error. Makefile scripts require to be ran as sudo most of the time so it's pretty problematic for me. Any help?

How to extract pairs of values from a file and echo them to an output file

Posted: 17 Aug 2021 12:20 PM PDT

I have hundreds of language files that belong to a project.

These files are like this

/*       Created by Bla bla bla    Copyright by XYZ    December 20th, 2020    */    "car" = "Carro";  "door" = "Porta";  

How to process a file like this, using a bash script and extract the parts like

"car" = "Carro";  "door" = "Porta";  

and echoing/printing them to an output file?

the elements I want have always this format

"string" = "another string";  

NOTE: "another string" may contain accented chars.

I want the output file to have just the pairs, one per line.

How do I do that?

Create a secure configuration file for zsh scripts

Posted: 17 Aug 2021 11:10 AM PDT

I want to store some default variables for a zsh shell script that I'm working on. I know that using a source line in my script would work, but wouldn't be the most secure method.

To ensure maximum compatibility for all of my users, is there a way using the tools available by default in zsh (on Amazon Linux 2, for specifics) to securely read lines from a text file and extract a set of preset variables from the config file?

While I know the text file itself won't be hashed, that's not my issue. My goal is simply to avoid the possibility of someone inserting malicious code into the config file and having it processed by the script.

Files are corrupted when accessing files from host OS and the passive device on a virtual USB driver

Posted: 17 Aug 2021 10:55 AM PDT

I am doing an experimental project to make a virtual USB device to transfer photos from a camera to a Linux computer. In this case, I am using a Jetson-nano board and Ubuntu as the operating system. I have prepared a FAT32 partition and configured it as a mass storage using USB gadget driver. Now the partition is visible as a mass storage for the Ubuntu system itself. Also, I connected a camera via OTG cable to save the images from camera to this storage. Images also getting saved and I wrote a program to copy the files from mass storage to the Ubuntu system after camera is done its job (by putting milliseconds and seconds level delays). I observed the images are getting corrupted when copying or accessing the files to get the size of the files from the mass storage. Also if I reboot the system, same image file can be seen correctly. Hence problem is happen when a program is trying to access the files in real time (while camera is saving the images to mass storage partition). with this use case, following things are happening.

  1. camera is saving images to mass storage
  2. host OS application is either copy to local storage or opening the files for displaying

functionality is working fine if

  1. if we copy entirely different file (put a dummy image file in the storage and use that for displaying at a storage change)
  2. Sometimes work if we put a very long delay like 10 seconds

in this case I have following questions

  1. how the corrupted files are restored at the system reboot ?
  2. Is my approach not a feasible one. I got the idea from following resource. (Make a computer act as a virtual USB device for other equipments)

How to create a system user on WSO2 with readonly access to the LDAP server?

Posted: 17 Aug 2021 10:01 AM PDT

I have two systems that include the identity server and application server. My application server needs to read the ldap information from the identity server. I can create a new super admin on the identity server via the deployment.yml file, however that will treat the new user as an admin user and thus giving write permission to the application server. And the application doesn't need write permission in order to sync the users. How would I create a system level user that only has read permission to the ldap server w/o modifying openldap manually?

How do I install debian manually in Termux?

Posted: 17 Aug 2021 09:56 AM PDT

I want to know How can I install debian manually (step by step) in Termux without a third party shell script to avoid possible MITM attack?

Salt size in /etc/shadow

Posted: 17 Aug 2021 11:53 AM PDT

After user password change the size of salt decreased in RHEL/Centos 6, eg:

cat /etc/shadow    ...  root:$6$FkMNsNxT$FW77....................nbL0......  bin:*:15422:0:99999:7:::  ...  

As you can see, FkMNsNxT is 8 characters.

Why it happens? In the beginning, after installation, the size is 16 chars.

How to make a Linux distribution? [closed]

Posted: 17 Aug 2021 09:55 AM PDT

I was just wondering how I can make my own Linux Distribution. Mainly what I'm looking for is more of a list of what I need to learn. Meaning what sites, or books I might have to look at. Of course anything helps though

Is access to root isolated from software knowing the password?

Posted: 17 Aug 2021 12:06 PM PDT

I have seen that programs like sudo among other things can easily gain/give root access if you provide them with the password.

Wouldn't that mean that any app can simply spoof (or guess if the password is simple enough, which in many cases can be the case for desktop users) the password as I type it in some other place, then use that to give root access to itself without me even knowing?

Bad Internet Causes Bad Local SSH connect

Posted: 17 Aug 2021 10:23 AM PDT

I'm running into an issue that has me scratching my head a bit and can't seem to find the right information online to clear things up for me. networking has never been strongest subject, but hopefully, I'm reaching out to the right people for some guidance.

My setup is farely simple, I have 1 client windows laptop that I use to SSH into a linux sever on the same network. Additionally, the laptop uses port forwarding for vnc.

The issue I have is that, just today, I discovered that my internet quality seems to negatively affect my SSH connection (Bad Internet = bad ssh). I began randomly receiving disconnent errors when connecting to my server (network failure software caused abort). I've tried adjusting my tcp keepalives, but it still drops out.

From my limited network understanding, since they are on the same network then any information sent/received from the client doesn't even make it all way down the stack and just looks at the destination IP and reroutes to the server's local IP. Is that a fair over-simplification? So, doesn't this sort of behave like a WLAN and should be independent of internet quality?

If not, would I be able to make it independent of internet using the same router and not disrupt the existing network (other people use this wifi)?

The goal is to to achieve a stable ssh connection on a WLAN that's performance is independent of internet speed. Also, the server doesn't necessarily need access to the internet but my laptop defenitely will (while connected to the server).

Any input would be greatly appreciated.

Thank you

UPDATE 1: After running "mtr -4b google.com" from my linux server, I see the following performance metrics:

enter image description here

Is there any red flags here? or is this typical?

Can't open serial port via minicom, but fine via Python and shell

Posted: 17 Aug 2021 10:04 AM PDT

I have been having issues with connecting to serial ports via minicom the last two weeks. For some reason, /dev/ttyACM0 maps to tty8 when I try to connect to it. My user is member of the dialout group, and the permissions on /dev/ttyACM0 seem to be set correctly.

Can't open serial device via shell

enter image description here

I also tried to setup a connection with pyserial, and this behaves as I expect..

enter image description here

I tried installing the latest system updates (I run Zorin OS, based on Ubuntu 20.04 LTS) and rebooting several times. I also tried different USB ports, without results. Does anyone have an idea what could be wrong with my setup here?

Edit: I just got the idea to communicate directly via my shell, and this seems to be working. I therefore think it is a minicom issue. Still very strange, since I can't find other people with the same problem. enter image description here

Tools for batching N commands over L scripts (for N≫L)?

Posted: 17 Aug 2021 11:33 AM PDT

Let's say that I have access to a high-performance Linux cluster equipped with a scheduler (e.g. LSF, Slurm, etc.) that will allow me to have up to M jobs either running or pending at any one time, of which at most L < M can be running concurrently.

Now, suppose that I want to run N independent commands as quickly as possible.

If N ≤ M, I can just submit each command as a separate job to the scheduler, and be done with.

But what if N > M? Or N ≫ M even?


The N ≫ M scenario occurs extremely often in my line of work, so often in fact that a hope to find tools to facilitate dealing with it would not be unreasonable1.

One very general and straightforward way to get around the scheduler-imposed limits is to split the N independent commands into L separate one-time "batching" scripts, and submit the latter to the scheduler, as L separate jobs2.

Granted, creating such one-time batching scripts is a dull, somewhat annoying chore, but someone who is handy with their shell, or with a scripting language like Python, Perl, etc., can easily take care of it, and even home-roll their own hacks to automate it.

My question is, however, are there publicly (and freely) available tools in the Unix ecosystem that can be used even by those with less programming skill to automate the chore of generating L such batching scripts, given as input a list of N independent commands?


1Actually, the scenario occurs so often that I am surprised that schedulers do not already have built-in support for it. At least the schedulers that I am most familiar with (Slurm and LSF) do not have any such support, as far as I can tell. Please correct me if I missed something.

2 More generally, one could to batch the N commands into k batching scripts, as long as k ≤ M, but, in my experience, choosing k = L is the most straightforward way to achieve a maximal, or near-maximal, throughput under these constraints. The reasons for this are not too difficult to see, but an adequate discussion of the matter would require more time than I want to take up here.

Install 'top' and 'find' on stripped a down debian linux with apt-get install?

Posted: 17 Aug 2021 12:16 PM PDT

I have a docker image I'm extending and it has a stripped down version of Debian. I've already installed some packages with the initial Dockerfile push I did but I'm also wanting to install top and file commands (already installed htop...). Does anyone know which packages I could install that include these with apt-get install that will work with Debian?

Also, I'm not sure how to find this info myself so if there is an easy way to figure it out that I could have done myself that info would be an awesome FYI to include.

Output of running cat /etc/*-release below:

PRETTY_NAME="Debian GNU/Linux 10 (buster)"         NAME="Debian GNU/Linux"  VERSION_ID="10"  VERSION="10 (buster)"  VERSION_CODENAME=buster  ID=debian  HOME_URL="https://www.debian.org/"  SUPPORT_URL="https://www.debian.org/support"       BUG_REPORT_URL="https://bugs.debian.org/"     

Adding second IP to RHEL 8 virtual machine

Posted: 17 Aug 2021 12:00 PM PDT

I have an existing RHEL8 virtual machine used for running httpd and a single virtualhost. I need to add a second IP/virtual host and am running into an issue. My understanding is that NetworkManager still parses network-scripts.

The existing IP is configured as:

[user@box]# cat /etc/sysconfig/network-scripts/ifcfg-ens3   TYPE=Ethernet  PROXY_METHOD=none  BROWSER_ONLY=no  BOOTPROTO=none  DEFROUTE=yes  IPV4_FAILURE_FATAL=no  NAME=ens3  UUID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx  DEVICE=ens3  ONBOOT=yes  IPADDR=xxx.xxx.xxx.111  PREFIX=24  GATEWAY=xxx.xxx.xxx.2  DNS1=xxx.xxx.1.1  ZONE=drop  

I created a second script set up with the new IP:

[user@box]# cat /etc/sysconfig/network-scripts/ifcfg-ens4   TYPE=Ethernet  PROXY_METHOD=none  BROWSER_ONLY=no  BOOTPROTO=none  DEFROUTE=yes  IPV4_FAILURE_FATAL=no  NAME=ens4  UUID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx  DEVICE=ens4  ONBOOT=yes  IPADDR=xxx.xxx.xxx.222  PREFIX=24  GATEWAY=xxx.xxx.xxx.2  DNS1=xxx.xxx.1.1  ZONE=drop  

I then restarted NetworkManager with

systemctl restart NetworkManager  

But I'm not seeing the new device named ens4 listed, just the existing IP (ens3)

[user@box]# ip addr  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00      inet 127.0.0.1/8 scope host lo         valid_lft forever preferred_lft forever  2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000      link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff      inet xxx.xxx.xxx.111/24 brd xxx.xxx.xxx.255 scope global noprefixroute ens3         valid_lft forever preferred_lft forever  

Device ens3 works fine.

The existing bridge from the host machine works since device ens3 works fine (I can view site content, ssh to machine, ect). So I'm not super sure this is a VM host setup issue.

What step(s) am I missing to add a second IP to RHEL8? Is the process different when the server is virtual?

sed regex fails to capture the entire paragraph containing the pattern

Posted: 17 Aug 2021 12:24 PM PDT

I have this XML file (example)

<This is a line of text with a year=2020 month=12 in it  This line of text does not have a year or month in it  This year=2021 is the current year the current month=1  This is the year=2021 the month=2/>      <This is a line of text with a year=33020 month=12 in it  This line of text does not have a year or month in it  This year=33020 is the current year the current month=1  This is the year=33020 the month=2/>  

Using the sed installation provided by my Linux distribution ( sed (GNU sed) 4.2.2) I search within this file with the following regexp:

 sed -En 'N;s/\<(This.*2020.*[\s\S\n]*?)\>/\1/gp' test2.txt  

However, it captures only this string:

<This is a line of text with a year=2020 month=12 in it  This line of text does not have a year or month in it  

But I try to capture the entire first paragraph between < and > that contains the pattern.

What am I doing wrong here?

HP 1/8 G2 medium changer not detected in Oracle Linux 8

Posted: 17 Aug 2021 12:29 PM PDT

I have a HP 1x8 G2 Autoloader that connected to a SAN switch, on my VMware environment I have an Oracle Linux that should work with the tape. The problem is after connecting tape to VM, medium changer is not detected but tape drive is OK!

$ cat /proc/scsi/scsi   Attached devices:  Host: scsi2 Channel: 00 Id: 00 Lun: 00    Vendor: VMware   Model: Virtual disk     Rev: 2.0    Type:   Direct-Access                    ANSI  SCSI revision: 06  Host: scsi2 Channel: 00 Id: 01 Lun: 00    Vendor: HP       Model: Ultrium 6-SCSI   Rev: 25MW    Type:   Sequential-Access                ANSI  SCSI revision: 06  Host: scsi0 Channel: 00 Id: 00 Lun: 00    Vendor: NECVMWar Model: VMware IDE CDR00 Rev: 1.00    Type:   CD-ROM                           ANSI  SCSI revision: 05  
$ lsscsi -g   [0:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR00 1.00  /dev/sr0   /dev/sg2  [2:0:0:0]    disk    VMware   Virtual disk     2.0   /dev/sda   /dev/sg0  [2:0:1:0]    tape    HP       Ultrium 6-SCSI   25MW  /dev/st0   /dev/sg1  
$ ls -l /dev/tape/by-path  lrwxrwxrwx 1 root root  9 Jul 30 08:49 pci-0000:00:10.0-scsi-0:0:1:0 -> ../../st0  lrwxrwxrwx 1 root root 10 Jul 30 08:49 pci-0000:00:10.0-scsi-0:0:1:0-nst -> ../../nst0  
$ lsmod | grep scsi  scsi_transport_spi     32768  1 mptspi  mptscsih               36864  1 mptspi  mptbase                94208  2 mptspi,mptscsih  
$ lsmod | grep sg   sg                     36864  0  
$ lsmod | grep st  st                     61440   

I installed latest version of HPE Array Controller for Centos 8

$ yum list installed   kmod-hpsa.x86_64                     3.4.20-5.el8_4.elrepo                       @elrepo  

and tape Autoloader was in Sequential mode which I changed it to Auto.

kernel info:

$ uname -r  5.4.17-2102.202.5.el8uek.x86_64  

mtx outputs:

$ mtx -f /dev/nst0 status  mtx: Request Sense: Long Report=yes  mtx: Request Sense: Valid Residual=no  mtx: Request Sense: Error Code=70 (Current)  mtx: Request Sense: Sense Key=Illegal Request  mtx: Request Sense: FileMark=no  mtx: Request Sense: EOM=no  mtx: Request Sense: ILI=no  mtx: Request Sense: Additional Sense Code = 20  mtx: Request Sense: Additional Sense Qualifier = 00  mtx: Request Sense: BPV=no  mtx: Request Sense: Error in CDB=no  mtx: Request Sense: SKSV=no  READ ELEMENT STATUS Command Failed  
$ mtx -f /dev/nst0 inquiry  Product Type: Tape Drive  Vendor ID: 'HP      '  Product ID: 'Ultrium 6-SCSI  '  Revision: '25MW'  Attached Changer API: No  

How can I profile virtual memory accesses made in user mode and kernel mode?

Posted: 17 Aug 2021 12:18 PM PDT

I would like to generate a log of all virtual memory accesses performed in user mode and kernel mode as a result of running some program.

Besides collecting memory access locations, I also want to capture other state information (e.g., instruction pointer, thread identifier). I anticipate that I won't be able to collect all of my desired statistics with any tool out of the box.

I intend on doing this profiling off-line, so I'm not concerned about the performance impacts. In fact, depending on what is available, it would be helpful to know which tools can record all memory accesses and which can only sample.

I was originally going to augment Valgrind's lacky tool until I realized that it only records user mode memory accesses. Looking into what other tools I might use, I'm at a loss at how I can quickly determine which tool is capable of capturing the information I want.

Here are some resources I've found that have gotten me started:

Dual boot (Ubuntu)-(Ubuntu with boot partition on usb)

Posted: 17 Aug 2021 10:27 AM PDT

I have two internal SSDs in my computer, one that currently has Ubuntu 20 installed with the following partitioning:

nvme0n1      │                                                                             ├─nvme0n1p1      │    vfat         EFI                                                   ├─nvme0n1p2      │    ext4         /boot                        └─nvme0n1p3           crypto       LUKS                          └─luks-long_uuid           LVM2_m                                ├─vgubuntu-root          │  ext4         /                            └─vgubuntu-swap_1             swap         swap  

That work's well with the default bootloader GRUB2

But I want to install a second Ubuntu 20 on my other drive with a detached boot partition (on an usb thumb). The second drive has the following partitioning :

sda                                                                           ├─sda1 empty (I will use that later)      │                                                                             ├─sda2 empty (I will use that later)      │                                                                             ├─sda3 empty (I will use that later)      │                                                                             └─sda5           crypto       LUKS                          └─sda5_crypt           ext4         /  

And I installed my boot partition on my USB as follows :

sdc                                                                       ├─sdc1  │    vfat   EFI                                                 ├─sdc2  │    ext4         /boot                    └─sdc3       ext4         empty  

When I install my second ubuntu with ubiquity from a live CD all works well (I can boot with my usb to my SSD) but when I update grub on the previous SSD (nvme0n1) because the previous configuration has been removed by the fresh installation I cannot boot anymore with my usb (but I can boot to the first SSD/nvme0n1)

I tried to install the second ubuntu with or without an EFI partition, with or without a bootloader. But the main point is that when I update grub from the first SSD/nvme0n1 it's not detecting the second ubuntu (os-prober does not find my second OS even if I mounted it)

The ideal situation for me would be to have my EFI and boot partitions on my usb with the rest of my second SSD in my computer, but I could also go for only my boot partition on a USB.

How to lock fan speed for amd gpu in Ubuntu 20.04?

Posted: 17 Aug 2021 12:16 PM PDT

I'm trying to lock RPM of my AMD Radeon videocard fans at the full speed:

echo 1 > /sys/class/hwmon/hwmon1/pwm1_enable  echo 255 > /sys/class/hwmon/hwmon1/pwm1  

What I have tried so far

Obviously, it doesn't work due to missing permissions (even with sudo/root) because it is /sys:

$ sudo su  $ echo 255 > /sys/class/drm/card1/device/hwmon/hwmon1/pwm1  bash: echo: write error: Invalid argument  

I have also tried sysfs config to edit these params but it didn't work:

$ cat /etc/sysfs.conf  class/drm/card1/device/hwmon/hwmon1/pwm1 = 255  class/drm/card1/device/hwmon/hwmon1/pwm1_enable = 1  

echo 5 | sudo tee ... also doesn't work.

Neither does sudo sh -c:

sudo sh -c 'echo 225 > /sys/class/drm/card1/device/hwmon/hwmon1/pwm1'  sh: 1: echo: echo: I/O error  

Archilinux Wiki states it should be possible though https://wiki.archlinux.org/index.php/fan_speed_control#Configuration_of_manual_control They edit values directly with echo and looks like it works for them.

Another guide also recommends configuring fans this way https://linuxconfig.org/overclock-your-radeon-gpu-with-amdgpu

Python amdgpu-fan package also doesn't work for me.

sudo fancontrol doesn't work as well:

$ sudo fancontrol  Loading configuration from /etc/fancontrol ...    Common settings:    INTERVAL=10    Settings for hwmon1/pwm1:    Depends on hwmon1/temp1_input    Controls     MINTEMP=10    MAXTEMP=60    MINSTART=50    MINSTOP=0    MINPWM=0    MAXPWM=255    AVERAGE=1    Enabling PWM on fans...  Starting automatic fan control...  /usr/sbin/fancontrol: line 649: echo: write error: Invalid argument  Error writing PWM value to /sys/class/hwmon/hwmon1/pwm1  Aborting, restoring fans...  Verify fans have returned to full speed  

Daemon (service) also doesn't work:

fancontrol[1877]:   MAXPWM=255  fancontrol[1877]:   AVERAGE=1  fancontrol[1877]: Enabling PWM on fans...  fancontrol[1877]: Starting automatic fan control...  fancontrol[1877]: /usr/sbin/fancontrol: line 649: echo: write error: Invalid argument  fancontrol[1877]: Error writing PWM value to /sys/class/hwmon/hwmon1/pwm1  fancontrol[1877]: Aborting, restoring fans...  fancontrol[1877]: Verify fans have returned to full speed  systemd[1]: fancontrol.service: Main process exited, code=exited, status=1/FAILURE  systemd[1]: fancontrol.service: Failed with result 'exit-code'.  

To sum up: seems that I can't edit /sys/ amdgpu-related entries at all

Part 2

It seems that there has to be another way around, like some amdgpu config or something like that. Maybe override kernel-defined values during boot?

In Windows, it's possible to tune fans directly from the AMD Radeon driver GUI app.

I don't want fancy curves, I'm simply trying to force lock static RPM (full-on mode). I'm using amdgpu-pro drivers, Ubuntu 20.04. I'd like to avoid using scripts like fancontrol

The question itself

I wonder if that's possible just to set pwm1_enable to 1 and pwm1 to 255? Looks like the suggested method should be working, but Ubuntu 20.04 security limitations are more restrictive than other distros' ones.

update This thing works! But only for 1-2 seconds, after that, fans go back to system-defined speed https://github.com/DominiLux/amdgpu-pro-fans/blob/master/amdgpu-pro-fans.sh

update 2

Disabling pwm works for about 1-2 seconds. echo 0 > /sys/class/hwmon/hwmon1/pwm1_enable

But after that, some daemon reverts this value back to 2. How could I prevent it from changing by other users except me? E.g. prevent it from changing by the system?

Filter script output during runtime

Posted: 17 Aug 2021 11:03 AM PDT

I have a script that runs about 10 other scripts in the background that constantly generate new output. I would like to keep that initial script running and be able to simply type in it to filter all the output displayed on the terminal in real time.

For the sake of simplicity let say each of these for loops represents one of my background scripts (The outputs contain color codes btw.):

for i in {0..1000} ; do      echo -e "\033[0;31mHello world\033[0m $i"      sleep 1  done &      for i in {0..1000} ; do      echo -e "\033[0;34mHello world\033[0m $i"      sleep 1  done &  

My first idea was to redirect all the output of the background scripts into a file and then use the read command to get a search query and pass it to grep like so:

for i in {0..1000} ; do      echo -e "\033[0;31mHello world\033[0m $i"      sleep 1  done >> ./output.txt 2>&1 &    for j in {0..1000} ; do      echo -e "\033[0;34mHello world\033[0m $j"      sleep 1  done >> ./output.txt 2>&1 &    while true ; do      read -p "Search: " query      clear      cat ./output.txt | grep "$query"  done  

But there are several issues with that.

Update problem: The output won't update when the output.txt file changes. So you have to repeatedly search again to get up-to-date results.

Color code problem: If I search for 3 it will print all lines because the color codes contains a 3. I could of course completely filter out the colors like so: cat ./output.txt | sed 's/\x1b\[[0-9;]*m//g' | grep "$query", but I don't want to lose the color in the final output so it's not that easy.

Disappearing input problem: Even if I'd manage to get new output to be printed in real time after hitting enter for a search, the user won't be able to type (or see, to be more accurate) his/her next search properly. I would like the filter text the user is typing to always be visible.

Any ideas how this could be accomplished?

Can't format USB storage at /dev/sdb

Posted: 17 Aug 2021 10:55 AM PDT

I have an 8GB USB storage and lsblk shows it is accessible at /dev/sdb.

When trying to:

sudo mkfs.ntfs -L "label" /dev/sdb  

I got:

/dev/sdb is entire device, not just one partition.  Refusing to make a filesystem here!  

What to do?

I'm on Ubuntu 18.04.

Using netcat and curl together in a bash script

Posted: 17 Aug 2021 12:04 PM PDT

This question is more related to infosec, but I can't seem to find a workaround in automating the following process:

There is a cURL command which triggers a connection to the netcat. Without automatization, I type in nc -lvnp 9191, and in another terminal I enter the cURL command which establishes a connection back to my machine at port 9191 which I can then execute some commands in a remote machine.

I am trying something like this in my bash script:

nc -lvnp 9191&    curl ......    

The netcat starts a listener, goes into the background, the cURL triggers the connection (I receive the connection back), but the netcat immediately closes.

$ ./shell.sh   Ncat: Version 7.70 ( https://nmap.org/ncat )  Ncat: Listening on :::9191  Ncat: Listening on 0.0.0.0:9191  Ncat: Connection from xxx.xxx.xxx.xxx.  Ncat: Connection from xxx.xxx.xxx.xxx:xxxxx.  $  

If I remove the nc -lvnp 9191& from the bash script and leave just the cURL command in the bash script, the following happens:

$ nc -lvnp 9191&    [1] 22609  Ncat: Version 7.70 ( https://nmap.org/ncat )                                                                                                     Ncat: Listening on :::9191  Ncat: Listening on 0.0.0.0:9191  $ ./shell.sh    Ncat: Connection from xxx.xxx.xxx.xxx.  Ncat: Connection from xxx.xxx.xxx.xxx:xxxxx.    cmd>    

However, once I click 'enter', the netcat job gets suspended immediately:

[1]  + 22609 suspended (tty input)  nc -lvnp 9191  

I have to fg to resume the netcat job and continue working, but I was wondering if I could somehow save myself from all this trouble within the bash script itself.

How to get persistent (permanent) smb mount using kerberos authentication on RHEL7?

Posted: 17 Aug 2021 11:28 AM PDT

Environment: I have joined a few of my RHEL 7.3 boxes with MS AD domain using realmd/sssd. I have allowed only members of a few allowed groups can login to the box. Credentials caching is disabled. All works well without any problem.

What I need to achieve next: I want one Windows SMB share to be permanently mounted to the Linux (in the fstab or else) using Kerberos(passwordless).

What I have achieved so far: I am able to mount the Windows SMB path, but it expires when the manually generated TGT ticket expires.

How I'm doing it: I generate TGT ticket using 'kinit'

then TGT ticket for cifs mount using kvnp

Then making an entry in the fstab with 'sec=krb5' and providing the uid of the desired service account.

Using the above the SMB share is mounted successfully but expires in 9 hours upon expiration of the TGT ticket.

Please suggest if there is something that I can do to make the mount permanent.

Note: I'm not modifying the TGT ticket expiration time thinking it may cause some security or compliance concerns.(please, correct me if I'm wrong).

How to show the host name in Linux commandline prompt

Posted: 17 Aug 2021 11:10 AM PDT

I have several VMs and right now my command-line prompt looks like -bash-3.2$; identical on every VM, because it doesn't contain the host name. I need to always see which VM I'm on using hostname before I do any operation. How can I add the host name to the shell prompt?

ENV: CentOS/ssh

SELinux is preventing /opt/google/chrome/chrome-sandbox from write access on which file?

Posted: 17 Aug 2021 10:06 AM PDT

I keep getting the following error ever since upgrading to Chrome google-chrome-stable-42.0.2311.90-1.x86_64.

SELinux is preventing /opt/google/chrome/chrome-sandbox from write access on the file .

I have not installed any custom plugins or modified my Chrome settings. Various search on Google turns up bug reports being closed as not a bug, and instructions on how to bypass SELinux by applying custom policy.

The SELinux troubleshooter suggested the following:

SELinux is preventing /opt/google/chrome/chrome-sandbox from write access on the file .    *****  Plugin chrome (98.5 confidence) suggests   ****************************    If you want to use the plugin package  Then you must turn off SELinux controls on the Chrome plugins.  Do  # setsebool -P unconfined_chrome_sandbox_transition 0    *****  Plugin catchall (2.46 confidence) suggests   **************************    If you believe that chrome-sandbox should be allowed write access on the  file by default.  Then you should report this as a bug.  You can generate a local policy module to allow this access.  Do  allow this access for now by executing:  # grep chrome-sandbox /var/log/audit/audit.log | audit2allow -M mypol  # semodule -i mypol.pp      Additional Information:  Source Context                unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c                                0.c1023  Target Context                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1                                023  Target Objects                 [ file ]  Source                        chrome-sandbox  Source Path                   /opt/google/chrome/chrome-sandbox  Port                          <Unknown>  Host                          fqdn  Source RPM Packages           google-chrome-stable-42.0.2311.90-1.x86_64  Target RPM Packages             Policy RPM                    selinux-policy-3.12.1-197.fc20.noarch  Selinux Enabled               True  Policy Type                   targeted  Enforcing Mode                Enforcing  Host Name                     fqdn  Platform                      Linux fqdn 3.19.4-100.fc20.x86_64 #1 SMP                                Mon Apr 13 21:46:59 UTC 2015 x86_64 x86_64  Alert Count                   68  First Seen                    2015-04-25 18:15:53  Last Seen                     2015-04-30 20:51:59  Local ID                      ab14f    Raw Audit Messages  type=AVC msg=audit(123.456:300): avc:  denied  { write } for  pid=3642 comm="chrome-sandbox" name="oom_adj" dev="proc" ino=52951 scontext=unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=file permissive=0      type=SYSCALL msg=audit(123.456:300): arch=x86_64 syscall=openat success=no exit=EACCES a0=3 a1=402138 a2=1 a3=0 items=0 ppid=3480 pid=3642 auid=1000 uid=1000 gid=1000 euid=0 suid=0 fsuid=0 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=1 comm=chrome-sandbox exe=/opt/google/chrome/chrome-sandbox subj=unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 key=(null)    Hash: chrome-sandbox,chrome_sandbox_t,unconfined_t,file,write  

I do not quite agree with the recommendation to turn off SELinux controls on Chrome Plugins. I also do not know what write access on file . means. Is it current folder of chrome-sandbox? I tried searching for the inode 52591, but could not find the file.

Can anyone explain what is the problem and how this issue can be resolved?

Passing named arguments to shell scripts

Posted: 17 Aug 2021 10:14 AM PDT

Is there any easy way to pass (receive) named parameters to a shell script?

For example,

my_script -p_out '/some/path' -arg_1 '5'  

And inside my_script.sh receive them as:

# I believe this notation does not work, but is there anything close to it?  p_out=$ARGUMENTS['p_out']  arg1=$ARGUMENTS['arg_1']    printf "The Argument p_out is %s" "$p_out"  printf "The Argument arg_1 is %s" "$arg1"  

Is this possible in Bash or Zsh?

How can I reduce a video's size with ffmpeg?

Posted: 17 Aug 2021 10:08 AM PDT

How can I use ffmpeg to reduce the size of a video by lowering the quality (as minimally as possible, naturally, because I need it to run on a mobile device that doesn't have much available space)?

I forgot to mention that when the video can use subtitles (*.srt or *.sub), I'd like to convert them too to fit the parameters of the converted video file.

No comments:

Post a Comment