Thursday, May 5, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


ELF symbol: GLOBAL+HIDDEN

Posted: 05 May 2022 12:14 PM PDT

Based on eg. this Oracle description:

STB_GLOBAL Global symbols. These symbols are visible to all object files being combined. One file's definition of a global symbol will satisfy another file's undefined reference to the same global symbol. ...

STV_HIDDEN A symbol defined in the current component is hidden if its name is not visible to other components. Such a symbol is necessarily protected. This attribute is used to control the external interface of a component. An object named by such a symbol may still be referenced from another component if its address is passed outside.
A hidden symbol contained in a relocatable object is either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object.

However, looking at readelf -s of some simple test program (compiled with GCC on x86-64 Linux), there are some global hidden symbols:

FUNC    GLOBAL HIDDEN    16 _fini  OBJECT  GLOBAL HIDDEN    25 __dso_handle  OBJECT  GLOBAL HIDDEN    25 __TMC_END__  

According to the description above this should be both nonsensical and not allowed at all.

What are the properties (visibility, interpositioning ability, ...) of this combination?

How to remove a specific color from a whole pdf document?

Posted: 05 May 2022 11:55 AM PDT

Is their a way, with imagemagick, pdftk or other stuff, to remove a specific color from a whole pdf document?

I mean, I give an html hex color code to a tool, and it remove all occurences of this color from a pdf file.

How to do it?

One liner to archive, test the archive and stop if error or remove source folder

Posted: 05 May 2022 11:33 AM PDT

I've made my small shell function to un-compress the latest archive in a specific folder, then use it (code removed for sake of clarity), and then make an archive, test it and if everything is ok, remove the tmp folder, otherwise just stop. And sometimes, it doesn't work (archive problem I dont know when I retry it works), so I should not remove the folder, and stop. My small script doesn't work. I've made a comment where the one-liner doesn't work, so here's my script:

mine() {      src="/mnt/myfolder"      game_folder="MyGameFolder"      src_folder="${src}/${game_folder}"      src_archive="${src}/${game_folder}.tar"      tmp="/tmp/tmpfolder"        # Expand path (don't do this if path is set by user input!):      echo "Folder tmp: '${tmp}'."      [ ! -d "${src}" ] && echo "Folder src: '${src}' not found. Exiting." && return 1      rm -rf "${tmp}"      mkdir "${tmp}"      [ ! -d "${tmp}" ] && echo "Folder tmp: '${tmp}' not found. Exiting." && return 1      cd "${tmp}"      if [ -d "${src_folder}" ]; then          # Archive folder exists -> find latest archive and uncompress:          latest="$(ls -t "${src_folder}/" | head -1)"          full_latest="${src_folder}/$latest"          if [ -f "${full_latest}" ]; then              echo Copying "${latest}"...              cp "${full_latest}" .              echo Unpacking "${latest}"...              tar xf "${latest}"          else              echo "Warn: no archive found in: '${src_folder}'"          fi      else          echo "No folder: '${src_folder}', creating folder, it's a new game..."          mkdir "${src_folder}" \          || (echo "Unable to create '${src_folder}'" ; return 1)      fi        archive="$(date '+%Y.%m.%d-%Hh%Mm%Ss').${game_folder}.tar.bz2"      printf "\n\nMaking archive '${archive}'..."        # here's the one-liner that doesn't work:      tar cjf "${archive}" "${game_folder}/" \      && mv "${archive}" "${src_folder}/" \      && latest="$(ls -t "${src_folder}/" | head -1)"      && tar -tf "${latest}" \      || (echo "Error tar cjf ${archive}" "${src_archive}/" && exit 1)      rm -rf "${tmp}"      cd      printf "\nDone. You can exit the shell if you want now.\n\n"      return 0  }  

What should I change to make it work?

How to merge arrays from multiple arrays in two JSON with JQ

Posted: 05 May 2022 12:25 PM PDT

I have two JSON files (file1.json and file2.json) with the following same structure as defined below with two array lists as shown below.

The first file is (file1.json):

{    "Lists1": [     {        "point": "a",        "coordinates": [          2289.48096,          2093.48096        ],     }    ]    "Lists2": [     {        "point": "b",        "coordinates": [          2289.48096,          2093.48096        ],     }   ]  }  

The second file is (file2.json):

{    "Lists1": [     {        "point": "c",        "coordinates": [          2289.48096,          2093.48096        ],     }    ]    "Lists2": [     {        "point": "d",        "coordinates": [          2289.48096,          2093.48096        ],     }   ]  }  

so my expected output will be:

{    "Lists1": [     {        "point": "a",        "coordinates": [          2289.48096,          2093.48096        ],     },     {        "point": "c",        "coordinates": [          2289.48096,          2093.48096        ],     }    ]    "Lists2": [     {        "point": "b",        "coordinates": [          2289.48096,          2093.48096        ],     },     {        "point": "d",        "coordinates": [          2289.48096,          2093.48096        ],     }   ]  }  ``        I am trying to merge (combine) these two files using `jq`. I found using the command below, but this only work with one list.     ```sh  jq -n '{ list1: [ inputs.list1 ] | add }' file1.json file2.json  

Is there a way to modify this function to combine both list1 and list2?

SSH/SCP CLI Connection Works Correctly, but SFTP via GUI Refuses to Connect

Posted: 05 May 2022 10:48 AM PDT

I recently configured a new web server (AWS EC2 instance) running Ubuntu 22.04. I am able to connect to the server via SSH/SFTP/SCP through a CLI on both Windows and Mac, but when I attempt an SFTP connection via a GUI (WinSCP on Windows; Commander One on Mac) my authentication is refused. I am using a private-key connection without a password, and the same exact key is being used in the CLI and in the GUI.

On the remote Ubuntu Server I am running byobu but I have tried disabling it (as byobu modified my .bashrc and .profile), and that has not fixed the problem.

I have a number of other servers all running different versions of Ubuntu (the problem server is the only one on 22.04), all of them have byobu enabled, and there are no issues connecting to them via SSH or GUI SFTP.

Maybe something changed in the latest version of OpenSSH and OpenSSL on Ubuntu 22.04? The versions installed on Ubuntu 22.04 are OpenSSH_8.9p1 Ubuntu-3 & OpenSSL 3.0.2 15 Mar 2022.

I have also added PubkeyAcceptedKeyTypes=+ssh-dss to my sshd_config file, but that has not helped.

Lastly, I had UFW running, but have disabled it and that has not changed anything.

stdin/stderr redirection, piping and color

Posted: 05 May 2022 11:32 AM PDT

I've seen a zillion permutations on this question but I think none is an exact duplicate.

Can I copy only stderr (or eventually stderr and stdin) to a file, while keeping the colorized output on the screen (if the files are colorized also, that's a bonus)

ps command: what does "/bin/login -p --" exactly mean? What is its purpose to be shown?

Posted: 05 May 2022 10:36 AM PDT

Through Virtual Box for Ubuntu Server, having:

  • the 6 tty being logged with 3 different users (2 users in 2 tty, for example user1 logged at tty1 and tty3, user2 logged at tty2 and tty4 and so on)
  • 3 SSH connections.

With the ps a command the output is as follows:

  PID TTY      STAT   TIME COMMAND   1238 tty1     Ss     0:00 /bin/login -p --   2517 tty1     S+     0:00 -bash   2529 tty2     Ss     0:00 /bin/login -p --   2607 tty2     S+     0:00 -bash   2631 tty4     Ss     0:00 /bin/login -p --   2632 tty3     Ss     0:00 /bin/login -p --   3244 tty3     S+     0:00 -bash   3830 tty4     S      0:00 -bash   3846 tty5     Ss     0:00 /bin/login -p --   3912 tty5     S+     0:00 -bash   3928 tty6     Ss     0:00 /bin/login -p --   3994 tty6     S+     0:00 -bash   4086 pts/0    Ss+    0:00 -bash   4185 pts/1    Ss     0:00 -bash   4266 pts/2    Ss     0:00 -bash   4385 tty4     S+     0:00 man ps   4395 tty4     S+     0:00 pager   4509 pts/1    S+     0:00 man ps   4519 pts/1    S+     0:00 pager   4570 pts/2    R+     0:00 ps a  

And with the ps -a command the output is as follows:

  PID TTY          TIME CMD   2517 tty1     00:00:00 bash   2607 tty2     00:00:00 bash   3244 tty3     00:00:00 bash   3830 tty4     00:00:00 bash   3912 tty5     00:00:00 bash   3994 tty6     00:00:00 bash   4385 tty4     00:00:00 man   4395 tty4     00:00:00 pager   4509 pts/1    00:00:00 man   4519 pts/1    00:00:00 pager   4571 pts/2    00:00:00 ps  

For the two outputs shown is clear at in a first glance that the main difference between them is the inclusion of the /bin/login -p --. The second is about -bash and bash

Question

  • What does /bin/login -p -- exactly mean?

It specially about the -p and -- parts

At a first glance it indicates some user is logged - but it seems "redundant" - because for each tty# (user logged) practically appears in the report the tty# S+ 0:00 -bash pattern - so if -bash appears therefore automatically is assumed or it means that an user is logged, right?. It generates/arises the first extra question

Extra Questions

  • What is the purpose to report /bin/login -p --?
  • Why does not appear something "similar" for a SSH connection?

In the report about the command and cmd headers of both commands respectively

  • Do the -bash and bash have an explicit difference? (observe the - part) or is just presentation?

Note I read both man ps and ps --help a and there is no information about this.

Debian 10 kernel header package version mismatch

Posted: 05 May 2022 10:34 AM PDT

I install linux-headers-4.19.0-16-amd64 on Debian 10 running the kernel from package linux-image-4.19.0-16-amd64.

I try to build WANPIPE driver from Sangoma and find in /lib/modules/4.19.0-16-amd64/build/Makefile

VERSION = 2  PATCHLEVEL = 6  MAKEARGS := -C /usr/src/linux-headers-4.19.0-16-common O=/usr/src/linux-headers-4.19.0-16-amd64  MAKEFLAGS += --no-print-directory  

So it makes the Setup script of WANPIPE driver thinks it's a 2.6 kernel.

Any hint about why Makefile is so or it's just a bug?

Thanks

Finding the right drivers in the linux kernel

Posted: 05 May 2022 10:31 AM PDT

I have an ELAN touch-pad with vendor id 04F3:3128 and I'm trying to find the right Linux kernel drivers to support it. I will start by noting that the touch-pad works with live CDs, like for example Linux Mint. I can, however, not seem to find the right settings in the kernel to get it to work.

(On a live CD where the mouse pad works) if I go into /sys/bus/hid/devices, I can find the device here listed as 0018:04F3:3128.0001. If I then cd into the device and then into the subsystem directory and then further into the directory drivers, here I can find hid-generic and hid-multitouch. I have enabled those using make nconfig and compiled the kernel, but it still can't find the mouse pad.

How can I find the proper settings (or modules) in the kernel to support my mouse pad?

Linux service ExecStop wait for bash script to finish

Posted: 05 May 2022 09:30 AM PDT

Currently I am trying to run a minecraft server on a linux instance. I am using a linux service in order to start the server when the instance boots up, and shut the server down before stopping the instance. Unfortunately I am having a little bit of trouble getting this to work, since the service does not seem to wait for the bash script triggered by ExecStop to finish before actually shutting down the instance.

[Unit]  Description=Minecraft Server  After=network.target    [Service]  User=minecraft  Type=forking  Nice=5  KillMode=mixed  SuccessExitStatus=0 1  InaccessibleDirectories=/root /sys /srv /media -/lost+found  NoNewPrivileges=false  WorkingDirectory=/opt/minecraft/server  ReadWriteDirectories=/opt/minecraft/server  TimeoutStopSec=600    #### Command to start the server.  ExecStart=/opt/minecraft/server/startserverbash  ExecStop=/opt/minecraft/server/stopserverbash    [Install]  WantedBy=multi-user.target  

I tried using TimeoutStopSec=600 in order to wait 10 minutes with shutting down the instance, but this does not seem to work. Also if it would, i don't really like the implementation.

I read something about using KillMode=mixed which should do the job, but unfortunately the service still does not wait for the stopserverbash to finish stopping the server before shutting down the instance.

Could someone help me with implementing a solution that will wait for my game server to stop before shutting down the instance?

Side note: the stopserverbash sends a stop command to a screen called serverscreen in order to stop the server, and then checks every 5 seconds whether the serverscreen is still running before stopping the script.

Unable to use SCP to do SCP from server to Host

Posted: 05 May 2022 11:07 AM PDT

First off, I gotta admit I'm still kind of a major noob with Linux, so that might explain some simple mistakes I might be making.

I'm currently trying to extract some files from a Server (Ubuntu 20.04) to a domain computer (Windows 10) via SCP.

But I've so far been unable to do it successfully.

Basically summing up the situation

I'm using Putty to connect via SSH to an Ubuntu Server (connecting via IP and a specific port) and with user and password authentication.

I'm running the SCP command like this:

SCP -P (the port used for the SSH connection to the server) /folder/subfolder/file domain_account_name@domain_computer_IP:"Destination Location"  

But my SCP attempts always end up in a time out.

I've tried running the SCP code with the specific port used when connecting to the Server and also the default one (22), and both attempts end up with the same result.

Any ideas as to where I might be messing up?

Thanks

Unix-domain Socket

Posted: 05 May 2022 09:40 AM PDT

I'm trying to set my server up and came across some troubles related to Unix domain sockets. I don't have so much experience with Unix, despite the stack for web development: Apache, PHP and SQL. I installed Apache and PostgreSQL, but trying to access the psql shell I came across the following error:

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "root" does not exist

My pg_hbs.confhas this appearence:

TYPE DATABASE USER ADDRESS METHOD
local all root/postgres/home (all was tried already)
IPv4
host all root 127.0.0.1:5232 scram-sha-256
IPv6
host all root ::1/128 scram-sha-256

The error references the "local" field in the config file. I just opened up some documentation about Unix sockets, it's very interesting, and I will want to know more about but, despite looking like "I'd be to recreating the wheel", I just want to set the environment for development right now.

Any help will be welcome.

Thanks.

`docker run --rm debian:jessie apt update` does not work on Fedora host

Posted: 05 May 2022 10:15 AM PDT

I'm having trouble debugging a docker issue. On my machine as host, every apt/apt-get/apt-cache command in the debian:jessie image hangs and I can't figure out why.

On other machines with docker, when I run (for example)

docker run --rm debian:jessie apt list  

it takes a few seconds but then the list pops up. On my machine, it just hangs forever (> 30 minutes) and uses a full CPU core.

Any ideas on how to debug this problem?

I'm on a fedora 35 (x86_64) with recent and decent hardware. I've already

  • tried to run different commands - all take a CPU core and freeze. I tried at least apt update, apt upgrade, apt list, apt show apt, apt-cache showpkg apt and certainly a few more I can't remember
  • tried to disable selinux via setenforce 0 on the host, to no effect
  • tried to take the network away via the --network none arguments to docker, to no effect
  • updated my fedora host system, to no effect
  • checked that the docker-ce version is the latest stable - it is
  • tried it with docker run --rm debian:latest apt list (i.e. the latest debian) - this works, but I need the old one (jessie, not latest)
  • tried to stop the fedora firewall via systemctl stop firewalld.service and restart the docker daemon via systemctl restart docker (thanks @rubynorails), to no effect

Any ideas on how to go from here?

How can we create a deployment pipeline without triggering the build from Jenkins?

Posted: 05 May 2022 09:10 AM PDT

I have used webhooks which are triggering the jobs finely. But I also need parameters to be fed in the build job and don't want to manually start the build from Jenkins. It should happen once the pull request is merged with the master branch.

PPS on focal/20.04 timed out and never recovers

Posted: 05 May 2022 09:14 AM PDT

we recently have upgraded to a new industry PC from Vecow/Plugin and to Ubuntu 20.04 from 18.04. From the BIOS (build date BIOS ~17.02.2022) and the IO chip according to it is a SuperIO 8786: https://github.com/huchanghui123/ITE-SuperIO/blob/master/IT8786E-I_B_V0.2.pdf

We have a PPS device connected to one (but tried all) serial/COM/RS232 port we have available (DCD Pin, we also connected GND). Which we attach to with ldattach pps /dev/ttyS0 and want to integrate with chrony again.

ldttach works and also ppstest. What happens is that after a short time (30-100 s), which seems to be rather random, it often fails to fetch the time stamps and times out and never recovers. But after deattaching and reattaching the ldisc it works again (for some time).

Instead of our PPS device we also tried a function generater at 1 Hz (pulse or duty cycle 50%, 1ms, 10ms, 100 and 200 ms). The Voltage level of our device which worked on the previous PC is 0 - ~3.7V. We set the function generator to operate within RS-232 at +/-3.7, 5, 6.6 and 10V (upper limit of our generator). Issue is the same.

We are on the HWE generic kernel btw (so 5.13). On the old PC it worked (even live via Ubuntu 20.04). We also tried an Ubuntu 22.04 live image (kernel 5.15) and Fedora 35 but it fails there too. Also on our second identical PC.

Anybody experienced something similar or has a clue how to debug it further? Especially to rule out a driver error (or any other HW error).

Thanks!

binaries not executable by user (Permission denied) after cmake install / make install to /usr/local/bin

Posted: 05 May 2022 10:10 AM PDT

After I install any project on my Debian (Buster) machine with sudo cmake install or sudo make install command, the binary gets placed inside /usr/local/bin but although the PATH variable is set correctly and even after a reboot, bash or fish cant find the command for the binaries installed that way.

This happened with cmake and nvim so far. For nvim, for example, I followed the build from source instructions:

  1. cloned repo with git
  2. make CMAKE_BUILD_TYPE=Release
  3. sudo make install

Now if I run nvim, the command is not found, but if I run sudo nvim the binary is started correctly.

I compared the file permissions of binaries that are perfectly executable without sudo rights inside /usr/bin and they are exactly the same permissions like the binaries inside /usr/local/bin.

-rwxr-xr-x 1 root root.

What am I doing wrong and why are the binaries inside /usr/bin exexutable without sudo and files installed from source inside /usr/local/bin not?

This is my PATH variable: /usr/local/bin:/usr/bin:/bin:/usr/games

Additional info: If I run: /usr/local/bin/nvim this is the output: fish: The file "/usr/local/bin/nvim" is not executable by this user

If I run type -a nvim the output is: type: Could not find 'nvim'

How to mount a ZFS volume in FreeBSD for cloning

Posted: 05 May 2022 09:54 AM PDT

I am in the process of trying to clone a FreeBSD installation onto a new hard drive and need to mount it and then find the mount points in order to proceed with the cloning process.

The internal drive that I want to clone to currently has a Windows 10 install and a not very optimised FreeBSD install that I want to clone over.

I am happy to use the current UFS partition scheme for the FreeBSD.

I will boot from a live FreeBSD USB stick in order to run the appropriate commands. The problem that I am having is that the disk I want to clone from is partitioned using ZFS and I can't get my head round how to mount it and then how to find the mount points. The disk is connected to my computer using a USB-SATA adapter.

Ethernet adapter in "lspci" but not available in "nmtui"

Posted: 05 May 2022 10:21 AM PDT

How can I activate an Ethernet adapter which is visible in lspci but otherwise not exposed?

Messing around, I recently moved an SSD with a Fedora install from one computer to another. Without changing anything, most everything is working quite adequately-- it is great how flexible things were! However, while I can see the network interface hardware on the new computer with lspci, I cannot see it in ifconfig.

The only interfaces I have available are the loopback and a "bridge" interface. The card is not disabled in BIOS and was working to PXE boot previously. I tried manually adding it via ifcfgs generated by nmtui including adding MACADDR/HWADDR fields to those, but with those in place, systemctl would fail to restart networkmanager.

Edit: In front of the system again. Strangely, when I boot with a USB NIC attached to get around this issue, it is not enumerated in ifconfig unless I unplug/re-plug. I am able to in BIOS specify the passthrough MAC to be the NIC1 MAC, so I have the same MAC on the USB Ethernet adapter. This doesn't solve the root issue, which I am still trying to solve.

cron is no longer logging, but it seems to be running

Posted: 05 May 2022 10:27 AM PDT

I am running Ubuntu 20.04 as a server on a remote machine. I have confirmed that cron is running as a service:

  $ sudo service cron status  ● cron.service - Regular background program processing daemon       Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)       Active: active (running) since Mon 2022-05-02 12:17:55 PDT; 4h 45min ago         Docs: man:cron(8)     Main PID: 2769 (cron)        Tasks: 1 (limit: 526)       Memory: 4.7M       CGroup: /system.slice/cron.service               └─2769 /usr/sbin/cron -f  

And it has jobs to run under /var/spool/cron/crontabs :

* * * * * /bin/bash -l -c '/tmp/test.sh' >>/tmp/crontest 2>&1  

which creates correct output:

$ cat /tmp/crontest   Mon 02 May 2022 05:02:01 PM PDT  Mon 02 May 2022 05:03:01 PM PDT  Mon 02 May 2022 05:04:01 PM PDT  

But is not being logged:

$ cat /etc/rsyslog.d/50-default.conf   cron.*              /var/log/cron.log  
$ ls -lt /var/log/cron.log  -rw-rw---- 1 syslog adm 0 Mar 28  2021 /var/log/cron.log  

I have stopped and restarted the service. I have rebooted the server. I changed the group permissions. I tried to change the log directory to /tmp per this question, which did not work, so I am not thinking this is a permissions issue.

I am not sure how to go forward from here. There are lots of people with similar issues, but mostly these seem to be related to misconfigured crontabs. Any help is appreciated.

Edit: Adding the journalctl output. Seems to be working there too.

$ journalctl -xe -u cron.service | tail    May 02 12:17:55 sidero systemd[1]: Started Regular background program processing daemon.  -- Subject: A start job for unit cron.service has finished successfully  -- Defined-By: systemd  -- Support: http://www.ubuntu.com/support  --   -- A start job for unit cron.service has finished successfully.  --   -- The job identifier is 736.    

I need help with KWIN crashing on Linux

Posted: 05 May 2022 09:07 AM PDT

I use Nitrux as my Linux distribution, and when I switch apps, sometimes KWIN crashes. I tried to see if my settings were causing a problem, but I couldn't find anything. Please help.

systemd service file closing socket

Posted: 05 May 2022 09:05 AM PDT

I need to run a C++ binary with systemd.

When I execute the binary directly or with a bash script it runs fine for days:

  • nohup ./testbinary &
  • ./test.sh

test.sh:

#!/bin/bash  LD_LIBRARY_PATH="/home/test01/lib/"  export LD_LIBRARY_PATH  /home/test01/testbinary  

But when I execute this script with the following systemd service file:

[Unit]  Description=cr06    Wants=network.target  After=syslog.target network-online.target    [Service]  Type=simple  ExecStart=/home/test01/test.sh  Restart=on-failure  RestartSec=10  KillMode=process    [Install]  WantedBy=multi-user.target  

It runs for some time, like 6 to 7 minutes, then it gives errors, and I need to restart the service.

The socket connection that this binary is making to other applications fails. It only happens when the binary is executed as a systemd service.

Kitty terminal automatically deselects text?

Posted: 05 May 2022 09:12 AM PDT

Every time I highlight text to copy from the Kitty terminal, it automatically deselects it. This is creating a situation where I cannot copy from the terminal.

What might be causing this behaviour?

How to merge arrays from multiple json files with JQ?

Posted: 05 May 2022 11:10 AM PDT

I have multiple JSON Files with the same structure , the list is the array.

$ jq 'keys' file_1.json  [    "itemsPerPage",    "links",    "list",    "startIndex"  ]  

the list field looks like this

file1.json

 "list" : [ {"id: 123, "fname":"SAM" }, {"id: 125, "fname":"JOE" } .....]  

fileX.json

 "list" : [ {"id: 783, "fname":"Danny" }, {"id: 785, "fname":"Kingmo" } .....]  

trying to generate an output as follows (Only List and Ignoring other fields which are itemsPerPage/links/startIndex)

 "list" : [ {"id: 123, "fname":"SAM" }, {"id: 125, "fname":"JOE" },  {"id: 783, "fname":"Danny" }, {"id: 785, "fname":"Kingmo" }]    

what's the best way to read all those files in with jq and generate a single file with one list array that has all the objects from all the JSON files ?

evaluating dual blocking commands in a bash condition statement

Posted: 05 May 2022 10:00 AM PDT

I am attempting to write a loop that refreshes a terminal either

  1. when the file(s) have been modified, or
  2. when user input is detected second interval.

I know how to do one at a time, like so:

while inotifywait -q -e mofidy /path/to/file -r ; do ls; done  

... and I can easily do

while read; do ls; ls; done  

But how would I do them congruently? as in, refresh when either read returns true and/or when inotifywait returns true? I've tried a few examples, but I haven't put too much thought into it.

setup wireless router using systemd-networkd *.network files

Posted: 05 May 2022 10:06 AM PDT

I would like to configure an embedded device to behave as a wireless router, and I would like to achieve it preferably using networkd configuration files.

I have two *.network files, a wired WAN interface and a wireless LAN interface, and I would like LAN traffic to be able to access WAN.

# cat /etc/systemd/network/wired.network   [Match]  Name=eth0    [Network]  DHCP=ipv4  IPForward=yes  IPMasquerade=yes  

As is common for wireless routers, the wireless LAN network anso provides DHCP. I used the systemd integrated DHCP server.

# cat /etc/systemd/network/wireless.network  [Match]  Name=wlan0*    [Network]  Description = Wireless IP interface  DHCPServer= yes    [Address]  Address   = 192.168.128.1/24  Broadcast = 192.168.128.255    [DHCPServer]  PoolOffset          = 10  PoolSize            = 40  EmitDNS             = yes  DNS                 = 8.8.8.8, 8.8.4.4  DefaultLeaseTimeSec = 600  MaxLeaseTimeSec     = 7200    [Route]  

I assume there should be a NAT between the two networks, as is common for wireless routers, but it is not an explicit requirement.

This is as far as I got with my current knowledge, the wired interface connects to WAN properly, and the wireless access point also provides DHCP addresses. But I am unable to access WAN (internet) if I connect to the WiFi AP.

Here is some network interface status:

# ip a  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00      inet 127.0.0.1/8 scope host lo         valid_lft forever preferred_lft forever      inet6 ::1/128 scope host         valid_lft forever preferred_lft forever  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000      link/ether 00:26:32:f0:03:21 brd ff:ff:ff:ff:ff:ff      inet 192.168.178.107/24 brd 192.168.178.255 scope global dynamic eth0         valid_lft 4650sec preferred_lft 4650sec      inet6 fe80::226:32ff:fef0:321/64 scope link         valid_lft forever preferred_lft forever  3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default      link/sit 0.0.0.0 brd 0.0.0.0  4: wlan0wext: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether 00:1d:43:40:0d:04 brd ff:ff:ff:ff:ff:ff      inet 192.168.128.1/24 brd 192.168.128.255 scope global wlan0wext         valid_lft forever preferred_lft forever      inet6 fe80::21d:43ff:fe40:d04/64 scope link         valid_lft forever preferred_lft forever  

And route status:

# ip route  default via 192.168.178.1 dev eth0  proto dhcp  src 192.168.178.107  metric 1024  192.168.128.0/24 dev wlan0wext  proto kernel  scope link  src 192.168.128.1  192.168.178.0/24 dev eth0  proto kernel  scope link  src 192.168.178.107  192.168.178.1 dev eth0  proto dhcp  scope link  src 192.168.178.107  metric 1024    # ip route show table local  broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1  local 127.0.0.0/8 dev lo  proto kernel  scope host  src 127.0.0.1  local 127.0.0.1 dev lo  proto kernel  scope host  src 127.0.0.1  broadcast 127.255.255.255 dev lo  proto kernel  scope link  src 127.0.0.1  broadcast 192.168.128.0 dev wlan0wext  proto kernel  scope link  src 192.168.128.1  local 192.168.128.1 dev wlan0wext  proto kernel  scope host  src 192.168.128.1  broadcast 192.168.128.255 dev wlan0wext  proto kernel  scope link  src 192.168.128.1  broadcast 192.168.178.0 dev eth0  proto kernel  scope link  src 192.168.178.107  local 192.168.178.107 dev eth0  proto kernel  scope host  src 192.168.178.107  broadcast 192.168.178.255 dev eth0  proto kernel  scope link  src 192.168.178.107  

I was not able to find many examples for the [Route] section, and I only have the basic understanding of routing.

Regards, Iztok Jeras

Mounting efi disk on external USB

Posted: 05 May 2022 11:05 AM PDT

Recently I bought new sshd to replace my old one on my notebook, but I have problem. I installed Ubuntu 15.10 on new one and put the old on usb case I have, but the disk on USB doesnt have partition (I screamed for 5 minutes because I can't lose data).

So I moved back my old disk inside the disk bay and put the new on usb case, and all my data was here intact but the disk on usb shows no partition.

Both of disks when in usb case show the model and factory correctly but not the partitions. The case is OK, tested with old HDD that doesn't have GPT/EFI partition.

How can I mount the external disk so I can transfer my files?

Ouput of commands:

 $ sudo blkid /dev/sdb    /dev/sdb: PTTYPE="PMBR"       $ sudo parted /dev/sdb print    Error: /dev/sdb: unrecognised disk label   Model: ST1000LM 014-1EJ164 (scsi)                                        Disk /dev/sdb: 1000GB Sector size (logical/physical): 4096B/4096B   Partition Table: unknown Disk Flags:    $ sudo gdisk /dev/sdb   GPT fdisk (gdisk) version 1.0.0    Partition table scan:    MBR: protective    BSD: not present    APM: not present    GPT: not present  

gpg2 decryption timeout/no secret key

Posted: 05 May 2022 12:08 PM PDT

I'm having an issue decrypting files with gpg2. I originally encrypted the files with gpg version 1.4. The machine I'm on now has both gpg (1.4) and gpg2. Decryption with gpg works just fine, but when I execute the same command with gpg2, it times out:

$ echo "This is a test" > test.txt  $ gpg -r MyOwnId --encrypt test.txt    (creates test.txt.gpg)  $ gpg --decrypt test.txt.gpg    (provide passphrase for MyOwnId)    -> This is a test  $ gpg2 --decrypt test.txt.gpg    (after a long timeout)    -> gpg: encrypted with 2048-bit RSA key, ID #######, created YYYY-MM-DD "MyOwnId"       gpg: public key decryption failed: Timeout       gpg: decryption failed: No secret key  

What's going on? It says "No secret key", but running gpg2 --list-secret-keys shows this:

/home/me/.gnupg/pubring.kbx  -------------------------------  sec   rsa2048/######## YYYY-MM-DD  uid         [ unknown] MyOwnId  ssb   rsa2048/######## YYYY-MM-DD  

Update 1:

Looks like the problem isn't with gpg2 itself, but rather with my Gnome keyring or something. Previously, when I tried to decrypt files with gpg2, it would simply hang, then time out. However, once I encrypted a test file with my own key, then decrypted that file, it prompted me for my passphrase. Now that my passphrase is in my keyring, everything's working. Might have just been a temporary thing (I logged out and back in between then and now). If anyone has more info on issues like this, I'd love to know. I'll give it another day or two, then close the question if it doesn't happen again.

How to convert a color pdf to black-white?

Posted: 05 May 2022 10:42 AM PDT

I'd like to transform a pdf with some coloured text and images in another pdf with only black&white, in order to reduce its dimensions. Moreover, I would like to keep the text as text, without transforming the pages elements in pictures. I tried the following command:

convert -density 150 -threshold 50% input.pdf output.pdf  

found in another question, a link, but it does what I don't want: the text in the output is transformed in a poor image and is no longer selectable. I tried with Ghostscript:

gs      -sOutputFile=output.pdf \          -q -dNOPAUSE -dBATCH -dSAFER \          -sDEVICE=pdfwrite \          -dCompatibilityLevel=1.3 \          -dPDFSETTINGS=/screen \          -dEmbedAllFonts=true \          -dSubsetFonts=true \          -sColorConversionStrategy=/Mono \          -sColorConversionStrategyForImages=/Mono \          -sProcessColorModel=/DeviceGray \          $1  

but it gives me the following error message:

./script.sh: 19: ./script.sh: output.pdf: not found  

Is there any other way to create the file?

How do I remove a directory and all its contents?

Posted: 05 May 2022 09:19 AM PDT

In bash all I know is that

rmdir directoryname  

will remove the directory but only if it's empty. Is there a way to force remove subdirectories?

No comments:

Post a Comment