Friday, June 25, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Failed to load module "pk-gtk-module" and other errors installing Maya 2022

Posted: 25 Jun 2021 11:18 AM PDT

I downloaded and unzipped Autodesk Maya's Linux 64 Bit System and tried to run ./Setup file in the terminal. A GUI window with the title "Autodesk Install" appears temporarily, but then disappears and the following error messages are printed:

enter image description here

I've tried a number of things but nothing seems to be working yet. Any ideas?

Thanks so much!

How can I send the outputs of two different commands as one email in Linux?

Posted: 25 Jun 2021 10:21 AM PDT

In a script, I need to send the contents of two separate Linux commands in one email. I understand that I can append the outputs of the two commands to a file and send that file as an attachment. However, the script will also be run by other users so they may not have permission to view/edit/send this files. Therefore, I was wondering if there is a way to directly send the outputs of two different commands in one email.

Stripping and Renaming parent directory for each line output in tar -T -?

Posted: 25 Jun 2021 09:57 AM PDT

I have an list of directory output from the following command that I want to tar:

find ./temp -type f -name '*'

./temp/main/randomfile.txt  ./temp/main/dir_a/random.txt  ./temp/main/dir_b/random.txt  ./temp/main/dir_c/random.txt  

Then I pipe the result: tar -zchf ./tars/randomtar.tar.gz -T -

Combined commands: find ./temp -type f -name '*' | tar -zchf ./tars/randomtar.tar.gz -T -

This will take each result from the output and tar into randomtar.tar.gz

How do I change the parent directory of each output from find command when compressing?

When I untar the file, I would get:

./temp/main/randomfile.txt  ./temp/main/dir_a/random.txt  ./temp/main/dir_b/random.txt  ./temp/main/dir_c/random.txt  

I want to get this result when I untar:

./new_parent_name_main/randomfile.txt  ./new_parent_name_main/dir_a/random.txt  ./new_parent_name_main/dir_b/random.txt  ./new_parent_name_main/dir_c/random.txt  

No Bash Prompt after SSH login to rPI (Pi-Hole)

Posted: 25 Jun 2021 10:34 AM PDT

I have had an rPi serving up pi-hole DNS for some time now. The issue has existed for at this point years. I would like to be able to understand and potentially resolve without rebuild.

After an OS update I no longer get a prompt when I login over SSH on any user.

Authentication goes through, the prompt is blank, if I leave it there, it will eventually timeout. If I ctrl+c it will drop me to a basic bash shell.

Linux blackholedns 4.19.66+ #1253 Thu Aug 15 11:37:30 BST 2019 armv6l    The programs included with the Debian GNU/Linux system are free software;  the exact distribution terms for each program are described in the  individual files in /usr/share/doc/*/copyright.    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent  permitted by applicable law.  Last login: Fri Jun 25 11:27:59 2021 from x.x.x.x  

^ This is all I will see, unless I throw ctrl +c at the session.

like so:

Last login: Fri Jun 25 11:35:04 2021 from x.x.x.x  ^C  -bash-4.4$   

If I whoami, its the pi user:

-bash-4.4$ whoami  pi  

If I su to pi, it then returns to the familiar prompt and I can go about my business.

-bash-4.4$ su pi  Password:   pi@blackholedns:~ $   

For the past 2 years. I was content with just manually bypassing the issue.

Now, I would like to setup syncing for a backup pi and in order to setup gravity sync. The replica pi, requires the ability to ssh into this pi. That presents the issue shown above. The session attempts to connect and eventually times out.

What have I tried to fix this issue? (none of which has worked)

  • Set hosts entry for both systems in /etc/hosts on the troubled system.
  • "UseDNS no" in sshd
  • "GSSAPIAuthentication no" in sshd
  • "QOS = IPQoS 0x00" in sshd
  • Created a new user, ssh with this new user, has the same result. no prompt.
  • Tried logging in via ssh keys instead of pw
  • Attempted to restore .bashrc or .profile so I went and copied from /etc/skel the .bashrc and the .profile file back into /home/pi

Here is a debug of the connection with -vvv

OpenSSH_7.9p1 Raspbian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019  debug1: Reading configuration data /etc/ssh/ssh_config  debug1: /etc/ssh/ssh_config line 19: Applying options for *  debug2: resolve_canonicalize: hostname 10.10.10.5 is address  debug2: ssh_connect_direct  debug1: Connecting to 10.10.10.5 [10.10.10.5] port 22.  debug1: Connection established.  debug1: identity file /home/pi/.ssh/id_rsa type 0  debug1: identity file /home/pi/.ssh/id_rsa-cert type -1  debug1: identity file /home/pi/.ssh/id_dsa type -1  debug1: identity file /home/pi/.ssh/id_dsa-cert type -1  debug1: identity file /home/pi/.ssh/id_ecdsa type -1  debug1: identity file /home/pi/.ssh/id_ecdsa-cert type -1  debug1: identity file /home/pi/.ssh/id_ed25519 type -1  debug1: identity file /home/pi/.ssh/id_ed25519-cert type -1  debug1: identity file /home/pi/.ssh/id_xmss type -1  debug1: identity file /home/pi/.ssh/id_xmss-cert type -1  debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Raspbian-10+deb10u2  debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Raspbian-10+deb9u7  debug1: match: OpenSSH_7.4p1 Raspbian-10+deb9u7 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002  debug2: fd 3 setting O_NONBLOCK  debug1: Authenticating to 10.10.10.5:22 as 'pi'  debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"  debug3: record_hostkey: found key type ECDSA in file /home/pi/.ssh/known_hosts:1  debug3: load_hostkeys: loaded 1 keys from 10.10.10.5  debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521  debug3: send packet: type 20  debug1: SSH2_MSG_KEXINIT sent  debug3: receive packet: type 20  debug1: SSH2_MSG_KEXINIT received  debug2: local client KEXINIT proposal  debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c  debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa  debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com  debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com  debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1  debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1  debug2: compression ctos: none,zlib@openssh.com,zlib  debug2: compression stoc: none,zlib@openssh.com,zlib  debug2: languages ctos:   debug2: languages stoc:   debug2: first_kex_follows 0   debug2: reserved 0   debug2: peer server KEXINIT proposal  debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1  debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519  debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com  debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com  debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1  debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1  debug2: compression ctos: none,zlib@openssh.com  debug2: compression stoc: none,zlib@openssh.com  debug2: languages ctos:   debug2: languages stoc:   debug2: first_kex_follows 0   debug2: reserved 0   debug1: kex: algorithm: curve25519-sha256  debug1: kex: host key algorithm: ecdsa-sha2-nistp256  debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none  debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none  debug3: send packet: type 30  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY  debug3: receive packet: type 31  debug1: Server host key: ecdsa-sha2-nistp256 SHA256:3jpMhHMt9SbH1sv9XDxKm+f/ONgSf3BhpjNAHn41dqc  debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"  debug3: record_hostkey: found key type ECDSA in file /home/pi/.ssh/known_hosts:1  debug3: load_hostkeys: loaded 1 keys from 10.10.10.5  debug1: Host '10.10.10.5' is known and matches the ECDSA host key.  debug1: Found key in /home/pi/.ssh/known_hosts:1  debug3: send packet: type 21  debug2: set_newkeys: mode 1  debug1: rekey after 134217728 blocks  debug1: SSH2_MSG_NEWKEYS sent  debug1: expecting SSH2_MSG_NEWKEYS  debug3: receive packet: type 21  debug1: SSH2_MSG_NEWKEYS received  debug2: set_newkeys: mode 0  debug1: rekey after 134217728 blocks  debug1: Will attempt key: /home/pi/.ssh/id_rsa RSA SHA256:PtWlqIMMnTLjjxDnqoVlfumTiemrv93ksoT92Jp1Qj0  debug1: Will attempt key: /home/pi/.ssh/id_dsa   debug1: Will attempt key: /home/pi/.ssh/id_ecdsa   debug1: Will attempt key: /home/pi/.ssh/id_ed25519   debug1: Will attempt key: /home/pi/.ssh/id_xmss   debug2: pubkey_prepare: done  debug3: send packet: type 5  debug3: receive packet: type 7  debug1: SSH2_MSG_EXT_INFO received  debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>  debug3: receive packet: type 6  debug2: service_accept: ssh-userauth  debug1: SSH2_MSG_SERVICE_ACCEPT received  debug3: send packet: type 50  debug3: receive packet: type 51  debug1: Authentications that can continue: publickey,password  debug3: start over, passed a different list publickey,password  debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password  debug3: authmethod_lookup publickey  debug3: remaining preferred: keyboard-interactive,password  debug3: authmethod_is_enabled publickey  debug1: Next authentication method: publickey  debug1: Offering public key: /home/pi/.ssh/id_rsa RSA SHA256:PtWlqIMMnTLjjxDnqoVlfumTiemrv93ksoT92Jp1Qj0  debug3: send packet: type 50  debug2: we sent a publickey packet, wait for reply  debug3: receive packet: type 60  debug1: Server accepts key: /home/pi/.ssh/id_rsa RSA SHA256:PtWlqIMMnTLjjxDnqoVlfumTiemrv93ksoT92Jp1Qj0  debug3: sign_and_send_pubkey: RSA SHA256:PtWlqIMMnTLjjxDnqoVlfumTiemrv93ksoT92Jp1Qj0  debug3: sign_and_send_pubkey: signing using ssh-rsa  debug3: send packet: type 50  debug3: receive packet: type 52  debug1: Authentication succeeded (publickey).  Authenticated to 10.10.10.5 ([10.10.10.5]:22).  debug1: channel 0: new [client-session]  debug3: ssh_session2_open: channel_new: 0  debug2: channel 0: send open  debug3: send packet: type 90  debug1: Requesting no-more-sessions@openssh.com  debug3: send packet: type 80  debug1: Entering interactive session.  debug1: pledge: network  debug3: receive packet: type 80  debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0  debug3: receive packet: type 91  debug2: channel_input_open_confirmation: channel 0: callback start  debug2: fd 3 setting TCP_NODELAY  debug3: ssh_packet_set_tos: set IP_TOS 0x10  debug2: client_session2_setup: id 0  debug2: channel 0: request pty-req confirm 1  debug3: send packet: type 98  debug1: Sending environment.  debug3: Ignored env SHELL  debug3: Ignored env NO_AT_BRIDGE  debug3: Ignored env PWD  debug3: Ignored env LOGNAME  debug3: Ignored env XDG_SESSION_TYPE  debug3: Ignored env HOME  debug1: Sending env LANG = en_GB.UTF-8  debug2: channel 0: request env confirm 0  debug3: send packet: type 98  debug3: Ignored env LS_COLORS  debug3: Ignored env SSH_CONNECTION  debug3: Ignored env XDG_SESSION_CLASS  debug3: Ignored env TERM  debug3: Ignored env USER  debug3: Ignored env SHLVL  debug3: Ignored env GS_INSTALL  debug3: Ignored env XDG_SESSION_ID  debug3: Ignored env XDG_RUNTIME_DIR  debug3: Ignored env SSH_CLIENT  debug3: Ignored env PATH  debug3: Ignored env MAIL  debug3: Ignored env SSH_TTY  debug3: Ignored env TEXTDOMAIN  debug3: Ignored env _  debug2: channel 0: request shell confirm 1  debug3: send packet: type 98  debug2: channel_input_open_confirmation: channel 0: callback done  debug2: channel 0: open confirm rwindow 0 rmax 32768  debug3: receive packet: type 99  debug2: channel_input_status_confirm: type 99 id 0  debug2: PTY allocation request accepted on channel 0  debug2: channel 0: rcvd adjust 2097152  debug3: receive packet: type 99  debug2: channel_input_status_confirm: type 99 id 0  debug2: shell request accepted on channel 0  Linux blackholedns 4.19.66+ #1253 Thu Aug 15 11:37:30 BST 2019 armv6l    The programs included with the Debian GNU/Linux system are free software;  the exact distribution terms for each program are described in the  individual files in /usr/share/doc/*/copyright.    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent  permitted by applicable law.  Last login: Fri Jun 25 12:17:24 2021 from 10.10.10.40  

Any guidance is greatly appreciated.

Updates: Check for references to files that no longer exist in the .profile or .bash_profile. I do not see anything referenced such as awk, grep, sed in the file.

.profile

pi@blackholedns:~ $ cat .profile  # ~/.profile: executed by the command interpreter for login shells.  # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login  # exists.  # see /usr/share/doc/bash/examples/startup-files for examples.  # the files are located in the bash-doc package.    # the default umask is set in /etc/profile; for setting the umask  # for ssh logins, install and configure the libpam-umask package.  #umask 022  set -x    # if running bash  if [ -n "$BASH_VERSION" ]; then      # include .bashrc if it exists      if [ -f "$HOME/.bashrc" ]; then          . "$HOME/.bashrc"      fi  fi    # set PATH so it includes user's private bin if it exists  if [ -d "$HOME/bin" ] ; then      PATH="$HOME/bin:$PATH"  fi  

/home/pi:

pi@blackholedns:~ $ ls -la  total 72  drwxr-xr-x 6 pi   pi    4096 Jun 25 13:02 .  drwxr-xr-x 6 root root  4096 Jun 25 11:22 ..  -rw------- 1 pi   pi    9465 Jun 25 12:27 .bash_history  -rw-r--r-- 1 pi   pi     220 Mar 13  2018 .bash_logout  -rw-r--r-- 1 pi   pi    3523 Dec 12  2020 .bashrc  -rw-r--r-- 1 pi   pi    3523 Mar 13  2018 .bashrc.old  drwxr-xr-x 2 pi   pi    4096 May  2  2018 .nano  -rw-r--r-- 1 pi   pi     682 Jun 25 12:59 .profile  -rw-r--r-- 1 pi   pi     675 Mar 13  2018 .profile.old  -rw-r--r-- 1 root root 12288 Jun 25 12:51 .profile.swp  drwx------ 2 pi   pi    4096 Jan 21  2019 .rapid7_tmp  -rw-r--r-- 1 pi   pi       0 May  2  2018 .selected_editor  drwxrwxrwx 2 pi   pi    4096 Dec 18  2019 .splunk  drwx------ 2 pi   pi    4096 Dec 11  2020 .ssh  -rw-r--r-- 1 pi   pi     171 Oct 11  2019 .wget-hsts  

The .bashrc referenced in the output was restored from /etc/skel back in Dec of 2020. The last time I attempted to fix this issue on my own.

Update: Set trace on .profile results with this:

    pi@blackholedns:~ $ bash .profile      + '[' -n '4.4.12(1)-release' ']'      + '[' -f /home/pi/.bashrc ']'      + . /home/pi/.bashrc      ++ case $- in      ++ return      + '[' -d /home/pi/bin ']'      + PATH=/home/pi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games  pi@blackholedns:~ $   

I assume since I am back at a prompt, the .profile did not get hung up.

Custom XKB layout before login

Posted: 25 Jun 2021 10:38 AM PDT

I have made a custom keyboard layout with XKB, but when I type my password on the login screen, the system still uses a QWERTY layout, only after the login my customized layout is applied. Is it possible to make Ubuntu 18.04 load my custom XKB layout before login?

Need to set a new default path for command in Linux

Posted: 25 Jun 2021 09:27 AM PDT

Basically, what the title says. I'm setting up a new version of LUA and HAProxy under my user account in Redhat, so the bin directory that contains it is /home/user1/testing/usr/local/bin. I've tried adding this to the PATH in my existing .profile, and .bash_profile files, but when I use which lua, I still get the older version under /usr/bin, in the root directory.

My path looks like this:

echo $PATH  /usr/local/bin:/usr/bin:/home/user1/testing/usr/local/bin/  

Is there any way for me to do this without overwriting all the other commands?

Fix too many levels of symbolic links. Linux from scratch

Posted: 25 Jun 2021 09:12 AM PDT

I was trying to follow the Linux from scratch book but I'm having trouble compiling glibc, I think this is related to the problem I'm having with the tools directory.

On one part of the book, I was supposed to use the following command cp -rv dest/include* /tools/include but I get the following error cp: failed to access '/tools/include': Too many levels of symbolic links

So, I'm having trouble with the symbolic link and I have no clue how to fix it. When I run find -L /tools >/dev/null I get the same error.

If I run ls -l /tools I can see why it is failing yet I don't know what to do about it. This is what I get lrwxrwxrwx 1 root root 6 Jun 23 13:47 /tools -> /tools

I'm a windows user so I don't know much about this and I would prefer an explain like I'm 5 years old answer, thank you.

The problem I'm having with glibc is this:
makedb.c:51:11: fatal error: selinux/selinux.h: No such file or directory 51 | # include <selinux/selinux.h> | ^~~~~~~~~~~~~~~~~~~ compilation terminated.

How to search for multiline text files containing a set of words (e.g., AAA & (BBB | CCC) & ~DD)?

Posted: 25 Jun 2021 09:34 AM PDT

I need to find the files that fulfill relatively complex condition. For example, I want to find all files that fulfill all below conditions:

  • does contain word AAAA
  • does contain word BBB or CCCCC (may contain both of them)
  • does not contain word DDD

The words may appear in any order and may appear in different lines.

I have one solution, that combines find and egrep, but is not very legible.

 find . \( -type f -and -exec egrep -q 'BBB | CCCCC' {} \; \      -and -exec egrep -q AAAA {} \; \      -and -not -exec egrep -q DDD \) -print  

Is there any better way to solve that problem?

Find anywhere epoch times in milliseconds in a log and replace them to human readable time

Posted: 25 Jun 2021 09:11 AM PDT

I would like to find and replace all epoch times in milliseconds with human readable times. I got already a solution how to do that, if the epoch times is in the first column for example, but not randomly searching for 13 digits and replace it then with time like "23:59:59 01.01.1980" This is to be done on a Linux machine

So the epoch times could be like:

sms address="+********" body="This is some example text 🙄" date="1620053279300" locked="0" protocol="0" read="1" status="-1" type="1"/>

or even

some log some log "1602674980448"

or

some log some log 1602674980448 some log some log

Any ideas? Thanks a lot in advance.

bash to kill a process by name

Posted: 25 Jun 2021 10:29 AM PDT

I have these attempts to shut down processes (and childs) by name (I got both from this site and adapted them):

read -p "Set process name: " PS    # first option  f() { ps ax | grep "$1" | grep -v grep | awk '{print $1}' | xargs kill -9; }  f $PS    # second option  for pid in $(ps -ef | awk '/$PS/ {print $2}'); do kill -9 $pid; done    # end of bash  if [  $? -gt 0 ]; then     echo "no process:" $PS  else     echo "Finished"  fi  

But I don't know which of the two is more effective (or none of the above)

Additionally, the second loop does not complete (that is, if there are no processes, it should exit "no process:" name of process), but it goes straight to "Finished"

And in both cases there is a problem with kill command. If there are no processes, a message appears indicating options on the use of kill. I can hide it with &> /dev/null or set +m, set -m but but I don't know if kill will have any flag (switch) to silence the output

Update:

thanks to @steeldriver I was able to see the error that awk does not accept variables (/$PS/) so i found this solution HERE:

And replace this:

for pid in $(ps -ef | awk '/$PS/ {print $2}'); do kill -9 $pid; done  

with this:

for pid in $(ps -ef | grep "$PS" | awk '{print $2}'); do kill -9 $pid; done  

Kill processes only if a specific number of PIDs match criteria

Posted: 25 Jun 2021 08:12 AM PDT

I am trying to improve this one liner I use as an (abused) docker-compose healthcheck that runs inside a container:

ps -C program.bin -o pid,pcpu --no-headers | awk '$2 > 98 {print $1}' | xargs kill -9

In current form, I filter the PIDs with CPU utilization over 98% and kill any matching PID right away.

However, I would like to kill only if an exact number of resulting PIDs have the high utilization (in other words, if one program.bin PID has CPU over 98%, don't kill it, but if 2 of them meet the criteria, kill them both). Any pointers on how to do this? Thanks!

Can't login with root at Runlevel 3

Posted: 25 Jun 2021 08:09 AM PDT

i used init 3 to move to runlevel 3 , but after I can't login with root password , i viewed the the file "/var/log/secure" and found this :

Jun 25 17:39:12 localhost login: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=tty1 ruser= rhost= user=root Jun 25 17:39:13 localhost login: FAILED LOGIN SESSION FROM (null) FOR root, Permission denied

what could be the issue ?

Regards

Linux Mint not shutting down

Posted: 25 Jun 2021 08:14 AM PDT

people!

I use Linux Mint 19.3 Tricia and it's not shutting down sometimes. I have been researching and looks like a kernel panic with a BAD RIP value code,but I'm not sure and I don't know how to solve it.

Sorry for the lack of information, but I don't know too much about Linux, but if some more information were necessary I can provide it. It's happening almost everyday

I'm attaching the image of a screen that appear when it's not turning off and I press ESC: Screen

Thanks for help!

What is my hard drive physical sector size? fdisk, smartctl etc.. give different answers

Posted: 25 Jun 2021 08:22 AM PDT

The harddrive is connected with an external enclosure via USB3.0.

$ sudo smartctl -a /dev/sdb    === START OF INFORMATION SECTION ===  Model Family:     Seagate Barracuda 3.5  Device Model:     ST4000DM004-2CV104  Firmware Version: 0001  User Capacity:    4,000,787,030,016 bytes [4.00 TB]  Sector Sizes:     512 bytes logical, 4096 bytes physical  Rotation Rate:    5425 rpm  Form Factor:      3.5 inches  Device is:        In smartctl database [for details use: -P show]  ATA Version is:   ACS-3 T13/2161-D revision 5  SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)  SMART support is: Available - device has SMART capability.  SMART support is: Enabled  
  • You can see that it shows 4096 bytes physical in the above output.

  • But all the following results show 512 bytes:

$ sudo fdisk -l /dev/sdb    Disk /dev/sdb: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors  Disk model: USB3.0  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 4096 bytes / 33553920 bytes  
$ cat /sys/block/sdb/queue/hw_sector_size  512    $ cat /sys/block/sdb/queue/physical_block_size  512  
$ lsblk -o NAME,PHY-SeC /dev/sdb  NAME   PHY-SEC  sdb        512  └─sdb1     512  
$ sudo blockdev --getbsz /dev/sdb  512  

So what is the real hard drive physical sector size?

I think it should be 4096, but I don't know why all other commands give me wrong result.

  • Btw, the reason why I want to find the real physical sector size is because I want to use -b 4096 when running badblocks.

Thanks a lot.

  • PS: If the answer is 4096, are there any other tools in Linux can show the real result other than smartctl?

I found another command will show 4096:

$ sudo hdparm -I /dev/sdb | grep -i physical          Physical Sector size:                  4096 bytes  

Screen artifacts after waking laptop from sleep

Posted: 25 Jun 2021 09:05 AM PDT

I used the ArchWiki to solve this problem but the issue still persists. I am using only amdgpu currently .

inxi -b  System:    Host: Asus Kernel: 5.4.124-1-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.21.5 Distro: Manjaro Linux   Machine:   Type: Laptop System: ASUSTeK product: VivoBook_ASUSLaptop X570ZD_F570ZD v: 1.0 serial: <superuser required>              Mobo: ASUSTeK model: X570ZD v: 1.0 serial: <superuser required> UEFI: American Megatrends v: X570ZD.312              date: 02/25/2020   Battery:   ID-1: BAT0 charge: 23.1 Wh (55.1%) condition: 41.9/48.1 Wh (87.1%) volts: 11.7 min: 11.7   CPU:       Info: Quad Core AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx [MT MCP] speed: 1889 MHz min/max: 1600/2000 MHz   Graphics:  Device-1: NVIDIA GP107M [GeForce GTX 1050 Mobile] driver: nouveau v: kernel              Device-2: AMD Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series] driver: amdgpu v: kernel              Device-3: IMC Networks USB2.0 VGA UVC WebCam type: USB driver: uvcvideo              Display: x11 server: X.Org 1.20.11 driver: loaded: amdgpu,ati,nouveau unloaded: modesetting              resolution: 1920x1080~60Hz              OpenGL: renderer: AMD Radeon Vega 8 Graphics (RAVEN DRM 3.35.0 5.4.124-1-MANJARO LLVM 12.0.0) v: 4.6 Mesa 21.1.2   Network:   Device-1: Intel Wireless 8265 / 8275 driver: iwlwifi              Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8169              Device-3: Intel Bluetooth wireless interface type: USB driver: btusb   Drives:    Local Storage: total: 931.51 GiB used: 117.66 GiB (12.6%)   Info:      Processes: 233 Uptime: 11m Memory: 6.74 GiB used: 2.36 GiB (35.1%) Shell: Bash inxi: 3.3.04   

How to check if Linux booted on CSM/Legacy/BIOS mode in a PC with UEFI?

Posted: 25 Jun 2021 09:21 AM PDT

I'm doing an ssh to a PC that no one can actually physically reach, yet. Said PC was made after 2011, so it defintely has UEFI.

The issue is that every posts on the web is about checking if the PC has a UEFI or BIOS (e.g. How to know if I'm booting using UEFI?), which is not what I'm trying to find out.

 

My question is then pretty simple: How do I tell if a PC with UEFI, booted with CSM/Legacy/BIOS Mode enabled or not ?

Merging inputs on my command

Posted: 25 Jun 2021 09:14 AM PDT

I have a numeric table for each letters in enlglish. Evey letter has random number. And my command converts theese random numbers to binary codes. But it can convert just 1 letter at the same time. I want to merge automaticily any words when i typed. Like apple, pen, table, ...

My command

#/bin/bash    echo "Write a letter"  read n  a=$(grep $n ~/Desktop/letter-table | awk '{print $2}')    echo `perl -e 'printf "%b\n",'$a`  

Output

[hoovy@turbine Desktop]$ sh code-lang.sh  Write a letter  a  1111001  [hoovy@turbine Desktop]$ sh code-lang.sh  Write a letter  p  10010001  [hoovy@turbine Desktop]$ sh code-lang.sh  Write a letter  p  10010001  [hoovy@turbine Desktop]$ sh code-lang.sh  Write a letter  l  10010001  [hoovy@turbine Desktop]$ sh code-lang.sh  Write a letter  e  10111010  [hoovy@turbine Desktop]$  

Schedule reboot in the background during debian preseeding

Posted: 25 Jun 2021 09:27 AM PDT

I want to schedule a 30-minute reboot timer inside a Debian preseed so that in case of download problems etc. the installation does not hang (requiring someone on-site to reboot the machine manually).

I am installing from a netboot image.

The following does not work (it does not run in the background, but in the foreground):

d-i preseed/early_command string reboot -d 1800 &  
d-i preseed/early_command string sh -c 'reboot -d 1800 &' ;  

I think the culprit is the log-output program used here https://salsa.debian.org/installer-team/preseed/-/blob/master/preseed_command#L16

Is there an alternative way to accomplish the scheduled reboot? Bonus if I do not have to install additional software (again, network problems …)

XKB not recognizing my custom layout

Posted: 25 Jun 2021 09:34 AM PDT

I created a custom keyboard layout (the file is called "brc") based on Colemak for my Lubuntu 18.04, and copied it to /usr/share/X11/xkb/symbols:

default partial  xkb_symbols "basic" {      name[Group1]= "brc";        // Alphanumeric section      key <TLDE> { [   apostrophe,        quotedbl,        notsign,          notsign ] };      key <AE01> { [            1,          exclam,    onesuperior,   exclamdown ] };      key <AE02> { [            2,              at,    twosuperior,          onehalf ] };      key <AE03> { [            3,      numbersign,  threesuperior,    threequarters ] };      key <AE04> { [            4,          dollar,       sterling,       onequarter ] };      key <AE05> { [            5,         percent,           cent,     threeeighths ] };      key <AE06> { [            6,  dead_diaeresis,        notsign,        diaeresis ] };      key <AE07> { [            7,       ampersand,      braceleft,     seveneighths ] };      key <AE08> { [            8,        asterisk,    bracketleft,        trademark ] };      key <AE09> { [            9,       parenleft,   bracketright,        plusminus ] };      key <AE10> { [            0,      parenright,     braceright,           degree ] };      key <AE11> { [        minus,      underscore,         endash,     questiondown ] };      key <AE12> { [        equal,            plus,        section,      dead_ogonek ] };      key <AE13> { [ bracketright,      braceright,      masculine,        masculine ] };      key <BKSP> { [    BackSpace,       BackSpace,      BackSpace,        BackSpace ] };        key <AD01> { [            q,               Q,          slash,            slash ] };      key <AD02> { [            w,               W,       question,         question ] };      key <AD03> { [            f,               F,       EuroSign,         EuroSign ] };      key <AD04> { [            p,               P,          thorn,            THORN ] };      key <AD05> { [            g,               G                                   ] };       key <AD06> { [            j,               J,            yen                   ] };      key <AD07> { [            l,               L                                   ] };      key <AD08> { [            u,               U                                   ] };      key <AD09> { [            y,               Y,         oacute,           Oacute ] };      key <AD10> { [     ccedilla,        Ccedilla,                                  ] };      key <AD11> { [   dead_acute,      dead_grave,         acute,             grave ] };      key <AD12> { [  bracketleft,       braceleft,    ordfeminine,      dead_macron ] };        key <AC01> { [            a,               A,             ae,               AE ] };       key <AC02> { [            r,               R,     registered,       registered ] };      key <AC03> { [            s,               S                                   ] };      key <AC04> { [            t,               T                                   ] };      key <AC05> { [            d,               D                                   ] };      key <AC06> { [            h,               H                                   ] };      key <AC07> { [            n,               N                                   ] };      key <AC08> { [            e,               E                                   ] };      key <AC09> { [            i,               I                                   ] };      key <AC10> { [            o,               O,             oe,           OE     ] };      key <AC11> { [   dead_tilde, dead_circumflex,     asciitilde,     asciicircum  ] };      key <AC12> { [        slash,        question,   questiondown                   ] };        key <AB01> { [            z,               Z,  guillemotleft                   ] };      key <AB02> { [            x,               X, guillemotright                   ] };      key <AB03> { [            c,               C       copyright,        copyright ] };       key <AB04> { [            v,               V                                   ] };       key <AB05> { [            b,               B                                   ] };      key <AB06> { [            k,               K                                   ] };      key <AB07> { [            m,               M,             mu,               mu ] };      key <AB08> { [        comma,            less                                   ] };      key <AB09> { [       period,         greater                                   ] };      key <AB10> { [    semicolon,           colon                                   ] };         key <SPCE> { [        space,           space,          space,     nobreakspace ] };    // Configures the "," for the numeric keypad      include "kpdl(comma)"    // Configures the use of the AltGr key      include "level3(ralt_switch)"  };  

I also altered the following files in /usr/share/X11/xkb/rules:

in evdev.xml

    <layout>        <configItem>          <name>brc</name>          <shortDescription>custom-clmk</shortDescription>          <description>custom-colemak-abnt2</description>          <languageList>             <iso639Id>por</iso639Id>          </languageList>        </configItem>        <variantList/>      </layout>  

in evdev.lst

! layout    brc             abnt2+colemak  

And this is the result:

~$ setxkbmap -v brc  Warning! Multiple definitions of keyboard layout           Using command line, ignoring X server  Trying to build keymap using the following components:  keycodes:   evdev+aliases(qwerty)  types:      complete  compat:     complete  symbols:    pc+brc+inet(evdev)  geometry:   pc(pc105)  Error loading new keyboard description  

Also, this is my current layout:

~$ setxkbmap -v  Trying to build keymap using the following components:  keycodes:   evdev+aliases(qwerty)  types:      complete  compat:     complete  symbols:    pc+br+inet(evdev)  geometry:   pc(pc105)  

How can I make xkb recognize my custom layout?

How to make a port open?

Posted: 25 Jun 2021 08:59 AM PDT

When I ping, there is reply.

$ ping 10.26.14.16  64 bytes from 10.26.140.160: icmp_seq=1 ttl=63 time=0.525 ms  

When I ping with port, there is no reply.

$ nmap -p 5016 10.26.14.16  5016/tcp closed unknown  

Question: How to make port 5016 open?

Curl gives "SSL routines:ssl3_read_bytes:sslv3 alert handshake failure"

Posted: 25 Jun 2021 10:19 AM PDT

When I run curl on https://www.ethics.state.tx.us/data/search/lobby/TEC_LA_CSV.zip I get a

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure  

I've tried adding -2 and -3 and other things I've seen online, but nothing seems to work. How can I resolve this issue and download this file with curl.

Here is the output from curl below,

$ curl -vvvk "https://www.ethics.state.tx.us/data/search/lobby/TEC_LA_CSV.zip"  *   Trying 204.65.203.80:443...  * TCP_NODELAY set  * Connected to www.ethics.state.tx.us (204.65.203.80) port 443 (#0)  * ALPN, offering h2  * ALPN, offering http/1.1  * successfully set certificate verify locations:  *   CAfile: /etc/ssl/certs/ca-certificates.crt    CApath: /etc/ssl/certs  * TLSv1.3 (OUT), TLS handshake, Client hello (1):  * TLSv1.3 (IN), TLS alert, handshake failure (552):  * error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure  * Closing connection 0  curl: (35) error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure  

I'm also seeing this when I try to use -2,

curl: (4) OpenSSL was built without SSLv2 support  

With -3

curl: (4) OpenSSL was built without SSLv3 support  

How to get the relative path between two directories?

Posted: 25 Jun 2021 08:26 AM PDT

Say I have a variable with a path release/linux/x86, and want the relative path from a different directory (i.e. ../../.. for current working directory), how would I get that in a shell command (or possibly GNU Make)?

Soft link support not required.


This question has been heavily modified based on the accepted answer for improved terminology.

MDADM - Stop Resync and Force Clean - Possible and/or Safe?

Posted: 25 Jun 2021 09:05 AM PDT

I have been having issues with my FileServer recently.

See "rcu_sched detected stalls on CPUs/tasks" - jiffies - ESXi Ubuntu 16 FileServer Guest

I just rebuilt it since I couldn't get any guidance on the issue. Unfortunatley, its resyncing my array again.

Seeing how this has been done multiple time in the last few days, I'm fairly confident that its "in sync".

I have a few questions to that regard.

  • When it resync's what is happening, is it just doing read operations on every piece of data? I feel i'm really abusing my HDD's at the moment
  • Can I cancel resync? (I still want to be able to use the MDADM Though!)
  • So Can I force it to "clean" state and remount?
  • Is resync automatic when you mount a new MDADM (This is a new VM), or is there an error in the metadata that is forcing a resync and I NEED to let it finish. (It takes about 24 Hours and my server is extremely slow during that time)

Thanks!

Update: There are 4x 5tb HDDs in raid5 passed through via mapped raw lun to a VM guest which then exports nfs and smb.

This question is mostly about if the commands i want exist for mdadm and what sync does.

Fixing a problem with lightdm; boot-loop

Posted: 25 Jun 2021 08:06 AM PDT

I think I messed up my Ubuntu 17.04 a little. In order to describe my problem I can only provide the symptoms + a suspicious log-file.

My quenstion on this is: 1.: Can I repair it by doing something with lightdm? (cf. below)?

Symptoms: When I start the pc, it never reaches the log-in-mask. Instead it seems to be trying to launch the graphical surface over and over again, but always fails to do so. I can hardly work on it in this state. I can switch to Ctrl+Alt+F2 and log in via terminal. Here I can do stuff, but roughly all 30seconds the monitor becomes black and shortly displays 'No signal'. After some seconds I can re-switch to there and start from were I left. Reboot does not help.

DISPLAY-variable is 1. $startx does not work.

System: Ubuntu 17.04, build pc, all parts were bought 2 months ago.

What I did: I installed pekwm and started it a few times, I also switched between the window-managers via $pekwm --replace& resp. $compiz --replace&. It worked fine. I installed conky and wrote a .desktop-file to autostart it. This never worked. I deleted said .desktop-file, after the problem occurred. Right before the problem occured, I do not recall having done anything else than firefox, LaTeX and mathematica.

It MIGHT be, that I messed up lighdm, without realizing. Here are last few lines of /var/log/lightdm/lightdm.log:

[+29.10s] DEBUG: Exiting with return value 1  [+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log  [+0.00s] DEBUG: Starting Light Display Manager 1.22.0, UID=0 PID=5482  [+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/45-unity8.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-disable-guest.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-disable-log-backup.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf  [+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf  [+0.00s] DEBUG: Registered seat module local  [+0.00s] DEBUG: Registered seat module xremote  [+0.00s] DEBUG: Registered seat module unity  [+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager  [+0.01s] DEBUG: Monitoring logind for seats  [+0.01s] DEBUG: New seat added from logind: seat0  [+0.01s] DEBUG: Seat seat0: Loading properties from config section Seat:*  [+0.01s] DEBUG: Seat seat0: Starting  [+0.01s] DEBUG: Seat seat0: Creating greeter session  [+0.01s] DEBUG: Seat seat0: Creating display server of type x  [+0.02s] DEBUG: Using VT 7  [+0.02s] DEBUG: Seat seat0: Starting local X display on VT 7  [+0.02s] DEBUG: XServer 1: Logging to /var/log/lightdm/x-1.log  [+0.02s] DEBUG: XServer 1: Writing X server authority to /var/run/lightdm/root/:1  [+0.02s] DEBUG: XServer 1: Launching X Server  [+0.02s] DEBUG: Launching process 5487: /usr/bin/X -core :1 -seat seat0 -auth /var/run/lightdm/root/:1 -nolisten tcp vt7 -novtswitch  [+0.02s] DEBUG: XServer 1: Waiting for ready signal from X server :1  [+0.02s] DEBUG: Acquired bus name org.freedesktop.DisplayManager  [+0.02s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0  [+0.02s] DEBUG: Loading users from org.freedesktop.Accounts  [+0.02s] DEBUG: User /org/freedesktop/Accounts/User1000 added  [+0.31s] DEBUG: Seat seat0 changes active session to c12  [+0.91s] DEBUG: Got signal 10 from process 5487  [+0.91s] DEBUG: XServer 1: Got signal from X server :1  [+0.91s] DEBUG: XServer 1: Connecting to XServer :1  [+1.18s] DEBUG: Seat seat0: Display server ready, starting session authentication  [+1.18s] DEBUG: Session pid=5642: Started with service 'lightdm-greeter', username 'lightdm'  [+1.18s] DEBUG: Seat seat0 changes active session to   [+1.20s] DEBUG: Session pid=5642: Authentication complete with return value 0: Success  [+1.20s] DEBUG: Seat seat0: Session authenticated, running command  [+1.20s] DEBUG: Session pid=5642: Running command /usr/lib/lightdm/lightdm-greeter-session /usr/sbin/unity-greeter  [+1.20s] DEBUG: Creating shared data directory /var/lib/lightdm-data/lightdm  [+1.20s] DEBUG: Session pid=5642: Logging to /var/log/lightdm/seat0-greeter.log  [+1.27s] DEBUG: Activating VT 7  [+1.28s] DEBUG: Activating login1 session c13  [+1.28s] DEBUG: Seat seat0 changes active session to c13  [+1.28s] DEBUG: Session c13 is already active  [+1.51s] DEBUG: Greeter connected version=1.22.0 api=1 resettable=false  [+1.79s] DEBUG: Greeter start authentication for hein  [+1.79s] DEBUG: Session pid=5796: Started with service 'lightdm', username 'hein'  [+1.80s] DEBUG: Session pid=5796: Got 1 message(s) from PAM  [+1.80s] DEBUG: Prompt greeter with 1 message(s)  [+3.52s] DEBUG: Seat seat0 changes active session to 2  [+29.98s] DEBUG: Greeter closed communication channel  [+29.98s] DEBUG: Session pid=5642: Exited with return value 0  [+29.98s] DEBUG: Seat seat0: Session stopped  [+29.98s] DEBUG: Seat seat0: Stopping; failed to start a greeter  [+29.98s] DEBUG: Seat seat0: Stopping  [+29.98s] DEBUG: Seat seat0: Stopping display server  [+29.98s] DEBUG: Sending signal 15 to process 5487  [+29.98s] DEBUG: Seat seat0: Stopping session  [+29.98s] DEBUG: Session pid=5796: Sending SIGTERM  [+29.98s] DEBUG: Session pid=5796: Terminated with signal 15  [+29.98s] DEBUG: Session: Failed during authentication  [+29.98s] DEBUG: Seat seat0: Session stopped  [+29.98s] DEBUG: Process 5487 exited with return value 0  [+29.98s] DEBUG: XServer 1: X server stopped  [+29.98s] DEBUG: Releasing VT 7  [+29.98s] DEBUG: XServer 1: Removing X server authority /var/run/lightdm/root/:1  [+29.98s] DEBUG: Seat seat0: Display server stopped  [+29.98s] DEBUG: Seat seat0: Stopped  [+29.98s] DEBUG: Required seat has stopped  [+29.98s] DEBUG: Stopping display manager  [+29.98s] DEBUG: Display manager stopped  [+29.98s] DEBUG: Stopping daemon  [+29.98s] DEBUG: Exiting with return value 1  [+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log  [+0.00s] DEBUG: Starting Light Display Manager 1.22.0, UID=0 PID=5861  [+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/45-unity8.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-disable-guest.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-disable-log-backup.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf  [+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf  [+0.00s] DEBUG: Registered seat module local  [+0.00s] DEBUG: Registered seat module xremote  [+0.00s] DEBUG: Registered seat module unity  [+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager  [+0.02s] DEBUG: Monitoring logind for seats  [+0.02s] DEBUG: New seat added from logind: seat0  [+0.02s] DEBUG: Seat seat0: Loading properties from config section Seat:*  [+0.02s] DEBUG: Seat seat0: Starting  [+0.02s] DEBUG: Seat seat0: Creating greeter session  [+0.02s] DEBUG: Seat seat0: Creating display server of type x  [+0.02s] DEBUG: Using VT 7  [+0.02s] DEBUG: Seat seat0: Starting local X display on VT 7  [+0.02s] DEBUG: XServer 0: Logging to /var/log/lightdm/x-0.log  [+0.02s] DEBUG: XServer 0: Writing X server authority to /var/run/lightdm/root/:0  [+0.02s] DEBUG: XServer 0: Launching X Server  [+0.02s] DEBUG: Launching process 5866: /usr/bin/X -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch  [+0.02s] DEBUG: XServer 0: Waiting for ready signal from X server :0  [+0.02s] DEBUG: Acquired bus name org.freedesktop.DisplayManager  [+0.02s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0  [+0.02s] DEBUG: Loading users from org.freedesktop.Accounts  [+0.02s] DEBUG: User /org/freedesktop/Accounts/User1000 added  [+0.04s] DEBUG: Seat seat0 changes active session to c13  [+0.61s] DEBUG: Got signal 10 from process 5866  [+0.61s] DEBUG: XServer 0: Got signal from X server :0  [+0.61s] DEBUG: XServer 0: Connecting to XServer :0  [+0.66s] DEBUG: Seat seat0: Display server ready, starting session authentication  [+0.66s] DEBUG: Session pid=5888: Started with service 'lightdm-greeter', username 'lightdm'  [+0.68s] DEBUG: Session pid=5888: Authentication complete with return value 0: Success  [+0.68s] DEBUG: Seat seat0: Session authenticated, running command  [+0.68s] DEBUG: Session pid=5888: Running command /usr/lib/lightdm/lightdm-greeter-session /usr/sbin/unity-greeter  [+0.68s] DEBUG: Creating shared data directory /var/lib/lightdm-data/lightdm  [+0.68s] DEBUG: Session pid=5888: Logging to /var/log/lightdm/seat0-greeter.log  [+0.71s] DEBUG: Activating VT 7  [+0.71s] DEBUG: Activating login1 session c14  [+0.71s] DEBUG: Seat seat0 changes active session to c14  [+0.71s] DEBUG: Session c14 is already active  [+0.78s] DEBUG: Greeter connected version=1.22.0 api=1 resettable=false  [+0.92s] DEBUG: Greeter start authentication for hein  [+0.92s] DEBUG: Session pid=5943: Started with service 'lightdm', username 'hein'  [+0.92s] DEBUG: Session pid=5943: Got 1 message(s) from PAM  [+0.92s] DEBUG: Prompt greeter with 1 message(s)  [+4.29s] DEBUG: Seat seat0 changes active session to 2  [+29.09s] DEBUG: Greeter closed communication channel  [+29.09s] DEBUG: Session pid=5888: Exited with return value 0  [+29.09s] DEBUG: Seat seat0: Session stopped  [+29.09s] DEBUG: Seat seat0: Stopping; failed to start a greeter  [+29.09s] DEBUG: Seat seat0: Stopping  [+29.09s] DEBUG: Seat seat0: Stopping display server  [+29.09s] DEBUG: Sending signal 15 to process 5866  [+29.09s] DEBUG: Seat seat0: Stopping session  [+29.09s] DEBUG: Session pid=5943: Sending SIGTERM  [+29.09s] DEBUG: Session pid=5943: Terminated with signal 15  [+29.09s] DEBUG: Session: Failed during authentication  [+29.09s] DEBUG: Seat seat0: Session stopped  [+29.09s] DEBUG: Process 5866 exited with return value 0  [+29.09s] DEBUG: XServer 0: X server stopped  [+29.09s] DEBUG: Releasing VT 7  [+29.09s] DEBUG: XServer 0: Removing X server authority /var/run/lightdm/root/:0  [+29.09s] DEBUG: Seat seat0: Display server stopped  [+29.09s] DEBUG: Seat seat0: Stopped  [+29.09s] DEBUG: Required seat has stopped  [+29.09s] DEBUG: Stopping display manager  [+29.09s] DEBUG: Display manager stopped  [+29.09s] DEBUG: Stopping daemon  [+29.09s] DEBUG: Exiting with return value 1  [+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log  [+0.00s] DEBUG: Starting Light Display Manager 1.22.0, UID=0 PID=6033  [+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/45-unity8.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-disable-guest.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-disable-log-backup.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf  [+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf  [+0.00s] DEBUG: Registered seat module local  [+0.00s] DEBUG: Registered seat module xremote  [+0.00s] DEBUG: Registered seat module unity  [+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager  [+0.02s] DEBUG: Monitoring logind for seats  [+0.02s] DEBUG: New seat added from logind: seat0  [+0.02s] DEBUG: Seat seat0: Loading properties from config section Seat:*  [+0.02s] DEBUG: Seat seat0: Starting  [+0.02s] DEBUG: Seat seat0: Creating greeter session  [+0.02s] DEBUG: Seat seat0: Creating display server of type x  [+0.02s] DEBUG: Using VT 7  [+0.02s] DEBUG: Seat seat0: Starting local X display on VT 7  [+0.02s] DEBUG: XServer 1: Logging to /var/log/lightdm/x-1.log  [+0.02s] DEBUG: XServer 1: Writing X server authority to /var/run/lightdm/root/:1  [+0.02s] DEBUG: XServer 1: Launching X Server  [+0.02s] DEBUG: Launching process 6038: /usr/bin/X -core :1 -seat seat0-auth /var/run/lightdm/root/:1 -nolisten tcp vt7 -novtswitch  [+0.02s] DEBUG: XServer 1: Waiting for ready signal from X server :1  [+0.02s] DEBUG: Acquired bus name org.freedesktop.DisplayManager  [+0.02s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0  [+0.02s] DEBUG: Loading users from org.freedesktop.Accounts  [+0.02s] DEBUG: User /org/freedesktop/Accounts/User1000 added  [+0.27s] DEBUG: Seat seat0 changes active session to c14  [+0.88s] DEBUG: Got signal 10 from process 6038  [+0.88s] DEBUG: XServer 1: Got signal from X server :1  [+0.88s] DEBUG: XServer 1: Connecting to XServer :1  [+1.14s] DEBUG: Seat seat0: Display server ready, starting session authentication  [+1.14s] DEBUG: Session pid=6193: Started with service 'lightdm-greeter', username 'lightdm'  [+1.14s] DEBUG: Seat seat0 changes active session to   [+1.16s] DEBUG: Session pid=6193: Authentication complete with return value 0: Success  [+1.16s] DEBUG: Seat seat0: Session authenticated, running command  [+1.16s] DEBUG: Session pid=6193: Running command /usr/lib/lightdm/lightdm-greeter-session /usr/sbin/unity-greeter  [+1.16s] DEBUG: Creating shared data directory /var/lib/lightdm-data/lightdm  [+1.16s] DEBUG: Session pid=6193: Logging to /var/log/lightdm/seat0-greeter.log  [+1.21s] DEBUG: Activating VT 7  [+1.21s] DEBUG: Activating login1 session c15  [+1.22s] DEBUG: Seat seat0 changes active session to c15  [+1.22s] DEBUG: Session c15 is already active  [+1.49s] DEBUG: Greeter connected version=1.22.0 api=1 resettable=false  [+1.75s] DEBUG: Greeter start authentication for hein  [+1.75s] DEBUG: Session pid=6340: Started with service 'lightdm', username 'hein'  [+1.75s] DEBUG: Session pid=6340: Got 1 message(s) from PAM  [+1.75s] DEBUG: Prompt greeter with 1 message(s)  [+6.23s] DEBUG: Seat seat0 changes active session to 2  

Thanks in advance!

How to automatically detect and write to usb with variable spaces in its name

Posted: 25 Jun 2021 11:04 AM PDT

I am doing the second BASH exercise from TLDP Bash-Scripting Guide, and I have most of it figured out up until the part when it comes time to copy the compressed files to an inserted USB.

Home Directory Listing

Perform a recursive directory listing on the user's home directory and save the information to a file. Compress the file, have the script prompt the user to insert a USB flash drive, then press ENTER. Finally, save the file to the flash drive after making certain the flash drive has properly mounted by parsing the output of df. Note that the flash drive must be unmounted before it is removed.

As I progress with the script it is becoming less ..elegant, and was wondering if there was a better way to do this. I know creating files is likely not the most efficient way to do the comparisons, but have not got the shell expansions figured yet, and intend to change those once I get it working.

The problem specifically is, to ensure that the usb is mounted and that I am writing to the USB and nowhere else. I am comparing the last line of df after the USB is plugged in with the last line of df from the diff between df before USB is plugged in and df after USB is plugged in, and looping until they match. Unfortunately, the diff result starts with a >, but I intend to use sed to get rid of that. The real problem is the path to where my usb is mounted is:

/media/flerb/"Title of USB with spaces"

To make this portable for USBs that may have different names is my best bet from here to do something with awk and field separators? And as a follow-up, I know this is pretty inelegant, and wonder if there is a cleaner way to go about this...especially because this is the second exercise and still in EASY.

The output from the df tails is:

/dev/sdb1                     15611904  8120352   7491552  53% /media/flerb/CENTOS 7 X8  > /dev/sdb1                     15611904  8120352   7491552  53% /media/flerb/CENTOS 7 X8  

The script so far

 1 #!/bin/bash    2     3 if [ "$UID" -eq 0 ] ; then    4         echo "Don't run this as root"    5         exit 1    6 fi    7     8 #Create a backup file with the date as title in a backup directory    9 BACKUP_DIR="$HOME/backup"   10 DATE_OF_COPY=$(date --rfc-3339=date)   11 BACKUP_FILE="$BACKUP_DIR/$DATE_OF_COPY"   12    13 [ -d "$BACKUP_DIR" ] || mkdir -m 700 "$BACKUP_DIR"   14    15 #find all files recursively in $HOME directory   16 find -P $HOME >> "$BACKUP_FILE"   17    18 #use lzma to compress   19 xz -zk --format=auto --check=sha256 --threads=0 "$BACKUP_FILE"   20    21 #making files to use in operations   22 BEFORE="$BACKUP_DIR"/before_usb.txt   23 AFTER="$BACKUP_DIR"/after_usb.txt   24 DIFFERENCE="$BACKUP_DIR"/difference.txt   25    26 df > "$BEFORE"   27 read -p 'Enter USB and press any button' ok   28 sleep 2   29 df > "$AFTER"   30 diff "$BEFORE" "$AFTER" > "$DIFFERENCE"   31 sleep 2   32 echo   33    34 TAIL_AFTER=$(tail -n 1 "$AFTER")   35 TAIL_DIFF=$(tail -n 1 "$DIFFERENCE")   36    37 until [ "$TAIL_AFTER" == "$TAIL_DIFF" ] ;   38 do   39         echo "Not yet"   40         df > "$AFTER"   41         TAIL_AFTER=$(tail -n 1 "$AFTER")   42         diff "$BEFORE" "$AFTER" > "$DIFFERENCE"   43         TAIL_DIFF=$(tail -n 1 "$DIFFERENCE")   44         echo "$TAIL_AFTER"   45         echo "$TAIL_DIFF"   46         sleep 1   47    48 done   49 exit $?  

Test if postfix is running

Posted: 25 Jun 2021 11:24 AM PDT

I'm searching for a reliable way to test if postfix is running from inside a bash script.

My first attempt was simply trying pidof postfix, which doesn't work.

Then I tried to get the postfix status:

POSTFIX_LOCATION=/var/packages/MailServer/target/sbin/postfix # location of postfix  result=`$POSTFIX_LOCATION status`  if [ -z $result ]; then      echo "Error: No status output from postfix"  elif [[ "$result" == *"is running"* ]]; then      echo "postfix is running!"  else echo "postfix is not running!"  fi  

But even though the status is reported to the console, the result variable stays empty. This is the console output:

postfix/postfix-script: the Postfix mail system is running: PID: 11996  Error: No status output from postfix  

I finally found a way to test if postfix is running by getting the process name of PID: 11996, which is "master". So the following does work:

pidof master  

But this is not very verbose and I'm not sure if this is a reliable way to test if postfix is running.

So my questions are:

  • How can I get the output of postfix status from inside a bash script? - Anything I'm doing wrong there?
  • Is there a better reliable way to test if postfix is running from inside a bash script?

How do I scan grayscale with simple-scan?

Posted: 25 Jun 2021 10:07 AM PDT

I really like simple-scan because:

  1. It's really simple
  2. It has an interface that fits with GNOME setup on Debian (unlike Skanlite)

However, I can't seem to be able to set it to scan in grayscale. How can I do this? The two options, photo and text seem to serve as colour and B&W respectively, which is a problem when I want to scan documents with a high level of detail but without colour (I scan a lot of documents and storage becomes an issue).

Anyway, I realise that the ideal solution would be to use a proper scanning tool, but since I'm really just after exactly what simple-scan offers with one tiny extra feature I thought I'd ask in case someone knew how to set this up (maybe I can add a "grayscale" profile to the list?)

Easy way to paste command line output to paste bin services?

Posted: 25 Jun 2021 10:18 AM PDT

Are there any command line tools on Linux that allow you to post output from commands or text files directly to a sharing service such as pastebin.com?

Can emacs use gpg-agent in a terminal at all?

Posted: 25 Jun 2021 07:54 AM PDT

I understand that there are problems with getting pinentry-curses to work with emacs (see some of the comments on http://emacswiki.org/emacs/EasyPG), and so using emacs in a terminal isn't compatible with gpg-agent because of this.

I can't use a graphical pinentry tool in this case as this is over an ssh connection to a remote machine.

However, is it possible to feed the gpg-agent the passphrase beforehand and then have emacs use this, but not to prompt for a passphrase if the agent doesn't already have this info?

What settings would allow this to work with notmuch.el and EasyPG?

Or, are there alternative methods of caching the passphrase which would achieve the same effect, but may have security problems (which is the reason gpg-agent exists in the first place)?

No comments:

Post a Comment