Thursday, February 3, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


ipcrm won't delete some shared memory blocks

Posted: 03 Feb 2022 10:57 AM PST

I have shared memory I am trying to delete using ipcrm on a Mac.

I managed to delete all segments except the below:

T     ID     KEY        MODE       OWNER    GROUP  Shared Memory:  m 2359296 0x00000000 --rw-r--r--   me  m 2293761 0x00000000 --rw-r--r--   me  m 2097154 0x00000000 --rw-r--r--   me  m 1966083 0x00000000 --rw-r--r--   me  

I am executing ipcrm -m 1966083 etc but it keeps returning:

ipcrm: shmid(1966083): : Invalid argument

How can I delete these four blocks?

Crontab is overwritten by HiveOS on boot

Posted: 03 Feb 2022 10:53 AM PST

I am trying to add some additional cronjobs to a rig running on HiveOS, which is running on linux. I am adding the cronjobs, for example one for duckdns and then after I reboot the system, the line in crontab dissapeared. The crontab contains some lines that are used for HiveOS, so I assume that HiveOS overwrites the crontab on startup.

Is there any possibility to run cronjobs without the lines being overwriten by HiveOS on the next restart?

Thank you in advance

Stop command in ssh session without exiting ssh

Posted: 03 Feb 2022 10:53 AM PST

I've a ssh session and I'm running a script. I want to terminate the script without exiting the ssh session. In a local PC I press Ctrl-C and the script stops, while if I press Ctrl-C in remote session I close the ssh session itself (and also the script in this case). How can I stop the script in remote shell without interrupting the ssh connection?

sed replacing a string with itself and a new line

Posted: 03 Feb 2022 11:07 AM PST

I have the following string multiple times in a html file

<br> <h4 id=...  

Now, I know sed might not be perfect for html editing, but could tell me how can I
replace br> <h4 id
with br>\n <h4 id (where '\n' is the new line; there is a single space between <br> and <h4...)?

I'd tried sed 's/br> <h4 id/br> \n<h4 id/g' report.html but it doesn't do the trick. There are other questions regarding sed and new line replacement, on this subject on this stackexchange, but they don't work for my case. Thank you!

Update: I'm running from a windows machine with Visual Studio Code bash terminal and (Git) Bash (which is some sort of MINGW64)

Launch terminal and 'conda activate env' from bash script

Posted: 03 Feb 2022 10:28 AM PST

I've seen some similar questions on here, but they haven't covered this particular use-case and I haven't been able to make it work on my own.

I'm trying to do the following using a script:

  1. Open a new terminal in a specific directory (and keep it open)
  2. Activate a specific conda environment in that terminal
  3. Launch my IDE (atom), also from that terminal

I've tried this:

#!/bin/sh      gnome-terminal --working-directory=~/Desktop/Atom/myEnv/ -e 'conda activate myEnv && atom'  

But receive this error message:

Failed to execute child process "conda" (No such file or directory)

I've also tried the following code, which results in a conda not found error:

#!/bin/sh  eval "$(conda shell.bash hook)"  conda activate myEnv  bash -i  

The following code opens a terminal and displays the expected python version for that environment, but doesn't carry-over the activation to the 'bash -i' window:

#!/bin/bash  source ~/miniconda3/bin/activate myEnv  python --version  bash -i  

Please let me know if there is a simple way to accomplish this task.

Understanding the various Python directories

Posted: 03 Feb 2022 10:25 AM PST

according to dpkg --listfiles python3.9, said package owns the directories /usr/lib/python3/dist-packages/ and /usr/lib/python3.9.

I'm struggling to work out what the difference between these two directories is. This post suggests that the former is a convention of Debian and it's derivatives, and a location where Python packages and modules are placed if they are installed by the native package manager.

Is that the case? And if so, what is /usr/lib/python3.9 for? If it is the case then I'm a little confused as I usually don't install anything save for using APT, yet my python3.9 directory contains a decent amount of files.

Getting newer GCC version in Ubuntu

Posted: 03 Feb 2022 10:19 AM PST

I have Ubuntu 18.04. I want to get newer GCC version. How to do that from ternimal? I am getting this:

gcc --version  gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0  Copyright (C) 2017 Free Software Foundation, Inc.  This is free software; see the source for copying conditions.  There is NO  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

Disabling writing dump files to efivars

Posted: 03 Feb 2022 11:04 AM PST

Recently I noticed an issue where both of my machines (ThinkPad X230 and W530) independently started running out of NVRAM which stores UEFI boot variables. This prevents them from booting. Fortunately, I managed to boot the OS (Ubuntu 20.04.1 on both) after switching to Legacy boot mode, but this is no fix.

Upon further inspection, it turns out that after every boot, there are numerous "dump-type0" variables created in /sys/firmware/efi/efivars. While displaying the contents of "normal" variables using cat clearly shows some contents (garbled of course, because this is binary data), cat-ting the dump variables shows nothing - they seem completely empty, yet take lots of space. These dump variables typically have long names such as dump-type0-11-1-1643821377-C-cfc8fc79-be2e-4ddc-97f0-9f98bfe298a0.

I started digging further and searched for parts of these variables' names in journalctl. I found out that these are written to efivars by pstore, evidenced by logs such as this one:

Feb 03 10:37:35 slazien-thinkpad-x230 systemd-pstore[1367]: PStore dmesg-efi-164382137702001 moved to /var/lib/systemd/pstore/164382137/dmesg-efi-164382137702001  

As I understand, it's systemd-pstore which is responsible for moving kernel dumps from /sys/fs/pstore to /sys/firmware/efi/efivars (please correct me in case I'm wrong). Hence I tried disabling pstore processing by setting Storage=none in pstore.conf(5). While this got rid of the aforementioned journalctl logs, the (empty?) dump files are still being written.

For reference, systemd-pstore is running fine:

systemctl status systemd-pstore.service  ● systemd-pstore.service - Platform Persistent Storage Archival       Loaded: loaded (/lib/systemd/system/systemd-pstore.service; enabled; vendor preset: enabled)       Active: active (exited) since Thu 2022-02-03 11:03:13 EST; 2h 13min ago         Docs: man:systemd-pstore(8)     Main PID: 1287 (code=exited, status=0/SUCCESS)        Tasks: 0 (limit: 18853)       Memory: 0B       CGroup: /system.slice/systemd-pstore.service    Feb 03 11:03:13 slazien-thinkpad-x230 systemd[1]: Starting Platform Persistent Storage Archival...  Feb 03 11:03:13 slazien-thinkpad-x230 systemd[1]: Finished Platform Persistent Storage Archival.  

For now, I would simply want to disable writing of these dump efivars while I troubleshoot the root cause. How can I do that?

EDIT: After some detective work I found out the root cause. A good overview is provided in this Gist.

KDE Plasma changes brightness on wrong GPU

Posted: 03 Feb 2022 09:53 AM PST

I am able to change brightness manually by issuing the command:

echo 512 | sudo tee - /sys/class/backlight/intel_backlight/brightness  

This changes the brightness output of my Intel integrated GPU on my laptop. However, this laptop also has a dedicated NVIDIA video card which also has a backlight section:

/sys/class/backlight/nvidia_0/brightness  

The problem is that when I change the brightness using the brightness changing hotkeys, Plasma (or whatever program is responsible for changing brightness) thinks it should change the brightness in the nvidia_0 section of the backlight instead of the intel_backlight. How do I fix this? BTW I'm running Arch Linux.

RPM macro and quotes

Posted: 03 Feb 2022 09:31 AM PST

I would like to include a file in a package with a directory which is dependendat on the system.

I define the directory with

%define completions_dir "%( pkg-config --variable=completionsdir bash-completion )"  

and I can use it successfully for example

%install  make DESTDIR=${RPM_BUILD_ROOT}%{nagiospluginsdir} MANDIR=${RPM_BUILD_ROOT}%{_mandir} COMPLETIONDIR=${RPM_BUILD_ROOT}%{completions_dir} install  

The problem is when I have to define the list of files

The file is there. The following works

%files  /usr/share/bash-completion/completions/check_ssl_cert  

If I use the variable

%files  %{completions_dir}/check_ssl_cert  

I get the following error:

RPM build errors:      More than one file on a line: /check_ssl_cert  

To debug I tried with

%files  /%{completions_dir}/check_ssl_cert  %endif  

and in this case I get

    File not found: /root/rpmbuild/BUILDROOT/nagios-plugins-check_ssl_cert-2.20.0-0.fc35.x86_64/"/usr/share/bash-completion/completions"/check_ssl_cert  

The path is correct but the quotes are a problem.

How do I include a file using a path defined with a macro?

Multimonitor with two graphic cards

Posted: 03 Feb 2022 10:49 AM PST

Today I connected a second monitor to my PC (OpenSuse Leap 15.3 with KDE Desktop ). So far I had only one (Lenovo ThinkVision T27i-10) connected to my Nvidia GeForce GTX 660 and now I Connected a second one (Dell 2007FP) to my internal graphics card.

Here some infos about the graphic cards: Code

mark@localhost:~> sudo lspci -nnk | grep -i "VGA\|'core'\|3D\|Display" -A2  00:02.0 Display controller [0380]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [8086:0412] (rev 06)          Subsystem: ASUSTeK Computer Inc. device [1043:8534]          Kernel driver in use: i915  --  01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK106 [GeForce GTX 660] [10de:11c0] (rev a1)          Subsystem: CardExpert Technology Device [10b0:11c0]          Kernel driver in use: nvidia  

For the Nvidia graphics card I use the proprietary driver from the repos.

To get a picture on the second screen at all, I had to delete the /etc/X11/xorg.conf. This was created by the nvidia-settings when I enabled the setting to prevent tearing, now that the file is gone the picture tears again of course.

But now I have the problem that the mouse pointer in the taskbar, start menu and some menus on both screens becomes oversized, otherwise it has a normal size.

enter image description here

I think this is also related to the fact that the login screen shifts when I get to the edge of the screen and the screen order is not correct there.

enter image description here

Does anyone whats the reason for this and how to solve it?

export function with different name

Posted: 03 Feb 2022 10:55 AM PST

I have a script that exports a function for child scripts to use and would like to change what function is exported based on a conditional. I know I could just declare the two different functions within the conditional but would prefer to avoid that if possible.

So an example would be:

#!/bin/bash    foo () { echo foo; }  bar () { echo bar; }    if [[ $var == foo ]]; then      #in this case my_func() should execute foo()      export -f my_func  elif [[ $var == bar ]]; then      #in this case my_func() should execute bar()      export -f my_func  fi  

I guess I could also just make a simple inception function like my_func() { foo "$@"; } inside the conditional before the export too but am asking if there is a better way to do this.

Using sed to replace one character with another within an xml tag

Posted: 03 Feb 2022 10:23 AM PST

I need to replace the character S with T in:

<episode-num system="onscreen">S1 E12</episode-num>  

The result I expect:

<episode-num system="onscreen">T1 E12</episode-num>  

I don't know how Git works in depth, I'm just using it to replace that character in my xml tag, researching in forums I found some information and tried the following command line:

sed -e :l -e 's@\(<episode-num system="onscreen">.*\)S\([^amp;]\)\(.*</episode-num>\)@\1T\2\3@;tl' guide.xml  

But it does not work, I hope you can help me please.

reformat json using jq

Posted: 03 Feb 2022 08:50 AM PST

I have the below JSON file:

{ data : [    {     "name" : "name1"     "date" : [       {        "date1" : "aaa",        "date2" : "bbb"       },       {        "date1" : "ccc",        "date2" : "ddd"       },       {        "date1" : "eee",        "date2" : "fff"       },       "var" : "ggg"   },  {     "name" : "name2"     "date" : [       {        "date1" : "hhh",        "date2" : "iii"       },       {        "date1" : "jjj",        "date2" : "kkk"       },       "var" : "lll"    }   ]  }  

I would like to have CSV file in this format:

name, date, var  name1, aaa ccc eee, ggg  name2, hhh jjj, lll  

Is this possible by using only jq?

Blank screen at startup, xset is unable to open display ""

Posted: 03 Feb 2022 10:27 AM PST

Seemingly from out of nowhere, I get a blank screen during startup on Arch Linux. Going into the TTY shows me

xset:  unable to open display ""  Unable to connect to X server  

I use X11, LightDM and i3. Here LightDM seems to be able to show a blank screen with a cross as a cursor (both during startup and after running lightdm in the TTY).

I suspect it can be can be caused of i3, since the file ~/.xsession-errors has the content

i3status: trying to auto-detect output_format setting  i3status: auto-detected "i3bar"  i3status: exiting due to signal.  

However, running exec i3 -V -d all &>> "$HOME/i3.log" only shows i3: Cannot open display, so perhaps its not i3.

When running htop, I can see that Xorg is running with command

/usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch  

which should tell me that the correct display indeed is :0. I tried export DISPLAY=":0", but I don't know what to do after this.

I did update my system yesterday via pacman, could something there have caused this? I see that i3wm for Arch was updated a couple of days ago, which could explain it.

What should I do in order to get it working?

Linux command to list all files readable by others

Posted: 03 Feb 2022 09:42 AM PST

I need to list all files that are readable by public, in any directory. For example, files with permission 777, 444, 604, etc. How can I do this?

grep with pipe and variables NOT working on remote server through ssh (working locally)

Posted: 03 Feb 2022 09:23 AM PST

Below grep command is not giving expected result (matching line number) if I run it through ssh from a remote machine (passwordless authentication enabled). Variables have been defined correctly as well.

From Server 1 :

ssh user@server2 grep -n -i $J2C_ID1 $CUST_NODE_PATH1/resources.xml | awk '{print $1}' | tr -d ':'  

above command returns blank output.

From Server 2 (running locally) returns expected output i.e., a line number:

grep -n -i $J2C_ID1 $CUST_NODE_PATH1/resources.xml | awk '{print $1}' | tr -d ':'     474  

(expected out i.e., a line number of matching string specified in $J2C_ID, on the specified file resources.xml)

I tried modifying the command which is giving me full line as output, though I just need the line number and not the full line:

ssh user@server2 grep -n -i "'$J2C_ID1' '$CUST_NODE_PATH1/resources.xml' | awk '{print $1}' | tr -d ':'"    474        <resourceProperties xmiid="J2EEResourceProperty" name="Password" type="java.lang.String" value="null" description="password" required="false" ignore="false" confidential="false" supportsDynamicUpdates="false"/>  

Need to get rid of redundant text and see just the line number as o/p.

Can you please help fix the command to run successfully and return the line number of matching string IF run as ssh from another server? Quick help is highly appreciated.

Thanks

Stuck in initramfs after reboot

Posted: 03 Feb 2022 09:41 AM PST

I got that error already twice while having my laptop, and I previously were able to fix it after them google search and switching to AHCI in BIOS. However, this time it seems to be another problem because even though sata-mode is AHCI it kicks me back to initramfs.

I tried this, How to switch from IDE to AHCI, with the hope to not get that error in the future. After that I sadly got the error that I am now stuck on.

Original error message

Original error message

Output from cat /proc/modules and ls dev

Output from cat /proc/modules and ls dev

Help is greatly appreciated.

Simulate human mouse movement using xdotool

Posted: 03 Feb 2022 09:30 AM PST

I'm currently using bash and xdotool to write a simple script which will hold down a few keys and, at the same time, move the mouse relative to the current pointer position. Everything works, except I dislike the choppiness the instant mouse movement from xdotool provides. Is there any way to make xdotool move the mouse over a period of time or a curve? Or even a flag to "smoothen" the mouse that I missed? Any help is appreciated. My current code is pasted below.

#!/bin/bash    printf "This script requires xdotool to work. Please install it if you haven't already.\n"  read -n 1 -s -r -p "Press any key to continue"  printf "...\n"  printf "Process will begin in 5 seconds.\n"  printf "Press Ctrl+C at any time to halt the script\n"  sleep 5  xdotool mousedown 1  xdotool keydown w  xdotool keydown k  end=$((SECONDS+1300))  while [ $SECONDS -lt $end ]; do  xdotool mousemove_relative --sync 0 50  xdotool mousemove_relative --sync -- 0 -50  :  done  

Docker reporting that my Linux kernel doesn't support cgroup cpu real-time period

Posted: 03 Feb 2022 10:05 AM PST

I've configured Docker on my Ubuntu 18.04 Server to expose its API so I can create and deploy Docker containers via REST requests, which I need to add certain features to my project. This worked fine for first few endpoints I tried. However, when I attempt to create a new Docker container (the main point of the exercise), I get the message:

{"message": "Your kernel does not support cgroup cpu real-time period"}  

Is this true? Alternatively is it instead that I need to set something up to enable this functionality, or is Docker reporting incorrectly?

curl -X POST -H "Content-Type: application/json" -d "@./test-data/docker-create-api-test.json" http://localhost:1112/containers/create  {"message":"Your kernel does not support cgroup cpu real-time period"}  

Very grateful for any assistance given as this functionality is critical to my project.

Python3 - Too many levels of symbolic links

Posted: 03 Feb 2022 09:52 AM PST

Everytime I open up a terminal, I get the below message printed on the shell screen.

bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: Too many levels of symbolic links  

Could someone help me understand what is happening here and how I could fix this issue?

EDIT:

ls -l /usr/bin | grep python3  

returned the below

lrwxrwxrwx 1 root   root           29 Aug 15 20:59 dh_python3 -> ../share/dh-python/dh_python3  lrwxrwxrwx 1 root   root           23 Aug 20 16:08 pdb3.5 -> ../lib/python3.5/pdb.py  lrwxrwxrwx 1 root   root           23 Oct  9 11:57 pdb3.6 -> ../lib/python3.6/pdb.py  lrwxrwxrwx 1 root   root           31 Aug 26  2018 py3versions -> ../share/python3/py3versions.py  lrwxrwxrwx 1 root   root           18 Oct 24 17:25 python3 -> /usr/bin/python3.5  lrwxrwxrwx 1 root   root           16 Oct 24 17:24 python3.5 -> /usr/bin/python3  lrwxrwxrwx 1 root   root           33 Aug 20 16:08 python3.5-config -> x86_64-linux-gnu-python3.5-config  -rwxr-xr-x 1 root   root      4460272 Aug 20 16:08 python3.5m  lrwxrwxrwx 1 root   root           34 Aug 20 16:08 python3.5m-config -> x86_64-linux-gnu-python3.5m-config  -rwxr-xr-x 2 root   root      4604496 Oct  9 11:57 python3.6  -rwxr-xr-x 2 root   root      4604496 Oct  9 11:57 python3.6m  lrwxrwxrwx 1 root   root           10 Aug 26  2018 python3m -> python3.5m  lrwxrwxrwx 1 root   root           34 Aug 20 16:08 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config  -rwxr-xr-x 1 root   root         3185 Aug 20 16:05 x86_64-linux-gnu-python3.5m-config  lrwxrwxrwx 1 root   root           33 Mar 23  2016 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.5-config  lrwxrwxrwx 1 root   root           34 Mar 23  2016 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.5m-config  

Thanks, Zaman

How to edit grub config manually?

Posted: 03 Feb 2022 09:04 AM PST

I have a USB Debian installer and I would like to add a new menu item to the grub menu (Automated install with some boot parameters). I did find grub.cfg and I added my custom menu item but it does not show up in the grub menu. Rechecked the grub.cfg file, my menu item is still there so it did not get overwritten but it does not work.

Any idea what I am doing wrong?

Mutt error SMTP session failed: read error

Posted: 03 Feb 2022 10:05 AM PST

set ssl_starttls=yes  set ssl_force_tls=yes    set imap_user = 'name@gmail.com'  set imap_pass = 'password'    set from='name@gmail.com'  set realname='name@gmail.com'    set folder = imaps://imap.gmail.com/  set spoolfile = imaps://imap.gmail.com/INBOX  set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"    set header_cache = "~/.mutt/cache/headers"  set message_cachedir = "~/.mutt/cache/bodies"  set certificate_file = "~/.mutt/certificates"    set smtp_url = 'smtp://name@gmail.com:password@smtp.gmail.com:465/'    set move = no  set imap_keepalive = 900    set smtp_pass="secrets"  

When sending a mail got that error. Firewall also off on server and port 465 open on Security group. Is it required to install postfix with mutt?

Connection to smtp.gmail.com closed SMTP session failed: read error Could not send the message.  

I can read the mails on my inbox but can't send emails. This is on my maillog,

Mar  1 10:20:01 appsvr2 postfix/qmgr[6075]: 9703F3F7974: from=<root@appsvr2.localdomain>, size=768, nrcpt=1 (queue active)  Mar  1 10:20:01 appsvr2 postfix/local[5970]: 9427E3F796E: to=<root@appsvr2.localdomain>, orig_to=<root>, relay=local, delay=0.04, delays=0.03/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)  Mar  1 10:20:01 appsvr2 postfix/qmgr[6075]: 9427E3F796E: removed  Mar  1 10:20:01 appsvr2 postfix/local[5970]: 9703F3F7974: to=<root@appsvr2.localdomain>, orig_to=<root>, relay=local, delay=0.04, delays=0.03/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)  Mar  1 10:20:01 appsvr2 postfix/qmgr[6075]: 9703F3F7974: removed  Mar  1 10:30:01 appsvr2 postfix/pickup[5945]: A43FB3E643: uid=0 from=<root>  Mar  1 10:30:01 appsvr2 postfix/cleanup[5980]: A43FB3E643: message-id=<20190301050001.A43FB3E643@appsvr2.localdomain>  Mar  1 10:30:01 appsvr2 postfix/qmgr[6075]: A43FB3E643: from=<root@appsvr2.localdomain>, size=827, nrcpt=1 (queue active)  Mar  1 10:30:01 appsvr2 postfix/local[5983]: A43FB3E643: to=<root@appsvr2.localdomain>, orig_to=<root>, relay=local, delay=0.04, delays=0.03/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)  Mar  1 10:30:01 appsvr2 postfix/qmgr[6075]: A43FB3E643: removed  

PAM: Authentication failure, with valid password

Posted: 03 Feb 2022 09:24 AM PST

Command

pamtester -v auth pknopf authenticate  pamtester: invoking pam_start(auth, pknopf, ...)  pamtester: performing operation - authenticate  Password:  pamtester: Authentication failure  

journctl

Feb 06 13:22:17 PAULS-ARCH unix_chkpwd[31998]: check pass; user unknown  Feb 06 13:22:17 PAULS-ARCH unix_chkpwd[31998]: password check failed for user (pknopf)  Feb 06 13:22:17 PAULS-ARCH pamtester[31997]: pam_unix(auth:auth): authentication failure; logname= uid=1000 euid=1000 tty= ruser= rhost=  user=pknopf  

As it stands right now, every lock screen will prevent me from "unlocking" (KDE lock screen, i3lock, etc).

If I start i3lock as sudo, I can then properly type in the root password to unlock the screen. However, if I run it as normal user, and I can't use normal user or root password to unlock.

Here is my PAM config for i3lock.

#  # PAM configuration file for the i3lock screen locker. By default, it includes  # the 'system-auth' configuration file (see /etc/pam.d/login)  #  auth include system-auth  

Running ls -l /etc/passwd /etc/shadow /etc/group shows

-rw-r--r-- 1 root root 803 Feb 6 14:16 /etc/group  -rw-r--r-- 1 root root 1005 Feb 6 14:16 /etc/passwd  -rw------- 1 root root 713 Feb 6 14:16 /etc/shadow  

This is a fresh install of Arch, so I don't think the configuration is too wonky. What should I be looking for to debug this?

Running ls -l /sbin/unix_chkpwd shows

-rwxr-xr-x 1 root root 31392 Jun  9  2016 /sbin/unix_chkpwd  

Why is systemd stopping service immediately after it is started?

Posted: 03 Feb 2022 09:23 AM PST

I have a C++ based application which I'm running(executable) as a daemon with systemd.

Unit File:

  [Unit]  Description=Console Service  After=network.target    [Service]  Environment="USER=ubuntu" "Path=/home/ubuntu/console/bin"   WorkingDirectory=/home/ubuntu/console/bin  ExecStart=/bin/sh -ec "exec /sbin/start-stop-daemon -S -c ${USER} -d ${Path} --pidfile=/var/run/console.pid --oknodo  --exec consoleExecutable " #2>/dev/null  ExecStop=/bin/sh -ec "exec /sbin/start-stop-daemon -K --quiet -c ${USER} -d ${Path} --pidfile=/var/run/console.pid  --retry=TERM/30/KILL/5 --oknodo --exec consoleExecutable" #2>/dev/null  Restart=on-failure  RemainAfterExit=no  TimeoutStopSec=10  SuccessExitStatus=0 1  TimeoutStartSec=360    [Install]  WantedBy=multi-user.target    

When I issue start command the service is starting up, but then it immediately receives a shutdown signal and then exits. Any clue, what is happening?

  sudo systemctl status console.service  ● console.service - Console Service     Loaded: loaded (/etc/systemd/system/console.service; enabled; vendor preset: enabled)     Active: deactivating (stop-sigterm) since Mon 2017-09-25 19:58:58 UTC; 1s ago    Process: 8706 ExecStop=/bin/sh -ec exec /sbin/start-stop-daemon -K --quiet -c ${USER} -d ${Path} --pidfile=/var/run/console.pid  --retry=TERM/30/KILL/5 --oknodo --exec consoleExecutable #2>/dev/null (code=exited, status=0/SUCCESS)    Process: 8701 ExecStart=/bin/sh -ec exec /sbin/start-stop-daemon -S -c ${USER} -d ${Path} --pidfile=/var/run/console.pid --oknodo  --exec consoleExecutable  #2>/dev/null (code=exited, status=0/SUCCESS)   Main PID: 8701 (code=exited, status=0/SUCCESS)      Tasks: 1     Memory: 1.8M        CPU: 53ms     CGroup: /system.slice/console.service             └─8705 consoleExecutable    Sep 25 19:58:58 mgmt1 systemd[1]: Started Console Service.    sudo systemctl status console.service  ● console.service - Console Service     Loaded: loaded (/etc/systemd/system/console.service; enabled; vendor preset: enabled)     Active: inactive (dead) since Mon 2017-09-25 19:59:01 UTC; 947ms ago    Process: 8706 ExecStop=/bin/sh -ec exec /sbin/start-stop-daemon -K --quiet -c ${USER} -d ${Path} --pidfile=/var/run/console.pid  --retry=TERM/30/KILL/5 --oknodo --exec consoleExecutable #2>/dev/null (code=exited, status=0/SUCCESS)    Process: 8701 ExecStart=/bin/sh -ec exec /sbin/start-stop-daemon -S -c ${USER} -d ${Path} --pidfile=/var/run/console.pid --oknodo  --exec consoleExecutable  #2>/dev/null (code=exited, status=0/SUCCESS)   Main PID: 8701 (code=exited, status=0/SUCCESS)    Sep 25 19:58:58 mgmt1 systemd[1]: Started Console Service.  

How to test linux NAPI feature?

Posted: 03 Feb 2022 09:46 AM PST

I am trying to test the NAPI functionalities on embedded linux environment. I used 'pktgen' to generate the large number of packets and tried to verify the interrupt count of my network interface at /proc/interrupts.

I found out that interrupt count is comparatively less than the packets generated. Also I am trying to tune the 'netdev_budget' value from 1 to 1000(default is 300) so that I can observe the reduction in interrupt count when netdev_budget is increased.

However increasing the netdev_budget doesn't seems to help. The interrupt is similar to that of interrupt count observed with netdev_budget set to 300.

So here are my queries:

  1. What is the effect of 'netdev_budget' on NAPI?
  2. What other parameters I can/should tune to observe the changes in interrupt count?
  3. Is there any other way I can use to test the NAPI functionality on Linux?(Apart from directly looking at the network driver code)

Any help is much appreciated.

Thanks in advance.

Scalability of 'sort -u' for gigantic files

Posted: 03 Feb 2022 09:23 AM PST

What is reasonable scalability limit of sort -u? (in dimensions of "line length", "amount of lines", "total file size")

What is Unix alternative for files exceeding this in dimension of "amount of lines"?

Of course I can easily implement one, but I wondered if there is something that can be done with few standard Linux commands.

Bash limiting precision of floating point variables

Posted: 03 Feb 2022 10:27 AM PST

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the decimal point to be zero and get rid of the zero to the left of the decimal point. How can I transform, say 0.005000000 into .005? This is necessary due to my file naming convention. Thanks for your recommendations.

UPDATE: Can I use it for already defined shell variables and redefining them? The following code gives me an error.

~/Desktop/MEEP$ printf "%.3f\n" $w  bash: printf: 0.005000: invalid number  0,000  

The output of locale

@vesnog:~$ locale  LANG=en_US.UTF-8  LANGUAGE=en_US  LC_CTYPE="en_US.UTF-8"  LC_NUMERIC=tr_TR.UTF-8  LC_TIME=tr_TR.UTF-8  LC_COLLATE="en_US.UTF-8"  LC_MONETARY=tr_TR.UTF-8  LC_MESSAGES="en_US.UTF-8"  LC_PAPER=tr_TR.UTF-8  LC_NAME=tr_TR.UTF-8  LC_ADDRESS=tr_TR.UTF-8  LC_TELEPHONE=tr_TR.UTF-8  LC_MEASUREMENT=tr_TR.UTF-8  LC_IDENTIFICATION=tr_TR.UTF-8  LC_ALL=  

The output of echo $w

@vesnog:~$ echo $w  0.005000  

How can I investigate what other users are currently logged in?

Posted: 03 Feb 2022 11:04 AM PST

Since the last few days I get an error message when I try to shut my laptop down:

System policy prevents stopping the system when other users are logged in

This error message includes a prompt for administrator password.

I don't think that there should be other users logged in.

How can I find out what the problem is?

What I've tried

$ w   08:00:47 up  1:50,  2 users,  load average: 0,74, 0,95, 0,70  USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT  moose    tty8     :0               07:57    1:49m  4.88s  0.11s x-session-manager  moose    pts/0    :0.0             08:00    2.00s  0.11s  0.00s w      $ loginctl     SESSION        UID USER             SEAT                      c1        117 couchdb                                    c2       1000 moose            seat0             

2 sessions listed.

I'm not sure: is that already the problem?

$ sudo shutdown -h now worked as expected.

How I shut the computer down

By clicking on System > Shut Down... > Shut Down:

enter image description here

System information

I have Linux Mint MATE:

$ uname -a  Linux pc08 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux  $ cat /etc/issue  Linux Mint 16 Petra \n \l  

How to check if $PWD is a subdirectory of a given path

Posted: 03 Feb 2022 09:25 AM PST

E.g. check if $PWD is a subdirectory of /home. In other words I'm searching for a bash string operation to check if one string starts with another.

No comments:

Post a Comment