Wednesday, August 11, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


File Manager - attach a file

Posted: 11 Aug 2021 11:16 AM PDT

I am running Debian 10 Cinnamon (among others) and am wondering if there is a way to change the order in the dialog for attaching a file to an email. Currently it is strictly alphabetic and I would prefer to have folders on top (alphabetically) then files (alphabetically). My Mint Cinnamon dialog behaves this way. Knowing how versatile Linux is I presume there must be a way to accomplish this. Thanks.

Printing to Impact Printer from Command Line

Posted: 11 Aug 2021 11:06 AM PDT

I have a Raspberry Pi running Raspbian and I bought an impact printer (Epson LX-350) that I plan on hooking up to the computer via USB cable once it arrives. My goal is to be able to have a script periodically output lines of ASCII text to the printer as certain events happen. I don't care about it being pretty, in fancy fonts, large font sizes, worrying about files, or worrying about spooling print jobs from multiple users over multiple printers.

It seems like I can plug in the printer, not install any specific drivers, and then use commands like echo "Line 1\r\nLine 2\r\nLine 3\r\n" | lp -d /dev/usb/lpXXX.

I don't have the printer right now to try it out on, but am I missing anything I should research while I'm waiting for the printer to arrive?

How to redirect the local audio from FreeBSD 13 to Ubuntu 21.04 emulated with vm-bhyve

Posted: 11 Aug 2021 11:24 AM PDT

I don't hear any sound within my Ubuntu 21.04 VM,emulated with vm-bhyve on FreeBSD 13. On Ubuntu I have installed xrdp and as u can see below,it's working great :

enter image description here

and on FreeBSD I'm trying to make work xfreerdp and remmina. I run xrdp with the following command :

xfreerdp /v:192.168.1.3:3389 /relax-order-checks

but it is not working. The error is :

enter image description here

In the remmina client should I fill the value for "redirect the local audio ouput" ? because I don't know which value should I put there. If I keep it empty,inside the linux vm I see the message : establishing connection to pulseaudio but nothing happens. On FreeBSD pulseaudio works great for me :

marietto@marietto:~ $  pactl info    Stringa server: /var/run/user/1001/pulse/native  Versione protocollo libreria: 34  Versione protocollo server: 34  Locale: sì  Indice client: 11  Dimensione tile: 65472  Nome utente: marietto  Nome host: marietto  Nome server: pulseaudio  Versione server: 14.2  Specifica di campionamento predefinita: s16le ch 2 44100 Hz  Mappa del canale predefinita: front-left,front-right  Sink predefinito: oss_output.dsp8  Sorgente predefinita: oss_input.dsp8  Cookie: e95d:2589  

But Inside Ubuntu 21.04,when I try to hear some music from youtube,I don't hear anything,but I see that from the dummy output the sound level is moving :

enter image description here

In addition to remmina and xrdp I've installed anydesk on FreeBSD and on Ubuntu / vm-bhyve. On the anydesk that run on FreeBSD I've configured the audio like this :

transmissions :    v : enable audio transmissions  -specify device = /dev/dsp8    output :    v : enable playback  -playback device = /dev/dsp0  

But I'm not sure what device is correct for transmissions and playback. I'm not able to understand how to detect what are the correct devices.

Instead on the remmina client I tried to fill the value for "redirect the local audio ouput" but I don't know which value should I put there.

enter image description here

I tried with /dev/dsp0 but it does not work because this error that comes from the log of remmina that run on FreeBSD :

[15:29:16:748] [2613:04409000] [INFO][com.freerdp.core] - freerdp_tcp_is_hostname_resolvable:freerdp_set_last_error_ex resetting error state    [15:29:16:748] [2613:04409000] [INFO][com.freerdp.core] - freerdp_tcp_connect:freerdp_set_last_error_ex resetting error state    [15:29:18:960] [2613:04409000] [ERROR][com.winpr.commandline] - Failed at index 1 [/dev/dsp0]: Unexpected keyword    [15:29:18:960] [2613:04409000] [ERROR][com.freerdp.core] - [static] rdpsnd_virtual_channel_init_event_ex reported an error. Error was 20    [15:29:18:960] [2613:04409000] [ERROR][com.freerdp.core] - checkChannelErrorEvent() failed - 0  

I tried with dev:dsp0,but I've got this inside the remmina log :

marietto@marietto:~ $ remmina      Load modules from /usr/local/lib/remmina/plugins    Remmina plugin glibsecret (type=Segreto) has been registered, but is not yet initialized/activated. The initialization order is 2000.    The glibsecret secret plugin has been initialized and it will be your default secret plugin    StatusNotifier/Appindicator support: your desktop does support it, but you did not compile Remmina with CMake's -DWITH_APPINDICATOR=on    Warning: Remmina is running with a secrecy plugin, but it cannot connect to a secrecy service.      (org.remmina.Remmina:2810): Gtk-WARNING **: 16:35:55.327: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem      (org.remmina.Remmina:2810): Gtk-CRITICAL **: 16:36:22.880: gtk_widget_set_sensitive: assertion 'GTK_IS_WIDGET (widget)' failed      (org.remmina.Remmina:2810): Gtk-CRITICAL **: 16:36:22.880: gtk_toggle_tool_button_set_active: assertion 'GTK_IS_TOGGLE_TOOL_BUTTON (button)' failed      (org.remmina.Remmina:2810): Gtk-CRITICAL **: 16:36:22.880: gtk_widget_set_sensitive: assertion 'GTK_IS_WIDGET (widget)' failed    [16:36:22:814] [2810:0b17db00] [ERROR][com.freerdp.common.settings] - [freerdp_settings_get_bool] Invalid key index 131    [16:36:22:814] [2810:0b17db00] [ERROR][com.freerdp.common.settings] - [freerdp_settings_get_bool] Invalid key index 0    [16:36:23:816] [2810:0b17db00] [INFO][com.freerdp.core] - freerdp_connect:freerdp_set_last_error_ex resetting error state    [16:36:23:817] [2810:0b17db00] [ERROR][com.freerdp.common.settings] - [freerdp_settings_set_bool] Invalid key index 2816    [16:36:23:817] [2810:0b17db00] [INFO][com.freerdp.client.common.cmdline] - loading channelEx rdpdr    [16:36:23:817] [2810:0b17db00] [INFO][com.freerdp.client.common.cmdline] - loading channelEx rdpsnd    [16:36:23:817] [2810:0b17db00] [INFO][com.freerdp.client.common.cmdline] - loading channelEx cliprdr    [16:36:23:817] [2810:0b17db00] [INFO][com.freerdp.client.common.cmdline] - loading channelEx drdynvc    [16:36:23:148] [2810:0b17db00] [INFO][com.freerdp.primitives] - primitives autodetect, using optimized    [16:36:23:149] [2810:0b17db00] [INFO][com.freerdp.core] - freerdp_tcp_is_hostname_resolvable:freerdp_set_last_error_ex resetting error state    [16:36:23:149] [2810:0b17db00] [INFO][com.freerdp.core] - freerdp_tcp_connect:freerdp_set_last_error_ex resetting error state    [16:36:23:187] [2810:0b17db00] [WARN][com.freerdp.crypto] - Certificate verification failure 'self signed certificate (18)' at stack position 0    [16:36:23:187] [2810:0b17db00] [WARN][com.freerdp.crypto] - CN = ubuntu-budgie.homenet.telecomitalia.it    [16:36:24:334] [2810:0b17db00] [INFO][com.freerdp.gdi] - Local framebuffer format PIXEL_FORMAT_BGRA32    [16:36:24:334] [2810:0b17db00] [INFO][com.freerdp.gdi] - Remote framebuffer format PIXEL_FORMAT_BGRA32    [16:36:24:335] [2810:0b17db00] [INFO][com.freerdp.channels.rdpsnd.client] - [static] Loaded oss backend for rdpsnd    [16:36:24:335] [2810:0b17db00] [INFO][com.freerdp.channels.drdynvc.client] - Loading Dynamic Virtual Channel disp    [16:36:24:335] [2810:0b17db00] [INFO][com.freerdp.channels.drdynvc.client] - Loading Dynamic Virtual Channel rdpsnd    [16:36:24:335] [2810:0b17db00] [INFO][com.freerdp.channels.drdynvc.client] - Loading Dynamic Virtual Channel audin    [16:36:24:335] [2810:0b17db00] [INFO][com.freerdp.channels.audin.client] - Loaded oss backend for audin    [16:36:24:335] [2810:0b17db00] [INFO][com.freerdp.channels.drdynvc.client] - Loading Dynamic Virtual Channel rdpgfx  

If I use remmina,inside the Ubuntu VM I see :

enter image description here

accidently deleted boot folder. Can't boot Linux now

Posted: 11 Aug 2021 10:29 AM PDT

I was doing something in my windows 10 system. Then I accidently deleted all of the files from boot folder. Including the grub folder and all of the vmlinuz stuff. Nothing is left there. So now whenever I try to boot from a pendrive I get the grub command line. I didn't see grub rescue. I tried booting with both kali Linux and parrot OS pendrive. None of it worked. It still shows grub command line. But I can still boot into my windows 10 system. When I type ls command in the grub command line I can see all of the partitions including the pendrive.

like (hd0,gpt1),(hd0,gpt2)

I can see the files inside my pendrive. I can also see the system partition where the boot and EFI and also startup.nsh file resides. There are two folders in the EFI folder. /boot and /microsoft. Please help me fix my grub.

My system configurations -

  1. windows 10 21h1
  2. partition style GPT
  3. bios mode UEFI
  4. sandisk cruzer blade 8gb pendrive

How do I find a file in an environment variable?

Posted: 11 Aug 2021 11:23 AM PDT

I am trying to find a file that might be located in one of the folders in the $LD_LIBRARY_PATH. Basically I am trying to:

 find $LD_LIBRARY_PATH -name "*libdl*"  

However the above command fails because of multiple entries in the variable and separated my a :. I get the error:

    No such file or directory  

How to accomplish this?

Regular expression pattern matching with sed

Posted: 11 Aug 2021 10:13 AM PDT

My file abc contains only one line:

<fruits>  

and I'd like to replace them with possible strings, e.g.:

apple, orange, pear   

I know I could do it with one string like this:

$sed 's/<fruits>/apple/' abc  

However I am not sure how to do it with multiple strings (apple, orange, pear), in one line sed script.

This is to later run an awk program in a file containing list of fruits and not fruits, to see if apple, orange, pear is part of a fruit.

Could I possibly just use || (or operator)? like ```$sed 's//apple||orange||pear/' abc

Thank you so much!

How to perform a make install without any apt confirmation

Posted: 11 Aug 2021 10:04 AM PDT

When installing packages with apt one can skip the confirmation prompt by specifying -y. However, sometimes when using the make command, that confirmation prompt will show up if depencies are missing.

How can I speficy to the make command that I don't want a confirmation when using the package manager? This is problematic in an automated environment

I can't find a equivalent make install -y

Partition table on nother device

Posted: 11 Aug 2021 09:54 AM PDT

I'm curious if it's possible to store disk partition tables on different device and load it from grub

Partitions or virtual mapping on device, not making file system

Posted: 11 Aug 2021 09:33 AM PDT

I am running raspbian on raspberry pi 3 and using pi-power-tools to create a img.

When I try to make an image I get the error

mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making filesystem

I have no idea what this is or how to fix it. Does anyone have a clue

Trouble using VSFTPD service for ftp server on AWS S3

Posted: 11 Aug 2021 09:39 AM PDT

First post on here so I apologize if its in the wrong place or format.

So currently I have a working ftp server on aws linux EC2 and S3 with users that can connect via

ftp/ftps/sftp

. However the way I got it to work adds a few seemingly unnecessary steps for the client.

Directory setup:
/home/username/ftp/files/Storage

The user's home directory is configured to be at the
/home/username/ftp
level and the s3 is mounted on the /home/username/ftp/files level. In basic terms anything in
/home/username/ftp/files
and below is stored on the ec2 instance and anything
/home/username/ftp/files/Storage
and above is stored on the S3 bucket.

Issue I am having is when a user logs in, they are sent to the
/home/username/ftp
directory as their root directory and can go through files and Storage to eventually reach their data. I need them to land on
/home/username/ftp/files/Storage
in order to simplify their process.

Unfortunately any other home directory I have tried ends up sending me various errors. Any ideas?

Thanks, Tyler

How to display stdout command in less with as few keystrokes as possible?

Posted: 11 Aug 2021 11:17 AM PDT

I often find myself piping a command's output into less because less is far superior for studying the output than the normal terminal.

While I can always append | less to every command, I was wondering if there is a more concise way of doing this requiring fewer keystrokes.

One option would be to alias less allowing me to type |L instead of |less.

Is there a smarter way? Like binding | less to a certain key combination?

I use fish but answers for zsh and bash are equally welcome, though more generic ones are preferred.

Launch GUI app from udev rule

Posted: 11 Aug 2021 08:48 AM PDT

I am trying to launch a GUI app upon plugging in a certain USB device. The udev rule gets triggered, but the app does appear on my screen. Running the script from another TTY makes the app open in my graphical environment. I can also confirm that the rule is getting triggered by appending a date to a file from the rule.

/etc/udev/rules.d/99-betaflight.rules:

SUBSYSTEMS=="usb", ATTR{serial}=="314839673237", RUN+="/usr/bin/su daniel -c '/home/daniel/bin/betaflight-configurator'"  

/home/daniel/bin/betaflight-configurator:

#!/bin/bash    export DISPLAY=:1  /opt/betaflight/betaflight-configurator/betaflight-configurator    

The way I understand it is that the GUI app has difficulties starting, since it's not starting in the context of the X server. Still, running the code from another tty opens the app perfectly fine.

What can I improve to make the app run upon plugging in my USB device?

bengali fonts displaying very late in Libreoffice writer

Posted: 11 Aug 2021 11:25 AM PDT

I have installed a flatpack version of LibreOffice 7 in my MX Linux 19.4 KDE version since the apt version was having problems in my system. In this version of LibreOffice, Bengali words do display but with a problem. The text does not appear instantly by letter; instead, it appears as a word after pressing the spacebar. For example, suppose I am writing some text in Bengali. The words began to display after I hit the spacebar, but they don't appear before that. Here is the link to demonstrate the problem:

Bengali font problem

If you do not understand the language of the text written in the video, please don't stress yourself. Just notice that the letters do not appear instantly.

Read Linux Shell Script

Posted: 11 Aug 2021 10:42 AM PDT

how to read this?

if [ $# -lt 1 ]; then      print_package_file_error_and_exit "No package-file specified."  fi    readonly package_file="$1"  

setup sftp server with special permissions

Posted: 11 Aug 2021 10:01 AM PDT

I want to setup SFTP server with special permissions, and most importantly, how to set up the idea

My idea: You access Via secure FTP protocol using Winscp, and you have your own folder, can upload files, download files, read, write, overwrite, delete; and can't go out from your folder another thing, one user can't create a folder too!

/etc/passwd on Kali Linux shows the password encryption type to be $y$

Posted: 11 Aug 2021 10:09 AM PDT

I know the typical encryption types for Linux are $1$, $2a$, $2y$, $5$, and $6$, but I haven't found any answers for what $y$ is. I'm using the latest version of Kali Linux. The two accounts are dummy accounts made for an exercise.

exam_user_1:$y$j9T$Sn7.l9zwy3VX0vbgSX1JQ0$iHN/q4Q9CPnTxm/x01joswdLKgfbexP1BKCkc13pqI6:18845:0:99999:7:::  exam_user_2:$y$j9T$ylZ/f6ILdzB/AFXh3lhRI/$adutx/xXKNf5PmGLUMMfzCa4/uIlS7ZzbU/5LIiPjo3:18845:0:99999:7:::  

Fix/Repair Can't find a SQUASHFS superblock

Posted: 11 Aug 2021 08:57 AM PDT

I have an old filesystem backup that I made and compressed into a squashfs. It was stored on an ext4 filesystem, and I suspect it suffered from some bitrot. I don't have a backup of the file. Is there any way I might be able to rescue this squashfs archive?

$ unsquashfs olddrive.sfs  Can't find a SQUASHFS superblock on olddrive.sfs  

Edit: Adding Info

$ file olddrive.sfs  olddrive.sfs: data  $ sudo mount -t squashfs -o ro olddrive.sfs /tmp/sq  mount: /tmp/sq: wrong fs type, bad option, bad superblock on /dev/loop10, missing codepage or helper program, or other error.  

Ubuntu routing problem between two physical ports

Posted: 11 Aug 2021 10:10 AM PDT

Looking to solve a problem on:

  • Ubuntu 18.04.5
  • Intel i3

I have two physical ports (enp1s0 & enp2s0), a router connected to enp1s0 and a camera on enp2s0.

  • enp1s0 is 192.168.1.10
  • Router connected is 192.168.1.1
  • enp2s0 is 192.168.0.10
  • Camera is 192.168.0.1

I would like to be able to access the internet from the camera. (for example: ping -I enp2s0 1.1.1.1).

|———--|    |—--——|  enp1s0      enp2s0         |_____|    |_____|      |         |      |         |    |--———|      Camera    Router    |_____|      |      |      Internet  

I have tried the following rules:

  • Enabling IP forwarding via:

      #vim /etc/sysctl.conf    net.ipv4.ip_forward = 1      #sysctl -p  
  • Updating IP tables

      iptables -A FORWARD -i enp2s0 -o enp1s0 -j ACCEPT    iptables -A FORWARD -i enp1s0 -o enp2s0 -j ACCEPT    iptables -t nat -A POSTROUTING -o enp1s0 -J MASQUERADE    iptables -t nat -A POSTROUTING -o enp2s0 -J MASQUERADE  

I'm still not able to make the two interfaces talk - looking to ping enp1s0 from enp2s0, then access the internet from enp2s0. They have to be on different subnets.

Can anyone help me understand the routing problem here to help these two subnets talk to each other?

Would it be best for PowerShell scripts to also have a shebang?

Posted: 11 Aug 2021 10:37 AM PDT

Shell scripts are better when having a shebang like so:

#!/bin/bash  echo "The shebang above this line works like a typical a comment but with a purpose"  

PowerShell scripts are also shell scripts. So it should be okay to do like so:

#!/usr/local/bin/pwsh  echo "The shebang above this line works like a typical a comment but with a purpose"  

It seems to does not make sense if the script was intended for Windows machines but for Linux and Mac machines they seem to make sense.

Do you think it would be best for PowerShell scripts to also have a shebang?

Setting up squid transparent proxy with SSL bumping on Debian 10

Posted: 11 Aug 2021 11:09 AM PDT

Debian 10 with squid working as a transparent proxy. Now want to add SSL.

# apt-get install openssl  # mkdir -p /etc/squid/cert  # cd /etc/squid/cert  # openssl req -new -newkey rsa:4096 -sha256 -days 365 -nodes -x509 -keyout myCA.pem -out myCA.pem  # openssl x509 -in myCA.pem -outform DER -out myCA.der  #     # iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j DNAT --to 192.168.1.51:3129  # iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j REDIRECT --to-port 3129  # iptables-save > /etc/iptables/rules.v4  

Question 1: Now what I read says that next I need to

/usr/lib/squid/security_file_certgen -c -s /var/cache/squid/ssl_db -M 4MB  

however I cannot find security_file_certgen on my system.

Question 2: If I now proceed anyway to add in squid.conf:

https_port 3129 intercept ssl-bump cert=/etc/squid/cert/myCA.pem generate-host-certificates=on  

then squid fails to start:

2020/10/07 14:09:27| FATAL: Unknown https_port option 'ssl-bump'.  2020/10/07 14:09:27| FATAL: Bungled /etc/squid/squid.conf line 5: https_port 3129 int  2020/10/07 14:09:27| Squid Cache (Version 4.6): Terminated abnormally.  CPU Usage: 0.017 seconds = 0.017 user + 0.000 sys  Maximum Resident Size: 57792 KB  Page faults with physical i/o: 0  FATAL: Bungled /etc/squid/squid.conf line 5: https_port 3129 intercept ssl-bump cert=  squid.service: Control process exited, code=exited, status=1/FAILURE  squid.service: Failed with result 'exit-code'.  Failed to start Squid Web Proxy Server.  

I notice that squid -v contains neither --enable-ssl-crtd nor --with-openssl, but I don't understand what to do about this.

Update

All of the guides on the Internet at the time of writing are obsolete because https://wiki.squid-cache.org/Features/SslBump ssl-bump
has been replaced with https://wiki.squid-cache.org/Features/BumpSslServerFirst server-first and server-first has been replaced with https://wiki.squid-cache.org/Features/SslPeekAndSplice peek-n-splice.

I was hoping this might work that I got from https://serverfault.com/questions/743483/transparent-http-https-domain-filtering-proxy :

https_port 3129 intercept ssl-bump  ssl_bump peek all  ssl_bump splice all    

but no:

2020/10/08 09:57:49| FATAL: Unknown https_port option 'ssl-bump'.  2020/10/08 09:57:49| FATAL: Bungled /etc/squid/squid.conf line 6: https_port 3129 int  2020/10/08 09:57:49| Squid Cache (Version 4.6): Terminated abnormally.  CPU Usage: 0.017 seconds = 0.008 user + 0.008 sys  Maximum Resident Size: 57152 KB  Page faults with physical i/o: 0  FATAL: Bungled /etc/squid/squid.conf line 6: https_port 3129 intercept ssl-bump  squid.service: Control process exited, code=exited, status=1/FAILURE  squid.service: Failed with result 'exit-code'.  Failed to start Squid Web Proxy Server.  

Update: compiling squid with SSL

# cd ~  # mkdir squid-build  # cd squid-build  # apt-get install openssh-server net-tools  # apt-get install openssl devscripts build-essential fakeroot libdbi-perl libssl-dev# libssl1.0-dev  # apt-get install dpkg-dev  # apt-get source squid  # apt-get build-dep squid  # cd squid-4.6/  # vi debian/rules  # dpkg-source --commit  

In debian/rules file add to DEB_CONFIGURE_EXTRA_FLAGS the flags:

--with-default-user=proxy \  --enable-ssl \  --enable-ssl-crtd \  --with-openssl \  --disable-ipv6  

...and build...

# debuild -us -uc  

...and install...

# cd ..  # pwd   /root/squid-build  # mv squid3*.deb squid3.deb.NotIncluded  # dpkg -i *.deb  

However, still no ssl_crtd.

Has it been renamed to security_file_certgen ? (https://bugzilla.redhat.com/show_bug.cgi?id=1397644)

Update: compiled squid

Got squid compiled and running for HTTP but don't know what to do for HTTPS -- and nor apparently does anyone else. Is it impossible? It seems to be something to do with certificates and squid.conf.

What's the shortcut to delete a word "forward" in a unix terminal?

Posted: 11 Aug 2021 10:07 AM PDT

I do Ctrl+W in the mac terminal to delete a word (deletes from where the cursor is at to the beginning of the word)

How do I do the opposite - deletes from where the cursor is to the end of the word?

start-stop-daemon no pid file was written

Posted: 11 Aug 2021 10:03 AM PDT

Have already --make-pidfile in start-stop-daemon, but still couldn't see pid file being created. Anybody can help why?

#!/bin/bash  ### BEGIN INIT INFO  # FIXME: set Provides and Short-Description  # Provides:          echobridge  # Required-Start:    $remote_fs $syslog  # Required-Stop:     $remote_fs $syslog  # Default-Start:     2 3 4 5  # Default-Stop:      0 1 6  # Short-Description: initscript for echobridge  ### END INIT INFO  # FIXME: your name here  # Author: Leonid Shevtsov <leonid@shevtsov.me>  # Do NOT "set -e"  PATH=/sbin:/usr/sbin:/bin:/usr/bin  # FIXME: configure your app here  DESC="home automation phillips hue emulator"  NAME="echobridge"  CWD=/home/pi/EchoBridge  DATA=/home/pi/EchoBridge/data  #IP=128.168.1.40  #PORT=80  USER=pi  GROUP=pi  JAVA="/usr/bin/java"  JVM_ARGS="-Dconfig.file=$DATA/habridge.config"  JAR_PATH=/home/pi/EchoBridge/ha-bridge-3.2.1.jar  #JAR_PATH=/home/pi/EchoBridge/ha-bridge-3.1.0.jar  JAVA_ARGS="$JVM_ARGS -jar $JAR_PATH"  PIDFILE=/var/run/$NAME.pid  SCRIPTNAME=/etc/init.d/$NAME  # Load the VERBOSE setting and other rcS variables  . /lib/init/vars.sh  # Define LSB log_* functions.  # Depend on lsb-base (>= 3.2-14) to ensure that this file is present  # and status_of_proc is working.  . /lib/lsb/init-functions  # Test that Java is installed  if [ ! -x "$JAVA" ]; then    echo "Java executable not found at $JAVA"    exit 2  fi  # Test that the application jar is present  if [ ! -r "$JAR_PATH" ]; then    echo "Application JAR not found at $JAR_PATH"    exit 2  fi  #  # Function that starts the daemon/service  #  do_start()  {    # Return    #   0 if daemon has been started    #   1 if daemon was already running    #   2 if daemon could not be started    start-stop-daemon --start \      --quiet \     # --name $NAME \      --make-pidfile \      --pidfile $PIDFILE \      --exec $JAVA \      --test > /dev/null \      || return 1    # FIXME: export environment variables here    # export PORT=8070    start-stop-daemon --start \      --quiet \     # --name $NAME \      --make-pidfile \      --pidfile $PIDFILE \     # --chuid $USER:$GROUP \      --chdir $CWD \      --background \      --exec $JAVA \      -- $JAVA_ARGS \      || return 2  }  #  # Function that stops the daemon/service  #  do_stop()  {    # Return    #   0 if daemon has been stopped    #   1 if daemon was already stopped    #   2 if daemon could not be stopped    #   other if a failure occurred    start-stop-daemon --stop \      --quiet \     # --name $NAME \      --pidfile $PIDFILE \      --exec $JAVA \      --retry=TERM/30/KILL/5    RETVAL="$?"    [ "$RETVAL" = 2 ] && return 2    rm -f $PIDFILE    return "$RETVAL"  }  #  # Function that checks if the daemon is running  #  do_status()  {    start-stop-daemon \      --start \      --test \      --oknodo \      --pidfile $PIDFILE \      --exec $JAVA  }  case "$1" in    start)    [ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME"    do_start    case "$?" in      0|1) [ "$VERBOSE" != no ] && echo 0 ;;      2) [ "$VERBOSE" != no ] && echo 1 ;;    esac    ;;    stop)    [ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME"    do_stop    case "$?" in      0|1) [ "$VERBOSE" != no ] && echo 0 ;;      2) [ "$VERBOSE" != no ] && echo 1 ;;    esac    ;;    status)    do_status    ;;    restart|force-reload)    echo "Restarting $DESC" "$NAME"    do_stop    case "$?" in      0|1)      do_start      case "$?" in        0) echo 0 ;;        1) echo 1 ;; # Old process is still running        *) echo 1 ;; # Failed to start      esac      ;;      *)      # Failed to stop      echo 1      ;;    esac    ;;    *)    echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2    exit 3    ;;  esac***  

How can I enable multiple systemd unit files with the same instance specifier?

Posted: 11 Aug 2021 09:01 AM PDT

Whenever I enable a certain instanced systemd service, I want two timers with the same instance specifier to be enabled as well. This is what my unit file foo@.service looks like:

[Unit]  Description=Does something cool  Documentation=man:foo(1)    [Service]  Type=forking  ExecStart=/usr/bin/foo %i  PIDFile=%t/foo/foo.pid  StandardOutput=journal    [Install]  WantedBy=network-online.target  Also=bar1@%i.timer  Also=bar2@%i.timer  

Running systemctl enable foo@test.service returns:

Failed to enable unit: Invalid argument  

If I remove the instance specifiers from the [Install] section and replace them with specific instance names (so it looks like the following), then it works just fine.

...  Also=bar1@test.timer  Also=bar2@test.timer  

The man page systemd.unit(5) says that the %i specifier is interpreted in the install section, so what gives?

The following specifiers are interpreted in the Install section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v.  

When a Linux (Ubuntu) system shuts down, which processes get sent a SIGTERM?

Posted: 11 Aug 2021 08:54 AM PDT

If I start an ongoing background process A which starts a child process B, and I ask the OS to shut down, which processes get sent a SIGTERM? Is it both A and B or is it just A (assuming that A should be responsible for shutting down B)?

How to avoid /usr/bin/env being marked in systemd logs as the executable

Posted: 11 Aug 2021 11:09 AM PDT

I've created a systemd service to run a tomcat application based on the information found in this article. The short version of the article recommends avoiding the shell script wrappers, and executing java directly, with the appropriate environment and command line.

Here is the entirety of the systemd service (with the app name replaced):

[Unit]  Description=MyApp Tomcat Container    [Service]  EnvironmentFile=/opt/myapp/environment  ExecStart=/usr/bin/env ${JAVA_HOME}/bin/java $JAVA_OPTS $CATALINA_OPTS \  -classpath ${CLASSPATH} \  -Dcatalina.base=${CATALINA_BASE} \  -Dcatalina.home=${CATALINA_HOME} \  -Djava.endorsed.dirs=${JAVA_ENDORSED_DIRS} \  -Djava.io.tmpdir=${CATALINA_TMPDIR} \  -Djava.util.logging.config.file=${CATALINA_BASE}/conf/logging.properties \  -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \  org.apache.catalina.startup.Bootstrap start    ExecStop=/usr/bin/env $JAVA_HOME/bin/java $JAVA_OPTS \  -classpath $CLASSPATH \  -Dcatalina.base=$CATALINA_BASE \  -Dcatalina.home=$CATALINA_HOME \  -Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS \  -Djava.io.tmpdir=$CATALINA_TMPDIR \  -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \  -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \  org.apache.catalina.startup.Bootstrap stop    [Install]  WantedBy=multi-user.target  

This works quite well as far as I know. The service starts, stops, and reports status correctly. The problem I'm having is with the logs as reported by journalctl:

# journalctl -u myapp.service --since today    Sep 14 00:26:00 myserver.domain.com env[654]: MyApp:2015-09-14 00:26:00: INFO Detail irrelevant  Sep 14 00:26:00 myserver.domain.com env[654]: MyApp:2015-09-14 00:26:00: INFO Detail irrelevant  Sep 14 00:26:17 myserver.domain.com env[654]: MyApp:2015-09-14 00:26:17: INFO Detail irrelevant  

See here that env is being logged as the running executable. I would much rather see java as the executable, considering that's the program we actually care about. The env is noise. I've noticed quite a few different systemd service files that recommend prefixing the start command with /usr/bin/env, so I assumed I might be able to find some information about the logs produced. Apparently not.

Can I report the executable as java rather than env while using this same pattern of executing java directly (not the startup.sh wrappers)?

For extra points, I would love some hints and tips about what my service file might be missing. This is the first time I've written a systemd service, and am keen to learn more about best practises.

Change Apache httpd "Server:" HTTP header

Posted: 11 Aug 2021 10:11 AM PDT

One of the HTTP headers that the Apache httpd sends back with response data is "Server". For example, my web server machine is relatively up-to-date Arch Linux. It sends back headers closely resembling the following:

HTTP/1.1 404 Not Found  Date: Thu, 10 Apr 2014 17:19:27 GMT  Server: Apache/2.4.9 (Unix)  Content-Length: 1149  Connection: close  Content-Type: text/html  

I have ServerSignature off in /etc/httpd/conf/httpd.conf, but the "Server:" header still appears. I have experimented with mod_headers. I have it enabled, and I've tried a few things:

<IfModule headers_module>  Header set ProcessingTime "%D"  Header set Server BigJohn  </IfModule>  

After stopping and starting httpd with the above configuration, the HTTP headers include something like ProcessingTime: 1523, but the "Server:" header line remains unchanged. So I know that "mod_headers" is installed and enabled, and working, but not as I desire.

I see that something called "mod_security" claims to do this, but I don't want all the rest of the baggage that mod_security carries with it.

UPDATE:

Once you get mod_security installed, you only need a few directives:

<IfModule security2_module>  SecRuleEngine on  ServerTokens Full  SecServerSignature "Microsoft-IIS/6.0"  </IfModule>  

That's for mod_security 2.7.7

slow Matlab on Ubuntu LTS and ZERO Swap

Posted: 11 Aug 2021 11:05 AM PDT

I was using Matlab2012 under Win7 and my algorithm was consuming a huge amount of memory though it was fast (80 seconds for one iteration).

Now I am using Matlab2013 under Ubuntu 12.04 LTS and though the usage of the RAM is very small, but the time is extremely higher than it was on windows (30 minutes for the iteration and not finished untill now).

As I said the RAM is showing a usage of 1G out of 8G ...while the swap is showing 0% of 8G. I checked the default value and it is 60, but not used by anyhow!!

What might be the problem, and how to speed up Matlab the way it was before?

How can I find out what keys gpg-agent has cached? (like how ssh-add -l shows you cached ssh keys)

Posted: 11 Aug 2021 09:00 AM PDT

ssh-add -l shows you all ssh-keys that have been added with ssh-add ~/.ssh/id_yourkey. How do I do the analogous thing with gpg and gpg-agent, in other words, ask it to show a list of cached keys?

How to scroll the screen using the middle click?

Posted: 11 Aug 2021 10:12 AM PDT

On Windows, most programs with large, scrollable text containers (e.g. all browsers, most word processors and IDEs) let you press the middle mouse button and then move the mouse to scroll. This scrolling is smooth and allows you to scroll very quickly using just the mouse.

When I've used Linux on laptops, two-finger scrolling performs roughly the same function; it's easy to scroll down a page quickly (much more quickly than one can by scrolling a mouse wheel) but the scrolling remains smooth enough to allow precise positioning.

I am unsure how to achieve the same thing when running Linux on a Desktop with a mouse. As far as I can tell after a whole bunch of Googling, there are neither application-specific settings to swap to Windows-style middle mouse button behaviour, nor any system-wide settings to achieve the same effect.

Just to make this concrete, let's say - if it's relevant - that I'm asking in the context of Firefox, Google Chrome, Gedit and Eclipse on a recent version of either Mint (what I use at home) or Ubuntu (what I use at work). I suspect this is a fairly distro-agnostic and application-agnostic question, though.

As far as I can tell, my options for scrolling are:

  • Scroll with the mousewheel - slow!
  • Use the PgUp / PgDn keys - jumps a huge distance at a time so can't be used for precise positioning, and is less comfortable than using the mouse
  • Drag the scroll bar at the right hand side of the screen up and down like I used to do on old Windows PCs with two-button mice. This is what I do in practice, but it's just plain less comfortable than Windows-style middle-mouse scrolling; on a huge widescreen, it takes me most of a second just to move the cursor over from the middle of the screen to the scrollbar, and most of a second to move it back again, and I have to take my eyes off the content I'm actually scrolling to do this.

None of these satisfy me! This UI issue is the single thing that poisons my enjoyment of Linux on desktops and almost makes me wish I was using a laptop touchpad instead of a mouse. It irritates me enough that I've concluded that either I'm missing some basic Linux UI feature that solves this problem, or I'm just an oversensitive freak and it doesn't even bother anyone else - but I'm not sure which.

So my questions are:

  1. Does Windows-style middle mouse button scrolling exist anywhere in the Linux world, or is it really purely a Windows thing? In particular, do any Linux web browsers let you use Windows-style scrolling?
  2. Are there any mechanisms for scrolling pages that exist in Linux but not in Windows, especially ones that perform the role I've described?
  3. Any other solutions that I'm missing?

No comments:

Post a Comment