Wednesday, June 16, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


NFSv4 wrong effective user / owner, sec=krb5 mount squashes to anonymous user

Posted: 16 Jun 2021 11:58 AM PDT

I'm setting up kerberized NFSv4 for personal use

  • manually configured NFS, KDC
  • no nameservers (using /etc/hosts instead), no LDAP
  • same users on all machines (not necessarily the same id) and using id mapping for all security modes (nfs4_disable_idmapping set to 'N')

I've got two machines, both running Ubuntu 20.04 LTS

  • arhiv.pecar (local address 192.168.56.200) has the NFS server and the KDC
  • client.pecar (local address 192.158.56.100) is the client

All plumbing seems to work and I can mount the share just fine, but

  • if the share is exported with sec=sys

    server exportfs -v output

    /srv/export     <world>(rw,async,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)  

    client mount output

    arhiv.pecar:/srv/export on /mnt type nfs4 (rw,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=krb5,clientaddr=192.168.56.100,local_lock=none,addr=192.168.56.200)  
    • root has full read / write access
    • other users can read / write files if sufficient privileges are set up
    • nfsidmap is active, listing files on the client properly translates usernames / groups
    • chown from client is possible, and properly translates usernames / groups

    Files are created under the uid/gid of the client, which means they are created with the wrong uid / gid on the server

    It gets mapped to the wrong owner if the server happens to have a user with the same uid, otherwise the owner is nobody:4294967294

    The effective user seems to be user specified by the clients uid.

    I suppose this is a known drawback when using sec=sys

  • if the share is exported with sec=krb5

    server exportfs -v output

    /srv/export     <world>(rw,async,wdelay,no_root_squash,no_subtree_check,sec=krb5p:krb5,rw,secure,no_root_squash,no_all_squash)  

    client mount output

    arhiv.pecar:/srv/export on /mnt type nfs4 (rw,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.56.100,local_lock=none,addr=192.168.56.200)  
    • all users have read access, no user (including root) has write access on files / folders owned by them
    • creating files in o+w folders will create them under the anonymous user (nobody:nogroup or anonuid:anongid if specified in exports entry)
    • nfsidmap is active, listing files on the client properly translates usernames / groups
    • chown from client fails with Operation not permitted.

    The effective user seems to be the anonymous user.

I'm at a loss on what could be wrong here, so I'd appreciate the communities insight.

I can provide the relevant configuration files (/etc/hosts, /etc/krb5.conf, /etc/idmapd.conf, /etc/default/nfs-common, service, kernel module list) upon request.

How to set background of gtk app as desktop wallpaper using vala

Posted: 16 Jun 2021 11:33 AM PDT

How can I make a gtk application use the current desktop wallpaper as its background image using vala? Any help would be great

Matlab QT libraries prevent programs from running

Posted: 16 Jun 2021 11:23 AM PDT

I have matlab on my machine with Compiler toolbox. In order for compiler code to work, it needs access to libraries. They are supposed to be saved in LD_LIBRARY_PATH

So I adjusted my .bashrc to include:

MATLAB_LIB="/usr/local/MATLAB/MATLAB_Runtime/v95/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v95/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v95/extern/bin/glnxa64"  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MATLAB_LIB  

but now i cannot run many programs from the command line, e.g.:

~$ gnuplot  gnuplot: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Network.so.5: no version information available (required by gnuplot)  gnuplot: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Core.so.5: no version information available (required by gnuplot)  gnuplot: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Core.so.5: no version information available (required by gnuplot)  gnuplot: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Gui.so.5: no version information available (required by gnuplot)  gnuplot: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libtiff.so.5: no version information available (required by /lib/x86_64-linux-gnu/libgd.so.3)  gnuplot: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libtiff.so.5: no version information available (required by /lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0)  gnuplot: relocation error: gnuplot: symbol qt_version_tag version Qt_5.11 not defined in file libQt5Core.so.5 with link time reference  

or

~$ vim  vim: symbol lookup error: /lib/x86_64-linux-gnu/libpython3.7m.so.1.0: undefined symbol: XML_SetHashSalt  

or

~$ kate  kate: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Xml.so.5: no version information available (required by kate)  kate: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Core.so.5: no version information available (required by kate)  kate: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Core.so.5: no version information available (required by kate)  kate: /usr/local/MATLAB/MATLAB_Runtime/v95/bin/glnxa64/libQt5Widgets.so.5: no version information available (required by kate...  

If i remove the definition of the libraries from the .bashrc file, all works well. Is there something that i can do to avoid these problems other than remove the path to the libraries in the .bashrc file?

Audio input doesn't work, internal or external

Posted: 16 Jun 2021 11:04 AM PDT

I can't figure out why I can't make the audio input work on my HP Omen 15 ek0006nl. In settings/sound/input I only find Rear Microphone - Built-in Audio with the volume bar stuck at a fixed level, and if I try to record something or make a call I receive a white noise.

A similar thing happens if I use my Bluetooth headset (Sony WH-1000XM3): the related audio input device is recognized but the volume bar in the settings is stuck at zero and I get no feedback. The very same happens if I use an external USB sound card (UGREEN FBA_30143).

In all the previous cases, the output audio works perfectly, with speakers, Bluetooth, 3.5mm jack and external USB sound card.

Here's something that may be useful.

Output of aplay --list devices

card 0: PCH [HDA Intel PCH], device 0: ALC245 Analog [ALC245 Analog]    Subdevices: 0/1    Subdevice #0: subdevice #0  card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 1: NVidia [HDA NVidia], device 10: HDMI 4 [HDMI 4]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 1: NVidia [HDA NVidia], device 11: HDMI 5 [HDMI 5]    Subdevices: 1/1    Subdevice #0: subdevice #0  

Output of lspci | grep Audio

00:1f.3 Multimedia audio controller: Intel Corporation Comet Lake PCH cAVS  

Output of cat /proc/asound/cards

 0 [PCH            ]: HDA-Intel - HDA Intel PCH                        HDA Intel PCH at 0x4042210000 irq 179   1 [NVidia         ]: HDA-Intel - HDA NVidia                        HDA NVidia at 0x78080000 irq 17    

Output of alsamixer

I run Debian 10 bullseye 5.10.0-7-amd64 in dual boot with Windows 10, where the audio input works perfectly.

Using echo or printf to print out new line and carriage returns as \n and \r

Posted: 16 Jun 2021 12:03 PM PDT

I am using echo to debug my shell script and would like to know how to use echo to also print out the new line \n and/or carriage return \r characters as well in the form \n and \r in order to inspect strings. Is this possible?

How can I shrink/use a Logical Volume and use it as swap

Posted: 16 Jun 2021 11:01 AM PDT

How am I able to reduce /var/lib/vz logical volume (/dev/vg/data) and use it/increase the current swap size?

/etc/fstab

UUID=c4408a1c-aa5b-4ce2-a9e8-1673660331e9       /       ext4    defaults        0       1  LABEL=EFI_SYSPART       /boot/efi       vfat    defaults        0       1  UUID=c90b3083-1b43-427c-8016-1d2406c36417       /var/lib/vz     ext4    defaults        0       0  UUID=e585755c-9908-4c01-a89b-d7fb1880b8f8       swap    swap    defaults        0       0  UUID=aea8f278-23a8-4ce0-97ca-4354720ca602       swap    swap    defaults        0       0  

vgdisplay

  --- Volume group ---    VG Name               vg    System ID    Format                lvm2    Metadata Areas        1    Metadata Sequence No  3    VG Access             read/write    VG Status             resizable    MAX LV                0    Cur LV                1    Open LV               1    Max PV                0    Cur PV                1    Act PV                1    VG Size               386.97 GiB    PE Size               4.00 MiB    Total PE              99065    Alloc PE / Size       99065 / 386.97 GiB    Free  PE / Size       0 / 0    VG UUID               e2YzU3-HzQe-DIqH-HGNr-tFqc-cWO1-K92uOR  

lvdisplay | grep "LV Path|LV Size"

  LV Path                /dev/vg/data    LV Size                386.97 GiB  

What's the expected way to reconnect to shell instantiated tmux sessions that have timed out?

Posted: 16 Jun 2021 12:43 PM PDT

When using tmux sessions that are invoked as part of the shell instantiation, a new session will be created each time a user SSHes into a system. When detached (as in session timeout), the sessions persists; however, when connecting back in, a new session will still be created instead of attaching to the previous session. What's the expected way to reconnect to or manage previous sessions?

Background

In the RHEL 8 STIG, there is a finding that requires that "session control is automatically started at shell initialization". The way this is done in the STIG is by starting tmux at login. Additionally, there are other controls that cause a tmux session to lock after activity, and for ssh to disconnect after inactivity. On my STIGed system where I'm causally testing aside my main development system, I end up with a lot of idle timeouts, and therefore a lot of detached sessions.

Example of timed-out sessions

[user@system ~]$ tmux list-sessions  0: 1 windows (created Tue Jun 15 14:09:29 2021) [202x47]  1: 1 windows (created Tue Jun 15 14:32:53 2021) [202x47]  10: 1 windows (created Wed Jun 16 10:34:15 2021) [202x47]  11: 1 windows (created Wed Jun 16 10:50:04 2021) [202x47] (attached)  3: 1 windows (created Tue Jun 15 15:11:01 2021) [202x47]  4: 1 windows (created Tue Jun 15 16:47:34 2021) [202x47]  5: 1 windows (created Tue Jun 15 16:50:10 2021) [80x24]  6: 1 windows (created Tue Jun 15 18:22:36 2021) [202x47]  7: 1 windows (created Wed Jun 16 09:41:14 2021) [202x47]  8: 1 windows (created Wed Jun 16 09:52:56 2021) [202x47]  9: 1 windows (created Wed Jun 16 10:14:31 2021) [202x47]  

How I've been dealing with it

If I try to reconnect to one of those, I get a warning:

[user@system ~]$ tmux attach-session -t 0  sessions should be nested with care, unset $TMUX to force  

If I unset the value and attach the session again, now I have nested sessions, which greatly complicates things. In theory, i can finish up what I was working on within this nested session, but it seems like there should be a better way. What if before finishing up I detach again, then have to reconnect to the prior session, and now I'm three sessions deep?

Note: I am using this system for testing and familiarizing myself with an environment that has implemented the RHEL 8 STIG. Hopefully, on a production system, the users are more mindful of the environment and there is a reduced chance of session idle timeouts. I can disable the timeouts for my use case, but I am trying to stay to the letter of the STIG.

How do I find duplicate lines in multiple files within folders

Posted: 16 Jun 2021 10:44 AM PDT

when i want to find duplicate lines between two files i use this command

comm -12 <(sort file1.txt) <(sort file2.txt)  

or

sort file1.txt file2.txt | awk 'dup[$0]++ == 1'  

But, how do I find duplicate lines in multiple files within folders. example:

mainfolder    folder1      file1-1.txt      file1-2.txt      etc    folder2      file2-1.txt      file2-2.txt      etc  

and that the result in terminal is displayed by file (that is, the lines repeated in all files but specify which file is the one that contains it) to know the origin of the problem.

PD: I tried this command and it didn't work for me

file_expr="*.txt"; sort $file_expr | sed 's/^\s*//; s/\s*$//; /^\s*$/d' | uniq -d | while read dup_line; do grep -Hn "^\s*$dup_line\s*$" $file_expr; done| sort -t: -k3 -k1,2 | awk -F: '{ file=$1; line=$2; $1=$2=""; gsub(/(^[ \t]+)|([ \t]+$)/,"",$0); if (prev != "" && prev != $0) printf ("\n"); printf ("\033[0;33m%s (line %s)\033[0m: %s\n", file, line, $0); prev=$0; }'  

mesa-common-dev: unmet dependencies

Posted: 16 Jun 2021 09:51 AM PDT

I'm trying to install mesa-common-dev on Ubuntu LTS:

sudo apt-get install mesa-common-dev

however, the system returns:

    The following packages have unmet dependencies:         mesa-common-dev : Depends: libgl-dev but it is not going to be installed                         Depends: libglx-dev but it is not going to be installed                         Depends: libglx-dev but it is not going to be installed  E: Unable to correct problems, you have held broken packages.  

apt-cache policy mesa-common-dev

mesa-common-dev:    Installed: (none)    Candidate: 20.0.4-2ubuntu1    Version table:       20.0.4-2ubuntu1 500          500 http://br.archive.ubuntu.com/ubuntu focal/main amd64 Packages  

apt-cache policy libgl-dev

libgl-dev:    Installed: 1.3.2-1~ubuntu0.20.04.1    Candidate: 1.3.2-1~ubuntu0.20.04.1    Version table:   *** 1.3.2-1~ubuntu0.20.04.1 100          100 /var/lib/dpkg/status       1.3.1-1 500          500 http://br.archive.ubuntu.com/ubuntu focal/main amd64 Packages  

apt-cache policy libglx-dev

libglx-dev:    Installed: 1.3.2-1~ubuntu0.20.04.1    Candidate: 1.3.2-1~ubuntu0.20.04.1    Version table:   *** 1.3.2-1~ubuntu0.20.04.1 100          100 /var/lib/dpkg/status       1.3.1-1 500          500 http://br.archive.ubuntu.com/ubuntu focal/main amd64 Packages  

apt-cache policy libdrm-dev

libdrm-dev:    Installed: (nenhum)    Candidate: 2.4.101-2    Version table:       2.4.101-2 500          500 http://br.archive.ubuntu.com/ubuntu focal/main amd64 Packages  

Thank you so much



grep -Rn --include=*.list ^[^#] /etc/apt/

/etc/apt/sources.list:5:deb http://br.archive.ubuntu.com/ubuntu/ focal main restricted  /etc/apt/sources.list:15:deb http://br.archive.ubuntu.com/ubuntu/ focal universe  /etc/apt/sources.list:24:deb http://br.archive.ubuntu.com/ubuntu/ focal multiverse  /etc/apt/sources.list:42:deb http://security.ubuntu.com/ubuntu focal-security main restricted  /etc/apt/sources.list:44:deb http://security.ubuntu.com/ubuntu focal-security universe  /etc/apt/sources.list:46:deb http://security.ubuntu.com/ubuntu focal-security multiverse  /etc/apt/sources.list.d/google-chrome.list:3:deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main  /etc/apt/sources.list.d/opera-stable.list:4:deb https://deb.opera.com/opera-stable/ stable non-free #Opera Browser (final releases)  /etc/apt/sources.list.d/sublime-text.list:1:deb https://download.sublimetext.com/ apt/stable/  /etc/apt/sources.list.d/microsoft-edge-beta.list:3:deb [arch=amd64] http://packages.microsoft.com/repos/edge/ stable main  


SUCCESS!! I add:

deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse

in the source.list file.

thanks for helping me

Dual-booting Fedora already installed and Manjaro Linux

Posted: 16 Jun 2021 09:07 AM PDT

I use Fedora with GNOME... I wanted to dual-boot it with Manjaro KDE because I want to discover more, and because GNOME is pretty buggy...

What should I do? I'm a new Linux user so I don't understand everything...

How can I filter data from a large corpus using a shell script?

Posted: 16 Jun 2021 09:11 AM PDT

I am trying to extract tweets from a big twitter corpus, filtered on a specific location the tweet is tweeted. After that, I want to search in the tweets for a specific word. I have a command to list all tweets as a tsv file: $ zless location/of/tweets.out.gz | /net/corpora/twitter2/tools/tweet2tab -i user.location text

This gave me the following output, with a tab seperated: user.location tweet

Now, I want to only list for instance tweets from location: Amsterdam. And after this, search for the word: hallo in all the tweets from Amsterdam. What is the best way to approach this problem using a shell script?

How to perform a hot repair of a functioning, but limping rootfs with the switch_root command and a blank partition?

Posted: 16 Jun 2021 09:06 AM PDT

I have an extreme edge case that I may never see again, but I'd like to be prepared. I have an embedded system (u-boot) whose primary disk has 4 partitions. One of the partitions is the rootfs (ext4) and unfortunately it is rw. The ext4 does a great job of handling rough interactions, but I saw an issue with it for the first time today. The mount was still functional but systemd-fsck-root.service failed and indicated it required a CTRL-D to continue and told me to run fsck.

systemd-fsck[1130]: /dev/mmcblk1p4: Superblock last mount time is in the future.  systemd-fsck[1130]:         (by less than a day, probably due to the hardware clock being incorrectly set)  systemd-fsck[1130]: /dev/mmcblk1p4 contains a file system with errors, check forced.  systemd-fsck[1130]: /dev/mmcblk1p4: Inodes that were part of a corrupted orphan linked list found.  systemd-fsck[1130]: /dev/mmcblk1p4: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.  systemd-fsck[1130]:         (i.e., without -a or -p options)  systemd-fsck[1130]: fsck failed with error code 4.  systemd-fsck[1130]: Running request emergency.target/start/replace  

My kernel does not have initramfs or a backup partition. All I have is:

  • A mostly unused partition next to the rootfs one
  • the switch_root command

My goal is the following:

  1. Copy the basic files I need to run linux on a different partition ( I am assuming the loaded kernel modules will stay loaded?)
  2. Copy fsck and anything else I need to repair the rootfs to the empty partition
  3. Jump over to the other partition with switch_root
  4. Umount the primary rootfs and perform the fsck fix
  5. reboot and the bootloader should just poitn back to the fixed primary

The main things I don't know are:

  • Will this work?
  • What are the basic files I need for #1? Do I need to include loaded kernel modules or will those stay in the kernel?
  • What would a very simple init script look like to facilitate the switch_root jump?

Use linux version of a command instead of the BSD version

Posted: 16 Jun 2021 10:34 AM PDT

I have a utility bash script from an old laptop that I'm trying to use on my current laptop. It fails because it's passing unknown options to the column command. Running man column, I see that this machine is using the BSD version of the command; the script is written for the Linux version, which has more options.

I don't have access to the old machine, so I can't say much about what might have been done to set it up, except that it should be very similar to the new one. The current machine is running Pop!OS 20.04, newly installed in the last couple days.

Is there an obviously correct way to specify which of these similar commands I want to use?

How to changes colors for files that their group owner is `root`?

Posted: 16 Jun 2021 11:48 AM PDT

I have tried How to change the color of different files in ls's solution to apply color changes in ls. I have observed that they do not apply in folders that has a root group owner?

For example a .json file differs in color in a root folder and a user's home folder.

enter image description here


~/folder/ > ls -l  -rw-rw-r-- 1 alper alper alper 0 2021-06-16 06:35 hello.json    ~/mnt/ > ls -l  -rwxrwxrwx 1 alper root alper 0 2021-06-16 06:38 alper.json  

Related question: https://superuser.com/q/1598934/723632, which has a solution only for folders.

Linux file permission confusion

Posted: 16 Jun 2021 11:51 AM PDT

My home folder contains 2 users. 1 admin users and 1 guest.

I basically want a guest user not to be able to change the directory to a directory outside his own home folder when he logs in via SSH session.

The users look as following:

root@Ubuntu-2004-focal-64-minimal / # id olw  uid=1000(olw) gid=1002(olw) groups=1002(olw),1000(admins)  
root@Ubuntu-2004-focal-64-minimal / # id guest  uid=1002(guest) gid=1001(guest) groups=1001(guest)  

The home directory:

drwxr-xr-x 5 root root 4096 Jun 16 11:01 home/

From my understanding this means that others (not in root group) can read or enter(execute) this directory.

Inside this directory the file system looks as following:

drwxr-xr-x  5 root root   4096 Jun 16 11:01 ./  drwxr-xr-x 18 root root   4096 Jun 14 16:13 ../  drwxrwx---  2 root guest  4096 Jun 16 11:11 guest/  drwxr-x---  4 olw  admins 4096 Jun 15 16:12 olw/  

So now the guest is able to switch back to the home directory once he is inside his own home directory because /home is executable to others.

I chmod o-rx home/ and changed to group of the home folder to admins too. Otherwise nobody except root or people inside the root group could do anything with the root folder.

drwxr-x---  5 root admins   4096 Jun 16 11:01 ./  drwxr-xr-x 18 root root   4096 Jun 14 16:13 ../  drwxrwx---  2 root guest  4096 Jun 16 11:11 guest/  drwxr-x---  4 olw  admins 4096 Jun 15 16:12 olw/  

The odd thing now:

When I switch to my admin everything is working. I can go into my home folder, go outside; do everything but with the GUEST account I get a

oot@Ubuntu-2004-focal-64-minimal /home # su guest  bash: /home/guest/.bashrc: Permission denied  

I cannot even read the default .bashrc file or execute an ls command.

I even switched the permission for the guest homefolder to full access from everyone ending up with:

drwxr-x---  5 root admins 4096 Jun 16 11:01 ./  drwxr-xr-x 18 root root   4096 Jun 14 16:13 ../  drwxrwxrwx  2 root guest  4096 Jun 16 11:11 guest/  drwxr-x---  4 olw  admins 4096 Jun 15 16:12 olw/  

I still get the error. What am I doing wrong? I want the guest not to be able to leave his own home directory but I want him to see his own home directory and be able to execute commands there. Why is it working with the olw user?

The file system inside the users looks as following

guest

drwxrwxrwx 2 root  guest  4096 Jun 16 11:11 ./  drwxr-x--- 5 root  admins 4096 Jun 16 11:01 ../  -rw------- 1 guest guest    42 Jun 16 11:22 .bash_history  -rwxrwxrwx 1 root  guest   220 Jun 15 15:00 .bash_logout*  -rwxrwxrwx 1 root  guest  3771 Jun 15 15:00 .bashrc*  -rwxrwxrwx 1 root  guest     0 Jun 15 15:00 .cloud-locale-test.skip*  -rwxrwxrwx 1 root  guest   807 Jun 15 15:00 .profile*  -rwxrwxrwx 1 root  guest    20 Jun 15 15:14 WELCOME.txt*    

olw

drwxr-x--- 4 olw  admins 4096 Jun 15 16:12 ./  drwxr-x--- 5 root admins 4096 Jun 16 11:01 ../  -rwxr-x--- 1 olw  olw     960 Jun 16 11:35 .bash_history*  -rwxr-x--- 1 olw  olw     220 Jun 15 14:38 .bash_logout*  -rwxr-x--- 1 olw  olw    3771 Jun 15 14:38 .bashrc*  drwx------ 2 olw  olw    4096 Jun 15 15:54 .cache/  -rwxr-x--- 1 olw  olw       0 Jun 15 14:38 .cloud-locale-test.skip*  drwxrwx--x 3 olw  olw    4096 Jun 15 15:10 .local/  -rwxr-x--- 1 olw  olw     807 Jun 15 14:38 .profile*    

How would I Open an Internally hosted Webpage and Login without User Input on LINUX?

Posted: 16 Jun 2021 12:00 PM PDT

I'm trying to add to my current lines of Code if possible to Continue to Open my webpage in Kiosk on Chromium during startup, which I've managed with the code below, however I'm trying to make a Username and Password be entered automatically, and press the login button into the Webpage that follows. This is what I have so Far, Stored in /home/pi/kiosk.sh

#!bin/bash  xset s noblank  xset s off  xset -dpms    unclutter -idle 0 -root &    chromium-browser --noerrdiaglogs --disable-infobars --kiosk https://192.168.0.1/webconsole  

I then have another set of Code stored in SystemD that I've enabled so it Executes on Startup. located as: /lib/systemd/system/kiosk.service:

  [Unit]  Description=Chromium Kiosk  Wants=graphical.target  After=graphical.target    [Service]  Environment=DISPLAY=:0.0  Environment=XAUTHORITY=/home/pi/.Xauthority  Type=simple  ExecStart=/bin/bash /home/pi/kiosk.sh  Restart=on-abort  User=pi  Group=pi    [Install]  WantedBy=graphical.target  

This all works great, However my only issue is trying to add something to make my login details for this page open automatically. Any Advice? I tried looking into cURL but have no idea with it. And sometimes I'd get a SSL error, which I assume is because the Internal webpage won't have a security Certificate. Thanks for anyone's time who reads this.

Restart network on RHEL8/CentOs8 thru ssh using nmcli with testing that the operation has finished

Posted: 16 Jun 2021 09:21 AM PDT

Thru ssh I'm updating the network configuration and then I want to restart the network.

systemctl restart NetworkManager   

doesn't work very well with ipv6 static changes.

So I tried:

nmcli connection reload && nmcli networking off && nmcli networking on  

The above doesn't work as expected but using also -w to set a timeout works most of the time.

I'm looking for a more reliable option like do a sort of a test in the command and if is not ok, to retry the commands for a number of times.

Everything needs to be done in one step, because when network is going down, the ssh connection will be lost. A probe will check later with the new configuration.

Convert this regex to be friendly within sed

Posted: 16 Jun 2021 12:16 PM PDT

I am trying to perform this regex with sed, but seems like sed does not support? It says invalid character range

Trying to match any digits range with 12 to 19 regardless of whitespaces,-, or . characters

Seems like the issue is fixed when I moved the dash up in the character range to (?:\d[-\s.]*){12,19} but it does nothing afterwards... Does that mean this is not matching? But regexr test cases say otherwise

Example:

A0000000000000000D  1234 1234 1234 1234  VISA 1234123412341234 EXP 1222 CVV 123  

I am trying to perform this regex with perl

info=$(echo "$info" | perl -p -e 's/(?:\d[\s-.]*){12,19}/**********/g')    xmlstarlet ed --inplace -u "(//*[local-name()='SpecialRequest'])[$i]" -v "${info}" ${s3file}  

Trying to match any digits range with 12 to 19 regardless of whitespaces,-, or . characters

When I perform this on $info, and let's say info looks like this

<ns4:RequestOption>  <ns4:SpecialRequest>** LoyalMember #1234123412341234 **</ns4:SpecialRequest>  </ns4:RequestOption>  

For some odd reason, it sets SpecialRequest into a string with all of the names of the files on my current directory. Like an ls command. Let's say my ls outputs

bthai~->ls  awscli-bundle.zip        script.sh        item.csv        misc.gz  

Then the resulting info turns into

<ns4:RequestOption>  <ns4:SpecialRequest>* awscli-bundle.zip item.csv LoyalMember misc.gz script.sh #********** **</ns4:SpecialRequest>  </ns4:RequestOption>  

Even if I dont use wildcard to replace, but using letter x, somehow the * (wildcard with space within the xml value or in the replacment) causes the file names in directory to pop into the replace string...

<ns4:RequestOption>  <ns4:SpecialRequest>* awscli-bundle.zip item.csv LoyalMember misc.gz script.sh #xxxxxxxxxx **</ns4:SpecialRequest>  </ns4:RequestOption>  

Struggling with systemd and user permissions for backup script

Posted: 16 Jun 2021 09:52 AM PDT

I could use some help with figuring out the right way to accomplish what I need using systemd. I feel like I have backed myself in between a rock and a hard place and am not sure where to go. here is the condensed context:

I successfully setup a systemd user unit to run a backup script nightly that does a few things:

  1. it uses my user's ssh key to ssh into another machine
  2. it calls pass (i.e. my user's password store) to send a password to the remote machine for a command on the remote that requires sudo
  3. it rsyncs some data from the remote machine to a backup drive

All this works great. Now the issue is that I need to also rsync some data locally to my backup drive, but the data is owned by root. Rsync fails with permission denied unless I use sudo to run the script. But the problem is I can't figure out how to automate the use of sudo with a systemd user unit - calling pass doesn't seem to work.

I read somewhere else that I should just use a normal systemd unit that runs as root to accomplish what I need, but the problem there is that all the other things that were working when running as a user unit break when running as root, because root doesn't have access to my user's ssh key or pass store.

TLDR: What is the best way to setup a systemd unit that can: 1) execute commands that require access to my ssh key and pass store, 2) also rsync data that requires elevated permissions, and 3) do both of these things in an automated way where I don't need to be at the keyboard to type in my user's password?

How do I enable mounting filesystems in docker containers using apparmor

Posted: 16 Jun 2021 12:38 PM PDT

I have a ubuntu 20.04 server running docker. Recently the default apparmor profile seems to have started enforcing a restriction on mount points in docker containers. So the containers write directly to the root filesystem rather than the mount.

Outside of docker I can navigate the mounts with no issues but when executing a shell in containers it is as if the mount points are not mounted.

I have narrowed this down to being caused by apparmor and disabling apparmor allows mounting and everything works as I would expect. The containers seem to be using the docker-default profile.

My question is: how do I enable mounting in docker container either on a global basis or on individual containers. I would rather not have to completely disable apparmor for this issue?

Downloading large folder from Google Drive

Posted: 16 Jun 2021 11:53 AM PDT

I want to write a script to download this folder from Google Drive. The script is aimed for non-expert UNIX users so I don't want to use more than curl or wget.  I've seen solutions with the fileid, but I cannot manage to get the fileid in my case.

Is there anyone that managed to download folders from Google Drive?

Here are the solutions I tried:

Modify grub to dual boot fedora with windows 10

Posted: 16 Jun 2021 11:07 AM PDT

I am trying to dual boot fedora with windows 10. I am new to linux. I have found this code to be written in 40_custom file in grub.

menuentry "Windows 10" {   set root='(hd0,1)'   chainloader +1   }   

But this does not seem to work. It says cannot find disk. I have my windows in /dev/sda3 What should I write in 40_custom file so that i can use dual boot properly?

EDIT: My laptop had windows 10 pre installed when I had bought it. I have installed fedora 29 workstation. I do see the grub screen but the windows 10 option there(Created due to the above code) tells disk not found. Windows boot entry was not created automatically when I had installed fedora

How do I stop KWallet from asking my password to let the system connect to WiFi?

Posted: 16 Jun 2021 10:51 AM PDT

I've just switched to KDE and although I feel interested in exploring the opportunity to use KWallet for all kinds of cryptographic key/certificate files and some browser passwords perhaps if it can do that (I don't know yet), I absolutely don't want to enter my password every time I want to connect to WiFi. In fact I have to enter my password twice at the boot time now - to log-in and to get WiFi connected right after that and I find this is very annoying.

Is it possible to disable KWallet WiFi passwords management and let the network selection applet (or whatever it is) remember it itself or to configure KWallet to just stop requiring explicit authorization for things this simple?

Validate ~/.XCompose

Posted: 16 Jun 2021 11:11 AM PDT

I'm working on creating my own compose key sequences in ~/.XCompose. As I add more and more sequences, occasionally I make typos or use the same sequence for different symbols.

Examples:

Typo / Non-Existent Codes

<Multi_key> <non-existent-keysym> : other-non-existent-keysym  

Full Collision

<Multi_key> <a> <b> : x      # overrule by 2nd rule  <Multi_key> <a> <b> : y  

Prefix Collisions

<Multi_key> <a> <b> <c> : y   <Multi_key> <a> <b> : x      # overruled by 1st rule  

Question

Is there a command that validates my ~/.XCompose file. Minimum requirement is a binary answer: Either »your XCompose is error free« or »your XCompose contains errors«. In case there are errors, a helpful error message like »collision for rule sequence prefix « would be welcome.

What I Tried

I created ~/.XCompose containing all errors from above and opened a text editor. The text editor shows no errors (on the console). Correct and non-overruled sequences work, all other sequences are ignored.

I read man 5 XCompose. In the documentation itself I found nothing helpful. I looked at the references at the end of man 5 XCompose. Only mkcomposecache(1) looks promising (judging from the googled manpage), but seems to be missing on my system (Linux Mint 18.3). Neither man -k mkcomposecache nor apt search mkcomposecache find anything.

Edit: As @quixotic suggested, I compiled mkcomposecache from the sources and ran it, but its exits status is 1, no matter what compose file I choose (with or without errors). There is no error message. No cache is generated. Example of how I call the program:

$ mkcomposecache en_US.UTF-8 /usr/share/X11/locale/en_US.UTF-8/Compose /tmp/  * XOpenDisplay: Success  $ echo $?  1  

The file /usr/share/X11/locale/en_US.UTF-8/Compose is Ubuntu's original compose file and should be error free. I guess there is a reason why it is not packaged in the Ubuntu and Arch Linux repositories.

I doubt that mkcomposecache is what I need, even if it would work.

502 Bad Gateway

Posted: 16 Jun 2021 10:01 AM PDT

I ran the following iptables commands to start pptp server:

iptables -A INPUT -i venet0 -p tcp --dport 1723 -j ACCEPT  iptables -A INPUT -i venet0 -p gre -j ACCEPT  iptables -A FORWARD -i ppp0 -o venet0 -j ACCEPT  iptables -A FORWARD -i venet0 -o ppp0 -j ACCEPT  iptables -t nat -A POSTROUTING -j SNAT --to-source 33.122.21.177  

But it damaged the php-fpm service. Nginx returns an error "502 Bad Gateway". Nginx error log tells

failed (104: Connection reset by peer) while reading response header from upstream, client: 199.239.99.13, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000"  

php-fpm service is running normally

service php-fpm status  php-fpm (pid  14157) is running...  

Could you advise me how to solve this problem?

how to run "play start" as a linux service

Posted: 16 Jun 2021 09:05 AM PDT

I want deploy a play framework web application from source, and run "play start" to start the application.

I wrote a startup script in /etc/init.d/ which execute "daemon play start" when service start, but the service start command did not return. I guess it's because play start is waiting for me to give him a Ctrl+D. "nohup" can fix it, but with "nohup", I have to run "kill -9 xxx" to stop the application, which is not what I like.

What's the best way to run a play framework application from source as a linux startup service.

Thanks a lot.

Notify-send doesn't work at Cinnamon

Posted: 16 Jun 2021 11:42 AM PDT

I am using Linux Mint 17.
I want to be informed every 50 min, at every hour for small break.

Here is cron job:

nazar@desktop ~ $ crontab -l    DISPLAY=:0.0  XAUTHORITY=/home/matrix/.Xauthority    00 13 * * * /home/nazar/Documents/scripts/lunch_break_job.sh # JOB_ID_2  50 * * * * /home/nazar/Documents/scripts/pc_break.sh # JOB_ID_1  * * * * * /home/nazar/Documents/scripts/cron_job_test.sh # JOB_ID  

Here is script for /home/nazar/Documents/scripts/cron_job_test.sh:

#!/bin/bash    export DISPLAY=0.0  export XAUTHORITY=/home/matrix/.Xauthority    if [ -r "$HOME/.dbus/Xdbus" ]; then    . "$HOME/.dbus/Xdbus"  fi    /usr/bin/notify-send -i "hello"  

This snippet of function:

if [ -r "$HOME/.dbus/Xdbus" ]; then    . "$HOME/.dbus/Xdbus"  fi  

Checks DBUS_SESSION_BUS_ADDRESS and uses it.

According to this answer I executed script, and now my Dbus is saved to $HOME/.dbus/Xdbus:

nazar@desktop ~ $ cat $HOME/.dbus/Xdbus  DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-flm7sXd0I4,guid=df48c9c8d751d2785c5b31875661ebae  export DBUS_SESSION_BUS_ADDRESS  

All should work. I couldn't find what is missed. Because notification doesn't work now.

From terminal it works fine:

enter image description here

How to solve this issue?

SOLUTION:

Now my crontab looks as follows:

DISPLAY=":0.0"  XAUTHORITY="/home/nazar/.Xauthority"  XDG_RUNTIME_DIR="/run/user/1000"  00 13 * * * /home/nazar/Documents/scripts/lunch_break_job.sh # JOB_ID_2  50 * * * * /home/nazar/Documents/scripts/pc_break.sh # JOB_ID_1  # * * * * * /home/nazar/Documents/scripts/cron_job_test.sh # JOB_ID  

and cron_job_test.sh looks now:

#!/bin/bash    /usr/bin/notify-send -i /home/nazar/Pictures/icons/Mail.png "hello" "It is just cron test message"  

pc_break.sh:

#!/bin/bash    /usr/bin/notify-send -i /home/nazar/Pictures/icons/download_manager.png "Break:" "Make a break for 10 min"  

lunch_break_job.sh:

#!/bin/bash    /usr/bin/notify-send -i /home/nazar/Pictures/icons/Apple.png "Lunch: " "Please, take a lunch!"  

What's the easiest way to find an unused local port?

Posted: 16 Jun 2021 10:01 AM PDT

What's the easiest way to find an unused local port?

Currently I'm using something similar to this:

port=$RANDOM  quit=0    while [ "$quit" -ne 1 ]; do    netstat -a | grep $port >> /dev/null    if [ $? -gt 0 ]; then      quit=1    else      port=`expr $port + 1`    fi  done  

It feels awfully roundabout, so I'm wondering if there's a more simple path such as a builtin that I've missed.

Change font in echo command

Posted: 16 Jun 2021 12:36 PM PDT

Is it possible to change the font attributes of the output of echo in either zsh or bash?

What I would like is something akin to:

echo -n "This is the font: normal "  echo -n $font=italic "italic,"  echo -n $font=bold "bold,"  echo -n "and"  echo -n $font=small "small".  

so that it print: "This is the font: normal, italic, bold, small" within a line of text.

No comments:

Post a Comment