Saturday, May 22, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Connect with curl to FTPS server and download file

Posted: 22 May 2021 10:52 AM PDT

I'm able to connect to my FTPS server with TLS1.2 by curl, using --cert, --key and --cacert files. The command looks like:

curl -3 -k -v --ftp-ssl --tlsv1.2 --ftp-ssl-reqd --ftp-pasv --verbose \                                  --ssl                                 \                                  --cert ./cert.pem                     \                                  --cert-type PEM                       \                                  --key ./cert.key                      \                                  --key-type PEM                        \                                  --cacert ./cacert                     \                                  ftp://user:pass@10.10.100.1/file.txt  

I see the contents of file.txt appear in the output of the command but I don't actually see the file being saved anywhere. Am I missing another argument in my curl command? I have not been able to find it yet.

Prevent string splitting in argument to readlink [duplicate]

Posted: 22 May 2021 10:55 AM PDT

I am writing a small script to symbolically link configuration files from my dotfiles directory to another one. I do not have control over the file names and unfortunately one of them is causing me a lot of trouble. The simplest reproducible case I have is as follows:

export file_name='My Configuration Text.theme'    readlink -f $file_name  

Which predictably returns:

/home/me/folder/My  /home/me/folder/Configuration  /home/me/folder/Text.theme  

I need this to not be split. I have also tried

readlink -f $(printf "%q " $file_name)  

And it does not seem to fix the problem. Is there a solution to this or am I better off rewriting my linking script in something more robust like Python?

Wi-Fi in Ubuntu 21.04 is painfully slow

Posted: 22 May 2021 10:06 AM PDT

I had been using Ubuntu 21.04 for a while and now all of a sudden the wifi is really slow (download rate is not more than ~7000 B/s) My internet is pretty fast and gives around 50Mbps.

Few days back I got myself with a ransomware in windows. So I had to reset windows and then afterwards Ubuntu is behaving like this. I reinstalled Ubuntu 21.04 twice using a bootable stick. The safeboot in windows seems to block my wifi adapter so I disabled it, Then I had the issue rising again yesterday and today after searching a lot I'm helpless. I disabled the power management and stuff and there is no hope I can't even do an update.

Is there a solution?

How to recover from accidental chmod 777 on /etc/sudoers

Posted: 22 May 2021 09:42 AM PDT

I am having a problem with an install of retropie on a raspberry pi where I have accidentally locked out the sudo command.

I am about to just re-image my pi and start over unless someone can help me get out of this pickle. The problem is that I accidentally changed the permissions on /etc/sudoer to 777 and now ALL attempts to use sudo command at all fail with

sudo: /etc/sudoers is world writable sudo: no valid sudoers sources found. quitting sudo: unable to initialize policy plugin

I read elsewhere that you can fix this by using pkexec 775 /etc/sudoers but the problem there is that the root user on retropie is disabled by default and pkexec works exclusively as the root user. I have also not been able to find out what the password is for the root user on a retropie image as all queries for that lead to "you dont need to use root user, use pi user"

How to check if an input number is an integer and greater than zero

Posted: 22 May 2021 09:04 AM PDT

I'am new to the bash and I'm trying to check if an input is an integer and positive number. The whole code should randomly generate the specified number of student serial numbers. And check if the input is an integer and greater than 0. I think the problem is on line 8, but I'am not sure.

#!/bin/bash  number=$1  if [ $# -eq 1 ]  then      echo "enter the number of candidates: "      read quantity      echo "#"      if [[ "$number" =~ ^[0-9]+$ ]] && (( number > 0));          then      for (( c=1; c<=quantity; c++ ))      do             echo $((1 + $RANDOM % $number))       done       echo "#"      else      echo "The number is not an integer or less than 0"      fi    else    echo "incorrect number of arguments"  fi  

What am I doing wrong? Thank you

Problem with the mdadm Raid 5 array on Linux

Posted: 22 May 2021 08:55 AM PDT

I have a big problem here:

Until a week ago everything worked perfectly with my mdadm array. I then let it shut down for a week and only now started it up again. Shortly afterwards, I noticed a first problem: the LED was not lit on one of my 3 500GB hard drives. So far, not bad. Then I went in via SSH and then found out: my raid was broken.

    pi@raspberrypi:~ $ sudo mdadm --detail /dev/md0  /dev/md0:             Version : 1.2       Creation Time : Sat May  2 18:51:06 2020          Raid Level : raid5       Used Dev Size : 488251904 (465.63 GiB 499.97 GB)        Raid Devices : 3       Total Devices : 1         Persistence : Superblock is persistent           Update Time : Fri May 21 13:46:39 2021               State : active, FAILED, Not Started      Active Devices : 1     Working Devices : 1      Failed Devices : 0       Spare Devices : 0                Layout : left-symmetric          Chunk Size : 64K    Consistency Policy : unknown                  Name : raspberrypi:0  (local to host raspberrypi)                UUID : 23f436a0:c3f13920:01784b25:b4581c36              Events : 48112        Number   Major   Minor   RaidDevice State         -       0        0        0      removed         -       0        0        1      removed         -       0        0        2      removed           -       8       33        1      sync   /dev/sdc1  pi@raspberrypi:~ $ cat /proc/mdstat  Personalities : [raid6] [raid5] [raid4]  md0 : inactive sdc1[4]        488254584 blocks super 1.2    unused devices: <none>  pi@raspberrypi:~ $ lsblk  NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT  sda           8:0    0 465,8G  0 disk  └─sda1        8:1    0 465,8G  0 part  sdb           8:16   0 465,8G  0 disk  └─sdb1        8:17   0 465,8G  0 part  sdc           8:32   0 465,8G  0 disk  └─sdc1        8:33   0 465,8G  0 part  mmcblk0     179:0    0  14,9G  0 disk  ├─mmcblk0p1 179:1    0   256M  0 part /boot  └─mmcblk0p2 179:2    0  14,6G  0 part /  

This should not be like that. / dev / sda, / dev / sdb and / dev / sdc should be yours in the array. I thought about it and it looks like 2 hard drives have failed at the same time (in retrospect I think the LED is always off when there is no activity) and now the array cannot be rebuilt. If I reboot with only 2 hard drives, this is what comes out:

    pi@raspberrypi:~ $ sudo mdadm --detail /dev/md0  /dev/md0:             Version : 1.2          Raid Level : raid0       Total Devices : 2         Persistence : Superblock is persistent                 State : inactive     Working Devices : 2                  Name : raspberrypi:0  (local to host raspberrypi)                UUID : 23f436a0:c3f13920:01784b25:b4581c36              Events : 48112        Number   Major   Minor   RaidDevice           -       8       17        -        /dev/sdb1         -       8        1        -        /dev/sda1  pi@raspberrypi:~ $ cat /proc/mdstat  Personalities :  md0 : inactive sdb1[4](S) sda1[0](S)        976509169 blocks super 1.2    unused devices: <none>  pi@raspberrypi:~ $ lsblk  NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT  sda           8:0    0 465,8G  0 disk  └─sda1        8:1    0 465,8G  0 part  sdb           8:16   0 465,8G  0 disk  └─sdb1        8:17   0 465,8G  0 part  mmcblk0     179:0    0  14,9G  0 disk  ├─mmcblk0p1 179:1    0   256M  0 part /boot  └─mmcblk0p2 179:2    0  14,6G  0 part /  

I rebooted the Pi and now this is coming out and I'm even more confused (it should be a Raid 5 array)

pi@raspberrypi:~ $ lsblk  NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT  sda           8:0    0 465,8G  0 disk  └─sda1        8:1    0 465,8G  0 part  sdb           8:16   0 465,8G  0 disk  └─sdb1        8:17   0 465,8G  0 part  sdc           8:32   0 465,8G  0 disk  └─sdc1        8:33   0 465,8G  0 part  mmcblk0     179:0    0  14,9G  0 disk  ├─mmcblk0p1 179:1    0   256M  0 part /boot  └─mmcblk0p2 179:2    0  14,6G  0 part /  pi@raspberrypi:~ $ cat /proc/mdstat  Personalities :  md0 : inactive sda1[0](S) sdc1[4](S) sdb1[3](S)        1464762761 blocks super 1.2    unused devices: <none>  pi@raspberrypi:~ $ sudo mdadm --detail /dev/md0  /dev/md0:             Version : 1.2          Raid Level : raid0       Total Devices : 3         Persistence : Superblock is persistent                 State : inactive     Working Devices : 3                  Name : raspberrypi:0  (local to host raspberrypi)                UUID : 23f436a0:c3f13920:01784b25:b4581c36              Events : 48112        Number   Major   Minor   RaidDevice           -       8       33        -        /dev/sdc1         -       8       17        -        /dev/sdb1         -       8        1        -        /dev/sda1  

I hope that someone will know how to get the array back together, since the data on all hard drives should still be there.

I do have a backup, but some data on the Raid isn't present on my backup.

Kind regards, Elytronn

Is it possible to parse a command's arguments automatically?

Posted: 22 May 2021 10:53 AM PDT

I would like to modify the git-clone command such it use a local cache, by creating a wrapper that does the following:

  1. If a repository doesn't exist in the cache, clone it.
  2. Copy it to the desired location.

But how do I parse the git-clone's command-line arguments to get the value of repository? It seems trivial; but I can't find a general solution to this problem. Is this so because command-line arguments don't have a standard structure (some could be a switch, some could follow with a value etc.)? In git's case <repository> can be followed by an optional <directory> argument, so I can't reliably go by the last argument.

Is there a way to do atleast specify the grammar specified in docs so that, I can get the repository argument automatically? Should I tools like getopts?

PS: I use multiple tools (Jenkins, Buildout etc.) that downloads git repositories automatically -- using the git command; so I thought a wrapper would be most generic solution to this problem.

There are some git specific solutions worth checking like local git server, URL rewrites etc.

Is it possible to install Visual Studio Code on Debian 10 buster 32-bit machine?

Posted: 22 May 2021 08:36 AM PDT

Is there any way to install Visual Studio Code on a Debian 10 32-bit machine?

How to change usb drive's "Disk model", as shown in fdisk -l?

Posted: 22 May 2021 09:49 AM PDT

Info

I have two USB flash drives. Both are "SanDisk Cruzer Blade"s. One is 8GB, the other is 64GB.

fdisk -l (8GB):

Disk /dev/sdd: 7.45 GiB, 8004304896 bytes, 15633408 sectors  Disk model: Cruzer Blade      Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disklabel type: dos  Disk identifier: 0xcf0c9ad9  

fdisk -l (64GB):

Disk /dev/sdc: 57.33 GiB, 61555605504 bytes, 120225792 sectors  Disk model: Cruzer Blade      Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disklabel type: gpt  Disk identifier: 3E29E0CB-68C6-3B47-9861-B92FC65CA0D6  

Problem

The "Disk model" values of both are "Cruzer Blade". Both have this name in my motherboard's boot menu, so I can't distinguish between the two when choosing a disk to boot from.

Questions

  • Can "Disk model" be changed?
  • If so, how?

I'd like to name 8GB "sandisk-8gb-1" and 64GB "sandisk-64gb-1".

My research

  • Every thread I find shows either how to change the partitions' or the filesystems' labels.

I can't find anything that shows how to change the disk model.

Headphone audio not working on Fedora 34

Posted: 22 May 2021 07:51 AM PDT

It seems that my headphone does not output any sound even though it is recognized as a valid device. I have tried installing alsamixer and it is enlisted as one of the "Items", yet even toggeling it in pavucontrol does not help. When I disconnect the jack the audio comes out of the speaker just fine and using the headphone on windows seems to be working (no hardware problem).

I'm wondering if there's a bug in the new version of fedora or is there a potential fix?

Why is there an issue with executing gedit? [closed]

Posted: 22 May 2021 08:34 AM PDT

I just started learning pen-testing. One of course topics included learning python3. I am using gedit on kali linux but when executing gedit FileName.py I get (gedit:22371): Gtk-WARNING **: 10:15:28.362: Calling org.xfce.Session.Manager.Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method "Inhibit" . After which the only way to get out of this is "control + Z" which suspends gedit FileName.py and i cannot edit the file anymore. I will have to close it and reopen it via gedit FileName.py every-time which is time consuming.

Why am I getting this error, and how do I resolve it?

Why my linux machine is running slow?

Posted: 22 May 2021 07:43 AM PDT

Hello I am using Lubuntu 20.04

abhishek@abhishek:~$ neofetch              .-/+oossssoo+/-.               abhishek@abhishek           `:+ssssssssssssssssss+:`           -----------------         -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.2 LTS x86_64       .ossssssssssssssssssdMMMNysssso.       Kernel: 5.4.0-72-generic      /ssssssssssshdmmNNmmyNMMMMhssssss/      Uptime: 44 mins     +ssssssssshmydMMMMMMMNddddyssssssss+     Packages: 2250 (dpkg)    /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Shell: bash 5.0.17   .ssssssssdMMMNhsssssssssshNMMMdssssssss.   Resolution: 1280x1024   +sssshhhyNMMNyssssssssssssyNMMMysssssss+   DE: LXQt   ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Openbox   ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM Theme: Lubuntu Arc   +sssshhhyNMMNyssssssssssssyNMMMysssssss+   Theme: Arc-Darker [GTK2/3]   .ssssssssdMMMNhsssssssssshNMMMdssssssss.   Icons: ePapirus [GTK2/3]    /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Terminal: qterminal     +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal Font: Ubuntu Mono 14      /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: Intel Core 2 Duo E7200 (2) @ 2.526GHz       .ossssssssssssssssssdMMMNysssso.       GPU: Intel 82945G/GZ         -+sssssssssssssssssyyyssss+-         Memory: 2045MiB / 2983MiB           `:+ssssssssssssssssss+:`              .-/+oossssoo+/-.                                                                                                                  abhishek@abhishek:~$   

My machine nowadays lags to such an extent, that it seems unusable. For example, previously, when I had freshly installed my Lubuntu 20.04 around 1.5 years (or before that, I used an older version of Lubuntu: 18.10), there were no such freezing or late response issues.

But lately, I am experiencing great trouble. Switching from one tab to another in firefox takes 2-3 minutes sometimes, and that time, the HDD makes a peculiar mouse-like squeaking sound.

I have a ram of 3 GB and a swap space of 4 GB. Why has the performance of my system degraded? How to rectify it?

iotop

iotop output

Running a sambashare with user configuration

Posted: 22 May 2021 07:31 AM PDT

I've been trying to achieve this:

  1. Use samba config file under .config/smb.conf

and

  1. a service config file under .config/systemd/user/smbd.service

and

  1. run systemctl --user start smbd.service

Yet the status fails, and all I get either from systemctl --user status smbd.service or journalctl --user --e is:

May 22 15:26:48 localhost.localdomain smbd[19674]: [2021/05/22 15:26:48.756294,  0] ../../lib/util/debug.c:1098(reopen_one_log)  May 22 15:26:48 localhost.localdomain smbd[19674]:   reopen_one_log: Unable to open new log file '/var/log/samba/log.smbd': Permission denied  May 22 15:26:48 localhost.localdomain smbd[19674]: [2021/05/22 15:26:48.756339,  0] ../../source3/smbd/server.c:1775(main)  May 22 15:26:48 localhost.localdomain smbd[19674]:   smbd version 4.11.6-Ubuntu started.  May 22 15:26:48 localhost.localdomain smbd[19674]:   Copyright Andrew Tridgell and the Samba Team 1992-2019  May 22 15:26:48 localhost.localdomain systemd[1582]: smbd.service: Main process exited, code=exited, status=1/FAILURE  May 22 15:26:48 localhost.localdomain systemd[1582]: smbd.service: Failed with result 'exit-code'.  May 22 15:26:48 localhost.localdomain systemd[1582]: smbd.service: Scheduled restart job, restart counter is at 5.  May 22 15:26:48 localhost.localdomain systemd[1582]: Stopped Samba SMB Daemon.  May 22 15:26:48 localhost.localdomain systemd[1582]: smbd.service: Start request repeated too quickly.  May 22 15:26:48 localhost.localdomain systemd[1582]: smbd.service: Failed with result 'exit-code'.  May 22 15:26:48 localhost.localdomain systemd[1582]: Failed to start Samba SMB Daemon.  

I'm aware of this line May 22 15:26:48 localhost.localdomain smbd[19674]: reopen_one_log: Unable to open new log file '/var/log/samba/log.smbd': Permission denied but I've no idea where it's coming from as the samba config file clearly indicates $HOME/logs/samba/log.%m.

For completeness I paste the config file:

[global]       workgroup = sm     client min protocol = NT1     server string = %h server (Samba, Ubuntu)    #### Debugging/Accounting ####    # This tells Samba to use a separate log file for each machine  # that connects     log file = $HOME/logs/samba/log.%m     max log size = 1000     logging = file    # Do something sensible when Samba crashes: mail the admin a backtrace     panic action = /usr/share/samba/panic-action %d    ####### Authentication #######       server role = standalone server     obey pam restrictions = yes     unix password sync = yes     passwd program = /usr/bin/passwd %u     passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .     pam password change = yes     map to guest = bad user     usershare allow guests = yes      [sambashare]      comment = Samba on Ubuntu      path = /home/sm/samba      read only = no      browsable = yes      directory mask = 0755  

If necessary I can add the user config file for the service unit. Any idea?

How to create a mkfs.ext4 file system on an SD card that can be written to by anyone?

Posted: 22 May 2021 07:39 AM PDT

I'm using up to date Arch Linux 5.12.5.

SD cards from time to time become corrupted, and if not bricked have to be reset/ reformatted.

I do this as follows

# 1. unmount the card / make sure it's unmounted  umount /dev/mmcblk0  umount /dev/mmcblk0p1    # 2. wipe the card. After this the card cannot be mounted becasue   #      there is no partition. There's nothing on it at all.  echo password | sudo -S dd bs=4M if=/dev/zero of=/dev/mmcblk0 oflag=sync    # 3. create a GPT partition table  #   the "-s" defaults the go ahead answer to "yes" so that   #      no user input is necessary rather confusingly the  #         command is 'mklabel' for creating a partition table!  sudo parted -s /dev/mmcblk0 mklabel gpt    # 4. create a GPT file system  #   HAVING THE "-E root_owner=$UID:$GID" IS ESSENTIAL,  #      OTHERWISE THE PARTITION CAN ONLY BE WRITTEN TO AS ROOT  sudo mkfs.ext4 -F -O ^64bit -E root_owner=$UID:$GID -L 'SD_CARD' '/dev/mmcblk0'  

If I use the below line, ie miss out setting the UID:GID to me as above, then ownership of the file system is for root only and the SD card cannot be written to by anyone other than root

sudo mkfs.ext4 -F -O ^64bit -L 'SD_CARD' '/dev/mmcblk0  

When I use the below line, which sets the UID:GID to my UID:GID, then ownership of the file system is for me only and the SD card cannot be written to by anyone other than me

sudo mkfs.ext4 -F -O ^64bit -E root_owner=$UID:$GID -L 'SD_CARD' '/dev/mmcblk0'  

How do I set the UID:GID so that the SD card file system can be written to by anyone?

ntpd does not properly update drift by itself

Posted: 22 May 2021 10:09 AM PDT

I am using ntpsec of Debian unstable. In my log I saw the following:

Mai 22 11:48:34 services ntpd[13428]: CLOCK: time stepped by 1.442261  Mai 22 11:55:06 services ntpd[13428]: CLOCK: time stepped by 1.524066  Mai 22 12:03:00 services ntpd[13428]: CLOCK: time stepped by 1.702944  Mai 22 12:08:34 services ntpd[13428]: CLOCK: time stepped by 1.517894  Mai 22 12:17:38 services ntpd[13428]: CLOCK: time stepped by 1.434055  Mai 22 12:24:07 services ntpd[13428]: CLOCK: time stepped by 1.084220  Mai 22 12:32:29 services ntpd[13428]: CLOCK: time stepped by 1.562280  Mai 22 12:38:38 services ntpd[13428]: CLOCK: time stepped by 1.211420  Mai 22 12:43:49 services ntpd[13428]: CLOCK: time stepped by 1.185642  Mai 22 12:48:58 services ntpd[13428]: CLOCK: time stepped by 0.796154  Mai 22 12:54:43 services ntpd[13428]: CLOCK: time stepped by 1.331323  Mai 22 13:00:21 services ntpd[13428]: CLOCK: time stepped by 0.849190  

And this is not just today, it goes on like that for days. So apparently, ntpd does not properly fix the system clock drift. In /var/lib/ntpsec/ntp.drift there is always:

500.000000  

What I have tried now:

  • disabled CONFIG_RTC_SYSTOHC, so the kernel doesn't automatically update the RTC. A few hours later, I ran hwclock -w --update-drift to get at least a better accuracy when reading the RTC. It set the drift factor to 0.78 seconds/day.
  • after that, I ran adjtimexconfig to fix the system clock (something that ntpd should have done). It said:
    Comparing clocks (this will take 70 sec)...done.  Adjusting system time by 275,531 sec/day to agree with CMOS clock...done.  

The result seems to be that ntpd has to step the time a lot less now:

Mai 22 14:24:20 services ntpd[13428]: CLOCK: time stepped by 0.234963  Mai 22 14:30:30 services ntpd[13428]: CLOCK: time stepped by 0.145163  

Good. But why doesn't ntpd do that by itself? 0.2sec/6min still seems way too inexact, so I guess I'll have to repeat that process a few more times. Any suggestions?

Pipe skip 99 lines out of every 100

Posted: 22 May 2021 09:42 AM PDT

I have a bash commands pipeline that produces a ton of logging text output. But mostly it repeats the previous line except for the timestamp and some minor flags, the main output data changes only once in a few hours. I need to store this output as a text file for future handling/research. What should I pipe it to in order to print only 1st line out of every X?

Ruby installation in Manjaro (Arch-Based Linux)

Posted: 22 May 2021 08:13 AM PDT

I was reading the documentation. In Debian based Linux, I have to install build-essential, libssl-dev. But, what about Arch-Based Linux? I had tried

sudo pacman -Syy build-essential libssl-dev  

But, unfortunately those packages aren't available. I had tried with yay command also. But, I couldn't install them using yay also. I had installed base-devel also. I was reading the question also. But, don't need them. PHP works by Lampp/Xampp. But, Ruby needs build-essential && libssl-dev. While they aren't available in Manjaro than, how Ruby programmer works in Manjaro? So, there must be similar package like this.

  • I am using Rubymine
  • Ruby version : ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
  • gem version : 3.2.15

I had installed openssl while Google is saying build-essential is base-devel and, libssl-dev is openssl.

sudo pacman -Sy openssl  

Then, I had run following commands

gem install rails  ruby -v  gem -v   rake -v  bundle install  

When I tried bundle install I got an error Could not locate Gemfile.

  • Bundler version : Bundler version 2.2.15

But, when I installed bundler using the command gem install bundler I got following error

WARNING: You don't have /home/istiak/.local/share/gem/ruby/3.0.0/bin in your PATH,
gem executables will not run.
Successfully installed bundler-2.2.17
1 gem installed

When I check rails version I get there's no rails package. And, I had installed rails successfully.

gem install rails

WARNING: You don't have /home/istiak/.local/share/gem/ruby/3.0.0/bin in your PATH,
gem executables will not run.
Successfully installed rails-6.1.3.2
1 gem installed

When I try to compile the file in Rubymine than, I get Run Configuration Error: No Gemfile found.

I am adding error in short below :

  1. I don't have rails after installation also
  2. No Gemfile found error while compiling ruby file from Rubymine
  3. Could not locate Gemfile while executing bundle install

How to schedule a cron for 1st 2nd and 3rd week and on specific day of week?

Posted: 22 May 2021 07:23 AM PDT

I am trying to schedule a cron, where if a month has 5 weeks and 5 wednesdays, script A.sh should run on 1st week wednesday 2nd week Wednesday, 3rd week wednesday and 4th week wednesday, where as on 5th Week Wednesday it should run b.sh.

Else

I am trying to schedule a cron, where if a month has 4 weeks and 4 wednesdays, script A.sh should run on 1st week wednesday 2nd week Wednesday, 3rd week wednesday, where as on 4th Week Wednesday it should run b.sh.

Extracting substrings from command output

Posted: 22 May 2021 09:39 AM PDT

How can i extract only the kim, tin, and tintu substrings from the command output below. The substrings can't be had by simply splitting on -. The xxx bits are strings which are specific operator, so I hashed them out.

> kubectl get pods  xxxxxxxxxxxxxxx-x-ram-kdm-xxxxx-ramkim-6b4c49f589-6hqcj         xxxxxxxxxxxxxxx-x-ram-kdm-xxxxx-ramtin-8d49b4dc7-bmvck          xxxxxxxxxxxxxxx-x-ram-kdm-xxxxx-ramtintu-69b8c5b689-64fxw   

Sorry I could not add much info due to customer restriction . I will describe the nature of the output. ram is the fixed name with concatenated with a string that need to be extracted. no of - are not fixed in each output line and no of letters are also not fixed. in this example ram appeared as -ram- . I need to extract only string that is concatenated with ram+'extract-string' no matter where ever it is appeared but surly it appears only once.

Why Is OpenVPN Losing Connection Through CentOS 7 With OVH?

Posted: 22 May 2021 08:26 AM PDT

A few seconds after connecting to my VPN through CentOS 7 on my virtual machine, I lose connection with no errors in the log. This only appears to be happening with CentOS 7/8. OVH documentation (https://docs.ovh.com/gb/en/dedicated/network-bridging/) covers adding either

51.195.234.254 - 255.255.255.255 eth0  51.195.234.0 - 255.255.255.0 eth0  default 51.195.234.254  

or

51.195.234.254 dev eth0  default via 51.195.234.254  

to /etc/sysconfig/network-scripts/route-eth0 however this does not help.

Debian 10 (working):

ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00      inet 127.0.0.1/8 scope host lo         valid_lft forever preferred_lft forever      inet6 ::1/128 scope host          valid_lft forever preferred_lft forever  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000      link/ether 02:00:00:ff:3b:ea brd ff:ff:ff:ff:ff:ff      inet 145.239.xxx.xxx/32 brd 145.239.xxx.xxx scope global eth0         valid_lft forever preferred_lft forever      inet6 fe80::ff:feff:3bea/64 scope link          valid_lft forever preferred_lft forever  

ip r

default via 51.195.234.254 dev eth0   51.195.234.254 dev eth0 scope link  

After connecting to VPN: ip r

0.0.0.0/1 via 10.8.0.9 dev tun0  default via 51.195.234.254 dev eth0  10.8.0.0/24 via 10.8.0.9 dev tun0  10.8.0.9 dev tun0 proto kernel scope link src 10.8.0.10  VPNIP via 51.195.234.254 dev eth0  51.195.234.254 dev eth0 scope link  128.0.0.0/1 via 10.8.0.9 dev tun0  

CentOS 7:

ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00      inet 127.0.0.1/8 scope host lo         valid_lft forever preferred_lft forever      inet6 ::1/128 scope host          valid_lft forever preferred_lft forever  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000      link/ether 02:00:00:ff:3b:ea brd ff:ff:ff:ff:ff:ff      inet 145.239.xxx.xxx/32 brd 145.239.xxx.xxx scope global dynamic eth0         valid_lft 21599969sec preferred_lft 21599969sec      inet6 fe80::ff:feff:3bea/64 scope link          valid_lft forever preferred_lft forever  

ip r

default via 51.195.234.254 dev eth0   51.195.234.254 dev eth0 scope link  

After connecting to VPN: ip r

0.0.0.0/1 via 10.8.0.9 dev tun0   default via 51.195.234.254 dev eth0   10.8.0.0/24 via 10.8.0.9 dev tun0   10.8.0.9 dev tun0 proto kernel scope link src 10.8.0.10   VPNIP via 51.195.234.254 dev eth0   51.195.234.254 dev eth0 scope link   128.0.0.0/1 via 10.8.0.9 dev tun0  

I have also tried adding the gateway of the VPN

ip route add 5.45.126.254 dev eth0  

ip r

0.0.0.0/1 via 10.8.0.17 dev tun0   default via 51.195.234.254 dev eth0   5.45.126.254 dev eth0 scope link   10.8.0.0/24 via 10.8.0.17 dev tun0   10.8.0.17 dev tun0 proto kernel scope link src 10.8.0.18   VPNIP via 51.195.234.254 dev eth0   51.195.234.254 dev eth0 scope link   128.0.0.0/1 via 10.8.0.17 dev tun0  

Could I have to maybe modify VPNIP via 51.195.234.254 dev eth0 so that it's routed through VPNIP via 5.45.126.254 dev eth0 ? if so how can I achieve that.

Providing input for multiple read(stdin) calls via bash input redirection

Posted: 22 May 2021 10:30 AM PDT

Suppose we have the following program, which calls read() twice:

#include <stdio.h>  #include <unistd.h>    #define SIZE 0x100    int main(void)  {      char buffer1[SIZE];      char buffer2[SIZE];        printf("Enter first input: \n");      fflush(stdout);      read(STDIN_FILENO, buffer1, SIZE);        printf("Enter second input: \n");      fflush(stdout);      read(STDIN_FILENO, buffer2, SIZE);        printf("\nFirst input:\n%s", buffer1);      printf("\nSecond input:\n%s", buffer2);        return 0;  }  

When we call it directly, we can enter 1 for the first input and 2 for the second input in order to have it print:

First input:  1    Second input:  2  

How can this be achieved when using input redirection?

The following methods don't work, since the first read consumes both inputs:

Pipe redirection:

$ { echo "1"; echo "2"; } | ./main_read  Enter first input:  Enter second input:    First input:  1  2    Second input:    

Heredoc redirection:

$ ./main_read << EOF  1  2  EOF  Enter first input:  Enter second input:    First input:  1  2    Second input:    

The assumption is that the source code cannot be changed, and that the input must sometimes be shorter than SIZE.

Is there any way to signal the first read() to stop reading, in order for the second read() to consume the rest of the input?

User within a group cannot chmod on local disk mounted as NTFS

Posted: 22 May 2021 10:02 AM PDT

I have a local SSD disk, which is mounted via /etc/fstab on my Ubuntu machine:

/dev/sdb2 /media/Store ntfs-3g rw,nosuid,nodev,default_permissions,umask=0002,uid=deniss,gid=deniss 0 0  

I can read and write anything on that drive. Now I have installed nginx and php-fpm, and added www-data to my group and www-data in my group so i can edit files from both groups:

$ groups deniss  deniss : deniss adm cdrom sudo dip www-data plugdev lpadmin lxd sambashare    $ groups www-data  www-data : www-data deniss  

nginx user (www-data) can read and write all files on mounted share, the problem starts when it tries to chmod files on a drive:

$ sudo -u www-data chmod 644 test.txt  chmod: changing permissions of '/media/Store/file.txt': Operation not permitted  

Not that I need www-data to chmod files, but there are local websites running on the drive, and chmod sometimes is integrated into libraries and frameworks and I cannot disable them.

Unable to exclude directory /System on Mac while using find command to scan / directory

Posted: 22 May 2021 07:22 AM PDT

I was trying to scan entire Mac for finding files greater than 1GB. I couldn't stop the find command from scanning directories /System and /System/Volumes.

find -x / -type f -size +1G  

I tried prune, ! -path, -not -path and nothing seems to help.

Groff renders brackets and square roots incorrectly

Posted: 22 May 2021 08:19 AM PDT

The groff source

.EQ  left ( sqrt {1 over 2} right )  .EN  

produces this

expression

when a PDF is made, and viewed with most PDF readers. (Here, Atril.)

The error occurs with large round brackets and/or square root signs.

However, if PostScript is used instead, then the expression is rendered properly.

expression_2

Is there a way to fix this?

Ansible Synchronize - run task with different remote user

Posted: 22 May 2021 07:21 AM PDT

I apologize in advance if this is documented somewhere or on the site - I could not find a solution and so I'm asking here.

I'm trying to use Ansible's synchronize module to pull files from a remote host, like so:

- hosts: Server.A    gather_facts: no    tasks:      synchronize:        mode: pull        src: "file/to/pull"        dest: "path/to/destination"      delegate_to: NAS  

That is, I want the NAS host to SSH into Server.A and pull the files I'd like to upload.

The problem is, the NAS has a non-default user (admin).

I set the NAS's admin user via the inventory file, and I can communicate with the NAS ok.

However, when I run the synchronize task, it attempts to login to the source server (Server.A) with the admin user, which does not exist, and fails.

I've tried changing the remote_user, become the module's set_remote_user settings, in the playbook, the hosts file and the host_vars, but I can't get it to work and find it very confusing.

How would I go about running the synchronize command as a different remote user instead of the local one?

Thanks!

Mounting as <user>, a loop still assigns root ownership

Posted: 22 May 2021 08:45 AM PDT

I am trying to set up a virtual drive from a file. This file will then be written to a flash device (not relevant). Because creating and manipulating the virtual drive will be in a script, I need to do it in user space, i.e., not as root. The script is for building and creating an image for a flash device; so, running as root will be problematic.

In order to mount the file as a virtual drive, I added the following line to /etc/fstab:

/home/user/drive.img /home/user/mnt ext4 loop,rw,user,noauto,noexec 0 0

The problem is that when I mount the virtual drive, root takes ownership of ~/mnt, defeating the purpose of mounting it as a regular user.

I know that other file systems allow you to mount while specifying the uid/gid, but the virtual drive must be ext4 to be compatible with an existing process. I tried udisksctl, but it requires root authentication for loopback.

I am going to try mounting then changing ownership (as root) but never unmount it. I will do a 'sync' then take a snapshot of the virtual drive. I do not like it because it is not clean, but it may work for now.

udev rule triggers but any run command fails

Posted: 22 May 2021 07:50 AM PDT

I have a strange problem with udev using Raspian (Debian) Stretch on my Raspberry Pi. Here is a stripped down udev rule which triggers on attaching any usb flashdrive:

# /etc/udev/rules.d/70-usb-test.rules  KERNEL=="sd?1", SUBSYSTEMS=="usb", RUN+="/opt/bin/usb-test.sh"  KERNEL=="sd?1", SUBSYSTEMS=="usb", SYMLINK+="usb-test"  

Content of /opt/bin/usb-test.sh (The script is marked as executable):

#!/bin/bash  date >> /var/log/usb-test.log  

The symlink /dev/usb-test is created, but not the file /var/log/usb-test.log.

This is the output of tail /var/log/syslog:

Oct 30 15:24:02 raspberrypi kernel: [ 9382.740128] scsi 2:0:0:0: Direct-Access                               0.00 PQ: 0 ANSI: 2  Oct 30 15:24:02 raspberrypi kernel: [ 9382.747435] sd 2:0:0:0: Attached scsi generic sg2 type 0  Oct 30 15:24:02 raspberrypi kernel: [ 9382.748278] sd 2:0:0:0: [sdc] 15794176 512-byte logical blocks: (8.09 GB/7.53 GiB)  Oct 30 15:24:02 raspberrypi kernel: [ 9382.748810] sd 2:0:0:0: [sdc] Write Protect is off  Oct 30 15:24:02 raspberrypi kernel: [ 9382.748827] sd 2:0:0:0: [sdc] Mode Sense: 00 00 00 00  Oct 30 15:24:02 raspberrypi kernel: [ 9382.749235] sd 2:0:0:0: [sdc] Asking for cache data failed  Oct 30 15:24:02 raspberrypi kernel: [ 9382.749247] sd 2:0:0:0: [sdc] Assuming drive cache: write through  Oct 30 15:24:02 raspberrypi kernel: [ 9382.909187]  sdc: sdc1  Oct 30 15:24:02 raspberrypi kernel: [ 9382.913033] sd 2:0:0:0: [sdc] Attached SCSI removable disk  Oct 30 15:24:03 raspberrypi systemd-udevd[3853]: Process '/opt/bin/usb-test.sh' failed with exit code 1.  

lsusb:

$ lsusb  Bus 001 Device 005: ID 20a0:0006 Clay Logic   Bus 001 Device 011: ID 1307:0165 Transcend Information, Inc. 2GB/4GB/8GB Flash Drive  Bus 001 Device 006: ID 0480:a009 Toshiba America Inc Stor.E Basics  Bus 001 Device 009: ID 0480:a202 Toshiba America Inc Canvio Basics HDD  Bus 001 Device 004: ID 1a40:0101 Terminus Technology Inc. Hub  Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter  Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  

udevadm monitor:

$ udevadm monitor  monitor will print the received events for:  UDEV - the event which udev sends out after rule processing  KERNEL - the kernel uevent    KERNEL[9851.384334] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3 (usb)  KERNEL[9851.402507] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0 (usb)  KERNEL[9851.418037] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2 (scsi)  KERNEL[9851.418582] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/scsi_host/host2 (scsi_host)  UDEV  [9851.545506] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3 (usb)  UDEV  [9851.570276] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0 (usb)  UDEV  [9851.593606] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2 (scsi)  UDEV  [9851.615895] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/scsi_host/host2 (scsi_host)  KERNEL[9852.486019] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0 (scsi)  KERNEL[9852.486271] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0 (scsi)  KERNEL[9852.486448] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/scsi_disk/2:0:0:0 (scsi_disk)  KERNEL[9852.486620] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/scsi_device/2:0:0:0 (scsi_device)  KERNEL[9852.494568] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/scsi_generic/sg2 (scsi_generic)  KERNEL[9852.496172] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/bsg/2:0:0:0 (bsg)  KERNEL[9852.498091] add      /devices/virtual/bdi/8:32 (bdi)  UDEV  [9852.549816] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0 (scsi)  UDEV  [9852.560113] add      /devices/virtual/bdi/8:32 (bdi)  UDEV  [9852.590072] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0 (scsi)  KERNEL[9852.659280] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/block/sdc (block)  KERNEL[9852.659644] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/block/sdc/sdc1 (block)  UDEV  [9852.679376] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/scsi_disk/2:0:0:0 (scsi_disk)  UDEV  [9852.726897] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/scsi_device/2:0:0:0 (scsi_device)  UDEV  [9852.741386] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/bsg/2:0:0:0 (bsg)  UDEV  [9852.745223] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/scsi_generic/sg2 (scsi_generic)  UDEV  [9853.032330] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/block/sdc (block)  UDEV  [9853.256996] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/host2/target2:0:0/2:0:0:0/block/sdc/sdc1 (block)  

Anybody knows what's going on?

How to run batch sas job in unix sas?

Posted: 22 May 2021 09:02 AM PDT

I have 5 SAS jobs that I need to run sequentially, one after the other.

I typically type in nohup sas filename1.sas & in the command line to run and manually check for progress every few hours. If the 1st job is complete and no error, I then type in the 2nd job nohup sas filename2.sas & .

Is there a sas code or unix command I can run them sequentially rather than manually checking progress?

I thought about using %include statement in a master sas file, however I have many loop macros and do if then macros which throw the %include off I believe.

PS. I also need the log and lst file to be printed, typically it's printed for me automatically using the command above.

I'm trying to compile alsa-driver-RTv5.18 but get date-time error for gcc 4.9.2

Posted: 22 May 2021 10:03 AM PDT

/home/user/Downloads/Rt-Linux-HDaudio-5.18/alsa-driver-RTv5.18/alsa/acore/info.c:1065:22: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]     "Compiled on " __DATE__ " for kernel %s"                    ^  cc1: some warnings being treated as errors  

I've tried to

export CFLAGS="-Wno-error=date-time"  

but nothing changed.

Linux Mint 14.1 with Cinnamon - Mouse Sensitivity not Working

Posted: 22 May 2021 08:00 AM PDT

64-bit if that matters. My mouse sensitivity slider does nothing, but my acceleration slider works. I'd like acceleration off and sensitivity how I like it, but it refuses to work. I have tested the option on two computers, and both do not change the sensitivity. Any help?

No comments:

Post a Comment