Wednesday, June 1, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to create system.sfs with system.img?

Posted: 01 Jun 2022 09:53 AM PDT

I created an image file from system directory of an OS. I want to convert(or pack) with sfs format, but I don't know how to do this. I searched about it, but I didn't find any accurate method.

How to install armr5-none-eabi-g++ and associated toolchain?

Posted: 01 Jun 2022 09:38 AM PDT

I'm tasked with adding a cross-compiler to an existing Docker image that contains multiple cross-tools.

From our existing Dockerfile, I see that apt-get install -y --no-install-recommends build-essential has the effect of installing /usr/bin/x86_64-linux-gnu-g++ and its associated binaries/toolchain (sorry: my terminology may be lacking).

Similarly, apt-get install -y --no-install-recommends crossbuild-essential-arm64 seems to have the effect of installing /usr/bin/aarch64-linux-gnu-g++ and its associated binaries/toolchain.

Is there an apt-get install command that will similarly install armr5-none-eabi-g++ and its associated binaries/toolchain?

Searching online and on the various Stack Exchanges, I see reference to installing arm-none-eabi-g++, but I assume that is something distinct from armr5-none-eabi-g++(?)
Even if the two are functionally equivalent, I'd prefer a solution that installs specifically armr5-none-eabi-g++.

The Dockerfile base image is debian:10.3-slim.

setting a micrrocode of cpu in Debian

Posted: 01 Jun 2022 09:27 AM PDT

Like in question how to do it ? What you must do to set a microcode .

For example for microcode_amd_fam15h.bin

what is in /lib/firmware/amd-ucode

Convert from dual-screen to dual-display

Posted: 01 Jun 2022 09:08 AM PDT

I have a no name SBC similar to Raspberry Pi with 2 physical displays connected to it (one via HDMI and one via SPI). Below is my xorg config which gives me 2 separate X screens: :0.0 and :0.1

### HDMI    Section "Device"      Identifier  "device0"      Driver      "fbdev"      Option      "fbdev" "/dev/fb0"  EndSection    Section "Monitor"      Identifier  "monitor0"      Option      "Rotate" "normal"      Modeline    "1920x1080_60.00"       172.80  1920  2040   2248  2576   1080   1081   1084  1118   -HSync +Vsync  EndSection    Section "Screen"      Identifier  "screen0"      Device      "device0"      Monitor     "monitor0"      DefaultDepth 24      SubSection "Display"          Depth 24          Modes "1920x1080_60.00"      EndSubSection  EndSection    ### SPI    Section "Device"      Identifier  "device1"      Driver      "fbdev"      Option      "fbdev" "/dev/fb1"      Option      "SwapbuffersWait" "true"  EndSection    Section "Monitor"      Identifier  "monitor1"      Option      "Primary" "False"  EndSection    Section "Screen"      Identifier "screen1"      Monitor "monitor1"      Device "device1"      Subsection "Display"          Depth 16          Modes "320x240"      EndSubSection  EndSection    ### Layouts    Section "ServerLayout"      Identifier "multihead"      Screen  0 "screen0"      Screen  1 "screen1" rightof "screen0"  EndSection    Section "ServerFlags"      Option "DefaultServerLayout" "multihead"  EndSection  

What change would be required (if ever possible) in order to achieve 2 separate displays, :0 and :1 instead of separate screens? Can one make a ServerLayout which consists of displays, not screens?

Qt applications settings

Posted: 01 Jun 2022 08:59 AM PDT

where's the path in which Qt application will save default settings for all users? Wanted to set out some default settings for an old clumsy person... Thanks in advance

awk split a file into multiple files with specific names in another index file

Posted: 01 Jun 2022 08:59 AM PDT

I have a cluster fasta file (called file) which looks like:

>1AB2  >1AB2 AA  NWWIEUNJRNIBGOWNGIOWGRBIGBRGRIOWGI  NCIDHFR8EHGBVPIWOBGIGRI  >1AB3 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >1SC4 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >2CD5 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >2AC6  >2AC6 AA  NFIGEURHGEIROHEGHTUTJGENLJBBEOWRIU  NFIROUHBOERVERUGBERUOVREOIBROEBVUE  NVHIRE  >2ONM AA  BUCIEHBUORBREOBWQVURVELLAJFLHIEBGR  NHEIBVEURIGBVNRIHEOEAJVSJDNHVUGBVR  NEBIBVVBRU  >2POD AA  BUFEWIBOEUWBWOREBRIUBGUERIGBVOSRIP  BUEIBVEO  >7KZL  >7KZL AA  BUIREBVAUREVBREOIRGPNJBFDVERUBVROR  >6GH3  >6GH3 AA  NBVUIREVOIAWRHRUGRTYUVDNJKDFHUGSEI  FHUIERBLUUIREB  >6GH4 AA  BDFUIGEVUERERHOBERIHBSDLKFJBNIERIH  NFHILRUGAURHG  

the file has 4 groups: 1AB2, 2AC6, 7KZL, and 6GH3. the content during the first >1AB2 and the first >2AC6 belongs to the cluster 1AB2. the content during the first >2AC6 and the first >7KZL belongs to the cluster 2AC6.

I want to separate the file into 4 files at the second >XXXX with specific names in this index file (ind.txt):

HG001 1AB2  HG010 2AC6  HG023 7KZL  HG004 6GH3  

The result file should look like:

HG001.fa

>1AB2 AA  NWWIEUNJRNIBGOWNGIOWGRBIGBRGRIOWGI  NCIDHFR8EHGBVPIWOBGIGRI  >1AB3 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >1SC4 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >2CD5 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  

HG010.fa

>2AC6 AA  NFIGEURHGEIROHEGHTUTJGENLJBBEOWRIU  NFIROUHBOERVERUGBERUOVREOIBROEBVUE  NVHIRE  >2ONM AA  BUCIEHBUORBREOBWQVURVELLAJFLHIEBGR  NHEIBVEURIGBVNRIHEOEAJVSJDNHVUGBVR  NEBIBVVBRU  >2POD AA  BUFEWIBOEUWBWOREBRIUBGUERIGBVOSRIP  BUEIBVEO  

HG023.fa

>7KZL AA  BUIREBVAUREVBREOIRGPNJBFDVERUBVROR  

HG004.fa

>6GH3 AA  NBVUIREVOIAWRHRUGRTYUVDNJKDFHUGSEI  FHUIERBLUUIREB  >6GH4 AA  BDFUIGEVUERERHOBERIHBSDLKFJBNIERIH  NFHILRUGAURHG  

I tried to use

awk '/^>/ && NF==1; NR==FNR{a[$2]=$1} (substr($1,2) in a) {close(out); out="cluster/"a[substr($1,2)]".fa"}  {print > out}' ind.txt file  

but it didn't work, and I couldn't find the solution to the error.

Is it possible to use the magnet uri scheme in PKGBUILDs?

Posted: 01 Jun 2022 10:57 AM PDT

Is it possible to use resources exchanged with the BitTorrent protocol in pacman's PKGBUILDs?

Path in script different than actual path

Posted: 01 Jun 2022 07:37 AM PDT

When I echo $PATH in a terminal window, it outputs:

/home/charles/anaconda3/bin:  /home/charles/anaconda3/condabin:  /usr/local/sbin:/usr/local/bin:  /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:  /usr/local/games:/snap/bin:/snap/bin:  /home/charles/.emacs.d/bin  

But when I run echo $PATH in a script, it only outputs the root paths, not the ones from my home directory:

/usr/local/sbin:/usr/local/bin:  /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:  /usr/local/games:/snap/bin:/snap/bin  

I'm trying to launch spyder from a script, which comes from:

$ which spyder  /home/charles/anaconda3/bin/spyder  

Is there some way to make the script recognize the parts of the path from my home directory?

Bash script - Need to monitor some process in linux system

Posted: 01 Jun 2022 11:09 AM PDT

I am writing this simply script which conver to into a daemon and run in the background. The script job is simple. And it need to monitor a process type say ls command process. And write it into a file for records.

My approach to this to just have a while true loop to constantly check for a process type using ps command. And if it detect it, it will append it to a file.

I was wondering if this is a bad approach to write this

my code as follow

while true  do      if [[ $(ps -aux | grep -w "ls") ]]     then          #append to file     fi   done &  

How to suffix or prefix each line coming from tail command

Posted: 01 Jun 2022 08:15 AM PDT

I have a file and I am running a tail command on this file like this

tail -n+1 -F "./log/catalina.log"  

I want to suffix or prefix another string to each line coming out of this file, which could be the file name itself so that if the file content is like below:

INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/9.0.1  INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Sep 27 2017 17:31:52 UTC  INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.1.0  INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux  

the output should look like this:

Cataline.log INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/9.0.1  Cataline.log INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Sep 27 2017 17:31:52 UTC  Cataline.log INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.1.0  Cataline.log INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux  

Parsing simple JSON without grep -oP possibility

Posted: 01 Jun 2022 08:57 AM PDT

Here is my JSON:

{"login":"WG1118412764OA","password":"9Hv1zd74nKhYovZa"}  

I have very basic grep, no Python, no Perl, and no jq obviously, just awk and sed.

Could somebody give me a hand on that?

I need to have login and password values as shell variables.

Thanks

Kal800

Linux: Is there a limit for the number of fork() calls one process goup can issue? (Not per user!)

Posted: 01 Jun 2022 08:02 AM PDT

We have a strange problem on a SuSE Linux Enterprise Server 12.5 system (kernel 4.12.14-122.60), which is the only KVM guest in a simliar KVM host:

One service started by systemd starts one program -> process which then forks an starts other programs -> child processes which again fork more programs -> child processes.

After appr. 50 or 60 forks including some JAVA children, this stops an all consecutive fork() calls from this process tree fail with errno=11 (ressource temp. unavail.).

A parallel running login session for the the same UID (user) can still create new processes, it can even start the programs that failed in the systemd initialized tree.

As far as I understand, the NPROC settings in /etc/security/limits.conf are system-wide limits for e.g. one UID. But here it looks as if there was a limit that pertains only to one parent process and its children and grand-children?

Is there such a limit, and how could we modify / extend it? Or could it be another parameter which is responsible indirectly for this behaviour?

Additional Info: This problem occurs only on one server installation that we have. All others work without problems. This one has 160 CPU cores and 128GB memory, all other have less than 50% of this. The default NPROC value on this system ist 628000 ...

Any hints or help appreciated.

Regards Stefan B.

PS: Found some similar problems dating back in 2016 for Arch-Linux, but I do not know if the solution using TasksMax applies here as well.

Unable to install pg gem on CentOS Linux release 7.6.1810

Posted: 01 Jun 2022 08:49 AM PDT

ruby --version ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]    gem --version 3.3.7  

PostgreSQL 9.2.24 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit When I run

env ARCHFLAGS="-arch x86_64" gem install pg  

according to this, I get

Building native extensions. This could take a while...  ERROR:  Error installing pg:          ERROR: Failed to build gem native extension.        current directory: /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.3.5/ext  /root/.rbenv/versions/3.1.2/bin/ruby -I /root/.rbenv/versions/3.1.2/lib/ruby/3.1.0 -r ./siteconf20220601-102563-hl61l1.rb extconf.rb  Calling libpq with GVL unlocked  checking for pg_config... yes  Using config values from /bin/pg_config  Using libpq from /usr/lib64  checking for libpq-fe.h... yes  checking for libpq/libpq-fs.h... yes  checking for pg_config_manual.h... yes  checking for PQconnectdb() in -lpq... no  checking for PQconnectdb() in -llibpq... no  checking for PQconnectdb() in -lms/libpq... no  Can't find the PostgreSQL client library (libpq)  *****************************************************************************    Unable to find PostgreSQL client library.    Please install libpq or postgresql client package like so:    sudo apt install libpq-dev    sudo yum install postgresql-devel    sudo zypper in postgresql-devel    sudo pacman -S postgresql-libs    or try again with:    gem install pg -- --with-pg-config=/path/to/pg_config    or set library paths manually with:    gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/    *** extconf.rb failed ***  Could not create Makefile due to some reason, probably lack of necessary  libraries and/or headers.  Check the mkmf.log file for more details.  You may  need configuration options.    Provided configuration options:          --with-opt-dir          --without-opt-dir          --with-opt-include          --without-opt-include=${opt-dir}/include          --with-opt-lib          --without-opt-lib=${opt-dir}/lib          --with-make-prog          --without-make-prog          --srcdir=.          --curdir          --ruby=/root/.rbenv/versions/3.1.2/bin/$(RUBY_BASE_NAME)          --with-pg          --without-pg          --enable-gvl-unlock          --disable-gvl-unlock          --enable-windows-cross          --disable-windows-cross          --with-pg-config          --without-pg-config          --with-pg_config          --without-pg_config          --with-pg-dir          --without-pg-dir          --with-pg-include          --without-pg-include=${pg-dir}/include          --with-pg-lib          --without-pg-lib=${pg-dir}/lib          --with-pq-dir          --without-pq-dir          --with-pq-include          --without-pq-include=${pq-dir}/include          --with-pq-lib          --without-pq-lib=${pq-dir}/lib          --with-pqlib          --without-pqlib          --with-libpq-dir          --without-libpq-dir          --with-libpq-include          --without-libpq-include=${libpq-dir}/include          --with-libpq-lib          --without-libpq-lib=${libpq-dir}/lib          --with-libpqlib          --without-libpqlib          --with-ms/libpq-dir          --without-ms/libpq-dir          --with-ms/libpq-include          --without-ms/libpq-include=${ms/libpq-dir}/include          --with-ms/libpq-lib          --without-ms/libpq-lib=${ms/libpq-dir}/lib          --with-ms/libpqlib          --without-ms/libpqlib    To see why this extension failed to compile, please check the mkmf.log which can be found here:      /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.3.5/mkmf.log    extconf failed, exit code 1    Gem files will remain installed in /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.3.5 for inspection.  Results logged to /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.3.5/gem_make.out  

I have done sudo yum install postgresql-devel

Package postgresql-devel-9.2.24-7.el7_9.x86_64 already installed and latest version  Nothing to do  

and curl -I https://rubygems.org/specs.4.8.gz

HTTP/1.1 200 Connected    HTTP/1.1 200 OK  Connection: keep-alive  Content-Length: 4701495  ...  

I have also done yum groupinstall 'Development Tools'

What should I do to install pg gem?

On Linux Mint host, my Windows 10 VM isn't passing through audio

Posted: 01 Jun 2022 08:00 AM PDT

My Windows 10.0 19044 is a physical installation I like to VM into, however even with VMWare Tools installed, it's not passing through audio. When I launch into the physical installation, there is audio, but on my Linux there is no application audio listed in my sound settings for the VM. Other VMs do have audio.

I'm using VMWare Workstation 16.2.3 build-19376536. Windows 10 lists the sole audio device as "Speakers (2- High Definition Audio Device)" with the most up to date drivers already installed.

Here's the vmx file.

config.version = "8"  virtualHW.version = "19"  mks.enable3d = "TRUE"  pciBridge0.present = "TRUE"  pciBridge4.present = "TRUE"  pciBridge4.virtualDev = "pcieRootPort"  pciBridge4.functions = "8"  pciBridge5.present = "TRUE"  pciBridge5.virtualDev = "pcieRootPort"  pciBridge5.functions = "8"  pciBridge6.present = "TRUE"  pciBridge6.virtualDev = "pcieRootPort"  pciBridge6.functions = "8"  pciBridge7.present = "TRUE"  pciBridge7.virtualDev = "pcieRootPort"  pciBridge7.functions = "8"  vmci0.present = "TRUE"  hpet0.present = "TRUE"  nvram = "Windows 10 and later x64.nvram"  virtualHW.productCompatibility = "hosted"  gui.exitOnCLIHLT = "FALSE"  powerType.powerOff = "soft"  powerType.powerOn = "soft"  powerType.suspend = "soft"  powerType.reset = "soft"  displayName = "Windows 10 and later x64"  usb.vbluetooth.startConnected = "TRUE"  firmware = "efi"  sensor.location = "pass-through"  guestOS = "windows9-64"  vpmc.enable = "TRUE"  tools.syncTime = "FALSE"  numvcpus = "6"  cpuid.coresPerSocket = "3"  memsize = "16384"  mem.hotadd = "TRUE"  sata0.present = "TRUE"  nvme0.present = "TRUE"  nvme0:0.fileName = "Windows 10 and later x64-0.vmdk"  sata0:1.deviceType = "cdrom-raw"  sata0:1.fileName = "/dev/cdrom"  sata0:1.present = "TRUE"  usb.present = "TRUE"  ehci.present = "TRUE"  usb_xhci.present = "TRUE"  svga.graphicsMemoryKB = "8388608"  ethernet0.addressType = "generated"  ethernet0.virtualDev = "e1000e"  serial0.fileType = "thinprint"  serial0.fileName = "thinprint"  ethernet0.present = "TRUE"  serial0.present = "TRUE"  extendedConfigFile = "Windows 10 and later x64.vmxf"  nvme0:1.deviceType = "rawDisk"  nvme0:1.fileName = "Windows 10 and later x64-0.vmdk"  nvme0:0.deviceType = "rawDisk"  numa.autosize.cookie = "60032"  numa.autosize.vcpu.maxPerVirtualNode = "6"  uuid.bios = "56 4d 4e 2e a1 cc 34 9e-4d 49 39 30 2a a3 60 e3"  uuid.location = "56 4d cc 26 08 1d 79 0f-44 d2 47 41 50 9c 2b f5"  vm.genid = "8724792138857890031"  vm.genidX = "-8964534315457435113"  nvme0:0.redo = ""  pciBridge0.pciSlotNumber = "17"  pciBridge4.pciSlotNumber = "21"  pciBridge5.pciSlotNumber = "22"  pciBridge6.pciSlotNumber = "23"  pciBridge7.pciSlotNumber = "24"  usb.pciSlotNumber = "32"  ethernet0.pciSlotNumber = "160"  ehci.pciSlotNumber = "34"  usb_xhci.pciSlotNumber = "192"  sata0.pciSlotNumber = "35"  nvme0.pciSlotNumber = "224"  svga.vramSize = "268435456"  vmotion.checkpointFBSize = "4194304"  vmotion.checkpointSVGAPrimarySize = "268435456"  vmotion.svga.mobMaxSize = "1073741824"  vmotion.svga.graphicsMemoryKB = "8388608"  vmotion.svga.supports3D = "1"  vmotion.svga.baseCapsLevel = "9"  vmotion.svga.maxPointSize = "189"  vmotion.svga.maxTextureSize = "32768"  vmotion.svga.maxVolumeExtent = "16384"  vmotion.svga.maxTextureAnisotropy = "16"  vmotion.svga.lineStipple = "1"  vmotion.svga.dxMaxConstantBuffers = "15"  vmotion.svga.dxProvokingVertex = "0"  vmotion.svga.sm41 = "1"  vmotion.svga.multisample2x = "1"  vmotion.svga.multisample4x = "1"  vmotion.svga.msFullQuality = "1"  vmotion.svga.logicOps = "1"  vmotion.svga.bc67 = "9"  vmotion.svga.sm5 = "1"  vmotion.svga.multisample8x = "1"  vmotion.svga.logicBlendOps = "1"  ethernet0.generatedAddress = "00:0C:29:A3:60:E3"  ethernet0.generatedAddressOffset = "0"  vmci0.id = "715350243"  monitor.phys_bits_used = "45"  cleanShutdown = "FALSE"  softPowerOff = "FALSE"  usb:1.speed = "2"  usb:1.present = "TRUE"  usb:1.deviceType = "hub"  usb:1.port = "1"  usb:1.parent = "-1"  checkpoint.vmState = ""  sata0:1.startConnected = "FALSE"  toolsInstallManager.lastInstallError = "0"  svga.guestBackedPrimaryAware = "TRUE"  tools.remindInstall = "FALSE"  toolsInstallManager.updateCounter = "2"  guestInfo.detailed.data = "architecture='X86' bitness='64' buildNumber='19044' distroName='Windows' distroVersion='10.0' familyName='Windows' kernelVersion='19044.1706' prettyName='Windows 10 Home, 64-bit (Build 19044.1706)'"  isolation.tools.hgfs.disable = "FALSE"  sharedFolder0.present = "TRUE"  sharedFolder0.enabled = "TRUE"  sharedFolder0.readAccess = "TRUE"  sharedFolder0.hostPath = "/home/ram/Torrents"  sharedFolder0.guestName = "Torrents"  sharedFolder0.expiration = "never"  sharedFolder1.present = "TRUE"  sharedFolder1.enabled = "TRUE"  sharedFolder1.readAccess = "TRUE"  sharedFolder1.writeAccess = "TRUE"  sharedFolder1.hostPath = "/home/ram/.steam/debian-installation"  sharedFolder1.guestName = "Steam"  sharedFolder1.expiration = "never"  sharedFolder.maxNum = "2"  hgfs.mapRootShare = "TRUE"  gui.lastPoweredViewMode = "fullscreen"  ethernet0.linkStatePropagation.enable = "TRUE"  floppy0.present = "FALSE"  sound.present = "TRUE"  sound.pciSlotNumber = "33"  sound.virtualDev = "hdaudio"  nvme0:0.present = "TRUE"  tools.upgrade.policy = "useGlobal"  usb_xhci:4.present = "TRUE"  usb_xhci:4.deviceType = "hid"  usb_xhci:4.port = "4"  usb_xhci:4.parent = "-1"  unity.wasCapable = "TRUE"  sound.autoDetect = "TRUE"  sound.fileName = "-1"  

I've tried setting explicit sound devices in the VM too, to no avail.

Am I missing something? Any help's appreciated!

Extracting a partial part from filename using SED

Posted: 01 Jun 2022 08:16 AM PDT

I am trying to understand this sed command to store something in a variable:

username=$(find . -iname '*.txt' | sed -e 's/.*_\([0-9]\{4\}_[0-9|A-z]*\).*/\1./i' | sort - | uniq -ui |tr -d '\n')  

I understand what sed does and the part at sed -e 's/.*_\([0-9]\{4\}_[0-9|A-z]*\).*/\1./i' is basically taking out the regex equivalent of the username example SOMETHING_USERNAME.

find . -iname '*.txt' - Finds the name of the file that has the extension txt? and iname is used because it should ignore the case?

sort - sorts the files in order if there are more than one files?

uniq -ui allows to only store unique usernames.

tr -d deletes the rest?

I am trying to see if the understanding here is correct and if not how does it work.

adding the code for further help and more understanding for myself.

function process_zip {      file="$1" #file is set to the INPUT      folder="$file-$(date +%s)" #Setting Foldername        declare -x   folder=${file%.*}     # Adding the file name to the left of the date and seconds.      echo "filename to process" $file #printing filename          echo "folderName" $folder #printing folder name      mv "input/$file" in_progress #Move the folder from input to in_progress      cd in_progress; #Go to progress        # check file for validity before unzipping          unzip -qq $file -d $folder; #not sure what -qq does exactly. This command unzips and checks if folder is available?      echo "unzip completed" #prints      cd $folder/placeholder/placeholder2; #goes into that folder?      chmod -R 770 ** #Run recursively? understand this little but need more help.      rsync -r * /placeholder1/placeholder2/placeholder3/placeholder4/;       echo "copy completed"      #I want to use this next line so that the cut isn't hardcoded and works for files longer than 10 characters.      #extract=$(find . -iname '*.txt' | sed -e 's/.*_\([0-9]\{4\}_[0-9|A-z]*\).*/\1,/i' | sort - | uniq -ui | tr -d '\n')      extract=$(cut -c -10 <<<"$file")      echo "Extracted part is"$extract      java -jar /placeholder1/placeholder2/placeholder3/placeholder4/placeholder5.jar $extract &      cd ../../..; #back to in_progress      pwd      mv $file ../completed      rm -r $folder &      cd ../;      echo "finished processing" $file  }    remaining=$(ls -1 input | grep .zip | wc -l) #It checks for more input files?    echo "${remaining} files to process"      while [ $remaining -gt 0 ]  do      file=$(ls -t1 input| grep .zip | head -n1)      echo "$file"      process_zip "$file";        remaining=$(ls -1 input | grep .zip | wc -l)      echo "${remaining} files to process"  done;      find completed/* -mtime +15 -exec rm {} \;  find errors/* -mtime +15 -exec rm {} \;  find logs/* -mtime +15 -exec rm {} \;    echo "all done"  

Thank you!

Add extra field to a file for records that have 6 fields instead of 7

Posted: 01 Jun 2022 07:38 AM PDT

I have a problem with text files separated by commas, when I'm going to begin receiving files (hundreds of them) with a mixed layout, some records will have 7 fields(a total of 6 commas) and other records in the same file will have 6 fields (a total of 5 commas).

When I find a record with 5 commas, I want to add at the end of that record a comma followed by NA so my loading process thinks it has 7 fields, being the last one NA.

This is what I have right now, the first record has 7 fields, the second only 6:

200000003183000100,Data,NA,0,IN,0,0.00  200000004625000000,Data,NA,0,IN,0  

This is what I expect (both records with 7 fields)

200000003183000100,Data,NA,0,IN,0,0.00  200000004625000000,Data,NA,0,IN,0,NA  

Can this be done counting commas with sed or something similar and adding at the end of the file ,NA whenever there's only 5 commas. Please keep in mind this is going to happened for hundreds of files, so I don't know if I need to use the filename as a parameter so something like that.

DD-WRT dhcp-host in Additional Dnsmasq Options working - except dig

Posted: 01 Jun 2022 08:44 AM PDT

Trying to move dnsmasq service from a Linux VM to a newly setup DD-WRT router running v3.0-r48810 std 05/06/22.

I'd like to keep the static addresses in ip addr order so instead of entering into DHCP Server/Static Leases I am trying to use dhcp-host in Additional Dnsmasq Options which the DD-WRT Static DHCP documentation suggests is possible - but it is confusing and it's not working correctly on the Linux Mint 19.3 systems that can not ping the Windows systems.

After posting the above question I set up a test network with a DD-WRT router and two laptops - one Windows and one Linux.

After reading forums and extensive testing the following setup seems to work except for the dig command output on the Linux system (more below).

I tried taking out some of the settings like in Additional Dnsmasq Options but dnsmasq will stop working and systems can't ping each other. I tried what some sites said is to put the router ip address into Static DNS 1 but that wouldn't work with any combination of settings.

DD-WRT version in test setup: v3.0-r44715 std (11/03/20)

Network Setup    Router IP      Local IP Address        192.168.1.1      Subnet Mask             255.255.255.0      Gateway                 0.0.0.0      Local DNS               0.0.0.0    Network Address Server Settings (DHCP)      DHCP Type               DHCP Server      DHCP Server             Enabled        Start IP Address        192.168.1.100      Maximum DHCP Users      75      Client Lease Expiration 1440min      Static DNS 1            1.1.1.1      Static DNS 2            1.0.0.1      Static DNS 3            0.0.0.0      WINS                    0.0.0.0      Use DNSMasq for DNS     Enabled        DHCP-Authoritative      Enabled      DHCP Server      Used Domain             LAN & WLAN      LAN Domain              Mydom      Add. DHCPd Opts         [none]      Static Leases           [none]    SmartDNS Resolver      SmartDNS Resolver       Disabled    Dnsmasq      Dnsmasq                 Enabled      Encrypt DNS             Disabled      Cache DNSSEC data       Disabled      Val DNS (DNSSEC)        Disabled      Chk unsign DNS rep      Disabled      No DNS Rebind           Enabled      Qry DNS in Strict Order Enabled      Add Reqr MAC to DNS Qry Disabled      RFC4039 Rapid Cmt Spt   Disabled      Maximum Cached Entries  1500    Additional Dnsmasq Option      domain=mydom      local=/mydom/      domain-needed      bogus-priv      expand-hosts      dhcp-option=3,192.168.1.1      dhcp-option=6,192.168.1.1      dhcp-host=B8:32:E3:AA:EA:5F,C9:F7:33:64:80:39,Winder,192.168.1.100      dhcp-host=F4:B7:E2:25:5D:F9,Linuxer,192.168.1.130  

With the above settings the Windows and Linux system can ping each other by ip address and by name. Nslookup looks normal on Windows - but the Linux dig command gets answered with a Refused. I don't know what to do about this or how important it is.

$ dig    ; <<>> DiG 9.11.3-1ubuntu1.17-Ubuntu <<>>  ;; global options: +cmd  ;; Got answer:  ;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 41574  ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1    ;; OPT PSEUDOSECTION:  ; EDNS: version: 0, flags:; udp: 4096  ;; QUESTION SECTION:  ;.              IN  NS    ;; Query time: 1 msec  ;; SERVER: 192.168.1.1#53(192.168.1.1)  ;; WHEN: Wed Jun 01 14:35:00 PDT 2022  ;; MSG SIZE  rcvd: 28  

awk/sed split a cluster file in to multiple files

Posted: 01 Jun 2022 08:47 AM PDT

I have a cluster fasta file (called file) which looks like:

>1AB2  >1AB2 AA  NWWIEUNJRNIBGOWNGIOWGRBIGBRGRIOWGI  NCIDHFR8EHGBVPIWOBGIGRI  >1AB3 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >1SC4 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >2CD5 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >2AC6  >2AC6 AA  NFIGEURHGEIROHEGHTUTJGENLJBBEOWRIU  NFIROUHBOERVERUGBERUOVREOIBROEBVUE  NVHIRE  >2ONM AA  BUCIEHBUORBREOBWQVURVELLAJFLHIEBGR  NHEIBVEURIGBVNRIHEOEAJVSJDNHVUGBVR  NEBIBVVBRU  >2POD AA  BUFEWIBOEUWBWOREBRIUBGUERIGBVOSRIP  BUEIBVEO  >7KZL  >7KZL AA  BUIREBVAUREVBREOIRGPNJBFDVERUBVROR  >6HG3  >6GH3 AA  NBVUIREVOIAWRHRUGRTYUVDNJKDFHUGSEI  FHUIERBLUUIREB  >6GH4 AA  BDFUIGEVUERERHOBERIHBSDLKFJBNIERIH  NFHILRUGAURHG  

the about file has 4 groups: 1AB2, 2AC6, 7KZL, and 6GH3. the content during the first >1AB2 and the first >2AC6 belongs to the cluster 1AB2. the content during the first >2AC6 and the first >7KZL belongs to the cluster 2AC6.

I want to separate the file into 4 files at the second >XXXX. each file should look like:

file_1

>1AB2 AA  NWWIEUNJRNIBGOWNGIOWGRBIGBRGRIOWGI  NCIDHFR8EHGBVPIWOBGIGRI  >1AB3 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >1SC4 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  >2CD5 AA  WNIOREHUEBRGOUERGHBERGIORBGREUGEGO  NWFWRUBGREOUEREOBRIOBNERIOBN  

file_2

>2AC6 AA  NFIGEURHGEIROHEGHTUTJGENLJBBEOWRIU  NFIROUHBOERVERUGBERUOVREOIBROEBVUE  NVHIRE  >2ONM AA  BUCIEHBUORBREOBWQVURVELLAJFLHIEBGR  NHEIBVEURIGBVNRIHEOEAJVSJDNHVUGBVR  NEBIBVVBRU  >2POD AA  BUFEWIBOEUWBWOREBRIUBGUERIGBVOSRIP  BUEIBVEO  

file_3

>7KZL AA  BUIREBVAUREVBREOIRGPNJBFDVERUBVROR  

file_4

>6GH3 AA  NBVUIREVOIAWRHRUGRTYUVDNJKDFHUGSEI  FHUIERBLUUIREB  >6GH4 AA  BDFUIGEVUERERHOBERIHBSDLKFJBNIERIH  NFHILRUGAURHG  

Is there a GUI to handle LVM and software RAID operations?

Posted: 01 Jun 2022 07:57 AM PDT

Are there any free graphical tools to manage advanced Linux storage schemes such as software RAID and LVM arrays in a similar fashion to how GParted handles partitions?

Unfortunately, it seems most Linux distributions don't come with such tools installed.

There is, for example, GNOME Disks, but it doesn't have the capability to do this any longer.

What tools are available that fit my criteria?

Squid deny_info https not working

Posted: 01 Jun 2022 09:51 AM PDT

I have squid proxy server configured on centos 8 and working fine i have blocked some sites through squid when anyone access to blocked url it simply show the page browser cant open the page. I just want to ERROR_ACCESS. here is below my configuration.

acl localnet src 200.200.200.0/24  acl localnet src 172.30.0.0/16    acl SSL_ports port 443  acl Safe_ports port 80      # http  acl Safe_ports port 21      # ftp  acl Safe_ports port 443     # https  acl Safe_ports port 70      # gopher  acl Safe_ports port 210     # wais  acl Safe_ports port 1025-65535  # unregistered ports  acl Safe_ports port 280     # http-mgmt  acl Safe_ports port 488     # gss-http  acl Safe_ports port 591     # filemaker  acl Safe_ports port 777     # multiling http  acl CONNECT method CONNECT    http_access deny !Safe_ports    http_access deny CONNECT !SSL_ports    http_access allow localhost manager  http_access deny manager    acl badsite url_regex "/etc/squid/block"  http_access deny badsite all  deny_info ERR_ACCESS_DENIED badsite    http_access allow localnet  http_access allow localhost    http_access deny all    http_port 3128  cache_dir ufs /var/spool/squid 100 16 256    coredump_dir /var/spool/squid    refresh_pattern ^ftp:       1440    20% 10080  refresh_pattern ^gopher:    1440    0%  1440  refresh_pattern -i (/cgi-bin/|\?) 0 0%  0  refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880  refresh_pattern .       0   20% 4  

manipulate icon-position of samba-shares on caja-desktop

Posted: 01 Jun 2022 10:17 AM PDT

I know how to manipulate the position of desktop icons with the gio set command

gio set -t string '/home/user/Schreibtisch/example' 'metadata::cajas-icon-position' '500,500'

But this does not works with samba-shares. I also can't find the samba-shares in ~.local/share/gvfs-metadata/ (where are external drives)

How dows one manipulate the Icons of samba-shares on Caja Desktops with gio?

Not able to start a new kex session in kali linux for wsl2

Posted: 01 Jun 2022 09:33 AM PDT

When I try to run kex in kali-linux for WSL2, following error message is thrown. There's no missing dependencies. I have tried all solutions listed in this thread, but none of it works for me. Any other suggestions will be really appreciated:

Win-KeX server sessions:    X DISPLAY #     RFB PORT #      PROCESS ID  :1              5901            584    You can use the Win-KeX client to connect to any of these displays.    randhir@LAPTOP-294HO1DB:~$  TigerVNC Viewer 32-bit v1.10.80  Built on: 2020-06-15 22:33  Copyright (C) 1999-2020 TigerVNC Team and many others (see README.rst)  See https://www.tigervnc.org for information on TigerVNC.    Mon Aug 24 21:52:43 2020   DecodeManager: Detected 4 CPU core(s)   DecodeManager: Creating 4 decoder thread(s)    Mon Aug 24 21:52:45 2020   CConn:       unable to connect to socket: No connection could be made because                the target machine actively refused it. (10061)  

fstab issue mount system call failed not a directory

Posted: 01 Jun 2022 08:35 AM PDT

I added two extra entries in my fstab file in an attempt to move tmp directories off SSD to HDD:

/dev/sdb1 /tmp none bind 0 0  /dev/sdb1 /var/tmp none bind 0 0  

However this stops my PC from booting up and there's an error: "mount: /var/tmp: mount(2) system call failed: Not a directory"

What am I doing wrong? How can I move those temp dirs from my SSD to HDD?

Make `Ctrl + W` and `Ctrl + Alt + H` in zsh behave the same as in bash

Posted: 01 Jun 2022 09:00 AM PDT

In bash behavior is like this:

  • Ctrl+W deletes the word behind the cursor up to the next space
  • Ctrl+Alt+H deletes the word behind the cursor up to the next seperation charcater like ., ,, -, / etc.

In zsh both Ctrl+W and Ctrl+Alt+H behave like the latter one in bash.

I would like the same behavior as in bash.

"You may not install to this volume because it is a Mac in target disk mode" error when installing Catalina on a mac in TDM

Posted: 01 Jun 2022 10:07 AM PDT

Hello Unix/Linux community, looking for your help. I am running into an issue where I am trying to install Catalina 10.15.2 on a machine that has been wiped. The machine is in target disk mode and I am using the "Install macOS Catalina" app to image this mac. When I launch the app I see all of my mounted devices including the machine that is in TDM but when I select it as the disk where I want Catalina installed I get a message that states that: "You may not install to this volume because it is a Mac in target disk mode". Is it not possible to image a mac that is in TDM? BTW I have tried imaging the disk as APFS and Mac Os Extended (Journaled). Any help/guidance is appreciated. Thank you.

LFTP exclude specific folder only

Posted: 01 Jun 2022 08:03 AM PDT

I have same folder name in different sub-directories, but while mirroring I want to exclude specific folder only.

Example :

I have directory "123" in different directories

./abc/123/  ./abc/xyz/123/  ./xxx/123/  ./abc/yyy/123/  

I want to exclude ./abc/123/ only, but if I use below command that exclude all occurance

lftp  -p 22 -e 'mirror --exclude ./abc/123/ './abc' '/var/www/' ; exit' sftp://user@domain.com  

How to prevent dd's progress from being meaningless on Linux?

Posted: 01 Jun 2022 11:11 AM PDT

When running dd command to copy an ISO on Linux, I get a single progress print that stays open for a long time (many minutes). Then another at the end.

The problem seems to be that a very large cache is being used which confuses dd 's output.

sudo dd bs=4M if=my.iso of=/dev/sdc status=progress  

Output (first line shows for a long time).

1535115264 bytes (1.5 GB, 1.4 GiB) copied, 1.00065 s, 1.5 GB/s  403+1 records in  403+1 records out  1692844032 bytes (1.7 GB, 1.6 GiB) copied, 561.902 s, 3.0 MB/s  

Is there a way to prevent this from happening so the progress output is meaningful?

run pm2 from remote shell script

Posted: 01 Jun 2022 09:05 AM PDT

I am trying to write a script which ssh into a bunch of my servers and runs some commands to start my app. One of the commands (pm2) always says pm2: command not found. This is how I'm attempting this:

ssh -o StrictHostKeyChecking=no -i /Path/to/key-pair.pem ubuntu@${ec2ips[i]} 'bash ' << 'STARTAPP'      cd ~/my-app-folder      pm2 start ./bin/www --name 'my-app'      exit  STARTAPP  

when I ssh in normally, all pm2 commands run fine. If I ssh in and run a script with pm2 in it, it also works as expected. It's only when I try and run it on a remote machine from my machine.

Can't change update settings on elementary?

Posted: 01 Jun 2022 11:06 AM PDT

I can't update elementary os, when I try to change the settings 'Install updates from', none of the check boxes will check, it stays like the following image. What should I do? enter image description here

No comments:

Post a Comment