Sunday, June 19, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Linux scrollwheel "Jump back" when I scroll

Posted: 19 Jun 2022 01:19 PM PDT

I have a very frustrating problem, I THINK the real problem is bad hardware, but I have had the problem with multiple brands (including logitech) so I assume the windows driver fix this and thus no reason to spend money on proper hardware.

Using

xev|grep "state 0x10"  

to track events on mouse gives this when scrolling down on wheel. Do anyone have a fix for this problem, I figure it should just ignore any 0x10 if there is no 0x1010

state 0x1010, button 5, same_screen YES  state 0x10, button 4, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 4, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 4, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 4, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 5, same_screen YES  state 0x1010, button 5, same_screen YES  state 0x10, button 5, same_screen YES  

Have anyone a solution

How do I kill all subprocesses spawned by my bash script?

Posted: 19 Jun 2022 01:10 PM PDT

I have a script that looks like this. Invoked with ./myscript.sh start

#!/bin/bash  if [[ "$1" == "start" ]]; then    echo "Dev start script process ID: $$"      cd /my/path1    yarn dev &> /my/path/logs/log1.log &    echo "started process1 in background"    echo "Process ID: $!"    echo "Logging output at logs/log1.log"    sleep 2      cd /my/path2    yarn start:dev &> /my/path/logs/log2.log &    echo "started process2 in background"    echo "Process ID: $!"    echo "Logging output at logs/log2.log"    sleep 2      cd /my/path2    yarn dev &> /my/path/logs/log3.log &    echo "started process3 in background"    echo "Process ID: $!"    echo "Logging output at logs/log3.log"  elif [[ "$1" == "stop" ]]; then    killall node   else    echo "Invalid argument"  fi  

When i run ps after I run this script, i can see a bunch of node processes (more than 3) that I assume has been started by the yarn dev commands. I want to run ./myscript.sh stop and stop all the node processes that were spawned from my previous run of ./myscript.sh start

How do I make this happen?

identify writable files and duplicates them, making the duplicate hidden and read-only

Posted: 19 Jun 2022 12:14 PM PDT

I thought through find . -type f -perm and mv test_folder .test_folder, failed

Make Samba report 0 bytes free to Windows

Posted: 19 Jun 2022 11:30 AM PDT

I have a Debian server running my samba share and use Win11 clients to mount it.

Everything is working, I just had to change the dfree command to

#!/bin/sh  df $1 | tail -1 | awk '{print $2" "$4}'  

per https://www.linuxtopia.org/online_books/network_administration_guides/using_samba_book/ch08_06_02.html because of different mounting points etc.

For a particular share I intentionally want to report it as "0 bytes free" always. I tried setting the second parameter $4 to "0" - Windows now shows "1 MB free of ...". Setting it to 1 yields "1 KB free of". The latter I actually understand, since sizes are given in KB. But why does "0" default to 1MB? Setting it to any other size also yields this value in KB. But I want it to be 0!

What is the equivalent of "task_struct" in linux's <linux/sched.h> for Mac OS?

Posted: 19 Jun 2022 10:02 AM PDT

I want to understand the Process Control block of Mac OS and Linux. For Lionux it was pretty strightforward, there was a post here asking about the same thing and someone replied to go take a look at "task_struct" in <linux/sched.h>. However i am finding it more difficult to find the equivalent information for Mac OS, someone in apple's developer forum asked a similar question and got told to look at proc_info.h and proc.h, but i am lost as to which struct i should be looking at. Is there a task_struct equivalent in Mac OS?

Restoring filesystem of an extended root partition

Posted: 19 Jun 2022 10:01 AM PDT

I have a Debian/Windows 10 dual boot with a shared partition in between and I tried to extend my Linux root partition because I was running out of space. I made some space but splitting the SHARED partition then deleted and re-created the Linux one with a start sector before the former one: (Linux is the 55.40Go partition)

Partitions

Now the Linux partition filesystem is not recognized anymore (For my information, if I had extended it from the end sector or used resize2fs, would it have been right?), so I am looking for a way to say "hey this partition is actually an EXT4". I guess all the relevant informations are now in the middle of the partition and not at the beginning, maybe I can move it to the right place?

If not, maybe I can reset it to the former start sector? (I expended it by 10,000 MiB)

In any case, I can reinstall everything, I backed up all my data but I am curious to know if I can fix it.

How Can I Open Multiple Files With xdg-open

Posted: 19 Jun 2022 10:28 AM PDT

Let's say I run xdg-open file.flac. It will be equivalent to mpv file.flac. But if I run xdg-open *.flac, it will give me an error because it thinks that the other files are "unexpected arguments". What I want it to do is run mpv *.flac.

can't connect to my minecraft server that uses ngrok

Posted: 19 Jun 2022 08:27 AM PDT

So I'm in the following situation: I have two computers: Computer A which is Linux: which have ngrok in the background and minecraft forge 1.18.2 server running

And computer B which is windows 11: they have Minecraft Java Forge 1.18.2

Problem: On computer B, I can't connect to the URL given by ngrok from computer A

Can someone help me?

How to update kernel and which version do I need to update to to fix usb driver

Posted: 19 Jun 2022 08:09 AM PDT

I have a problem with the usb driver for my serial port. In the kernel version that I am on (5.15.32-v8+) the driver does not work. It does work on an earlier 5.10.x that was installed as part of Raspberry Pi Os Buster but on the latest (bullseye) it does not work.

It seems this was discussed here and presumably a fix put in place. According to this discussion this is the commit that fixes the issue.

So I need to try and figure out which version of the kernel includes that fix and then update the kernel on my raspberry pi to that version.

  • How do I find out the version of the kernel that includes that commit?
  • How do I update the kernel
  • are there any dangers to updating the kernel in my OS install - is it likely to have any damaging effects?

Many thanks

Using "chmod -R 666 filename" does not give all files writing permissions

Posted: 19 Jun 2022 09:02 AM PDT

I have been running as root in a Linux Virtual Machine to change permissions to a whole list of files within a directory. When I check the permissions after using sudo chmod 666 -R /home/candidate/working/other_files, all the files have read and write privileges besides one hidden file (highlighted in the image). I am not sure how I can make it so that file will also have write privileges when I specifically wrote the chmod command that should give all the files read and write privileges.

The file .. does not have write permission for all other users after using chmod:

root@d3ac9495a31:/home/candidate/working# chmod -R 666 /home/candidate/working/other_files/  root@d3ac9495a31:/home/candidate/working# ls -la other_files  total 14108  drw-rw-rw- 1 root      root         4096 Feb 27  2018 .  drwxrwxr-x 1 candidate candidate    4096 Feb 27  2018 ..  -rw-rw-rw- 1 root      root      4537584 Feb 27  2018 file1.html  drwxrwxr-x 1 root      root      1123786 Feb 27  2018 file2.html  -rw-rw-rw- 1 root      root      5747804 Feb 27  2018 file3.html  -rw-rw-rw- 1 root      root      3013094 Feb 27  2018 file4.html  

Write a regular expression whose output will only be rows in a range 01/03/2021 - 01/03/2020

Posted: 19 Jun 2022 09:01 AM PDT

I have a file that got dates from 01/01/2020 to 04/04/2021 I want to get only the dates between 01/03/2020 to 01/03/2021 by using egrep. I tried to do

egrep "([0][1-9]|[1-2][0-9]|[3][0]/[0][3-9]|[1][0-2]/[2][0][2][0-1])$" dates.txt  

but it is still giving me all the dates in the file:

$ cat dates.txt   01/01/2020  24/01/2020  04/02/2020  23/02/2020  01/03/2020  13/03/2020  14/04/2020  29/05/2020  16/06/2020  17/07/2020  18/08/2020  19/09/2020  20/10/2020  21/11/2020  22/12/2020  23/01/2021  24/02/2021  01/03/2021  25/03/2021  04/04/2021  

Would a carriage return ^M in SSH key make a difference?

Posted: 19 Jun 2022 12:15 PM PDT

I cloned a git repo to a server that had same files scattered in different places. Then I compared two directories (cloned one to existing one) to make sure that they were exactly the same. The comp command showed that there is only one difference and that is in an ssh key on the remote server files. There is carriage return ^M present in the remote file. Would that change the key? If yes, how can I remove the carriage return in vim.

How can I repeat only a part of a command in bash?

Posted: 19 Jun 2022 08:20 AM PDT

I'd like to know if it's possible to just repeat part of a command. I.e. if I do ls /path/to/somewhere -a, I only want to remove ls and -a.

I know that if I do !! it repeats the previous command (appending the last command to whichever command you write before it) and that if I do !$ it includes the last part of the string, but I'd like to know if it's possible to re-use only the e.g. middle part of the previous command.

Why is my command giving wrong output?

Posted: 19 Jun 2022 10:50 AM PDT

I m trying to output lines if col 1 has digit value , but its not working. My sample file doesn't have digit in col 1 so shouldnt awk return nothing in this case?

my code

awk -F 'BEGIN {OFS=FS}{ if ( ( $2 ~/aaa/ || $2 ~/bbb/ || $2~/ccc/) && $1 ~ "[[:digit:]]$")print}' file    

cat file

8F3FTO|aaa|278346|  TYF98|bbb|89237|  YUG198|ccc|29834|  aljs23456|ccc|241298|    

my code returns

aljs23456|ccc|241298  

systemd resource control -- all users/root

Posted: 19 Jun 2022 10:27 AM PDT

I'm using Debian Bullseye with systemd 247. I have more than a hundred of users and I would like to enforce some limits using cgroups. I use set-property, which works as expected, for example for the memory and AllowedCPUs properties:

systemctl set-property user.slice MemoryHigh=300G  systemctl set-property user.slice MemoryMax=305G  systemctl set-property user.slice AllowedCPUs=9-64  

The idea is to allow ordinary users to use 80-90% of the memory and most of the CPUs. The other 10-20% of the resources should always be available for other slices and for the root user (we were very liberal with setting the limits and recently we accidentally were fork-bombed by a student).

But the limits seems to also affect the root user and I cannot find a user@0.slice or anything like that. The idea is to allow the root to use the spare resources if thigs go wrong and always have some spare I/O, memory and CPU aside. cgroups seems like a good idea, because all switches are there. Could someone help and tell how to achieve this goal or give some general best practices with systemd/cgroups in multiuser environment? Or am I doing this completely wrong and this should be done differently?

Proposed answer (June 19th, 2022):

I think I managed to do it as described below, but I do not know if this is a "right" way to do it.

  • systemd has a hierarchy within drop-in directories. In general, the more specific drop-in directories definitions override the less specific ones. (https://www.freedesktop.org/software/systemd/man/systemd.unit.html#)
  • /etc/systemd/system/user-.slice.d/somethin.conf will be overriden by /etc/systemd/system/user-0.slice.d/something.conf. Limits set in the former directory will apply to all users including root, but the definitions in the latter directory will override them and apply only to root. (https://www.freedesktop.org/software/systemd/man/user@.service.html)
  • Using spare resources reserved for the root user requires a proper root login, for example on a TTY or through a console in case of a virtual machine. sudo or su are methods of elevating privileges, but do not hook into cgroup system (or at least I do not know how to do this). Using sudo or su the user is still bound by the user-UID@ slice limits.

Kind Regards
~~
K.

Cannot shutdown computer or connect to Wi-Fi when /proc is mounted with hidepid=noaccess

Posted: 19 Jun 2022 09:37 AM PDT

When I modify /etc/fstab for security and privacy purposes to mount /proc like so:

# grep proc /etc/fstab   proc /proc proc rw,nosuid,nodev,noexec,relatime,hidepid=noaccess 0 0  

then I cannot connect to Wi-Fi by NetworkManager, it will say that I do not have the necessary permission:

Connection failure  Connection activation failed  Not authorized to control networking.  

Also, I cannot shut down the computer from the "Logout" menu by the window manager / desktop shell. A similar message appears and/or the button is greyed out (depending on where I try).

Is it possible that polkitd needs some proc feature (to see other users' processes? why?) to do its job?

Is there a way to make these things work again without removing the /etc/fstab line?

Postfix: enable DKIM signing on local non-secure submissions to port 25

Posted: 19 Jun 2022 09:26 AM PDT

I have a Postfix server which accepts outgoing mail submissions from local network on port 587 (TLS) which requires authentication, signs them with OpenDKIM and they get delivered nice and clean into peoples' inboxes rather than spam folders. Not bad.

The server also accepts mail on port 25. This works for both incoming mail addressed to the server, and relay submissions addressed outside (allowed from local network only). Not bad too.

The only issue is that outgoing messages submitted to port 25 do not get signed with DKIM. For local applications wishing to send mail outside, I want to use port 25 rather than 587 because the local network is trusted — there is no need for either TLS or auth, so no need to complicate the software and compromise on latency and resource use.

How do I get Postfix sign outgoing mail with DKIM for local submissions on port 25 — in addition to how it already does it on port 587?

Relevant lines from main.cf:

# Milter configuration  milter_default_action = accept  milter_protocol = 6  smtpd_milters = local:opendkim/opendkim.sock  non_smtpd_milters = local:opendkim/opendkim.sock  

How Can I Find Five Numbers Between Two Numbers

Posted: 19 Jun 2022 08:43 AM PDT

Suppose I have these two numbers: 800000 and 3200000. I want to find five numbers with an even difference in between these two numbers. Therefore, I want the output to be:

800000  1200000  1600000  2000000  2400000  2800000  3200000  

I know about the seq command but I'm not sure how to do this.

Linux gpg Conflicting values set

Posted: 19 Jun 2022 08:48 AM PDT

I am using Ubuntu 22.04, How can I fix this problem

E: Conflicting values set for option Signed-By regarding source https://packages.microsoft.com/repos/ms-teams/ stable: /usr/share/keyrings/ms-teams.gpg !=   E: The list of sources could not be read.  

Connection refused to connect a TCP/IP device

Posted: 19 Jun 2022 09:32 AM PDT

I'm trying to connect a TCP/IP device over ethernet adapter via ethernet cable. The connection is being seen in Network Manager and I can get output of ping command at least and I can't access a built-in web page of device. I am getting error "Connection refused" for telnet command. But, this problems are not in another operating system non-linux. So, I think I should change iptables, firewall or proxy settings. What should I do to connect web page of device and device itself via its default open port that is 8003? Thanks for your help in the future.

Several outputs: (the *s is added by me.)

$ ip a  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      inet6 ::1/128 scope host          valid_lft forever preferred_lft forever  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000      link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff      inet 169.254.227.2/16 brd 169.254.255.255 scope link noprefixroute eth0         valid_lft forever preferred_lft forever      inet6 ****:****:****:****:****/64 scope link noprefixroute          valid_lft forever preferred_lft forever  3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff      inet 80.***.**.***/23 brd 80.***.**.255 scope global dynamic noprefixroute wlan0         valid_lft 1626sec preferred_lft 1626sec      inet6 ****:****:****:****:****/64 scope link noprefixroute          valid_lft forever preferred_lft forever      $ ping 169.254.227.2  PING 169.254.227.2 (169.254.227.2) 56(84) bytes of data.  64 bytes from 169.254.227.2: icmp_seq=1 ttl=64 time=0.065 ms  64 bytes from 169.254.227.2: icmp_seq=2 ttl=64 time=0.079 ms  64 bytes from 169.254.227.2: icmp_seq=3 ttl=64 time=0.083 ms  64 bytes from 169.254.227.2: icmp_seq=4 ttl=64 time=0.079 ms  64 bytes from 169.254.227.2: icmp_seq=5 ttl=64 time=0.095 ms  64 bytes from 169.254.227.2: icmp_seq=6 ttl=64 time=0.081 ms  ^C  --- 169.254.227.2 ping statistics ---  6 packets transmitted, 6 received, 0% packet loss, time 103ms  rtt min/avg/max/mdev = 0.065/0.080/0.095/0.011 ms      $ telnet 169.254.227.2 8003  Trying 169.254.227.2...  telnet: Unable to connect to remote host: Connection refused  

There are extra some informations. I can configure device's IP address by hand on its panel (default 169.254.227.2) and its MAC address is 00:19:F9:18:02:E2.

And to be able to device, I'm configuring ethernet connection on Network Manager that cover infos (this informations is included device's manual): - The Method: by hand - Adress: 169.254.227.2 - Net Mask: 255.255.0.0 - Gateway: 0.0.0.0 - DNS: 0.0.0.0 But the MAC address is ::::: that belonging to eth0 an I can't change this situation.

Actually, I tried to use DHCP but my trying it fails. Can you suggestion how I configure dhcpd.conf file and network connections. Finally, I attached the last outputs.

$ ip a  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      inet6 ::1/128 scope host          valid_lft forever preferred_lft forever  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000      link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff      inet 169.254.227.2/16 brd 169.254.255.255 scope link noprefixroute eth0         valid_lft forever preferred_lft forever      inet6 ****:****:****:****:****/64 scope link noprefixroute          valid_lft forever preferred_lft forever  3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff      inet 80.***.**.***/23 brd 80.***.**.255 scope global dynamic noprefixroute wlan0         valid_lft 1277sec preferred_lft 1277sec      inet6 ****:****:****:****:****/64 scope link noprefixroute          valid_lft forever preferred_lft forever        $ less /etc/network/interfaces  # interfaces(5) file used by ifup(8) and ifdown(8)  # The loopback network interface  auto lo  iface lo inet loopback  # The primary network interface  auto eth0  iface eth0 inet dhcp        $ less /etc/dhcp/dhcpd.conf  default-lease-time 600;  max-lease-time 7200;  authoritative;     subnet 192.168.1.1  netmask 255.255.0.0 {   range 192.168.1.100 192.168.1.200;   option routers 192.168.1.254;   option domain-name-servers 192.168.1.1, 192.168.1.2;  #option domain-name "mydomain.example";  }    host archmachine {  hardware ethernet 00:19:F9:18:02:E2;  fixed-address 192.168.1.20;  }  

AMD GPU not being used by Debian

Posted: 19 Jun 2022 09:59 AM PDT

I'm running Debian 10 with kernel 5.10 via buster backports. The installed driver for amd is amdgpu and the output of dmesg from my understanding tells me the driver is being recognized,

[    2.774224] [drm] amdgpu kernel modesetting enabled.  [    2.774409] amdgpu: Topology: Add CPU node  [    2.774596] amdgpu 0000:03:00.0: amdgpu: Trusted Memory Zone (TMZ) feature not supported  [    2.792960] amdgpu 0000:03:00.0: amdgpu: Fetched VBIOS from ATRM  [    2.792962] amdgpu: ATOM BIOS: BR64533.001  [    2.811910] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_k_mc.bin  [    2.811918] amdgpu 0000:03:00.0: amdgpu: VRAM: 2048M 0x000000F400000000 - 0x000000F47FFFFFFF (2048M used)  [    2.811919] amdgpu 0000:03:00.0: amdgpu: GART: 256M 0x000000FF00000000 - 0x000000FF0FFFFFFF  [    2.811996] [drm] amdgpu: 2048M of VRAM memory ready  [    2.811997] [drm] amdgpu: 3072M of GTT memory ready.  [    2.812695] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_pfp_2.bin  [    2.812704] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_me_2.bin  [    2.812712] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_ce_2.bin  [    2.812721] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_rlc.bin  [    2.812776] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_mec_2.bin  [    2.812832] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_mec2_2.bin  [    2.813340] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_sdma.bin  [    2.813348] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_sdma1.bin  [    2.813383] amdgpu: hwmgr_sw_init smu backed is polaris10_smu  [    2.813465] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_uvd.bin  [    2.814530] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_vce.bin  [    2.815130] amdgpu 0000:03:00.0: firmware: direct-loading firmware amdgpu/polaris12_k_smc.bin  [    3.051566] amdgpu 0000:03:00.0: amdgpu: SE 2, SH per SE 1, CU per SH 5, active_cu_number 10  [    3.055642] [drm] Initialized amdgpu 3.40.0 20150101 for 0000:03:00.0 on minor 1  

and lshw -c video shows both the integrated and dedicated GPU

*-display                          description: VGA compatible controller         product: Intel Corporation         vendor: Intel Corporation         physical id: 2         bus info: pci@0000:00:02.0         version: 02         width: 64 bits         clock: 33MHz         capabilities: pciexpress msi pm vga_controller bus_master cap_list rom         configuration: driver=i915 latency=0         resources: irq:130 memory:c1000000-c1ffffff memory:a0000000-afffffff ioport:4000(size=64) memory:c0000-dffff    *-display         description: Display controller         product: Advanced Micro Devices, Inc. [AMD/ATI]         vendor: Advanced Micro Devices, Inc. [AMD/ATI]         physical id: 0         bus info: pci@0000:03:00.0         version: c0         width: 64 bits         clock: 33MHz         capabilities: pm pciexpress msi bus_master cap_list rom         configuration: driver=amdgpu latency=0         resources: irq:131 memory:b0000000-bfffffff memory:c0000000-c01fffff ioport:3000(size=256) memory:c2300000-c233ffff memory:c2340000-c235ffff  

However when I run glxinfo -B or DRI_PRIME=1 glxinfo -B the output is

name of display: :0  display: :0  screen: 0  direct rendering: Yes  Extended renderer info (GLX_MESA_query_renderer):      Vendor: VMware, Inc. (0xffffffff)      Device: llvmpipe (LLVM 7.0, 256 bits) (0xffffffff)      Version: 18.3.6      Accelerated: no      Video memory: 15817MB      Unified memory: no      Preferred profile: core (0x1)      Max core profile version: 3.3      Max compat profile version: 3.1      Max GLES1 profile version: 1.1      Max GLES[23] profile version: 3.0  OpenGL vendor string: VMware, Inc.  OpenGL renderer string: llvmpipe (LLVM 7.0, 256 bits)  OpenGL core profile version string: 3.3 (Core Profile) Mesa 18.3.6  OpenGL core profile shading language version string: 3.30  OpenGL core profile context flags: (none)  OpenGL core profile profile mask: core profile     OpenGL version string: 3.1 Mesa 18.3.6  OpenGL shading language version string: 1.40  OpenGL context flags: (none)     OpenGL ES profile version string: OpenGL ES 3.0 Mesa 18.3.6  OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00  

I have tried running programs that could use the GPU as well but they seem to keep using the VMWare llvmpipe gpu, the output of radeontop always shows up as 0%. How do I get my machine to use amdgpu?

Set retries on rsync to have fixed time between them

Posted: 19 Jun 2022 10:07 AM PDT

I have been having rsync try five times to connect. I have been getting exit codes of 11 indicating a file I/O error. When I try using robocopy I get an error 59 when I copy a set of files to the same target.

The thing is that robocopy succeeds where rsync fails, and when I looked in the robocopy logs I noticed right after it got the error that it did a retry 30 seconds later. I need to use rsync so I am wondering how to set up rsync to do a retry for say a network error 30 seconds later. This only happens say 5 times during a transfer of over 200K of files with varying sizes. When I look at the rsync logs immediately after code 11 it immediately requests the list of files from the source to get and it exits with that same exit code of 11 indicating to me it failed.

Command-line

rsync -rtlzv -e "ssh -i c:/RsyncKeys/wa-ecy-gov-test-rsync-key -o ConnectTimeout=140 -o ConnectionAttempts=18" --quiet --stats --exclude-from='rsyncfilter.txt' --force --delete cran-rsync@cran.r-project.org: //sdceco/Apps/RSTUDIO/RpackagesNew  --timeout=320 --log-file=c:/rsynclogs/rsync11-05-2020.log  

Many thanks for any advice!

grub2 error disk 'hd0,msdos1' not found, ls shows no disk

Posted: 19 Jun 2022 09:01 AM PDT

I have googled a lot for this problem. I found this, but it didn't solve my problem. Other solutions suggest me to reinstall grub (run grub-install), which didn't work either.

Here is what I am doing: (my grub version is 2.02)

  1. I use grub2-mkrescue to make my X.iso
  2. I boot a VMWareWorkstation virtual machine, which has a 1.0GB SATA disk, from X.iso
  3. I install X.iso on disk, the details are:

3.1. erase /dev/sda in case there are old partitions on it: dd if=/dev/zero of=/dev/sda bs=1M count=1

3.2. Create 3 primary partitions on /dev/sda as dev/sda1,sda2,sda3 (the size is 100M, 30M and 70M), and toggle sda1 to be bootable

Disk /dev/sda: 1024 MB, 1073741824 bytes, 2097152 sectors  130 cylinders, 255 heads, 63 sectors/track  Units: sectors of 1 * 512 = 512 bytes    Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type  /dev/sda1 *  0,1,1       12,191,50           63     204862     204800  100M 83 Linux  /dev/sda2    12,191,51   16,147,2        204863     266302      61440 30.0M 83 Linux  /dev/sda3    16,147,3    25,127,37       266303     409662     143360 70.0M 83 Linux  

3.3. Format the 3 partitions as ext2, and mount /dev/sda1

mkfs.ext2 /dev/sda1  mkfs.ext2 /dev/sda2  mkfs.ext2 /dev/sda3  ROOTFS_PATH=/var/.rootfs  mkdir $ROOTFS_PATH  mount /dev/sda1 $ROOTFS_PATH  

3.4 copy files...

for i in bzImage initrd.img vmlinuz-*; do      cp -rf /boot/$i $ROOTFS_PATH/boot  done  cp -f /boot/grub/device.map $ROOTFS_PATH/boot/grub/device.map  for i in init linuxrc; do      cp -rf /$i $ROOTFS_PATH  done  for i in bin etc lib sbin share usr; do      cp -a /$i $ROOTFS_PATH  done  for i in dev var proc sys tmp data log; do      mkdir -p $ROOTFS_PATH/$i  done  

3.5 Install grub and make grub config file

chroot $ROOTFS_PATH <<EOF  mount -a  mdev -s  grub-install $tdisk  grub-install --recheck $tdisk  grub-mkconfig -o /boot/grub/grub.cfg  exit  EOF  
  1. reboot

It says:

.  error: disk 'hd0,msdos1' not found  Entering rescue mode...  grub rescue>  

And the most strange thing is that ls command shows nothing in grub-rescue cli ---- as someone says, it should show disk list.

error after reboot

How to use mapfile/readarray

Posted: 19 Jun 2022 08:38 AM PDT

I have some code similar to this:

while read -r col1 col2 col3 col4 col5 col6 col7 col8 TRASH; do           echo -e "${col1}\n${col2}\n${col3}\n${col4}\n${col5}\n${col6}\n"  done< <(ll | tail -n+2 | head -2)  

(I'm not actually using ls / ll but I believe this redacted example displays the same issue I am having)

The problem is I need a conditional statement if ll | tail -n+2 | head -2 fails so I'm trying to create a mapfile instead and then read through it in a script. The mapfile gets created properly but I don't know how to redirect it in order to be properly read.

code

if ! mapfile -t TEST_ARR < <(ll | tail -n+2 | head -2); then          exit 1  fi  while read -r col1 col2 col3 col4 col5 col6 col7 col8 TRASH; do           echo -e "${col1}\n${col2}\n${col3}\n${col4}\n${col5}\n${col6}\n"  done<<<"${TEST_ARR[@]}"  

mapfile contents

declare -a TEST_ARR=(          [0]="drwxr-xr-x@ 38 wheel   1.2K Dec  7 07:10 ./"           [1]="drwxr-xr-x  33 wheel   1.0K Jan 18 07:05 ../"  )  

output

$ while read -r col1 col2 col3 col4 col5 col6 col7 col8 TRASH; do  >             echo -e "${col1}\n${col2}\n${col3}\n${col4}\n${col5}\n${col6}\n"  >     done<<<"${TEST_ARR[@]}"  drwxr-xr-x@  38  wheel  1.2K  Dec  7  

String redirect is clearly wrong in this case but I'm not sure how else I can redirect my array.

How to set NTP tinker step (which unit)? and how to query?

Posted: 19 Jun 2022 12:05 PM PDT

One of the workaround for old CentOS/CentOS kernel (6.1-6.3) which may "Systems hang due to leap-second livelock." (quoting redhat), is to set tinker step in /etc/ntp.conf. Bug the documentation is not clear about the unit/syntax (http://doc.ntp.org/4.2.6p5/miscopt.html#tinker).

What is the exact syntax (unit) for tinker step?

Also, how can I query the current value of tinker step on a running NTP daemon?

Any better alternative to chroot on an OpenVZ VPS?

Posted: 19 Jun 2022 01:05 PM PDT

Are there any better alternative to chroot environment? I'm thinking about running nginx on a jailed environment.

BTW, I'm on OpenVZ VPS, so modifying the Kernel is a no-no.

(I think that prevents me from installing SELinux, AppArmor, etc.)

Limit memory usage for a single Linux process

Posted: 19 Jun 2022 12:56 PM PDT

I'm running pdftoppm to convert a user-provided PDF into a 300DPI image. This works great, except if the user provides an PDF with a very large page size. pdftoppm will allocate enough memory to hold a 300DPI image of that size in memory, which for a 100 inch square page is 100*300 * 100*300 * 4 bytes per pixel = 3.5GB. A malicious user could just give me a silly-large PDF and cause all kinds of problems.

So what I'd like to do is put some kind of hard limit on memory usage for a child process I'm about to run--just have the process die if it tries to allocate more than, say, 500MB of memory. Is that possible?

I don't think ulimit can be used for this, but is there a one-process equivalent?

No comments:

Post a Comment