Sunday, March 20, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Is it possible to "daemonize a command"?

Posted: 20 Mar 2022 05:25 PM PDT

I have a command line utility which is able to receive an image via stdin and convert it to a different format and output it to stdout.

I use this from a program, but every time I run it, a subprocess needs to be invoked which is very slow.

So I wonder is there a way, ideally using systemd, to turn this command line program into a "server" that remains in memory and somehow is able to receive image data and output it?

Giving superuser access to user directory binaries

Posted: 20 Mar 2022 04:43 PM PDT

I am new to linux.

I have installed rust on a linux box (AWS EC2) using the official documentation. The binaries are installed in my home directory and the paths have been added to the $PATH variable. As such I can use the cargo ... command with any local directories. However, when I try to run sudo cargo ..., I get cargo: command not found. I believe this is happening because the binaries for cargo, rust, etc. are not in the /usr/bin/ folder.

How do I give the superuser access to these binaries? Do I have to move them to the /usr/bin/ directory?

Any insights or pointers in the right direction would be greatly appreciated. Thanks

KDE display not working on NixOS - Thinkpad P15 Gen 2, NVIDIA RTX A4000

Posted: 20 Mar 2022 04:38 PM PDT

I'm trying to install NixOS on a new Thinkpad P15 Gen 2, and I can't get the desktop environment to show anything on my screen. Anytime I turn it on or reboot, the screen stays black until I ctrl+alt+F4 to get into a shell. I'm trying to use KDE Plasma 5, but I'm willing to try other DEs if they might work better. I used an installer ISO with KDE on it and it was able to show the graphical displays and everything. Then after installing on my partition, I can't get a graphical display going.

Here is my configuration.nix (current channel is nixos/21.11):

{ config, pkgs, ... }:    {    imports =      [ # Include the results of the hardware scan.        ./hardware-configuration.nix      ];      # Use the systemd-boot EFI boot loader.    boot.loader.systemd-boot.enable = true;    boot.loader.efi.canTouchEfiVariables = true;      boot.kernelPackages = pkgs.linuxPackages_5_16;      networking.hostName = "fins-thinkpad"; # Define your hostname.        networking.networkmanager.enable = true;  # Easiest to use and most distros use this by default.      # Nvidia drivers unfree    nixpkgs.config.allowUnfree = true;      # Enable the X11 windowing system.    services.xserver.enable = true;      # Enable the Plasma 5 Desktop Environment.    services.xserver.displayManager.sddm.enable = true;    services.xserver.desktopManager.plasma5.enable = true;    services.xserver.videoDrivers = [ "nvidia" ];    hardware.opengl.enable = true;      users.users.finley = {      isNormalUser = true;      extraGroups = [ "wheel" ]; # Enable 'sudo' for the user.    };      environment.systemPackages = with pkgs; [      vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.      wget      firefox    ];      system.stateVersion = "22.05"; # Did you read the comment?  }  

And my hardware-configuration.nix:

{ config, lib, pkgs, modulesPath, ... }:    {    imports =      [ (modulesPath + "/installer/scan/not-detected.nix")      ];      boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ];    boot.initrd.kernelModules = [ ];    boot.kernelModules = [ "kvm-intel" ];    boot.extraModulePackages = [ ];      fileSystems."/" =      { device = "/dev/disk/by-uuid/7e6bcba1-25e7-43f5-8dd2-1458d863c0c4";        fsType = "ext4";      };      fileSystems."/boot" =      { device = "/dev/disk/by-uuid/19A7-C717";        fsType = "vfat";      };      swapDevices =      [ { device = "/dev/disk/by-uuid/14412169-fb90-4e0c-ae3f-735c817b8cf3"; }      ];      # The global useDHCP flag is deprecated, therefore explicitly set to false here.    # Per-interface useDHCP will be mandatory in the future, so this generated config    # replicates the default behaviour.    networking.useDHCP = lib.mkDefault false;    networking.interfaces.enp11s0.useDHCP = lib.mkDefault true;    networking.interfaces.wlp9s0.useDHCP = lib.mkDefault true;      powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";    hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;    # high-resolution display    hardware.video.hidpi.enable = lib.mkDefault true;  }  

And the logs from display-manager are on this pastebin raw link: https://pastebin.com/raw/YycVPVVd

And here is the output of lspci -k | grep -A3 'VGA':

00:02.0 VGA compatible controller: Intel Corporation Device 9a70 (rev 01)      Subsystem: Lenovo Device 22d8      Kernel driver in use: i915      Kernel modules: i915  --  01:00.0 VGA compatible controller: NVIDIA Corporation Device 24b7 (rev a1)      Subsystem: Lenovo Device 22d8      Kernel driver in use: nvidia      Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia  

Happy to post anymore logs or files if necessary and willing to try anything to get this working! Thank you in advance for any help!

How to remap a key combination to a key combination in X?

Posted: 20 Mar 2022 04:10 PM PDT

How do I remap a key combination Ctrl+54 (keycode for C) to Ctrl+C?

I want this because I am switching between keyboard layouts often, but many programs accept keyboard shortcuts only in latin layouts. For example Ctrl+U for pasting in nano doesn't work if I switch to the Russian keyboard layout.

I saw solutions for remapping a key combination to a key here, but don't know how to adopt them. My current solution is to use packages xbindkeys and xvkbd and create a file ~/.xbindkeysrc that looks like:

"xvkbd -xsendevent -text "\Cc""      m:0x04 + c:54  

This works only for nano, but doesn't work for zathura, another console application, nor for geany, a GUI text editor.

Shell script loop issue

Posted: 20 Mar 2022 04:23 PM PDT

I have code which need to run with pre-variables. I tired to run it with loop but, its not work. How can I edit script for correct work with pre-variables?

#!/bin/bash    port=$1        if [[ -z ${port} ]]; then          echo "STOP"          exit 1      fi    app_pid=app_${port}.pid  app_home=$(pwd)  mkdir -p $app_home/log        if [[ -e ${app_home}/log/${app_pid} ]]; then          echo "STOP"          exit 1      fi    nohup \      "$JAVA_HOME" app.jar ${port} \      ${app_home}/log/nohup.out 2>$1 &  

I tried this script. But its not work

#!/bin/bash    procpid=('1001' '1002' '1003' '1004')    for port in "${procpid[@]}" ; do    app_pid=app_${port}.pid  app_home=$(pwd)        if [[ -e ${app_home}/log/${app_pid} ]]; then          echo "STOP"          exit 1      fi    mkdir -p $app_home/log    nohup \      "$JAVA_HOME" app.jar ${port} \      > ${app_home}/log/nohup.out 2>$1 &    done  

avahi-resolve works but mdns

Posted: 20 Mar 2022 01:50 PM PDT

I have an updated debian 11 (bullseye) setup and want to use avahi to connect to locally connected computers.

avahi works, for example:

avahi-resolve -n4 prag11mono.local   

gives prag11mono.local 10.0.0.105 which is correct. however, ping (or ssh) for the same host

ping prag11mono.local  PING prag11mono.local.rpz.GS.local (127.0.0.2) 56(84) bytes of data.  64 bytes from 127.0.0.2 (127.0.0.2): icmp_seq=1 ttl=64 time=0.035 ms  

here I do not understand where the rpz.GS.local addition comes from. It is not added to ssh prag11mono.local, but the request goes to 127.0.0.2 as well.

In /etc/nsswitch.conf I have

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

but getent hosts bhutan.local

returns nothing. I have no /etc/mdns.allow file.

What makes the connection between avahi-daeomon and mdns4? I can restart the avahi-daemon with systemctl; how to resart mdns?

I fear that I miss some installation. I tried to install the package nss-mdns but get unable to locate package despite I find it should be available for bullseye. I installed libnss-mdns and checked that the required files are in `/lib/libnss_mdns*

What is missing? How to debug?

How do I select the proprietary nvidia drivers on Fedora 35 after installing them from RPM?

Posted: 20 Mar 2022 12:43 PM PDT

I'm trying Fedora after using Ubuntu for a while. After a fresh Ubuntu install, I would select the nvidia drivers by using the GUI application called "Additional Drivers". I do this because my monitors support 144 Hz refresh rate, which typically only works when I'm using the proprietary drivers. On Fedora, it doesn't for me, with the out of the box install.

For Fedora, I noticed there is no Additional Drivers application and I wasn't able to find a similar application already installed. I found this tutorial which I followed (https://www.linuxcapable.com/how-to-install-the-latest-nvidia-graphic-drivers-on-fedora-35-gnome-41/) except for the part where you run su to change to the root user. This wouldn't work for me because I didn't have a root password. The Fedora install process never prompted me to set one up. I figured it would be fine to run the commands in the tutorial from my user using sudo. So I ended up running the following:

sudo dnf upgrade --refresh -y  sudo dnf install dnf-plugins-core -y  sudo dnf install \    https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm  sudo dnf install \    https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm  sudo dnf update --refresh  sudo dnf install akmod-nvidia  sudo dnf install xorg-x11-drv-nvidia-cuda  

Then I rebooted my system and when I booted up I ran nvidia-smi, as the tutorial says, to check how the install went. Instead of getting the output in the tutorial where it displays information about the driver, I get:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.  

So it seems like where I'm at right now is that I need to select the driver now that I've installed it. How do I do this?

Data about my system:

$ lsb_release -a  LSB Version:    :core-4.1-amd64:core-4.1-noarch  Distributor ID: Fedora  Description:    Fedora release 35 (Thirty Five)  Release:    35  Codename:   ThirtyFive  

Card: 3070 Ti

How to use Vim-like registers across programs

Posted: 20 Mar 2022 12:37 PM PDT

I'd like to be able to dd j dd in Vim, then p "2p in a text box on another program.

The ideal solution would allow Vim yank and put bindings across the OS.

I'm using Arch Linux with DWM as my window manager.

Prohibit sudo commands when run from a SSH session

Posted: 20 Mar 2022 01:10 PM PDT

Is there a way to prohibit sudo commands when issued from a SSH session specifically, while allowing them from local terminals?

I looked at the sudoers and sudo.conf man pages and search for "terminal", without success.

Resizing Images in Linux

Posted: 20 Mar 2022 02:25 PM PDT

I have various folders with high res images sizes some more than 6000px x 4000px. some are 5000px x 3000px, size varies with folder to folder. I want to resize all images for saving resources like loading time/processing/memory space. I want to keep all images around minimum 3000x2000 max 3500x2200 . How I can do this with imagemagick in batch, Replacing original. Some one suggested my to use imagemagick with morgify on ubuntu?

Earlier when i had windows PC I used photosizer software. Selecting folder one by one, then process images with jpegMini software. So 5 mb photos decrease to the size to around 1.5 mb. Every folder contains images with different resolution. Its a long time consuming process. For every folder i had to decrease % in fotosizer to keep image size around 3000*2000 more or less maintaining aspect ratio.

Install teamviewer for debian 9 cli only

Posted: 20 Mar 2022 03:23 PM PDT

Until now I used zerotier in order to reach a remote linux debian 9 machine that is a sort of vpn service, it assign you virtual router and you can add machines to it.

Something got really strange since last update of the remote client. The machine is unreacheable, I have a person there with root access that can write a small list of command but he isn't very practical so keeping the list short is better.

What list of command can I send to him in order to get a 100% sure functioning teamviewer installation so that I can get back and login in this machine ?

The machine is a full classic Debian 9 installation with NO X or anything, only CLI classic terminal.

I've read various teamviewer installation threads but every one seems to be very technical for linux, while I need something easy and unattended where the person have to do a command once, tell me his id and let me enter to fix all the mess zerotier last update leaved.

BONUS:

The command list can be also put online so he have to write a single line like a command

runurl http:// some_pastebin_address ?

Thanks!

insert comment in the beginning of specified line in file

Posted: 20 Mar 2022 01:24 PM PDT

This is a pretty newbie question but what I am trying to do should be easy :( I am developing a script to automatically install a development environment but I need to comment out loadmodule in the Apache configuration file on my Linux machine.

LoadModule mpm_event_module modules/mod_mpm_event.so  

I have been able to remove a comment with the following command:

sudo sed -i '66s/.//' /etc/httpd/conf/httpd.conf  

How to fake write-protected script's $0 (zeroth arg) to be a path where I have no write-access?

Posted: 20 Mar 2022 01:25 PM PDT

It's said relying on $0 in a script is dangerous (often citing to fake it: exec -a ...). Yes, in dirs where I have write-access I can symlink to a script to fake its $0. But how to make $0 point to a path where I have no write-access (such as /bin/pwd below)?

Below, provided my script uses a shebang, I cannot achieve it. Can it be done when target script uses a shebang?

$ (exec -a /bin/pwd /tmp/a0.sh)  no-shebang: argv0=/bin/pwd /proc/.../cmdline=/bin/bash^@--noediting^@-i^@    $ (exec -a /bin/pwd /tmp/a1.sh)  yes-shebang: argv0=/tmp/a1.sh /proc/.../cmdline=/bin/sh^@/tmp/a1.sh^@    $ head /tmp/a0.sh /tmp/a1.sh  ==> /tmp/a0.sh <==  echo no-shebang: argv0="$0" /proc/.../cmdline=$(cat -v /proc/$$/cmdline)    ==> /tmp/a1.sh <==  #!/bin/sh  echo yes-shebang: argv0="$0" /proc/.../cmdline=$(cat -v /proc/$$/cmdline)  

That is, if a script (& its parent-dirs) are write-protected, AND uses a shebang, then its use of $0 is safe (from faking another write-protected path)?

Here using (on centos 7) bash's exec statement as easy fake of $0. C program using execve() won't be different? Is the failure to fake it downstream of the execve() (in kernel or shebang-target), not that bash's exec is too weak?

EDIT: execve() in C also does NOT fake the $0 in shebang case, same output as above:

#include <stdio.h>  int main(void) {    char* argv[] = { "/bin/pwd", NULL };    execve("/tmp/a1.sh", argv, NULL);    perror(NULL);  }  

I'm aware if users gain root, then fake $0 is least of your issues. But MY write-protected scripts, with shebang, cannot be $0 faked (to another write-protected path), by non-root users: the danger of $0 ('just use exec -a ...') seems false.

How to connect Linux network namespace with other VM using internal network?

Posted: 20 Mar 2022 05:43 PM PDT

I have two Virtual Machnes (VM) in Virtualbox connected with internal network. On the first one I have network namespace named n0. I want to connect this namespace to network interface and finally connect it with the second Virtual Machine (VM2) using internal connection. Network example:

Network example

As you can see, I want to have connection between 192.168.127.2/24 and 192.168.127.1/24.

My attempt to solve this problem using openvswitch (not working):

sudo ovs-vsctl add-br br0   sudo ifconfig br0 up  sudo ip link add veth type veth peer name veth-br   sudo ip link set veth netns ns0  sudo ifconfig veth-br up  sudo ovs-vsctl add-port br0 veth-br  sudo ip netns exec ns0 ip addr add 192.168.127.2/24 dev veth  sudo ip netns exec ns0 ip link set veth up  sudo ip addr add 192.168.127.3/24 dev br0  sudo ovs-vsctl add-port br0 eth0   

Could you please help me with this? Do you see how can I improve my solution to work properly?

Extended network topology:

enter image description here

There is a working connection between ns1 and ns0, but I try to connect ns1 with 192.168.127.1/24. To do this, besides the connection between 192.168.127.2/24 and 192.168.127.1/24, I need to add static routing but I can't do it. I was planning on trying to do this using openvswitch and commands:

sudo ip netns exec ns1 route add -net 192.168.127.0/24 gw 192.168.1.10 dev wlan1  sudo ip route add 192.168.1.0/24 via 192.168.127.2 dev br0   

where br0 is openvswitch - bridge.

problem with installing a repository on remote server with CentOS 7 without root permission

Posted: 20 Mar 2022 12:25 PM PDT

I am trying to install Chipyard Toolchain on a remote system with cshrc. I am connecting to it via ssh.

All the required dependencies were already installed on the system. I checked them with rpm -q command. So I skipped installing them.

I've done the setup phase as well (i.e. ./scripts/init-submodules-no-riscv-tools.sh was successful-- generated the expected output on env.sh file)

My problem is with the buiding the toolchains where I'm getting the errors:

enter image description here

I also recorded the full build process and its here.

My question is do i need to install the dependecies again (or upadate them) to get rid of the errors? if so could you please guide me how becaues I'm not the sudo.

I asked the admin but they replied that the admin is only for advanced stuff.

I'm not very experinced with linux. Any guidance will be appreciated.

EDIT

Installing toolchain to /local/data0/AS/chipyard/riscv-tools-install  =>  Starting riscv-gnu-toolchain build  ==>  Initializing riscv-gnu-toolchain submodule  ==>  Removing existing riscv-gnu-toolchain/build directory  ==>  Configuring riscv-gnu-toolchain  checking for gcc... gcc  checking whether the C compiler works... yes  checking for C compiler default output file name... a.out  checking for suffix of executables...   checking whether we are cross compiling... no  checking for suffix of object files... o  checking whether we are using the GNU C compiler... yes  checking whether gcc accepts -g... yes  checking for gcc option to accept ISO C89... none needed  checking for grep that handles long lines and -e... /bin/grep  checking for fgrep... /bin/grep -F  checking for grep that handles long lines and -e... (cached) /bin/grep  checking for bash... /bin/sh  checking for __gmpz_init in -lgmp... yes  checking for mpfr_init in -lmpfr... yes  checking for mpc_init2 in -lmpc... yes  checking for curl... /bin/curl  checking for wget... /bin/wget  checking for ftp... /bin/ftp  configure: creating ./config.status  config.status: creating Makefile  config.status: creating scripts/wrapper/awk/awk  config.status: creating scripts/wrapper/sed/sed  ==>  Building riscv-gnu-toolchain  mkdir -p /local/data0/AS/chipyard/riscv-tools-install/.test || \      (echo "Sorry, you don't have permission to write to" \       "'/local/data0/AS/chipyard/riscv-tools-install', use --prefix to specify" \       "another path, or use 'sudo make' if you *REALLY* want to" \       "install into '/local/data0/AS/chipyard/riscv-tools-install'" && exit 1)  rm -rf stamps/build-gdb-newlib build-gdb-newlib  mkdir build-gdb-newlib  rm -r /local/data0/AS/chipyard/riscv-tools-install/.test  cd build-gdb-newlib && CC_FOR_TARGET=riscv64-unknown-elf-gcc /local/data0/AS/chipyard/toolchains/riscv-tools/riscv-gnu-toolchain/build/../riscv-gdb/configure \      --target=riscv64-unknown-elf \       \      --prefix=/local/data0/AS/chipyard/riscv-tools-install \       \      --disable-werror \      --with-expat=yes  \      --enable-gdb \      --disable-gas \      --disable-binutils \      --disable-ld \      --disable-gold \      --disable-gprof  mkdir -p stamps/ && touch stamps/check-write-permission  

how to print 2 consecutive lines separated by 1 blank line into one line separated by ,

Posted: 20 Mar 2022 03:35 PM PDT

How to turn this text:

St1  number1  1234    St2  number2  456  

In to this one:

st1,number1,1234  st2,number2,1234  

Disk showing in windows but not in Ubuntu

Posted: 20 Mar 2022 12:21 PM PDT

New to linux but have been researching this for a few evenings without success. I have two disks in my machine. I wiped windows and installed Ubuntu on one of the disks. I can't seem to access the other disk.

  • it doesn't show in gparted
  • it doesn't show in the ubuntu command line

I have a completely different computer running windows 11 so I plugged the drive in there and it showed up. I tried reformatting as NTFS and plugging back into Ubuntu but still nothing.

Any help greatly appreciated.

Output of lsblk:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT  loop0         7:0    0     4K  1 loop /snap/bare/5  loop1         7:1    0  55.5M  1 loop /snap/core18/2284  loop2         7:2    0 110.7M  1 loop /snap/core/12821  loop3         7:3    0  54.2M  1 loop /snap/snap-store/558  loop4         7:4    0  61.9M  1 loop /snap/core20/1361  loop5         7:5    0  61.9M  1 loop /snap/core20/1376  loop6         7:6    0  65.2M  1 loop /snap/gtk-common-themes/1519  loop7         7:7    0 110.8M  1 loop /snap/core/12725  loop8         7:8    0  43.6M  1 loop /snap/snapd/15177  loop9         7:9    0 248.8M  1 loop /snap/gnome-3-38-2004/99  loop10        7:10   0     9M  1 loop /snap/canonical-livepatch/132  loop11        7:11   0  43.6M  1 loop /snap/snapd/14978  nvme0n1     259:0    0 232.9G  0 disk   ├─nvme0n1p1 259:1    0   512M  0 part /boot/efi  └─nvme0n1p2 259:2    0 232.4G  0 part /  

Update / solution

I have found the problem and I have to apologise but it was something I did without realising. When I wiped windows off I also removed the graphics card and stuck in a really old one. When doing so I must have plugged the SATA cable back into a different port on the motherboard. On this Gigabyte motherboard there are two SATA ports that are disabled when using an M.2 drive. I didn't know this but just found out today when troubleshooting this problem. Moved the cable to another port and now the drive shows up in Ubuntu. I'm terribly sorry for wasting anybodies time but hope posting this outcome might help others.

Remove specific CSV columns from large CSV file and duplicated rows with Perl

Posted: 20 Mar 2022 04:26 PM PDT

I have a large CSV file (300MB+) and I want to remove only columns 2,3 and 6-8 using Perl AND remove duplicated rows:

Note 1: all columns are separated by , (commas) but sometimes my cell values contains a , or multiple , and are separated by " (see last row, columns 9 and 10); thus I'd like still be able to process the input.csv file even if it has , inside the cells:

Note 2: I've added links to the input.csv and output.csv files:

input.csv

Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10  info 1,info 2,info 3,...,info 10  address 1,address 2,....,address 10  city 1,city 2,city 3,city 4,city 5,city 6,city 7,city 8,"city 9, extra","city 10, new"  

output.csv

Col1,Col4,Col5,Col9,Col10  info 1,info 4,info 5,info 9,info 10  address 1,address 4,address 5,address 9,address 10  city 1,city 4,city 5,"city 9, extra","city 10, new"  

I've found a Perl command that would remove the last column using regex, but don't know if it's good enough or how to tweak it to suit my case (any other suggestion is more than welcomed!):

perl -pe 's/.*\K,.*//'  

Is it possible to remove only columns 2,3 and 6-8 using Perl and remove any duplicated rows?

PS: updated the input.csv file to include duplicate rows as well

Thank you!

sorting files using string

Posted: 20 Mar 2022 11:37 AM PDT

I have a directory of 1000+ files (follow the same formatting) example file would be

giroof-doas-ob10roof-L1-202007020832-10.std  

Where year is 2020

month is 07

day is 02

hour is 08

min is 32

elevation is 10

I'd like to create a script that reads the day and hour and sorts it in a folder with that same name then into a sub directory based on elevation. example file would be copied into folder

../0208/10.std/  

I was able to use string features to read the day and hour and create the corresponding folders and also able to create the directories (see below). My issue is that I can't seem to copy the files while using "string reading".

This is where the files are located (may help explain my script attempt and why I used the cut function the way I did.

#/home/lmdjeu/qdoas-test/ob10roof/fitting/stdfiles/giroof-doas-ob10roof-L1-202007020832-10.std  
#!/bin/bash    #/home/lmdjeu/qdoas-test/ob10roof/fitting/stdfiles/giroof-doas-ob10roof-L1-202007020832-10.std      list=$(ls /home/lmdjeu/qdoas-test/ob10roof/fitting/stdfiles/*.std)  #echo "$list"    dir="$(cut -d'/' -f8 <<<"$list")"    loca="$(cut -d'-' -f5 <<<"$dir")"    elevstd="$(cut -d'-' -f6 <<<"$dir")"      hello="$(cut -c 7-10 <<< "$loca")"    mkdir /home/lmdjeu/test/hello/$hello      elev="$(cut -c 1-2 <<< "$elevstd")"  #echo "$elev"    for dir in /home/lmdjeu/test/hello/*/;     do        mkdir -- "$dir"/{00.std,01.std,02.std,03.std,04.std,05.std,06.std,07.std,08.std,09.std,10.std,ref};     done      stddir=/home/lmdjeu/qdoas-test/ob10roof/fitting/stdfiles  elevdir=/home/lmdjeu/test/hello  

This is the area of my script that I would like to improve. I want it to copy files into the corresponding directory and subdirectory even if the days and hours change.

for i in {00..10}; do    cp $stddir/giroof-doas-ob10roof-L1-2020070111*-"$i".std $elevdir/0111/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070112*-"$i".std $elevdir/0112/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070113*-"$i".std $elevdir/0113/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070114*-"$i".std $elevdir/0114/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070115*-"$i".std $elevdir/0115/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070116*-"$i".std $elevdir/0116/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070117*-"$i".std $elevdir/0117/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070118*-"$i".std $elevdir/0118/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070119*-"$i".std $elevdir/0119/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070120*-"$i".std $elevdir/0120/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070121*-"$i".std $elevdir/0121/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070122*-"$i".std $elevdir/0122/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070123*-"$i".std $elevdir/0123/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070200*-"$i".std $elevdir/0200/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070201*-"$i".std $elevdir/0201/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070202*-"$i".std $elevdir/0202/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070203*-"$i".std $elevdir/0203/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070204*-"$i".std $elevdir/0204/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070205*-"$i".std $elevdir/0205/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070206*-"$i".std $elevdir/0206/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070207*-"$i".std $elevdir/0207/"$i".std    cp $stddir/giroof-doas-ob10roof-L1-2020070208*-"$i".std $elevdir/0208/"$i".std  done          cp $stddir/giroof-doas-ob10roof-L1-2020070111*.ref  $elevdir/0111/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070112*.ref  $elevdir/0112/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070113*.ref  $elevdir/0113/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070114*.ref  $elevdir/0114/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070115*.ref  $elevdir/0115/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070116*.ref  $elevdir/0116/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070117*.ref  $elevdir/0117/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070118*.ref  $elevdir/0118/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070119*.ref  $elevdir/0119/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070120*.ref  $elevdir/0120/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070121*.ref  $elevdir/0121/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070122*.ref  $elevdir/0122/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070123*.ref  $elevdir/0123/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070200*.ref  $elevdir/0200/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070201*.ref  $elevdir/0201/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070202*.ref  $elevdir/0202/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070203*.ref  $elevdir/0203/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070204*.ref  $elevdir/0204/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070205*.ref  $elevdir/0205/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070206*.ref  $elevdir/0206/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070207*.ref  $elevdir/0207/ref/  cp $stddir/giroof-doas-ob10roof-L1-2020070208*.ref  $elevdir/0208/ref/  

LINUX unable to create a directory | mkdir: cannot create directory ‘test_nfs’: Permission denied

Posted: 20 Mar 2022 05:07 PM PDT

I am trying to create a new directory under /mnt but unable to do so.

I have presented a volume through nfs server to client.

-->RPCbind is active.    /mnt$ service rpcbind status  ● rpcbind.service - RPC bind portmap service       Loaded: loaded (/lib/systemd/system/rpcbind.service; enabled; vendor pres>       Active: active (running) since Wed 2021-05-05 03:00:42 PDT; 40min ago  TriggeredBy: ● rpcbind.socket         Docs: man:rpcbind(8)     Main PID: 712 (rpcbind)        Tasks: 1 (limit: 4614)       Memory: 2.3M       CGroup: /system.slice/rpcbind.service               └─712 /sbin/rpcbind -f -w    ubuntu:/mnt$ mkdir test_nfs  mkdir: cannot create directory 'test_nfs': Permission denied    drwxr-xr-x   3 root root      4096 Apr 16 04:19 mnt  

Any help would be highly appreciated. Thanks in advance.

How can I extract a RAR file on Debian?

Posted: 20 Mar 2022 11:56 AM PDT

I've got a 20GB RAR file to extract with a password on Debian Linux Google Cloud VM.

I first tried sudo apt-get install unrar but the following output was given:

Reading package lists... Done  Building dependency tree         Reading state information... Done  Package unrar is not available, but is referred to by another package.  This may mean that the package is missing, has been obsoleted, or  is only available from another source    E: Package 'unrar' has no installation candidate  

I found that this is likely to be because I don't have the multiverse activated, so I tried sudo add-apt-repository multiverse. This didn't work:

Error: 'multiverse' invalid  

I eventually found a post saying that 'unrar free' could be installed. I installed it, and ran unrar-free -x -p Filename.rar. It is currently going through each file in the archive and giving the following output:

Extracting  Folder_name/image/0/1.jpg                                  Failed      Extracting  Folder_name/image/0/10.jpg                                 Failed      Extracting  Folder_name/image/0/100.jpg                                Failed      Extracting  Folder_name/image/0/1000.bmp                               Failed  

Apparently unrar-free is unable to extract archives in the RAR 3.0 format. I don't know how to tell which version of RAR this archive was compressed in.

How can I extract this RAR file?

I don't mind paying some money if it means faster extraction - I've got 140GB of RAR files to get through.

using awk to print backslash

Posted: 20 Mar 2022 02:03 PM PDT

I am having trouble printing (or searching) for sequences containing backslashes when using awk For example -

echo "test\test" | awk '{ gsub(/\\\\t/, "\\\\&"); print }'  

will give the result:

test    est  

because the \t will be interperted as tab. I want to be able to have the string as is, meaning:

test\test  

The echo command is just another way for me to check a 1 liner for the awk command to see if it can find a pattern such as \t in a file (using a bash script). To be more sprcific - If I want to have an awk cmd that needs to find a sequence of

\"  

I am using the following:

awk -v st="$match_string" 'BEGIN {gsub(/\\\\"/,"\\\\&", st)} match($0,st {print;exit}' file.txt  

but the cmd does not work: for a file with :

547 %$   236 \"  4523 &*   8876 (*  8756 "/  ...  

it will output:

> \"  8756 "/  

What is the right way to use awk to find the

236 \"  

Thanks

Linking with GCC doesn't detect -fPIC flag

Posted: 20 Mar 2022 04:01 PM PDT

I am trying to link some files. Here is my command:

gcc -T linker.ld -o Stack\ Berry.bin -ffreestanding -O2 -nostlib kernel.o boot.o -fPIC -lgcc  

How ever, I get this error:

/usr/bin/ld: boot.o: relocation R_X86_64_32 against `.multiboot' can not be used when making a PIE object; recompile with -fPIC  /usr/bin/ld: final link failed: Nonrepresentable section on output  

I have included the -fPIC argument, have I just put it in the wrong place? I haven't been able to find any thing for the syntax for this flag. Thanks!

What are the correct permissions for a systemd .service?

Posted: 20 Mar 2022 02:46 PM PDT

I need to create a service for a web server called daphne I would like to know what are the correct linux permissions for this. or if exists a general rule for whatever systemd service?

openSUSE 42.3 does not start up from USB - black screen after loading kernel

Posted: 20 Mar 2022 03:03 PM PDT

I tried to install openSUSE on my desktop PC and load openSUSE 42.3 to my USB stick by using SUSE Studio Imagewriter (my laptop is running openSUSE). However, after a while the screen turns black and nothing happens.

My desktop PC loads the GRUB (at least it looks like GRUB) from USB and I choose the option Installation. The kernel seems to be loaded and things are printed on the screen. The last things printed on the screen before turning black are:

>>> openSUSE Leap 42.3 installation program v5.0.104 (c) 1996-2016 SUSE LLC <<< Starting udev...

After this, the PC seems to do nothing and my display turns black. First, I thought this was a problem of the USB stick, downloaded openSUSE a second time, checked its hash, and tried on my laptop (where everything seems to be OK) but nothing changed. Both, the DVD install and Net install showed the same issue or at least symptoms.

So I assume it has something to do with my desktop PC. It has AMD CPU and NVidia graphics card (my laptop has both from Intel). Maybe this needs some special attention?

Any suggestions what could be the problem or what to try next?

Many thanks and have a nice day.

Buildroot Zero-W wireless

Posted: 20 Mar 2022 03:43 PM PDT

Has anyone got WiFi working in buildroot for the Raspberry Pi Zero W? I can't find any online notes or walkthroughs on it.

The raspberrypi0_defconfig works fairly well, but doesn't include wireless.

I'm using the latest iteration of buildroot, 2017-08. I've added the rpi-wifi-firmware. Which packages are needed as a bare minimum to connect to a WiFi network?

Binding to systemd device units of connected bluetooth devices

Posted: 20 Mar 2022 03:48 PM PDT

When I connect a bluetooth device (e.g. a wiimote) to my machine and list all device units of systemd via systemctl list-units -t device, the device unit shows up as sys-subsystem-bluetooth-devices-hci0:ID.device.

Problem:

I want to bind a systemd service to a specific bluetooth device unit (e.g. wiimote). Thus, I will need an idea about the name. The ID differs on two Arch linux machines.

Questions:

  • Who assigns these device IDs to bluetooth systemd device units?
  • Is the ID static on one system and among system updates and thus is it safe binding services to that device unit, i.e., will this service only be triggered when connecting a bluetooth device of the same type?
  • Can I change/influence this ID?

Attempts:

I tried to change the ID with an udev rule following this description on the Arch wiki. Via udevadm info -a -p $(udevadm info -q path -n /dev/hidraw4 ) I got:

looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/bluetooth/hci0/hci0:256/0005:057E:0330.000C/hidraw/hidraw4':  KERNEL=="hidraw4"  SUBSYSTEM=="hidraw"  DRIVER==""    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/bluetooth/hci0/hci0:256/0005:057E:0330.000C':  KERNELS=="0005:057E:0330.000C"  SUBSYSTEMS=="hid"  DRIVERS=="wiimote"  ATTRS{country}=="00"  ATTRS{devtype}=="gen20"  ATTRS{extension}=="none"    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/bluetooth/hci0/hci0:256':  KERNELS=="hci0:256"  SUBSYSTEMS=="bluetooth"  DRIVERS==""  

All KERNEL(S) entries are not the same over two systems. I thus tried to apply the udev rule:

SUBSYSTEMS=="hid", DRIVERS=="wiimote", TAG+="systemd", SYMLINK+="wii"  

But that doesn't create any additional device unit.

How to exit a git merge asking for commit message?

Posted: 20 Mar 2022 01:18 PM PDT

I'm using git. I did a normal merge, but it keeps asking this:

# Please enter a commit message to explain why this merge is necessary,  # especially if it merges an updated upstream into a topic branch.  

And even if I write something, I can't exit from here. I can't find docs explaining this. How should I do?

how to test sco packets in bluetooth

Posted: 20 Mar 2022 01:00 PM PDT

Issue : Monitor sco packets between master and slave bluetooth.

Description of problem. I have small in-house Bluetooth device (developed in Linux fedora OS) and is configured as slave device.

I am interested in following things:

  1. Master to connect to our in-built device and establish an sco link. How would I verify link is established?

  2. Master to send sco packets to slave and slave send back( loopback) the same packets to master. Absolutely no idea how to do that?

What I did so far:

  1. Well I have configured our in-built device to slave and successfully connected to windows laptop via bluetooth.

  2. I have enabled headset profile in my in-house BT device and I can see headset icon on windows.

  3. on Linux side via c++ code I have modified /etc/asound.conf to include mac-address of connected device( in my case windows laptop) .
    sample is shown below

    pcm.btheadset {     type plug     slave {         pcm {             type bluetooth             device DC:A9:71:8D:2D:C6             profile "auto"         }     }  
  4. then play the sound on my in-house BT via command aplay -D btheadset " path of audio_file"

And I can successfully hear sound on my windows laptop.

So far so good.
Now when I do hciconfig -a

acl packets have increase but sco remain at 0

RX bytes:1041 acl:456 sco:0 events:36 errors:0  TX bytes:1347 acl:567 sco:0 commands:34 errors:0  

Will this proof that audio is working but not via sco?

  1. I have found that I don't have btsco driver or hcid.conf file. Do you think that could be an issue?

  2. if my audio is working via sco could someone provide me an example of how to test via hcidump?

  3. how to loop it back to master?

Cinnamon failed: desktop only, no panel, no dialog frame

Posted: 20 Mar 2022 12:01 PM PDT

I am using Linux Mint 14 (MATE) with Cinnamon installed. Cinnamon failed when I tried to delete an item on the menu with menu editor. The system froze, so I logged out by pressing Ctrl+Alt+Delete.

When I logged back in, the desktop panel was not loaded (shortcuts were there as normal, and right-click works as well). I can barely do anyting but get the terminal with Ctrl+Alt+t. But all the dialogue windows are presented without any frames.

Here are screenshots:

I tried reinstalling Cinnamon in the MATE desktop interface (it works fine), but it failed to solve the problem.

No comments:

Post a Comment