Thursday, July 8, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Failed to import EVE-NG.vmdk into vmware workstation

Posted: 08 Jul 2021 09:22 AM PDT

Aftter import this file ,appeared some waring signs

  1. failure writing secrtor 0xaa414 to 'hd0' vga=700 is deprecated. use set gfxpay .. before linux command instead.
  2. I/O error, dev sda,sector 690178 Buffer I/O error on dev sda1, logical block 344065, lost asymc page write

What is the failed policies and how should I fix it?

Take snapshot of top

Posted: 08 Jul 2021 09:25 AM PDT

I am trying to take a snapshot of top so that I can save it to a file. For example top -n 10 > top.txt. However top will of course continue to run, and I just want a snapshot. All the examples I can find for taking snapshots use the flag -b, but this doesn't seem to be supported on my version of top as I get invalid option or syntax: -b. I'm using MacOS big sur.

libvirt user access stopped working

Posted: 08 Jul 2021 09:00 AM PDT

I'm using virsh and virt-manager to manage some qemu/kvm VMs on an otherwise vanilla CentOS machine.

Our admins' user accounts are given the libvirt group. This had worked for a long time, but suddenly stopped. For some time now, access without root privileges has been broken. Running as user:

$ virsh -c qemu:///system list --all  error: failed to connect to the hypervisor  error: Fehler vom Service: CheckAuthorization: Failed to open file "/proc/2020139/status": No such file or directory  

I have checked the libvirtd.conf, which looks normal. I can see /var/run/libvirt populated as expected.

SELinux is enabled, but no entries in audit log and setenforce 0 did not change anything either.

Safest way to run a non-interactive script requiring sudo

Posted: 08 Jul 2021 09:02 AM PDT

I want to run a command that requires sudo, but non-interactively, so typing in a password isn't an option. In my specific case I want to create an automator/shortcut action on my phone to execute this script on my server via an ssh login.

In my case, I want to start a virtual machine with virsh start, which I know I can configure to allow a non-root user to start the machine, but I'm curious about this solution in general, especially in a case where a non-root option isn't available.

I'm also picturing that the unprivileged user only needs to be able to run a single script that I define, not an arbitrary command. In other words, the user simply needs to be able to trigger the script to run - they do not supply any arguments, and even if they found a way to do so the arguments would be ignored.

Also in my case the server is only used by me, and is behind a firewall. It has internet connectivity (In that it can download things), but cannot be accessed from the internet. I either have to be on my LAN or connected via VPN to reach it, and I only expect to use this script while specifically at home. Still - I'm concerned about learning "good practice" here.

The server itself is running Debian Testing. My concern is allowing passwordless sudo seems risky. Is there a better way to do this where a theoretically unprivileged account can trigger a privileged script or command to run? Should I just use a script running as root to monitor for some file to be created every minute or so and have the script just touch that file? Can I create a user who can only sudo that script?

Delete /tmp subvolume on btrfs partition scheme and make systemd-tmpfiles work with default tmpfs /tmp directory

Posted: 08 Jul 2021 08:28 AM PDT

I've made the mistake of mounting the /tmp directory as a btrfs subvolume. The problem is that systemd-tmpfiles won't clean it. How can I delete the /tmp subvolume and fix this? I'm new to filesystems, specially btrfs, and don't know much about how tmpfs and systemd(except for creating simple services) work.

Thanks in advance.

Does a file system snapshot includes deleted files

Posted: 08 Jul 2021 08:27 AM PDT

Let's say I create backups by file system snapshot once per day at midnight. Of course, after the snapshot is created, it will be archived to a separate drive.

If you create a lot of temporary files and delete them afterwards do these files increase the size of the daily snapshot?

Or is the snapshot only the delta between yesterday 00:00 and today 00:00?

pyarmor not working in kali

Posted: 08 Jul 2021 08:22 AM PDT

I am trying to compile a script with pyarmor but I keep getting the error

┌──(kali㉿kali)-[~/Desktop]  └─$ pyarmor-webui                                                                                       pyarmor-webui: command not found    

I installed it using

pip3 install pyarmor   

and trying to run the webui gives the same error

tried this but was not useful

python3 -m pyarmor-webui  

Got this

/usr/bin/python3: No module named pyarmor-webui    

Resize sidebar in document viewer (PDF file)

Posted: 08 Jul 2021 08:03 AM PDT

I an unable to find a way of resizing the document viewer sidebar while viewing PDF file on Ubuntu.

enter image description here

Is there a way?

Can I have multiple routes to the same remote LAN?

Posted: 08 Jul 2021 07:35 AM PDT

I am trying to connect two pfsense boxes with multiple OpenVPN tunnels. Currently, automatic route update makes only one route route active.

For example, I am connecting 192.168.33.0/24 and 192.168.33.0/24 LANs via 192.168.27.0/24 and 192.168.29.0/24 tuns and I have routes only via 27 network added.

What will happen if I add equivalent route via 29? Will it work out of the box? Will it load balance?

Virtually justifying text in Vim/neovim?

Posted: 08 Jul 2021 07:35 AM PDT

Is there a plugin or script to "virtually" justify text in Vim / Neovim? I mean, show the text on the screen as it if were justified but it is not justified on the actual file.

CONTEXT

Here is some context of what I was looking for:

I came accross this macro (see the "justify text" section) for justifying text https://neovim.io/doc/user/usr_25.html. (If you are using neovim, just run :packadd justify to add it)

Suppose we have the following text:

Quam tenetur est officiis velit. Aliquam autem esse exercitationem sit dolorum veniam. Deleniti molestias cumque praesentium ratione odio ea vero. Sed voluptatem iure aut officia est velit. Excepturi mollitia maiores in minima atque ratione.  

By pressing gqap in vim/neovim we get:

Quam tenetur est officiis velit. Aliquam autem esse exercitationem sit  dolorum veniam. Deleniti molestias cumque praesentium ratione odio ea vero. Sed  voluptatem iure aut officia est velit. Excepturi mollitia maiores in minima  atque ratione.  

By pressing vap_j using the plugin mentioned earlier, we get:

Quam  tenetur  est  officiis  velit.   Aliquam  autem  esse  exercitationem  sit  dolorum veniam. Deleniti molestias cumque praesentium ratione odio ea vero. Sed  voluptatem iure aut officia est velit.  Excepturi  mollitia  maiores  in  minima  atque ratione.  

The alignment above is even better than vim's gq. However, it adds extra whitespaces between words. So, what I'm looking for is a plugin/script to show text on the screen as if it were justified exactly like output of vap_j (kinda of the way some LaTeX plugins replace the math expressions with math symbols using conceallevel) but it is not justified in original file.

reading XML file and extract only node names and structure

Posted: 08 Jul 2021 08:55 AM PDT

I need to audit XML file structures and need to generate a report that shows only the DOM tree structure and omit the values. Essentially, I just the node names only and no values. I tried using xmllint and xmlstarlet but can't figure out how to do this.

Does anyone know of any tools or examples of above tools that do this?

cat $filename.xml | xmlstarlet format -t gives me what I need, but I want to omit all values.

vim to start edit right below the cursor

Posted: 08 Jul 2021 07:03 AM PDT

In the current behaviour of vim, at least on Ubuntu, it will clean the screen and make new edit window. I would like to just start right below the cursor, for example:

$vi test.txt
[start editing by press i]

Is it possible to achieve this with vim? If not then which terminal editor can do it?

Multiply numbers between two different patterns and print the whole file

Posted: 08 Jul 2021 07:59 AM PDT

I would like to replace number between patterns with multiplicated numbers and print the all the lines. The file is a tree file in newick format and consisted only a single line. My targets are all the numbers after ) and before :. I wanted to multiply all the numbers in between the two symbols with 100.

file:

((((A_8:0.000846,(A_5:0.002449,(A_1:1e-06,((A_4:1e-06,((A_7:1e-06,A_6:0.001061)0.714000:1e-06,A_3:1e-06)0.314500:1e-06)0.358667:1e-06,A_2:1e-06)0.361000:1e-06)0.434800:1e-06)0.683500:0.001619)0.888571:0.001931,A_9:0.00069)0.688471:0.000691,...  

The easiest way to me seemed to be splitting the file by replacing all the ":" symbols with a new line first. So all my target numbers are now in separate lines and appear after ). Then, I was using the awk script below to multiply the target numbers with 100, but didn't manage to keep the lines without my target number though.

script:

sed 's/:/\n/g' df9.tree | awk -F")" '{OFS=")"} $2=$2*100 {print $0}'  sed 's/:/\n/g' df9.tree | awk '$NF ~/)/ {$NF *=100}1'  

How can I multiply the numbers after ) and print the entire file in this case? Or is there other simpler way to directly look for the numbers lie between : and ), multiply them by 100 and print the whole file?

Update: Expected output

((((A_8:0.000846,(A_5:0.002449,(A_1:1e-06,((A_4:1e-06,((A_7:1e-06,A_6:0.001061)71.4000:1e-06,A_3:1e-06)31.4500:1e-06)35.8667:1e-06,A_2:1e-06)36.1000:1e-06)43.4800:1e-06)68.3500:0.001619)88.8571:0.001931,A_9:0.00069)68.8471:0.000691,...)  

Does Rsync use internet data to transfer files remotely?

Posted: 08 Jul 2021 08:22 AM PDT

I have learned to use rsync yesterday. I use it to push files to my Android device (Termux) and I even pull files from my Android device (Termux).

I use this command to push:

rsync -e 'ssh -p 8022' -vaP <source> <username>@<ipaddresss>:/sdcard/rsync   

And I use this command to pull:

rsync -e 'ssh -p 8022' -vaP <username>@<ipaddresss>:/sdcard/rsync/* /home/me/rsync/  

And I noticed that the transfer rate of files are more than 16000Kbps, which is way faster than my internet connection (which is slower than 250Kbps).

So, here's my question: doesn't rsync use internet data to transfer files remotely?

Note: Both my laptop and smartphone are connected to the same Wi-Fi network. :)

Solarized dark pdfs?

Posted: 08 Jul 2021 07:04 AM PDT

I'd like to know if there is a pdf reader with the option to select a colour scheme? Particularly solarized dark.

Keep matching pattern in shell parameter expansion

Posted: 08 Jul 2021 10:09 AM PDT

I can remove a pattern in a bash variable using ${variable##pattern} (leading) or ${variable%%pattern} (trailing).

But I can't find a bash-only way to keep the pattern and throw the rest.

I know there are solutions using sed, awk, or grep, but I want to know if there is a reasonably efficient bash-only solution that I am overlooking?

PS: This isn't just an idle question. The initial problem is that I want to process files where the name contains a pattern (technically, '[A-Z]+([A-Z])-[0-9][0-9]+([0-9])': capital letters followed by a dash and digits) and I want to use the same pattern to list the files and extract the matching string for further processing.

Edit: discussion of the brackets problem:

$nobrackets="ABC-123 something"  $printf "[%s]\n" "${nobrackets%%${nobrackets##$pattern}}"  [ABC-123]  $withbrackets="ABC-123 something with [brackets]"  $printf "[%s]\n" "${withbrackets%%${withbrackets##$pattern}}"  [ABC-123 something with [brackets]]  

How to use git credentials in systemd service

Posted: 08 Jul 2021 07:58 AM PDT

I'm using Github as the remote repository of my project and to save my time, I've executed the command git config --global credential.helper store to store the password in the file ~/.git-credentials.

So I can execute git pull without typing password.

Now I'm trying to create a service file git-clone.service as below, which executes a bash script named pull_basic_lib.sh containing the command cd ~/project && git pull:

[Install]  WantedBy=default.target    [Unit]  Description=git clone basic libraries    [Service]  Type=oneshot  ExecStart=/home/me/bin/pull_basic_lib.sh  

However, when I execute systemctl start git-clone.service, I get the error:

could not read Password for 'http://me@xxx.github.com': No such device or address  

Well, it doesn't seem that the file ~/.git-credentials can be imported into the service.

Is there any method to solve this problem?

How to solve failure in plugging external DVD driver in Ubuntu 20.04?

Posted: 08 Jul 2021 10:06 AM PDT

I have bought an external DVD driver but, after plugging (or booting with the unit already plugged) I see the unit listed in the resources of the computer but I cannot access it:

enter image description here

If I try to access the driver via VLC, I get the error VLC is unable to open the MRL 'cdda:///dev/sr0'.

The content of fstab is:

$ cat /etc/fstab  # /etc/fstab: static file system information.  #  # Use 'blkid' to print the universally unique identifier for a  # device; this may be used with UUID= as a more robust way to name devices  # that works even if disks are added and removed. See fstab(5).  #  # <file system> <mount point>   <type>  <options>       <dump>  <pass>  # / was on /dev/nvme0n1p2 during installation  UUID=341faa1b-4e49-49d7-85a4-e33acecb2212 /               ext4    errors=remount-ro 0       1  # /boot/efi was on /dev/nvme0n1p1 during installation  UUID=24D6-7429  /boot/efi       vfat    umask=0077      0       1  /swapfile                                 none            swap    sw              0       0  

What is the right way to plug a DVD in Ubuntu 20.04? Is it a problem with the driver (I need to buy another brand more Linux-prone)? Or do I need to change the permission of the driver with some sudo commands?

After I plug the DVD driver I get:

$ ls -lt | less | grep sr0  lrwxrwxrwx  1 root   root           3 May 27 21:15 cdrom -> sr0  lrwxrwxrwx  1 root   root           3 May 27 21:15 cdrw -> sr0  lrwxrwxrwx  1 root   root           3 May 27 21:15 dvd -> sr0  lrwxrwxrwx  1 root   root           3 May 27 21:15 dvdrw -> sr0  brw-rw----+ 1 root   cdrom    11,   0 May 27 21:15 sr0  

Thank you

Add new user without password but not disabled

Posted: 08 Jul 2021 09:11 AM PDT

I need to add new users who are only supposed to be usable through SSH. When adding a user, they get added to the shadow file with an exclamation mark (!) instead of an asterisk (*), so they are "disabled" and sshd does not allow them to be used.

Is there a way to add a user without a password that is enabled by default?

I have tried using busybox' adduser command and it adds them with a !. Similarly, Gentoo's default useradd command will add them with a !.

Manjaro MySQL - mariadb.service fails when trying to start

Posted: 08 Jul 2021 09:07 AM PDT

When trying to start MariaDB with systemctl status mariadb, I get:

● mariadb.service - MariaDB 10.3.15 database server     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)     Active: failed (Result: exit-code) since (date)       Docs: man:mysqld(8)             https://mariadb.com/kb/en/library/systemd/    Process: 2512 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)    Process: 2513 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)    Process: 2521 ExecStart=/usr/bin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)   Main PID: 2521 (code=exited, status=1/FAILURE)     Status: "Starting final batch to recover 13 pages from redo log"    [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded  [Note] Recovering after a crash using tc.log  [Note] Starting crash recovery...  [Note] Crash recovery finished.  [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist  [Note] Server socket created on IP: '::'.  [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist  mariadb.service: Main process exited, code=exited, status=1/FAILURE  mariadb.service: Failed with result 'exit-code'.  Failed to start MariaDB 10.3.15 database server.  

Through following so many various tutorials, I think I've also made it worse. I can't run mysql anymore (in the context of mysql < file.sql), since it says mysql: command not found.

I've tried removing, reinstalling mariadb and rebooting my computer in between; but I'm out of luck. Any ideas?

EDIT: A lot of other people seem to be having this problem, and while it's been >1 year and I don't recall what I did next, I do know that following the Arch Wiki page LINE BY LINE will guarantee a proper install. The formatting of the page made me read over things (important things were small, optional things were bold), but make sure you do that right and your installation should work.

relocation error using sudo apt

Posted: 08 Jul 2021 09:18 AM PDT

my system arch is amd64, i installed i386 as foreign arch and ran sudo apt dist-upgrade but after it finished, i keep getting this error while using apt:

apt-get: relocation error: /usr/lib/x86_64-linux-gnu/libapt-private.so.0.0: symbol ZN3URIcvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev version APTPKG_5.0 not defined in file libapt-pkg.so.5.0 with link time reference  

even when i use aptitude:

aptitude: relocation error: aptitude: symbol ZN3URIcvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev version APTPKG_5.0 not defined in file libapt-pkg.so.5.0 with link time reference  

any solution?

How do I check cgroup v2 is installed on my machine?

Posted: 08 Jul 2021 08:46 AM PDT

I want to try cgroup v2 but am not sure if it is installed on my linux machine

>> uname -r  4.14.66-041466-generic  

Since cgroup v2 is available in 4.12.0-rc5, I assume it should be available in the kernel version I am using.

https://www.infradead.org/~mchehab/kernel_docs/unsorted/cgroup-v2.html

However, it does not seem like my system has cgroup v2 as the memory interface files mentioned in its documentation are not available on my system.

https://www.kernel.org/doc/Documentation/cgroup-v2.txt

It seems like I still have cgroup v1.

/sys/fs/cgroup/memory# ls  cgroup.clone_children  memory.kmem.failcnt                 memory.kmem.tcp.usage_in_bytes   memory.memsw.usage_in_bytes      memory.swappiness  cgroup.event_control   memory.kmem.limit_in_bytes          memory.kmem.usage_in_bytes       memory.move_charge_at_immigrate  memory.usage_in_bytes  cgroup.procs           memory.kmem.max_usage_in_bytes      memory.limit_in_bytes            memory.numa_stat                 memory.use_hierarchy  cgroup.sane_behavior   memory.kmem.slabinfo                memory.max_usage_in_bytes        memory.oom_control               notify_on_release  docker                 memory.kmem.tcp.failcnt             memory.memsw.failcnt             memory.pressure_level            release_agent  memory.failcnt         memory.kmem.tcp.limit_in_bytes      memory.memsw.limit_in_bytes      memory.soft_limit_in_bytes       tasks  memory.force_empty     memory.kmem.tcp.max_usage_in_bytes  memory.memsw.max_usage_in_bytes  memory.stat   

Follow-up questions Thanks Brian for the help. Please let me know if I should be creating a new question but I think it might be helpful to other if I just ask my questions here.

1) I am unable to add cgroup controllers, following the command in the doc

>> echo "+cpu +memory -io" > cgroup.subtree_control  

However, I got "echo: write error: Invalid argument". Am I missing a prerequisite to this step?

2) I ran a docker container but the docker daemon log complained about not able to find "/sys/fs/cgroup/cpuset/docker/cpuset.cpus". It seems like docker is still expecting cgroupv1. What is the best way to enable cgroupv2 support on my docker daemon?

docker -v  Docker version 17.09.1-ce, build aedabb7  

Create backup image of running Ubuntu?

Posted: 08 Jul 2021 07:01 AM PDT

On Windows there is software like Acronis True Image that can create full backup images of a currently running system. Is there any alternative on Ubuntu for doing that?

Requirements:

  • still supported / maintained (e.g. not the case for systemback)
  • is able to make a consistent backup of a running system (e.g. live CDs like clonezilla are not what I am looking for)

Thanks for any hint on this!

Apache httpd does not load index.html when a web app is installed

Posted: 08 Jul 2021 10:04 AM PDT

In a CentOS 7 installation I installed OrangeScrum (which is a standard PHP application copied to /var/www/html). When I type the server IP I get the Apache test page and if I have an index.html page it will be displayed. And when I type the server-ip/orangescrum for example I get the web app. All this is fine.

Moving on to a server with Scientific Linux 7 I did the same, but when I install the app to the Apache and typing the server ip alone I get the app itself not the Apache status nor the index.html if any. Nothing has been done to httpd.conf except adding a virtual host definition like here

What am I missing to do in order to get the root index or the Apache test pages to work?

Why isn't my systemd service waiting for the network?

Posted: 08 Jul 2021 06:51 AM PDT

Per this question and its answers, I've added the following to my service file:

Wants=network-online.target  After=docker.service network.target network-online.target  

I've also run:

systemctl enable NetworkManager-wait-online.service  systemd-networkd-wait-online.service  

And yet my ExecStartPre task which uses git pull origin master still fails because of what appears to be a connectivity issue.

Mar 22 16:17:21 COMPUTER git[1983]: ssh: Could not resolve hostname github.com: Name or service not known  Mar 22 16:17:21 COMPUTER git[1983]: fatal: Could not read from remote repository.  

Am I missing something obvious? Is there another service I need to wait for in order to use git pull? (In case it's relevant, I'm using Ubuntu 16.10 and systemd 231.)

Interactive commands with pipe and grep

Posted: 08 Jul 2021 08:03 AM PDT

As you know, there are commands such as top, watch, Airodump-ng, etc, that whenever you run, everything on the terminal change all the time. what I want to do is that run one of theses interactive command and then use pipe in order to grep something I've been looking for. Take this for instance:

   airodump-ng wlan0 | grep "QQ:AF:00:55:8C:DF"  

In this example I'm looking for a MAC address, when this MAC turn up, it'll appear on screeen so that I can grep it.

the problem is that it doesn't work. I've searched a lot but I've found the answer in vain.

Running sh script: «Permission denied» despite the executable bit and root rights

Posted: 08 Jul 2021 07:59 AM PDT

I installed Debian in VirtualBox (for various experiments which usually broke my system) and tried to launch the VirtualBox guest addon script. I logged in as root and tried to launch autorun.sh, but I got «Permission denied». ls -l shows that the script have an executable rights.

Sorry, that I can't copy the output -- VirtualBox absolutely have no use without the addon, as neither a shared directory, nor a shared clipboard works. But just for you to be sure, I copied the rights by hands:

#ls -l ./autorun.sh  -r-xr-xr-x 1 root root 6966 Mar 26 13:56 ./autorun.sh  

At first I thought that it may be that the script executes something that gave the error. I tried to replace /bin/sh with something like #/pathtorealsh/sh -xv, but I got no output — it seems the script can't even be executed.

I have not even an idea what could cause it.

Is there a utility that interprets /proc/interrupts data over time?

Posted: 08 Jul 2021 07:29 AM PDT

Is there something out there? Like top is for ps

No comments:

Post a Comment