Tuesday, February 15, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


filter the data from an inputstring

Posted: 15 Feb 2022 04:52 AM PST

If user inputs the employees details as string and we want the output to display the employees with the top three years of experience in the same order of employee details as they apper in the input string. For example input string:

"EMP101:Jack:CA:jack@yahoo.com:10#EMP102:Jill:Doctor:jill@gmail.com:5#EMP103:Russell:Engineer:r234@yahoo.com:25#EMP104:Monica:Teacher:monica@yahoo.com:4#EMP105:John:Mangaer:john@yahoo.com:8"

Output string: For example input string: "Jack:CA:10#Russell:Engineer:25#John:Mangaer:8"

could anyone please tell me how to achive this in shellscript

mv + is it safe to move huge data from folder to folder

Posted: 15 Feb 2022 04:52 AM PST

the used size of folders under /var/kafka/kafka-data/kafka-topics/ , is around ~15T

in our script we use mv in order to move the folders from /var/kafka/kafka-data/kafka-topics/ to /var/kafka/kafka-topics

as following example:

mkdir /var/kafka/kafka-topics  mv /var/kafka/kafka-data/kafka-topics/* /var/kafka/kafka-topics  

since we are dealing on size around ~15T , we want to understand if mv can move the folders without problems , just to be sure and be on the safe side

How to grep the difference between two files into a file

Posted: 15 Feb 2022 04:25 AM PST

Saying that I have two files: a.txt and b.txt.

The content of a.txt:

mosfet23

cap098

inductors 98

metal96

The content of b.txt:

test 23 cap098

drc45 metal 96

lvs cap 098

Of course I can use vimdiff to check their difference

My question is how to record devices which exists in a.txt but doesn't exist in b.txt into a file?

also we cant use comm as b.txt is not sorted?

How to achieve using tcl,grep or sed?

Filling dynamic array [duplicate]

Posted: 15 Feb 2022 04:23 AM PST

I am new to shell scripting. I am trying to create an array ,where the string x (as of now I am using static value for testing purposes) will be an input by the user during the run time.

#!/bin/sh  x="101:Redmi:Mobile:15000#102:Samsung:TV:20000#103:OnePlus:Mobile:35000#104:HP:Laptop:65000#105:Samsung:Mobile:10000#106:Samsung:TV:30000"  i=0  index=0   declare -a categ_array=()  declare -a amnt_array=()  declare -a cnt_array=()  echo "$x"  | tr '#' '\n' | cut -d ":" -f 3-4 | while read -r line ;  do     echo "------Inside while loop------"     echo $line     category=$(echo "$line" | cut -d ":" -f 1 )     echo $category     amount=$(echo "$line" | cut -d ":" -f 2 )     echo $amount     echo $i     categ_array[$i]=${category}     amnt_array[$i]=${amount}     cnt_array[$i]=1     let i+=1       done    echo Category:  for n in "${categ_array[@]}"  do    echo $n  done  

When I run the above script, I do not get any output. Where as I want output as

categ_array should have data as

(Mobile,TV,Mobile,Laptop,Mobile,TV)  

amnt_array should have data as

(15000,20000,35000,65000,10000,30000)  

Can someone tell me where am I going wrong?

How to grep selected strings separated by -

Posted: 15 Feb 2022 04:45 AM PST

I am new in grep and I have a list of packages where I only need to display certain results.

Here's a list of packages:

apache2  apache2-bin  apache2-data  apache2-dbg  apache2-dev  apache2-doc  apache2-utils  

I've been trying to use regex but I'm sure that there's something wrong:

cat list | grep 'apache2-(bin|data|utils)'  

Here's my expected output:

apache2  apache2-bin  apache2-data  apache2-utils  

What is wrong/missing in my command?

Easy way to output a file and change the implicit newlines ($) in the file into literal (\n)

Posted: 15 Feb 2022 04:56 AM PST

I have a file with a number of invincible Newlines. In Vim it's shown as $ (can be seen with :set list). I had a hard time to convert them to an output which is represented as a one line string with the literal \n string instead of the invincible $.

Example:

# cat file.txt   test  file  with  newlines  

To see the newlines in vim enter :set list.

With this command, I could format the output as wanted:

# awk '{printf "%s\\n", $0}' file.txt   test\nfile\nwith\nnewlines\n  

however, I think there should be an easier way with sed, echo or printf

How to enable sudo privileges for user group to apt-get install anything

Posted: 15 Feb 2022 03:32 AM PST

I want to give a group permission to install software without needing to input a root/sudo password. I'm on Linux Mint 20.3 Cinnamon.

I have created a group called "basicsudo".

I first typed

$ which apt-get    /usr/bin/apt-get  

Then

sudo visudo  

then I added the following line

%basicsudo ALL=(ALL) NOPASSWD: /usr/bin/apt-get install

to /etc/sudoers.tmp

[...]  # Cmnd alias specification    # User privilege specification  root    ALL=(ALL:ALL) ALL    # Members of the admin group may gain root privileges  %admin ALL=(ALL) ALL    # Allow members of group sudo to execute any command  %sudo   ALL=(ALL:ALL) ALL    %basicsudo ALL=(ALL) NOPASSWD: /usr/bin/apt-get install  # See sudoers(5) for more information on "#include" directives:    #includedir /etc/sudoers.d  

I assigned the group to a user by using the Groups and Users GUI from the menu. To check this I've run

$ groupname Alice   Alice, basicsudo  

from my account.

When logged in as Alice, this is confirmed

$ groups  Alice, basicsudo  

But when trying to execute the following line as Alice, I do not succeed:

$ sudo apt-get install python3-pip    [sudo] password for Alice:             Sorry, user Alice is not allowed to execute '/usr/bin/apt-get    install python3-pip' as root on computername.  

So clearly a) I'm prompted for a password and b) I can't execute it despite entering a password.

What is the proper way to do this?

Problem with .bashrc when I use anima command

Posted: 15 Feb 2022 03:00 AM PST

I cannot use animaConvertImage in on an internal file in a folder other than the one where the anima commands are located. I tried using the .bashrc file, but to no avail, specifically:

-I added the following lines to my ~/.bashrc file in the following way:

gedit ~/.bashrc &

And added:

ANIMAHOME=~/Software/Anima/build    export PATH=$ANIMAHOME/bin:$PATH    export LD_LIBRARY_PATH=$ANIMAHOME/lib:$LD_LIBRARY_PATH  

and finally closed the terminal to make the changes active. Then when I go to use the command:

animaConvertImage -i dwi/Noddi_Combined_Tensors_final.nrrd -I  

With dwi folder external to the Software folder I always get as output:

-bash: animaConvertImage: command not found

How can I solve the problem (I'm not sure if the two are connected to each other since I'm a beginner)?

How to handle CHMOD permissions like an expert?

Posted: 15 Feb 2022 03:21 AM PST

From years, I am trying to fake I know how unix permissions works, but In fact, I don't understand anything.

www-data is the apache2 user My own user is my_user, it's having sudo access I am using root by using sudo su -

www-data is having all permissions on /var/www/html/ (755 www-data:www-data)

I can not connect as www-data and I want to PhpStorm to deploy on this server, using my_user.

So, by default, all folders are r-x, so I allow www-data's group to have full access (As root)

chmod -R g+rwx /var/www/html/project/themes

Then I add my user to this group (As root)

usermod -a -G www-data my_user

Now, logged my_user and phpstorm deployment are still returning "Permission denied". I disconnect my user, reconnect it and now this is working... What's going on dude ? So, I restart PhpStorm and this is working now.

I pushed my new folder on the server and I am now listing files

ls -la /var/www/html/project/themes

drwxrwx--- 2 my_user my_user 4096 Feb 15 09:51 new-folder

Wow buddy, I really need www-data to be able to read it, and edit it, and run it... I would like the new folders and files are owned by www-data:www-data to get it work. But maybe I am wrong ...

So, what is the best and definitive solution about these permissions issues ?

Compressing AMD graphics include directory "asic_reg" saves up to 230MB Linux Kernel storage size. Could make automate to (un)compress?

Posted: 15 Feb 2022 02:57 AM PST

Cloning a current kernel (e.g. 5.17-rc1 ) to a source directory requires around 1.4GB and a total of 2GB (debug kernels up to 4GB) free storage for compiling a default kernel configuration. While AMD's gpu include files are a huge part of that source download (mostly asic_reg directory) these are only required with utilizing an AMD gpu.
Compressing this drivers/gpu/drm/amd/include/asic_reg directory to an asic_reg.bz2 file (about 9MB) and removing the asic_reg folder, reduces kernel sources by almost 230MB to then around 1.0GB size (.git directory pack files cleared) on client side.

Compiling from sources was flawless, having only that bzip2 file available and no AMD gpu devices configured.
If there are any unusual drawbacks to this approach, that aren't obvious by now (beside decompressing this file within a few tens of seconds at most, if needed for AMD gpu driver support), hints are welcome.
Storage savings would be an advantage of almost 230MB, with automated decompressing and compressing during the common kernel compiling procedure, if needed.
Would it be possible to modify the make build system for that?

So far that had no interest, because there are no hints or questions about that idea/improvement within Unix & Linux database.

Find Directories Older Than X Days Named in YYYY-MM-DD & Delete If Exists

Posted: 15 Feb 2022 02:52 AM PST

I tried to create this one liner bash script which finds and then deletes directories older than X days based on their file names and code works flawlessly. The only issue is that if directory exist and is removed successfully, it still errors out "find: '/var/www/html/resources/cache/2022-02-08': No such file or directory"

Although I have put the condition which checks if the directory exists in result of find command and then delete it.

find '/var/www/html/resources/cache/' -type d -name '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' -exec sh -c 'd={}; [ "$(date -d "6 days ago" +%Y-%m-%d)" ">" "$(basename $d)" ] && [ -d $d ] && rm -rf $d' \;  

Let's say I have following directories located at /var/www/html/resources/cache

2022-02-08  2022-02-09  2022-02-10  2022-02-11  2022-02-12  2022-02-13  2022-02-14  2022-02-15  

[ "$(date -d "6 days ago" +%Y-%m-%d)" ">" "$(basename $d)" ] checks if file name is older than 6 days

[ -d $d ] checks if its a directory

How to show debug info on Kwin task switcher error?

Posted: 15 Feb 2022 01:23 AM PST

Recently I've installed Present Windows Clone tasks switcher on KDE store, but it won't work. Whenever I try to switch windows, it prints to notifications: "The Window Switcher installation is broken, resources are missing".

I've checked the source code and know that it's because it is too old and doesn't work on new plasmas(uses 1.1 APIs instead of 2.0). I tried to switch to new versions of KDE APIs in qml, but none worked.

So it's pointless, trying to change the code without debug info. So how could I see detailed log of this notification error in KDE?

P.S. Arch Linux x86_64, 5.16.8-arch1-1, Plasma 5.24.0, KWin, Wayland.

Does "no-auto-down" and "no-scripts" support pattern matching interfaces in /etc/network/interfaces?

Posted: 15 Feb 2022 01:17 AM PST

I tried reading the manual from https://man.cx/interfaces(5) and searching for some open-source code.
But I didn't find any specific description of the option of "no-auto-down" and "no-scripts".

The case I found was:

# /etc/network/interfaces    no-auto-down eth0  

But I want to know, for example, the following example is correct or not:

# /etc/network/interfaces    no-auto-down eth0 eth1 eth2  # or  no-auto-down /eth*=eth  

For every string in file1.txt check if it exists in file2.txt then do something

Posted: 15 Feb 2022 04:04 AM PST

I got two txt files, file1.txt and file2.txt. Both of them have one single string for each line. Strings in file1.txt are unique (no duplication), as well as strings in file2.txt...might file2 contain more information just than device information. The files have different numbers of strings. but we have to only compare string mentioned in file1.

file1.txt

diode1  bjt3  cap7  diode45   

file2.txt

drc info diode1  lvs property bjt3  

I'd like to compare those files, so that for every device(diode,bjt,etc) in file1.txt, if it exists in file2.txt, then it's ok. If not, than write that device in another file (file3.txt)

In this example, file3.txt would be:

file3.txt

cap7  diode45  

how to do this with grep, sed or tcl?

i have tried grep -vf file1 file2. But is printing the differences between both these files....i want ouput only if the devices mentioned in file1 is absent in file2 not vice- versa.

Parse pylint result to extract score?

Posted: 15 Feb 2022 01:33 AM PST

I am building a github CI using action and I was able to run pylint and write a message to PR with the result. However, I want to parse the exact score so I can fail the action if it's bellow a certain threshold, here is my relevant code:

- name: Lint with pylint    working-directory: ./    run: |      echo '${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}'      pip install pylint      OUTPUT=$(pylint ${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}  --exit-zero --jobs=0)      SCORE=$OUTPUT > sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p'      echo "Pylint finished with score: $SCORE"      echo 'MESSAGE<<EOF' >> $GITHUB_ENV      echo  "$OUTPUT"  >> $GITHUB_ENV      echo 'EOF' >> $GITHUB_ENV  

What is the command to parse the pylint results which is currently saved as $OUTPUT, and parse the exact score to save it in $SCORE?

    OUTPUT=$(pylint ${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}  --exit-zero --jobs=0)      SCORE=$OUTPUT > sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p'  

This is the output example, I need to parse the "0.18" part:

************* Module src.server  src/server.py:1:0: C0114: Missing module docstring (missing-module-docstring)  src/server.py:5:0: W0401: Wildcard import src.endpoints (wildcard-import)  ...  -----------------------------------  Your code has been rated at 0.18/10  

Trim column X leaving a specific number of chatacters if column Y and column Z are not equal to NULL

Posted: 15 Feb 2022 03:01 AM PST

I am trying to find a way to use awk/sed to filter a csv to truncate the value in a specific column such as column 1 to retain the last 8 characters and replace the beginning with a wildcard, only if two other specific columns are not equal to NULL- such as col 3 and col 5

Example data:

1597012957a0dg9a0t593qa_filename1.exe,NULL,NULL,DATA,NULL,DATA  asvasihtiqsafsoithqwtoihwoi_filename2.exe,NULL,DATA,DATA,DATA,DATA  

Would become:

1597012957a0dg9a0t593qa_filename1.exe,NULL,NULL,DATA,NULL,DATA  *.filename2.exe,NULL,DATA,DATA,DATA,DATA  

I have scripted this using a series of pipping rev and cut, but it is terribly inefficent and I am in the process of learning more advanced awk/sed filters as I am processing a lot of data and the script takes hours.

preserve environmental variables with find -exec

Posted: 15 Feb 2022 03:50 AM PST

Is it possible to preserve environmental variables with find -exec? I don't see any options using the FreeBSD version of find. I can switch to a for loop if absolutely required, but was hoping to use the brevity of exec as well as it is faster.

The other option I can think of isn't pretty and that is dumping the environment and then reading it back in in the command I'm executing.

EDIT:

find . -type f -name '*/*.patch/go' -exec go install {} \;  

In this example, I want go to use the http proxy. I already have code that tells git to configure a global http proxy (above this).

So, from the example below, I need to preface this with sh? Why?

What are the benefits of this command line (/usr/bin/awk '{$1=$1};1') instead of pure cat

Posted: 15 Feb 2022 03:54 AM PST

I am reading the AWS eic_harvest_hostkeys script and I don't understand this line:

key=$(/usr/bin/awk '{$1=$1};1' < "${file}")  

What is the of benefit awk? Isn't key=$(/bin/cat "${file}") better?

Installing chromium-browser:armhf and libwidevinecdm0 on Ubuntu

Posted: 15 Feb 2022 03:18 AM PST

I'm trying to install chromium-browser:armhf and libwidevinecdm0 on my Raspberry Pi (Ubuntu 21.10 64 bit) by doing the following command:

sudo apt install chromium-browser:armhf libwidevinecdm0  

According to this instruction.

But I'm getting the following output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package chromium-browser:armhf
E: Unable to locate package libwidevinecdm0

how to clear the lastlog file without interruption

Posted: 15 Feb 2022 02:19 AM PST

on our rhel machine ( production server ) we noticed that lastlog is huge

we not want to interrupt the OS logs that always wrote to log but we want to clear the lastlog

is it ok to clear the lastlog as

echo > /var/log/lastlog  

second

how is it possible to disable writing to lastlog as permanent?

Errors from nouveau display driver on Debian - firmware: failed to load nouveau/nvc1_fuc084 (-2)

Posted: 15 Feb 2022 01:42 AM PST

I've installed Debian 11 with dual boot on a laptop of mine lately. I installed the official image, so no non-free drivers got installed.

I had some driver issues reported when using dmesg (I think one was the bluetooth) and I seemed to have fixed them by installing some packages (I copied the failing driver name from dmesg, searched it with apt, and installed the best match).

At some point I've decided to add the contrib and non-free sources to my sources list, to see if getting non-free drivers would improve anything: https://www.xmodulo.com/install-nonfree-packages-debian.html

I was getting errors from the nouveau driver before that too (despite the fact that my screen was using the full resolution), so I was just trying to make the errors go away.

I've tried the nvidia-detect utility and after installing its suggestion my resolution dropped and wouldn't be set to a higher one. So, I've uninstalled that.

I've also tried the instructions here: https://wiki.debian.org/NvidiaGraphicsDrivers#Debian_11_.22Bullseye.22 Again, my resolution dropped.

I think that, in both cases I've installed a legacy driver (most likely nvidia-legacy-390xx-driver).

My graphics card seem to be a GA compatible controller: NVIDIA Corporation GF108M [GeForce GT 540M] (rev a1).

Eventually, I have uninstalled what I had installed (hopefully - not sure if anything stayed behind...) and my resolution is now restored, but I still get the same errors in dmesg:

[   14.913827] Bluetooth: Can't change to loading configuration err  [   14.913943] ath3k: probe of 1-1.5:1.0 failed with error -110  [   37.345865] nouveau 0000:01:00.0: firmware: failed to load nouveau/nvc1_fuc084 (-2)  [   37.345872] firmware_class: See https://wiki.debian.org/Firmware for information about missing firmware  [   37.345876] nouveau 0000:01:00.0: Direct firmware load for nouveau/nvc1_fuc084 failed with error -2  [   37.345892] nouveau 0000:01:00.0: firmware: failed to load nouveau/nvc1_fuc084d (-2)  [   37.345895] nouveau 0000:01:00.0: Direct firmware load for nouveau/nvc1_fuc084d failed with error -2  [   37.345898] nouveau 0000:01:00.0: msvld: unable to load firmware data  [   37.345901] nouveau 0000:01:00.0: msvld: init failed, -19  

These seem to be the only remaining errors.

If we exclude the bluetooth one at the top (which I have no idea why it happens), you see the failing nouveau driver afterwards.

And I am a bit confused by it really, because (from my understanding) the nouveau driver is supposed to be shipped with the kernel. So, why would it fail? How could there be a missing dependency to it or anything like that?

I think I also tried installing it (nouveau) with apt, but nothing got installed. Not sure what would happen if one of its dependencies was the wrong version (if it would be replaced or not). I guess it would be replaced if the existing binary is an older version, but I am not sure about that.

So, if anyone has any idea what I could do, feel free to drop his ideas. This is my first time dealing with Linux drivers, so I am a bit clueless.

For sure, I could just ignore the problem, since my screen seems to work fine.

Just, I can't unsterstand what is going on here... If the driver doesn't load, why is my screen working OK?

i2cdetect addresses 7-bit or 8-bit?

Posted: 15 Feb 2022 03:09 AM PST

Are the addresses reported by i2cdetect 7-bit or 8-bit I2C addresses? My hope is the more general 7-bit address.

I'm starting to run some experiments, but it would be nice if the manpages were a bit more explicit about the reported format.

$ sudo i2cdetect -y 2       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  00:          -- -- -- -- -- -- -- -- -- -- -- -- --   10: -- -- -- -- -- -- -- -- -- -- -- -- -- 1d -- --   20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --   30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --   40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --   50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --   60: -- 61 -- -- -- -- -- -- -- -- -- -- -- -- -- --   70: -- -- -- -- -- -- -- --     

How to blur webcam background in Microsoft Teams

Posted: 15 Feb 2022 01:58 AM PST

I am currently using Teams for a master and I would like to blur my backgrounds, do you know any way to do it?

Problem getting user input through script called by pam_exec

Posted: 15 Feb 2022 02:07 AM PST

I was trying to use pam_exec.so on Ubuntu to call a script, prompt for user input and allow the user to log in through SSH if the script exits with an exit code of 0. I was unable to get this to work. So I wrote a simple script as follows to test pam_exec.so and see if the problem was with my original script. However I am getting the same issues even with this simple script.

/usr/local/bin/test.sh

#!/bin/bash  echo -n "Please enter your name:"  read name  echo "Hello $name"  

I called it by including the following line after @include common-auth in /etc/pam.d/sshd

auth    required        pam_exec.so stdout /usr/local/bin/test.sh  

But when I SSH into this system as seen below, I do not get a prompt to enter any input. As soon as I enter the password, I get logged in. However, the output of the script is visible. enter image description here

Then I changed the above script as follows to exit with an exit code of 1 if no input is given.

#!/bin/bash  echo -n "Please enter your name:"  read name  if [ -z "$name" ]  then          exit 1  else          echo "Hello $name"          exit 0  fi  

Then I am unable to SSH into the system (screenshot below) even when I enter the correct password and I do not see any output of the script.

enter image description here

So what I want to know is how can I correct this problem and use pam_exec.so to run a script, get user input, and allow ssh authorization only if that script exits with an exit code of 0?

Getting "no IPv4 addresses" With isc-dhcp-server And Subinterfaces

Posted: 15 Feb 2022 01:04 AM PST

I have tried both subinterfaces and secondary ip address route and neither are working for isc-dhcp-server. It is refusing to pull the proper IP's. I am using Debian 8 Jessie and ISC-DHCP-SERVER 4.3.1.

My /etc/network/interfaces

## Corporate Network  auto eth0  allow-hotplug eth0  iface eth0 inet manual    ## New Subnet  auto eth0:0  allow-hotplug eth0:0  iface eth0:0 inet static      address 10.0.0.2      gateway 10.0.0.1      netmask 255.255.0.0      dns-nameservers 127.0.0.1 10.0.0.3      dns-search example.net      dns-domain example.net    ## Old Subnet  auto eth0:1  allow-hotplug eth0:1  iface eth0:1 inet static      address 10.136.136.253      netmask 255.255.255.0  

ifconfig

eth0      Link encap:Ethernet  HWaddr b8:27:eb:c0:59:e5            inet6 addr: fe80::ba27:ebff:fec0:59e5/64 Scope:Link            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1            RX packets:26688 errors:0 dropped:69 overruns:0 frame:0            TX packets:7301 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:1000            RX bytes:7174565 (6.8 MiB)  TX bytes:1286716 (1.2 MiB)    eth0:0    Link encap:Ethernet  HWaddr b8:27:eb:c0:59:e5            inet addr:10.0.0.2  Bcast:10.0.255.255  Mask:255.255.0.0            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1    eth0:1    Link encap:Ethernet  HWaddr b8:27:eb:c0:59:e5            inet addr:10.136.136.253  Bcast:10.136.136.255  Mask:255.255.255.0            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  

ip add

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000      link/ether b8:27:eb:c0:59:e5 brd ff:ff:ff:ff:ff:ff      inet 10.0.0.2/16 brd 10.0.255.255 scope global eth0:0         valid_lft forever preferred_lft forever      inet 10.136.136.253/24 brd 10.248.28.255 scope global eth0:1         valid_lft forever preferred_lft forever      inet6 fe80::ba27:ebff:fec0:59e5/64 scope link         valid_lft forever preferred_lft forever  

/var/log/syslog when starting isc-dhcp-server

Aug 12 09:48:20 ns01 dhcpd: Wrote 0 deleted host decls to leases file.  Aug 12 09:48:20 ns01 dhcpd: Wrote 0 new dynamic host decls to leases file.  Aug 12 09:48:20 ns01 dhcpd: Wrote 5544 leases to leases file.  Aug 12 09:48:21 ns01 dhcpd:  Aug 12 09:48:21 ns01 dhcpd: No subnet declaration for eth0:1 (no IPv4 addresses).  Aug 12 09:48:21 ns01 dhcpd: ** Ignoring requests on eth0:1.  If this is not what  Aug 12 09:48:21 ns01 dhcpd:    you want, please write a subnet declaration  Aug 12 09:48:21 ns01 dhcpd:    in your dhcpd.conf file for the network segment  Aug 12 09:48:21 ns01 dhcpd:    to which interface eth0:1 is attached. **  Aug 12 09:48:21 ns01 dhcpd:  Aug 12 09:48:21 ns01 dhcpd:  Aug 12 09:48:21 ns01 dhcpd: No subnet declaration for eth0:0 (no IPv4 addresses).  Aug 12 09:48:21 ns01 dhcpd: ** Ignoring requests on eth0:0.  If this is not what  Aug 12 09:48:21 ns01 dhcpd:    you want, please write a subnet declaration  Aug 12 09:48:21 ns01 dhcpd:    in your dhcpd.conf file for the network segment  Aug 12 09:48:21 ns01 dhcpd:    to which interface eth0:0 is attached. **  Aug 12 09:48:21 ns01 dhcpd:  Aug 12 09:48:21 ns01 dhcpd: failover peer failover: I move from normal to startup  Aug 12 09:48:21 ns01 dhcpd: Server starting service.  

SSHFS fails, Error - read: Connection reset by peer

Posted: 15 Feb 2022 01:21 AM PST

SCP is working, but the sshfs is displaying the above error.

sudo sshfs -o allow_other -o transform_symlinks username@192.168.2.207:/ /media/SSHFS_bbb  

Openvpn client and server cannot ping each other(Connection established)

Posted: 15 Feb 2022 04:01 AM PST

I have setup OpenVPN client and server between two VPS. I have a client and server setup, server using 10.8.0.1 and 10.8.0.2 IPs in tun interface, and client using 10.8.0.6 and 10.8.0.5 in tun interface. (vps1 is the client and vps2 is the server.) The client can ping server tun IP 10.8.0.1 but not any other IPs. From the server I'm not able to ping to any of the tun IPs or client tun IPs.

server conf:

port 1194  proto udp  dev tun0    ca ca.crt  cert server.crt  key server.key  tls-server  dh dh2048.pem  server 10.8.0.0 255.255.255.0  ifconfig-pool-persist ipp.txt    keepalive 10 120    comp-lzo  user nobody  group nobody  persist-key  persist-tun    verb 3  

client conf:

client  dev tun  proto udp  remote 198.168.XXX 1194  nobind  tun-mtu 1500  persist-key  persist-tun  keepalive 14 120  ca ca.crt  cert client.crt  key client.key  comp-lzo  verb 3  

As per the logs connection is setup successfully,

Jun  9 13:25:28 vps2 openvpn[6484]: MULTI_sva: pool returned IPv4=10.8.0.6, IPv6=(Not enabled)  Jun  9 13:25:28 vps2 openvpn[6484]: MULTI: Learn: 10.8.0.6 -> vps1.xxx/xxxxx:33012  Jun  9 13:25:28 vps2 openvpn[6484]: MULTI: primary virtual IP for vps1.xxx/xxxxx:33012: 10.8.0.6  Jun  9 13:25:30 vps2 openvpn[6484]: vps1.xxx/xxxxx:33012 PUSH: Received control message: 'PUSH_REQUEST'  Jun  9 13:25:30 vps2 openvpn[6484]: vps1.xxx/xxxxx:33012 send_push_reply(): safe_cap=940  Jun  9 13:25:30 vps2 openvpn[6484]: vps1.xxx/xxxxx:33012 SENT CONTROL [vps1.xxx]: 'PUSH_REPLY,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5' (status=1)  

And tunnels are established at both ends:

Server

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00            inet addr:10.8.0.1  P-t-P:10.8.0.2  Mask:255.255.255.255            UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1            RX packets:5 errors:0 dropped:0 overruns:0 frame:0            TX packets:28 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:100            RX bytes:420 (420.0 b)  TX bytes:1968 (1.9 KiB)  

Client

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00            inet addr:10.8.0.6  P-t-P:10.8.0.5  Mask:255.255.255.255            UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1            RX packets:0 errors:0 dropped:0 overruns:0 frame:0            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:100            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  

The client also able to ping and ssh to server via the gateway IP

root@vps1:~# ping 10.8.0.1  PING 10.8.0.1 (10.8.0.1) 56(84) bytes of data.  64 bytes from 10.8.0.1: icmp_seq=1 ttl=64 time=72.6 ms  64 bytes from 10.8.0.1: icmp_seq=2 ttl=64 time=72.6 ms  64 bytes from 10.8.0.1: icmp_seq=3 ttl=64 time=72.7 ms  ^C  --- 10.8.0.1 ping statistics ---  3 packets transmitted, 3 received, 0% packet loss, time 2002ms  rtt min/avg/max/mdev = 72.666/72.691/72.726/0.221 ms    root@vps1:~# ssh 10.8.0.1  root@10.8.0.1's password:  

But not able to ping the opnevpn ip's from server and client.

root@vps1:~# ping 10.8.0.2  PING 10.8.0.2 (10.8.0.2) 56(84) bytes of data.  ^C  --- 10.8.0.2 ping statistics ---  3 packets transmitted, 0 received, 100% packet loss, time 2000ms    root@vps1:~# ping 10.8.0.5  PING 10.8.0.5 (10.8.0.5) 56(84) bytes of data.  

Apache redirect full URL with RewriteRule

Posted: 15 Feb 2022 03:06 AM PST

I have a redirect problem with 'RewriteRule', i have this in mt .htaccess:

RewriteCond %{HTTP_HOST} ^foo.domain.com  RewriteRule ^(.*)$ http://www.domain.com/foo/$1 [R=permanent,L]  

If i go to foo.domain.com redirect to www.domain.com/foo/ and it's ok, instead i go to foo.domain.com/bar i have an error, must go to www.domain.com/foo/bar. Where is error?

Automatically run rfkill unblock on startup

Posted: 15 Feb 2022 04:22 AM PST

I'm running Elementary OS on an old(er) HP Pavilion dm1. Unfortunately, on startup my wireless is hard disabled, and I need to run sudo rfkill unblock all to get it up and running. Works fine once I do though.

Is there any way to either: 1) Automatically run this line with startup 2) Not need to do this anymore?

When I use rfkill to view any blocks, there's a hard block on the wireless, and the wireless button's light is orange. Pressing the button does nothing. After running the line, I can switch wireless on and off at will.

No comments:

Post a Comment