Sunday, September 5, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Boot into backup without GRUB

Posted: 05 Sep 2021 10:32 AM PDT

I want to boot into a Timeshift backup (btrfs) without the GRUB menu, as it isn't showing there. Is there a way to do this?

make socat constantly listen for the magic packet

Posted: 05 Sep 2021 09:53 AM PDT

I have a RPi 1b+ v1.2 with Raspbery Pi OS June 2021.

I'm using socat to trigger a bash script that wakes another pc in the network up. I use this command:

sudo socat UDP-LISTEN:10 EXEC:scripts/pi-wol.sh,fork but in throws an error 2021/09/05 19:26:38 socat[1743] E parseopts(): option "fork" not supported with this address type.

It works fine without fork but only once and I need it to constantly listen. Any ideas how can I do that?

Alpine Linux From Scratch - Initial Setup

Posted: 05 Sep 2021 09:51 AM PDT

I installed Alpine Linux with minimal packages.

# apk info  musl  busybox  alpine-baselayout  alpine-keys  ca-certificates-bundle  libretls  ssl_client  zlib  apk-tools  scanelf  musl-utils  libc-utils  libcrypto1.1  libssl1.1  

Now I have two problems that I want to solve.

How do I enable syntax highlighting in nano?

And the .bashrc file (Which I made myself with Touch, Because there is no other file on the root except the .ash_history file.) does not work either. How can I enable it?

How to fix kali linux resolution problem?

Posted: 05 Sep 2021 09:46 AM PDT

I installed kali linux yesterday and as soon as I entered I saw my screen was in 3840 x 2160.

It was so big and I decided to change it to 1920x1080. When I changed it using display options it kept reverting back. So I used terminal and ran the command below,

xrandr -s 1920x1080  

As soon as I ran the command, my screen was blank and that's it! black screen of death!

So I decided to use command mode using ctrl+alt+f1. And I ran the xrandr to list the resolution available, it shows "can't open display". What should I do to make everything normal?

Help me solve,

  • How to set the screen resolution normal like windows, ie 1920x1080 in kali linux?

  • Where is the file in kali linux that stores the display settings?

How can I revert to secure repository sources (without display access) for Linux Mint 19.1?

Posted: 05 Sep 2021 09:36 AM PDT

I'm using Linux Mint Cinnamon 19.1 Tessa. Recent unstable internet problems led me to install wcid and uninstall network manager(s). After reboot "unable to launch "cinnamon-session-cinnamon" X session ---- "...." not found. Tried Lord Boltar's solution (sudo apt-get update, sudo apt-get, install nemo, install cinnamon, reboot) but the mirror repository "evowise" is no longer signed and will not fetch the files I need. When I try to change repositories I can only open a display using nano /etc/apt/sources.list but the field is empty and I don't know how to add a new secure repository directly. I've been at this all day and I haven't been able to find any answers to this combination of problems. Please help! I work online these days.

How to save file permission in logrotate process

Posted: 05 Sep 2021 09:24 AM PDT

I want to rotate some log files but I don't want to create a new file . I want my original log file remain exactly as same as before . my conf_file is like this :

/path to log file/{

} it's working . because log file inod_number doesn't change after rotation . but file permission is changed. How can I save original log file permission without using directives like create or copytruncate ?

how to implement or improve a "killfile" for stack exchange?

Posted: 05 Sep 2021 09:19 AM PDT

SE doesn't have any killfile capability to hide posts by trolls and other abusive people. And, unfortunately, blocking such trolls can't be done with CSS hacks alone (because there's nothing in the CSS which distinguishes a troll from a normal person). Blocking trolls need to be done by matching their usernames in the actual text of the post or comment, so it requires javascript and a userscript manager like grease/tamper/violent-monkey.

I've come up with the following (based on the same code I've used for other sites to hide advertorial garbage hiding amongst actual articles - no obvious CSS differences, but with identifiable author By-Lines), which mostly works but it doesn't interact perfectly with posts that have lots of comments - it breaks the "Show more comments" link. Not a huge problem, but I'd rather it didn't do that.

Does anyone have any idea what's causing it to do that, or how to fix it? Is it the div class for comments div.comment-text.js-comment-text-and-form that I'm targeting?

// ==UserScript==  // @name         Killfile Userscript for Stack Exchange  // @namespace    MonkeyScripts  // @version      0.1  // @description  Hide posts by abusive/irritating users  // @author       cas  // @match        https://*.stackexchange.com/*  // @match        https://*.stackoverflow.com/*  // @match        https://*.serverfault.com/*  // @match        https://*.superuser.com/*  // @match        https://*.askubuntu.com/*  // @require      https://code.jquery.com/jquery-2.1.0.min.js  // @grant        none  // ==/UserScript==    // hide posts and comments by particular authors    (function() {        let Trolls = ['Ned Trollton','Angry Stalker','loser12345'];          let elements = ['div.comment-text.js-comment-text-and-form',                        'div.answercell.post-layout--right',                        'div.question'];          for (let i = 0; i < Trolls.length; i++) {            for (let j = 0; j < elements.length; j++) {                $(elements[j] + ":contains(" + Trolls[i] + ")").hide();            }      }  })();  

Kernel 5.11 probably doesn't like my TPM settings (Asus X541UAK)

Posted: 05 Sep 2021 09:03 AM PDT

This week I've tried several different Live USB Linux distros on my Asus X541UAK (4 GB RAM, 500 GB HDD, Inter Core i3-7100, Windows 10 Pro 19043 [latest], BIOS v311 [latest]):

  1. Manjaro 21.1.1, with kernel 5.4, started up instantly and ran flawlessly. Just perfection.

    a. Kubuntu 20.04, also with kernel 5.4 (which I tried a year ago, when it just came out), ran flawlessly, with no excess elements before startup.

  2. Kubuntu and Ubuntu Studio 20.04.2.0, both with kernel 5.8, showed an error

tpm_crb MSFT0101:00: [Firmware Bug]: ACPI region does not cover t  he entire command/response buffer. [mem 0xfed40000-0xfed4087f flags 0x200] vs fed40080 f80  

twice (two identical rows) before the respective logo appeared and the system checked all the files in itself, but after that it also ran flawlessly.

  1. Kubuntu and Ubuntu Studio 20.04.3, both with kernel 5.11, showed the same error screen, checked all their files, and that's all. Kubuntu has a "Try/Install" window before loading into Live session, and pressing Try button caused endless* loading; the rest of buttons were unclickable. Ubuntu Studio (with XFCE) didn't have a welcome window and loaded the desktop instantly. But none of apps (tried Firefox, Ardour, Okular) worked — they crashed with the Crash reporter. The application has a problem and crashed pop up appearing.

    a. Pop!_OS 20.04 also seems to have kernel 5.11 (the devs don't mark which subversion of Ubuntu it's based on, most probably 20.04.3, since it's downloaded within this week) and behaves identically to Ubuntu Studio.

*I didn't wait for more than 5 minutes and turned off the laptop manually

None of the images is corrupt, nor the USB sticks. The way of making em bootable (burning with Etcher, Rufus, creating a Ventoy partition) doesn't change anything.

The firmware bugs clearly show that there's something with my TPM, but my BIOS (even on latest version) doesn't have TPM even mentioned (although Windows shows that i have TPM 2.0 enabled).

Questions:

  1. Is it actually about kernels? The most flawless of them, Manjaro, is an Arch derivative, the rest are Ubuntu derivatives.
  2. If i'm about to use 5.11 kernel in future (I hope 5.13 or 5.14 won't have such an error), what can be the way to fix it?

I can't bind keys in ZSH / Where can I get escape sequence for the key in SHELL?

Posted: 05 Sep 2021 08:21 AM PDT

I try to bind 'left|right' keys in ZSH, but it seems a) the escape sequences are wrong or b) terminal (but all of them?? mate xterm, st?) is blocking these '\E' sequences. I can bind for example Ctrl+Left, Shift+Left, Home, End, but I don't know how to bind Shift+Home|End and Left|Right.

I've tested following escape sequences: "left" "\eOD" "right" "\eOC"
"shome" "\E[1;2~" "send" "\E[4;2~"

Is there any command "write '\e' sequence for the key $key"?? Thanks.

Trying to record from a USB sound card

Posted: 05 Sep 2021 09:46 AM PDT

I'm using a UGreen USB External Stereo Sound Card and would like to record the music from some old tapes.

I am not able to manage any kind of recording with it.

My Fedora recognizes it immediately as a USB Advanced Audio Device and gives me the following Profiles:

  • Analog Stereo Input
  • Digital Stereo (IEC958)-Input
  • Analog Stereo Output
  • Analog Stereo Duplex
  • Analog Stereo-Output + Stereo (IEC958)-Input
  • Digital Stereo (IEC958)-Output
  • Digital Stereo-Output + Analog Stereo-Input
  • Digital Stereo Duplex (IEC958)

It can be found:

$ cat /proc/asound/cards   0 [HDMI           ]: HDA-Intel - HDA Intel HDMI                        HDA Intel HDMI at 0xf7a14000 irq 36   1 [PCH            ]: HDA-Intel - HDA Intel PCH                        HDA Intel PCH at 0xf7a10000 irq 37   2 [Device         ]: USB-Audio - USB Advanced Audio Device                        C-Media Electronics Inc. USB Advanced Audio Device at usb-0000:00:14.0-2, full   

Also apparently audacity is able to find it:

$ arecord --list-devices  **** Liste der Hardware-Geräte (CAPTURE) ****  Karte 1: PCH [HDA Intel PCH], Gerät 0: VT1802 Analog [VT1802 Analog]    Sub-Geräte: 0/1    Sub-Gerät #0: subdevice #0  Karte 2: Device [USB Advanced Audio Device], Gerät 0: USB Audio [USB Audio]    Sub-Geräte: 0/1    Sub-Gerät #0: subdevice #0  

I have tried to do a short recording using hw2:

[qohelet@localhost Audio]$ arecord -f cd -D hw2,1 -d 20 test.wav  ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM hw2,1  arecord: main:830: Fehler beim Öffnen des Gerätes: Datei oder Verzeichnis nicht gefunden  [qohelet@localhost Audio]$ arecord -f cd -D hw2,0 -d 20 test.wav  ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM hw2,0  arecord: main:830: Fehler beim Öffnen des Gerätes: Datei oder Verzeichnis nicht gefunden  

(Both times the error is: Error during opening of the device: File or directory not found)

Inside audacity I don't have many choices. ALSA for the device; pulse/default for the input and that's it (except for the channels). I assume it takes the selection from the OS as I can get a pulse in audacity the moment I select a different profile from the Audio-Options. Everything else is essentially a line.

I have tried to stream it via VLC where my options are hw1,0 and hw2,0. I selected hw2,0 and get an error:

[00007fb6d8009890] access_alsa demux error: cannot open ALSA device "hw:2,0": Das Gerät oder die Ressource ist belegt  [00007fb6d801c590] main decoder error: buffer deadlock prevented  

The device or the resource is busy

There had often been the recommendation for the beta-version of audio-recorder. But this doesn't give any information and it seems it's not even properly working (notice the two non-functional buttons): enter image description here

I have tried to output from the old tape system's RCA connector to the headphones to see if the output is still working. The volume is weirdly low, but it works.

What could be the problem and how to solve it?

How to add a custom source to apt repositories?

Posted: 05 Sep 2021 08:14 AM PDT

I'm trying to add kata-containers repository to my apt sources (fresh debian install) but i keep getting an "unable to locate package x" despite adding the source, key and updating the package manager :

$ ARCH=$(arch)  $ BRANCH="${BRANCH:-master}"  $ sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/katacontainers:/releases:/${ARCH}:/${BRANCH}/xUbuntu_$(lsb_release -rs)/ /' > /etc/apt/sources.list.d/kata-containers.list"  $ curl -sL  http://download.opensuse.org/repositories/home:/katacontainers:/releases:/${ARCH}:/${BRANCH}/xUbuntu_$(lsb_release -rs)/Release.key | sudo apt-key add -  $ sudo -E apt-get update  $ sudo -E apt-get -y install kata-runtime kata-proxy kata-shim  

Source : https://github.com/kata-containers/documentation/blob/master/install/ubuntu-installation-guide.md

Inside sources.list.d/kata-containers.list :

deb http://download.opensuse.org/repositories/home:/katacontainers:/releases:/x86_64:/master/Debian_9/ /  

What did i miss ?

how to print file name and total number of fasta sequences?

Posted: 05 Sep 2021 08:23 AM PDT

I have a fasta file namely test.fasta, pas.fasta, cel.fasta as shown below

test.fasta  >tile  ATGTC  >259  TGAT    pas.fasta  >ta  ATGCT    cel.fasta  >787  TGTAG  >yog  TGTAT  >In  NNTAG  

I need to print the file name and the total number of fasta sequences as shown below,

test,2  pas,1  cel,3  

I have used the following commands but failed to serve my purpose

grep ">" test.fasta | wc -l && ls test.fasta  

Please help me to do the same.

Thanks in advance.

Is there any linux alternative of macOS application firewall?

Posted: 05 Sep 2021 09:17 AM PDT

By alternative it's not meant the program needs to be gui. Any method that allows a program to logs when something calls listen() and only allows selected programs to listen to the interface:port will works. I've seen opensnitch but it woeks with outbound connections only.

If such program doesn't exist can anyone point to how to create? Like using nftable rules. What I'm not looking for is to run a program in separate net namespace etc. The solution should work for all userland programs in general.

Pulseaudio not working with MPD

Posted: 05 Sep 2021 10:25 AM PDT

I have system-wide configuration for MPD, that runs in a remote server. I have

audio_output {          type            "pulse"          name            "My Pulse Output"          server          "jarnos-OptiPlex-9010.local"  }  

in /etc/mpd.conf, and

load-module module-native-protocol-tcp auth-ip-acl=192.168.100.10   

in /etc/pulse/default.pa of the remote server. (the IP is the one of jarnos-OptiPlex-9010.local.) Should I have auth-cookie-enabled=false in the line, too? Should I add port number?

Still, I don't hear audio from the MPD server in jarnos-OptiPlex-9010.local. Pulseaudio is not even running in the machine where the MPD server is running. I had this working before, but can't see what has changed.

Should you run Pulseaudio as system-wide daemon, if you run MPD with system-wide configuration?

The MPD machine is running Ubuntu 18.04 and the other one is running Ubuntu 20.04.

Regular expressions and wildcards in `if` statements

Posted: 05 Sep 2021 09:16 AM PDT

I am using regular expressions and wildcards in if statements.

Examples:

  [[ "$exitfn" =~ ^[yY]*$ ]] && return    [[ "$exitfn" == "[yY]*" ]] && return    [[ "$exitfn" == "*$fs*" ]] && return    [[ "$exitfn" == *$fs* ]] && return  

But really wonder about any difficulties introduced if I quote *$fs*" or do not quote *$fs*.

Also wondering about using =~ against ==.

Unable to locate an executable at "/Library/Java/JavaVirtualMachines

Posted: 05 Sep 2021 08:20 AM PDT

Whenever I try to run any apt command on my Mac I get

Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home/bin/apt" (-1)  

error.

My .bash_profile looks as below:

Export JAVA_HOME=/Library/Java/Home  # Setting PATH for Python 3.7  # The original version is saved in .bash_profile.pysave  PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"  export PATH  

Group files and directories based on first letter of their name and move them to directories of that letter

Posted: 05 Sep 2021 09:35 AM PDT

I have a directory with the following content:

$ mkdir dir && cd "$_"  ~/dir $ mkdir a1 a2 a3 a4 b1 c1 c2 1a 2a 2b 2c 2d 3a _1 _2  ~/dir $ touch a_1 a_2 a_3 a_4 b_1 c_1 c_2 1_a 2_a 2_b 2_c 2_d 3_a __1 __2  ~/dir $ ls  __1  1_a  __2  2_a  2_b  2_c  2_d  3_a  a_1  a_2  a_3  a_4  b_1  c_1  c_2  _1   1a   _2   2a   2b   2c   2d   3a   a1   a2   a3   a4   b1   c1   c2  

Now I want to group all these files and directories based on their first letter and move them to directories of the same letter. So the output would be:

~/dir $ ls  _  1  2  3  a  b  c  

And using exa, the tree would look something like this:

~/dir $ exa --tree  .  ├── 1  │  ├── 1_a  │  └── 1a  ├── 2  │  ├── 2_a  │  ├── 2_b  │  ├── 2_c  │  ├── 2_d  │  ├── 2a  │  ├── 2b  │  ├── 2c  │  └── 2d  ├── 3  │  ├── 3_a  │  └── 3a  ├── _  │  ├── _1  │  ├── _2  │  ├── __1  │  └── __2  ├── a  │  ├── a1  │  ├── a2  │  ├── a3  │  ├── a4  │  ├── a_1  │  ├── a_2  │  ├── a_3  │  └── a_4  ├── b  │  ├── b1  │  └── b_1  └── c     ├── c1     ├── c2     ├── c_1     └── c_2  

I know I can move using wildcards:

~/dir $ mkdir a && mv a* a  

Which throws an error:

mkdir: cannot create directory 'a': File exists  

But it gets the job done. And I can do something like this to avoid the error:

~/dir $ mkdir temp && mv a* temp && mv temp a  

And then I could use that in a for loop for every letter that I know. But the problem is that I don't know what those first letters could possibly be, we have quite a lot of letters. Is there a way I can achieve this without the need to know those letters?

Microphone issues on debian 10

Posted: 05 Sep 2021 09:05 AM PDT

I'm trying to set up discord chat with debian 10 installed on macbook pro. there are two input devices listed in discord. Default, and Built-in Audio Analog Stereo. I was using Default, and it worked fine. When I shut the computer down and started it back up the next day, discord says that it can't detect any input from my mic. I just want to use my built-in laptop mic.

alsamixer:
enter image description here
sudo alsamixer:
enter image description here
enter image description here
What should I change?

EDIT: Also: why is the "Mic" level empty?

Check the disk space in Ubuntu (with ls)

Posted: 05 Sep 2021 09:04 AM PDT

I am using AWS Free tier Ubuntu. It is saying that disk space full in /dev/xvda1 which is mounted on / . I am using df command to check it.

I went to the directory / and using command ls -l to check which file is taking much space. But, none of them is taking that much within / . What is the recommended way to find out which file is taking much space ?

I have attached the screenshot, please check it. You can see none of them is taking 99892768 space.

enter image description here

What does % symbol in Makefile mean

Posted: 05 Sep 2021 09:33 AM PDT

I am playing around with makefiles and I came across %.o or %.c. From what I understood, it specify all c or o files. But why this work:

%.o: %.c          $(CC) -c $^  -o $@    

and this doesn't work

SOURCE := $(wildcard *.c)    $(SOURCE:.c=.o): SOURCE          $(CC) -c $^  -o $@  

Both expression specify all the files. so what %.o: symbol in make file does ?

Need to find latest file in multiple folders with a pattern and move to another server

Posted: 05 Sep 2021 09:07 AM PDT

I have several folders on one server numbered 1-10. Each folder has multiple files. I need to find the latest file with a pattern name for example :

  • file 1 : NA_UW_CLUSTER_RESULTS_210916.zip
  • file 2 : UW_CLUSTER_RESULTS_210916.zip

I need to select 'file 2' and copy it to another server having multiple corresponding folders numbered 1-10.

So i need to copy latest file (UW_CLUSTER_RESULTS_210916.zip) with matching pattern from 'folder 1' in 'A' server to 'folder 1' in 'B' server.

collect and print multiple pages to single pdf file in linux

Posted: 05 Sep 2021 09:37 AM PDT

I have to print multiple documents from different applications (browsers, pdf readers etc) and print to a pdf file. What I want to do is collect the documents when i 'print' from these applications and be able to print those collected documents into a single PDF file. It would be even better if it allows some sort of editing or sorting of pages before i print to the PDF. Currently, I can print single files to pdfs using cups-pdf which shows up as a virtual pdf printer and then combine into one pdf file manually. It gets the job done but was wondering if there is an easy single step way.

wildcard usage for a directory displaying filenames in linux?

Posted: 05 Sep 2021 09:12 AM PDT

so one of the questions i have been working on is to display the contents of a directory files by using its wildcards do display specific contents, in this case aim using ls and the portion that I got lost on is I need to display filenames that stat is a but exclude everything that has aa. it can however be ab.

any hints, ill keep looking and post and answer if i find anything, and any help with usage of wildcards would be great. Thanks

UDP Port Fowarding: channel 2: open failed: connect failed: Connection refused

Posted: 05 Sep 2021 10:05 AM PDT

My situation is as follows:

I have currently trying to have a program between two Hosts send UDP packets over a SSH Tunnel. There is also a host intermediate between the two hosts. Note Server01 separates two subnets

Subnet: //// 10.11.X.X ///////// 192.168.X.X
Host: Client <------> Server01 <-----> Server02

enter image description here

I have successfully established a SSH connection and have used RSA key's so passwords are not needed.

I than followed this tutorial:

SSH Port Forwarding for UDP

In summary it tells me to use socat to configure a TCP-UDP relay on server01 by typing in:

server01$ socat tcp4-listen:8000,reuseaddr,fork udp:server02:53  

and a UDP-TCP relay on the client using socat also:

client$ socat -T15 udp4-recvfrom:53000,reuseaddr,fork tcp:localhost:8000  

Now comes the problem. When I attempt to have my program create a socket on the localhost UDP Port 53000 and send data,

channel 2: open failed: connect failed: Connection refused  channel 2: open failed: connect failed: Connection refused  channel 2: open failed: connect failed: Connection refused  

I believe my program is fine because when I put server02 on the same subnet as client my programs will exchange UDP packets perfectly.

Is there a setting I need to enable for my program to access the UDP port 53000 Socket? Or is it just impossible to create a socket on the UDP port because socat using it? I've been stuck on this for a while... Any help would be great.

Thanks in advance.

Issue with Hugepage reservation in linux

Posted: 05 Sep 2021 09:05 AM PDT

I have reserved hugepages for my process using below commands:

#echo 64 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages  #mkdir -p /mnt/huge  && mount -t hugetlbfs nodev /mnt/huge .  

And I have placed it in rc.local file.

After machine reboot, huge pages reserved successfully and /mnt/huge created.

But before my process startups, I could see 21 hugepages are not available for reservation. Below command output:

# cat /proc/meminfo | grep Huge   HugePages_Total: 64   HugePages_Free: 43   HugePages_Rsvd: 43   HugePages_Surp: 0   Hugepagesize: 2048 kB   

And no results for the below commands:

# lsof |grep /mnt/huge   [root@CLA-0(11) /root]   

Then I tried to free hugepages ...

# echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages   

No error message displayed. But below command output tells no change ..

# cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages    0   

But I could see if we echo > 64 it updates nr_hugepages. Also tested with other numbers, it only updates if value is greater then current value in nr_hugepages.

I am looking for below clarification in this site:

  1. 43 hugepages are free , who requested 21 hugepages allocation out of 64.
  2. Why echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepage is not updating nr_hugepages

Linux Kernel

# cat /proc/version   Linux version 2.6.34.13-WR4.3.x86_64_fbsa_standard-00038-gc4b8cb8 (gcc version 4.4.1 (Wind River Linux Sourcery G++ 4.4a-431) ) #1 SMP Wed Jan 8 20:40:41 EET 2014  

How do you move all files (including hidden) from one directory to another?

Posted: 05 Sep 2021 09:01 AM PDT

How do I move all files in a directory (including the hidden ones) to another directory?

For example, if I have a folder "Foo" with the files ".hidden" and "notHidden" inside, how do I move both files to a directory named "Bar"? The following does not work, as the ".hidden" file stays in "Foo".

mv Foo/* Bar/  

Try it yourself.

mkdir Foo  mkdir Bar  touch Foo/.hidden  touch Foo/notHidden  mv Foo/* Bar/  

No comments:

Post a Comment