Saturday, May 15, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Why F5 Big IP CLI self created file script doesn't work, although command works from terminal?

Posted: 15 May 2021 09:48 AM PDT

Here's my script which is saved as f5cli and chmod +x f5cli for executable. I'm using F5FPC_HOST environment variable to pick the value for host url

#!/bin/sh    user=$(echo "" | dmenu -p "Enter user:")  secret="'$(echo "" | dmenu -P -p  "Enter secret(PIN, OTP, Password):")'"    f5fpc --start -u $user -p $secret -t $F5FPC_HOST    

Replacement of variable values is not a problem, i have verified by printing the data in echo/notify-send. I have tried changing bin/sh to bin/zsh or bin/bash.

Command which works in terminal

f5fpc --start -u user -p 'XXXX123456PASSWORD' -t https://abc.com  

How to prevent destructive side effects from running exported bash functions?

Posted: 15 May 2021 09:38 AM PDT

With some versions of bash, the invoking by a script of a function that was made available to it by a prior export -f command results in the clobbering of the script's BASH_SOURCE array.

Here's a toy example. It is based on the short script clobber.sh shown below:

$ nl clobber.sh       1  #!/bin/bash       2  typeset -f noop       3  typeset -p BASH_SOURCE       4  noop       5  typeset -p BASH_SOURCE  

The shell interaction below shows the issue:

$ (noop() { :; } ; export -f noop ; ./clobber.sh)  noop ()   {       :  }  declare -a BASH_SOURCE='([0]="./clobber.sh")'  declare -a BASH_SOURCE='()'  

The first 4 lines of the output shows the definition that clobber.sh has for the noop function. (As its name suggests, this function does nothing1.) The remaining two lines of the output are produced by the two typeset -p commands (lines 3 and 5) in clobber.sh.

As the last line shows, BASH_SOURCE became empty after noop was invoked2.

I don't understand what is going on. I suppose it is a bug in bash, because such behavior happens with only some versions of it. Unfortunately, these versions include the one installed on my (work-provided) Mac laptop, and also on my company's Linux cluster, two instances of bash I have no control over.

Is there anything that a script can do to protect itself against such potential side effects? (I happen to know about the problem with BASH_SOURCE, but what else is getting messed up when I run a previously exported bash function?)


1 The details of the function does not matter, AFAICT. The same behavior occurs with every other function I have tested.

2 To be clear, if I comment out the invocation of noop in clobber.sh, the output of the second typeset -p command matches that of the first one shown above.

badblocks and mkfs.ext4

Posted: 15 May 2021 09:38 AM PDT

I've ran badblocks on a disk /dev/sdc and now I want to use the saved file with badblocks as an argument to mkfs.ext4 -l on a partition.

Block size used in both commands are the same. But I'm formating a partition which is not the first one of the disk.

Should block numbers be recalculated and if yes, how to do it?

I do not want to run mkfs.ext4 -c as that will take more time.

Mac clients cannot set permissions on Samba share

Posted: 15 May 2021 09:31 AM PDT

I'm running Samba on a Debian server in my local home network. The Samba version is 4.9.5-Debian. My Mac Mini (with Big Sur) connects to that server. There is a share for time machine backups and another one for storing data. Time machine backups seem to work (at least Time Machine does not complain and I successfully restored single files from backups).

However, I noticed that permissions on the data share do not work properly. If I try to change permissions of a file or folder, e.g., with chmod 640 testfile.txt, then permissions on the share are not affected. Permissions always stay the same.

I already tried various Samba settings based on information I found on the Internet, as well as reading man smb.conf and man vfs_fruit.

I added these parameters to the global section of my smb.conf file:

   server min protocol = SMB3_00     ea support = yes     vfs objects = acl_xattr catia fruit streams_xattr     fruit:aapl = yes     fruit:metadata = netatalk     fruit:resource = file     fruit:encoding = native     fruit:copyfile = yes     fruit:model = MacSamba     fruit:veto_appledouble = no     fruit:posix_rename = yes     fruit:zero_file_id = yes     fruit:wipe_intentionally_left_blank_rfork = yes     fruit:delete_empty_adfiles = yes     fruit:nfs_aces = no  

And the data share is configured like this:

[DataShare]     comment = Samba data share     path = /srv/samba/datashare     browseable = yes     read only = no     guest ok = no     valid users = myuser     create mask = 0777     directory mask = 0777  

I'm new to Samba and am a bit confused by all the different parameters. Right now I don't have any idea why my Mac client cannot set file permissions for files on the share.

For simply storing files this might even be OK, but it causes problems with applications. As an example, I wanted to put my large picture library on to the share. I copied it there and wanted to open it with Apple's Photos app - but Photos fails to do so, says permissions are broken, and also fails to repair permissions.

I'd really appreciate some help, because I'd love to get this setup working.

How to use `curl` to see the top of a very long output?

Posted: 15 May 2021 09:43 AM PDT

I use curl to access ASCII info from some server but it always moves to the bottom. How do I ensure that it starts from the top?

There is an analogous question about the cat command and I guess a solution could be to redirect the output to a file, then use less as suggested here. Is something more efficient possible?

Help required in setting up a CLI environment on my chromebook

Posted: 15 May 2021 09:13 AM PDT

I have an acer chromebook, I wish to set up a fully-fledged linux command-line environment on it. I mostly use the terminal on my other linux machine, I don't really care much for GUI evnironments. I need a setup on my chromebook that allows me to run all the commandline utilities of a typical linux distro. How do I begin?

What I've done so far:

I've tried using crouton to install chroot but chroot's installation gave me this error in the end: "W: Failure trying to run: dpkg --force-depends --install /var/cache/apt/archives/libc6_2.23-0ubuntu3_amd64.deb"

I tried installing costini but that requires you to set "Enable linux beta" option, and I do not have that option.

I tried looking for an 'kernel-next' in chrome://flags and that wasn't there either.

I just need a typical linux terminal environment.

In fixed width file new line char in data

Posted: 15 May 2021 08:36 AM PDT

Fixed width file has 15 fields,in 5th field-address it starts from 19 th char and ends at 58th char (its length is 40) getting \n char(new line char in data). How to replace it with double space without any impact actual line separator.

Input:

01 DAVIDS 800 ABC VISAL NAGAR, ABC  BUILDING HYD TELANGANA 6000 DEVELOPER HR DEPT FULL TIME EMPLOYEE  02 KAMAL  900 XYZ KAMAN NAGAR, DEF  BUILDING SEC TELANGANA 8000 DEVELOPER MR DEPT FULL TIME EMPLOYEE  

Output:

01 DAVIDS 800 ABC VISAL NAGAR, ABC  BUILDING HYD TELANGANA 6000 DEVELOPER HR DEPT FULL TIME EMPLOYEE  02 KAMAL  900 XYZ KAMAN NAGAR, DEF  BUILDING SEC TELANGANA 8000 DEVELOPER MR DEPT FULL TIME EMPLOYEE  

Close recently opened process in .sh

Posted: 15 May 2021 08:10 AM PDT

I am new to Linux and trying to learn how to launch and close processes automatically. Eventually I would like to run this/a similar process with cron. Here, just testing "checking in" to google.

gcheck.sh looks like this:

#!/bin/bash/  export DISPLAY=:0  firefox --new-window https://google.com  

I have added execute permissions to gcheck.sh with sudo chmod a+x. I know that $$ will give the PID of the script, but how can I get and kill the PID of just opened firefox window (in case I have other firefox windows open)?

Thank you in advance!

v4l2 loopback working fine with openCV but weird output on OBS

Posted: 15 May 2021 07:59 AM PDT

I'm as CS student and i'm trying to make a project where I output my webcam video flow but as an ascii art.

In order to do so, I get the image from v4l2. then i use OpenCV to decode the image (i wasn't able to find an easier way to do so)

Then i get the data from my openCV mat and, in a new buffer, create an ascii art from my image. after that i send data from my buffer in v4l2 but when i use the v4l2 loopback input on obs the output is realy weird (see image)

I've tried to output the image in a new mat using opencv and the image output correctly. i really don't understand what happen neither why. Also i've tried to use discord instead of OBS the output is completely black ...

Any help would be appreciate. Thanks by advance.

(all my code is available through github, i'm not sure if i should post it since this is not stack overflow. if ever you need it just let me know i'll add a link)

Expected Output (got from OpenCV): Expected Output

OBS Output : enter image description here

Can't set static IP on systemd-networkd

Posted: 15 May 2021 08:13 AM PDT

I can't set static IP on a wired interface using systemd-networkd. based on here, I should be able to set static IP using below code on /etc/systemd/network/eth0.network path:

[Match]  Name=enp1s0    [Address]  Address=10.1.10.9/24  Gateway=10.1.10.1  DNS=10.1.10.1  

but I give below log from systemd-networkd service:

May 15 13:49:45 xxx systemd[1]: Stopped Network Service.  May 15 13:49:59 xxx systemd[1]: Starting Network Service...  May 15 13:50:00 xxx systemd-networkd[481]: /etc/systemd/network/eth0.network:6: Unknown key name 'DNS' in section 'Address', ignoring.  May 15 13:50:00 xxx systemd-networkd[481]: eth0: Gained IPv6LL  May 15 13:50:00 xxx systemd-networkd[481]: Enumeration completed  May 15 13:50:00 xxx systemd[1]: Started Network Service.  May 15 13:50:00 xxx systemd-networkd[481]: eth0: IPv6 successfully enabled  May 15 13:50:00 xxx systemd-networkd[481]: eth0: DHCPv4 address 192.168.0.230/24 via 192.168.0.254  May 15 13:50:12 xxx systemd-networkd[481]: eth0: Configured  

you can find my hardware and software specification in below:

root@hostname:/etc/systemd/network# hostnamectl     Static hostname: hostname           Icon name: computer          Machine ID:              Boot ID:     Operating System: NXP i.MX Release Distro 5.4-zeus (zeus)              Kernel: Linux 4.1.15+        Architecture: arm  

format data into table

Posted: 15 May 2021 09:32 AM PDT

How to get the details and transpose it to horizontal form

Every record ends after Couse. Couse will never be blank or null

Note : This four header will be their for below data : Name , City , Age , Couse

if you see the second record their is no "Name" : "" -> missing so it should be null in place of that and remaining will be appended after that with pipe separated like this : null | Ors | 11 | MB

I have a data like below in demo.txt file

"Name":"asxadadad  ,aaf dsf"  "City":"Mum"  "Age":"23"  "Couse":"BBS"  "City":"Ors"  "Age":"11"  "Couse":"MB"  "Name":"adad sf"  "City":"Kol"  "Age":"21"  "Couse":"BB"  "Name":"pqr"  "Age":"21"  "Couse":"NN"   

Expected Output :

asxadadad  ,aaf dsf | Mum  | 23 | BBS  null                | Ors  | 11 | MB  adad sf             | Kol  | 21 | BB  pqr                 | null | 21 | NN  

I tried below code : but not working my logic

counter=0  var_0='Couse'     while read -r line           echo "$line"               counter=$(( counter + 1 ))       var_1=`echo "$line" | grep -oh "Couse"`          if [ $var_0 == $var_1 ]     then          head -$counter demo.txt > temp.txt          sed -i '1,$counter' demo.txt           counter = 0     else          echo "No thing to do"     fi                   done < demo.txt   

Retry command on failure but with different flags

Posted: 15 May 2021 08:55 AM PDT

So, I'm trying to retry failing or command-line with errors, BUT with different flags each time it retry...

I already know how to retry command on failure:

while ! "$@"  do    :    sleep 1  done  

As an example, I'll use the function above on a failing command on purpose to illustrate:

retry ls test # here this will usually fail and thus retry infinitely  

I'm aware this:

  • Retry infinitely (until the retried command succeed or return an exit code that is interpreted by the shell as successful)
  • Doesn't take into consideration any kind of errors/exit code other than failure whatsover

And all of the above is the wanted/expected effect.

Only thing I'm trying to add to that is support for additional flag when "retrying" N command (which I'll need to either supply as argument to the function or hardcode in the function depending on cases...)

Here what I tried:

bash  while ! "$(echo "$@" | sed "s/^pattern/pattern --otherflag/g")"  do    :    sleep 1  done  

Usage:

retry ls pattern  

Where the new command will become ls pattern --otherflag (which will obviously fail, but this is beside the point)

2nd Method:

while ! "${@/pattern/pattern --otherflag}"  do    :    sleep 1  done  

Same usage as above...

Here it will give the same result as above.

Now this seems to work on first glance, but if the supplied/failing command contain any kind of quotes, which usually come unquoted, the output/retried command will then have the quotes removed/ignored...

So following above two method/example, a command such as ls pattern "file" will become ls pattern --otherflag file where file doesn't have any quotes (same happen with single quotes).

To fix this I tried this answer's quote function but didn't manage to get satisfying result. Furthermore, it also seems like it doesn't wait/use the added flag only on failure (eg: when the retry function kicks in) but instead run it before it even fail, with the additional flags.

I don't want to have to use a if block/condition if possible and prefer to stay as close as possible to the above snippet. Prefer bash or/and sh alternative. Any feedback/answer is welcome.

Linux 64-bit SSH port numbers?

Posted: 15 May 2021 09:38 AM PDT

While there is usually no need for more than the 64k available ports, I am interested in the PoC that having a port number on 64 bits would mitigate the regular attacks on the access ports (ssh, vpn...). Having a 64b port makes it almost impossible to randomly attack a service, targeting either DoS or a login. Like

 ssh -p 141592653589793238 my.site.com  
  • Is it possible to configure Linux to use 64 bit ports? (of course both client and server should be configured)

and practically

  • Would that disturb the Internet equipment? ('transport' is OSI layer 4, above IP, thus the routing itself should not be impacted, but some devices go up to the upper layers for analysis / malware detection... ; a 64 bit ports Linux box would act as home router)

using awk to print if any three variables are true

Posted: 15 May 2021 09:38 AM PDT

i want the code print if any of these variables are true. this is not my real code, it's just an example

read -p "enter protocol: " protocol  read -p "enter src ip: " srcip  read -p "enter dst ip: " dstip  read -p "enter src port: " srcport   read -p "enter dst port: " dstport   

and so on

awk -F"," -v pro="$protocol" -v sip="$srcip" -v dip="$dstip" -v sport="$srcport"  -v dport="$dstport" '{ if(pro == "tcp" && sip == "10" && dip == "30" && sport == "4" && dport == "1")   print $1,$2,$3,$4,$5,$6,$7}' test.txt > test2.txt  

i will write it here by another way for more clarification

PROTOCOL,SRC IP,SRC PORT,DEST IP,DEST port  tcp      .10     29      .30     300  udp      .34     545     .94    90  tcp      .23     233     .23    42   

i need any three of these variables matching with user inputs, print the line

degraded iops and throughput on a linux machine in a cluster

Posted: 15 May 2021 10:02 AM PDT

we have a linux-based cluster on AWS with 8 workers.

OS version (taken from /proc/version) is:

Linux version 5.4.0-1029-aws (buildd@lcy01-amd64-021) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #30~18.04.1-Ubuntu SMP Tue Oct 20 11:09:25 UTC 2020

worker id 5 was added recently, and the problem that we see is that during times of high disk util% due to a burst of writes into the workers, the disk mounted to that worker's data dir (/dev/nvme1n1p1) shows a degraded performance in terms of w/sec and wMB/sec, which are much lower on that worker compared to the other 7 workers (~40% less iops and throughput on that broker).

the data in this table was taken from running iostat -x on all the brokers, starting at the same time and ending after 3 hours during peak time. the cluster handles ~2M messages/sec.

another strange behavior is that broker id 7 has ~40% more iops and throughput during bursts of writes compared to the other brokers.

worker type is i3en.3xlarge with one nvme ssd 7.5TB.

any idea as to what can cause such degraded performance in worker id 5 (or such a good performance on broker id 7)?

this issue is causing the consumers from this cluster to lag during high writes because worker id 5 gets into high iowait, and in case some consumer reads gets into lag and performs reads from the disk then the iowait on worker id 5 climbs into ~70% and all consumers start to lag and also the producers get OOM due buffered messages that the broker doesn't accept.

iops & throughput of all workers in the cluster (taken from iostat -x)

Kali installation failing at "Select and Install software"

Posted: 15 May 2021 09:43 AM PDT

I am trying to install Kali Linux onto VirtualBox virtual machine, but for some reason, I always get this error every time I try:

enter image description here

It can't be anything wrong with my computer, as I recently needed to reset my PC and it's still not working. I saw somewhere it might be something wrong with the network settings but am really confused as to what to do. I'd greatly appreciate any help, thanks!

Enabling core files on CentOS 8.1

Posted: 15 May 2021 08:23 AM PDT

I am trying to debug a broken application that renders X11 windows. I am running CentOS 8.1.

I have followed the instructions per Redhat on enabling core dumps.

  1. I have enabled DefaultLimitCORE=infinity in /etc/systemd/system.conf
  2. I rebooted the machine
  3. I set ulimit -c unlimited

When I try to run my application :

$ /usr/local/some/broken_executable  QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-aps003'  MESA-LOADER: failed to open swrast (search paths /usr/lib64/dri)  libGL error: failed to load driver: swrast  Aborted (core dumped)  

I don't see the core file generated either in the current working directory or in my home directory. I also tried uncommenting the #DumpCore=yes line in /etc/systemd/system.conf and rebooting the machine.

Question

  1. What am I missing here? I just want to be able to generate core files for debugging purposes.

Unable to use mouse and keyboard in Lightdm test mode

Posted: 15 May 2021 08:04 AM PDT

I have a Debian Buster as a VirtualBox guest, and when I run

/usr/bin/lightdm --test-mode --debug

I am unable to use both mouse and keyboard. (Ctrl+Shift does not help)

it outputs:

[+0.00s] DEBUG: Logging to /home/user/.cache/lightdm/log/lightdm.log  [+0.00s] DEBUG: Starting Light Display Manager 1.26.0, UID=1000 PID=7884  [+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/01_debian.conf  [+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/01_debian.conf  [+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration dirs from /usr/share/xfce4/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d  [+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf  [+0.00s] DEBUG: Running in user mode  [+0.00s] DEBUG: Using Xephyr for X servers  [+0.00s] DEBUG: Registered seat module local  [+0.00s] DEBUG: Registered seat module xremote  [+0.00s] DEBUG: Registered seat module unity  [+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager  [+0.02s] DEBUG: Monitoring logind for seats  [+0.02s] DEBUG: New seat added from logind: seat0  [+0.02s] DEBUG: Seat seat0: Loading properties from config section Seat:*  [+0.02s] DEBUG: Seat seat0: Starting  [+0.02s] DEBUG: Seat seat0: Creating greeter session  [+0.03s] WARNING: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files  [+0.03s] DEBUG: Loading user config from /etc/lightdm/users.conf  [+0.03s] DEBUG: User user added  [+0.03s] DEBUG: Seat seat0: Creating display server of type x  [+0.03s] DEBUG: posix_spawn avoided (fd close requested)   [+0.03s] DEBUG: Seat seat0: Starting local X display  [+0.03s] DEBUG: XServer 1: Logging to /home/user/.cache/lightdm/log/x-1.log  [+0.03s] DEBUG: XServer 1: Writing X server authority to /home/user/.cache/lightdm/run/root/:1  [+0.04s] DEBUG: XServer 1: Launching X Server  [+0.04s] DEBUG: Launching process 7889: /usr/bin/Xephyr :1 -seat seat0 -auth /home/user/.cache/lightdm/run/root/:1 -nolisten tcp  [+0.04s] DEBUG: XServer 1: Waiting for ready signal from X server :1  [+0.04s] DEBUG: Acquired bus name org.freedesktop.DisplayManager  [+0.04s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0  [+0.04s] DEBUG: Starting XDMCP server on UDP/IP port 177  [+0.04s] WARNING: Failed to create IPv4 XDMCP socket: Error binding to address: Permission denied  [+0.04s] WARNING: Failed to create IPv6 XDMCP socket: Error binding to address: Invalid argument  [+0.04s] DEBUG: posix_spawn avoided (automatic reaping requested) (fd close requested)   /bin/rm: no se puede borrar '/var/lib/lightdm/data/lightdm': Permiso denegado  [+0.15s] DEBUG: Got signal 10 from process 7889  [+0.15s] DEBUG: XServer 1: Got signal from X server :1  [+0.15s] DEBUG: XServer 1: Connecting to XServer :1  [+0.17s] DEBUG: Seat seat0: Display server ready, starting session authentication  [+0.17s] DEBUG: Session: Not setting XDG_VTNR  [+0.17s] DEBUG: Session pid=7894: Started with service 'lightdm-greeter', username 'user'    ** (process:7894): WARNING **: 10:40:04.829: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files  [+0.19s] DEBUG: Session pid=7894: Authentication complete with return value 0: Success  [+0.19s] DEBUG: Seat seat0: Session authenticated, running command  [+0.19s] DEBUG: Session pid=7894: Not setting XDG_VTNR  [+0.19s] DEBUG: Session pid=7894: Running command /usr/sbin/lightdm-gtk-greeter  [+0.19s] DEBUG: Creating shared data directory /var/lib/lightdm/data/user  [+0.19s] DEBUG: Session pid=7894: Logging to /home/user/.cache/lightdm/log/seat0-greeter.log  [+0.37s] DEBUG: Greeter connected version=1.26.0 api=1 resettable=false  [+0.50s] DEBUG: Greeter start authentication  [+0.50s] DEBUG: Session: Not setting XDG_VTNR  [+0.50s] DEBUG: Session pid=7909: Started with service 'lightdm', username '(null)'  [+0.52s] DEBUG: Session pid=7909: Got 1 message(s) from PAM  [+0.52s] DEBUG: Prompt greeter with 1 message(s)  ^C[+9.62s] DEBUG: Got signal 2 from process 0  [+9.62s] DEBUG: Caught Interrupt signal, shutting down  [+9.62s] DEBUG: Stopping display manager  [+9.62s] DEBUG: Seat seat0: Stopping  [+9.62s] DEBUG: Seat seat0: Stopping display server  [+9.62s] DEBUG: Sending signal 15 to process 7889  [+9.62s] DEBUG: Seat seat0: Stopping session  [+9.62s] DEBUG: Session pid=7894: Sending SIGTERM  [+9.62s] DEBUG: Seat seat0: Stopping session  [+9.62s] DEBUG: Session pid=7909: Sending SIGTERM  [+9.63s] DEBUG: Session pid=7909: Terminated with signal 2  [+9.63s] DEBUG: Session: Failed during authentication  [+9.63s] DEBUG: Seat seat0: Session stopped  [+9.63s] DEBUG: Session pid=7894: Terminated with signal 2  [+9.63s] DEBUG: Seat seat0: Session stopped  [+9.64s] DEBUG: Process 7889 exited with return value 0  [+9.64s] DEBUG: XServer 1: X server stopped  [+9.64s] DEBUG: XServer 1: Removing X server authority /home/user/.cache/lightdm/run/root/:1  [+9.64s] DEBUG: Seat seat0: Display server stopped  [+9.64s] DEBUG: Seat seat0: Stopped  [+9.64s] DEBUG: Display manager stopped  [+9.64s] DEBUG: Stopping daemon  [+9.64s] DEBUG: Exiting with return value 0  

Any ideas?

warning /dev/centos/root swap centos-root does not exist -- after configuring DRBD

Posted: 15 May 2021 10:04 AM PDT

I configured DRBD on default CentOS 7.3 Installation like following:

/dev/centos/home was taking all the space in sda2 so reduced it and created /dev/centos/home (20% space) and /dev/centos/drbd (remaining space using lvcreate -l 100%VG -n drbd centos)

DRBD resource device is /dev/drbd0 and disk is /dev/mapper/centos-drbd formatted as ext4.

Now everytime I reboot the system I get the errors:

Warning: /dev/centos/root does not exist  Warning: /dev/centos/swap does not exist  Warning: /dev/mapper/centos-root does not exist  

From dracut shell I run :

$ lvm vgscan  $ lvm vgchange -ay   $ exit  

and system boots fine. But It fails again at reboot.

Any solution?


UPDATE: Found the cause, drbd device was causing the issue. I removed it from both servers and it fixed the 2nd server but not the 1st one. blkid still shows wrong UUID and Type of /dev/sda2

$ blkid    /dev/sda1: UUID="bdfa3672-b24b-41ec-88f8-d0f0a81057d1" TYPE="xfs"  /dev/sda2: UUID="d8d241f07976f3ce" TYPE="drbd"  /dev/mapper/centos-swap: UUID="3c8653bb-060a-4e46-8eaa-ce51637752ee" TYPE="swap"  /dev/mapper/centos-root: UUID="93941d8b-22e0-4ad7-8666-1ce8ba8d1109" TYPE="xfs"  /dev/mapper/centos-home: UUID="63c9a5ad-9b4b-4852-8e95-22b356d8729a" TYPE="xfs"  

Delete all directory that begin with a particular string

Posted: 15 May 2021 09:36 AM PDT

What command do I have to use to delete all directories that begin with graphene-80 under the directory /tmp?

What can I add to the rm command as option?

slow download link with hostapd and ath9k_htc driver

Posted: 15 May 2021 08:04 AM PDT

Brief Intro:

Raspberry Pi 3 acting as a WiFi AP hosting 2.4Ghz and 5Ghz Wifi AP's. The AP of concern is the 2.4Ghz network. The NIC is a TP-Link WN722N adapter using driver ath9k_htc.

Tests:

A speedtest done from the Raspberry Pi 3 results in:

  • Download: 21.69 Mbit/s
  • Upload: 18.32 Mbit/s

which is expected and correct.

Clients connecting to the 2.4Ghz hosted network doing a speedtest results in:

  • Download: 1-11 Mbit/s (AVG: 2.5 Mbit/s)
  • Upload: 14-18 Mbit/s

note: Changing router channels does not have any effect on the download speed of hosted wifi network.

A shared ethernet connection, hosted by the Raspberry Pi, to which clients connect do not experience this issue. These achieve expected download speeds.

Question:

Since all NIC's report correct download and upload speed except the hosted wifi network (2.4Ghz adapter) using the ath9k_htc driver has slow download speed, is this an issue with the ath9k_htc driver?

Some HW Info:

note: The hosted 5Ghz network does not have this download issue, speeds are correct and as expected

NIC Info

sudo lshw -C net      *-usb:1                          description: Wireless interface         product: USB2.0 WLAN         vendor: ATHEROS         physical id: 3         bus info: usb@1:1.3         logical name: wlan2         version: 1.08         serial: 12345         capabilities: usb-2.00 ethernet physical wireless         configuration: broadcast=yes driver=ath9k_htc driverversion=4.9.35-v7+ firmware=1.3 ip=192.168.2.254 link=yes maxpower=500mA multicast=yes speed=480Mbit/s wireless=IEEE 802.11  

and hostapd config

cat /etc/hostapd/hostapd-2g.conf    interface=wlan2  driver=nl80211  ssid=local-wifi  hw_mode=g  channel=11  ieee80211n=1  wmm_enabled=1  ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]  macaddr_acl=0  auth_algs=1  ignore_broadcast_ssid=0  wpa=2  wpa_key_mgmt=WPA-PSK  wpa_passphrase=my_pass_here  rsn_pairwise=CCMP  logger_syslog=-1  

"netstat -p"/"ss -p" not showing the process of a listening port

Posted: 15 May 2021 08:51 AM PDT

On my CentOS 7, at one point, sudo ss -plt listed a port marked as LISTENING on *:30565, but there was no information whatsoever in the process column of its row. The other listening ports were showing their owning process as usual, like users:(("sshd",pid=1381,fd=3)), but that one row did not have any process information. lsof -i :30565 or netstat -p did not yield any information either.

I haven't been able to reproduce this, and I struggle to think of a situation a "non-process" might be listening on a port (as I'm quite sure Linux does the intended cleanup work when a tcp-listening process dies). As it happens with multiple programs too, the only explanation I can think of is that this is an "intended but very rootkit-y" behaviour of CentOS, but I'm most surely missing something. What might possibly have caused this?

How to use Ctrl+mouse click in tmux?

Posted: 15 May 2021 09:06 AM PDT

Due to the change in Tmux2.1, I need to remap my mouse's middle click to tmux's paste:

bind -T root MouseDown2Pane run -b "tmux paste-buffer"  

However, I also would like to enable using Ctrl (or Alt, Cmd) + middle click to paste the system's clipboard.

This is what I have tried (failed) so far:

bind -T root M+MouseDown2Pane run -b "pbpaste | tmux load-buffer -; tmux paste-buffer"  

How to add an attribute in a tag in XML file by command-line?

Posted: 15 May 2021 09:12 AM PDT

I am trying to add field at the end of tag using sed script. Suppose I have a tag in XML file:

<book name="Sed tutorial" price="250"/>  

Now I want to add field as Book_Width="A" after end of <book/> tag so that my tag becomes:

<book name="Sed tutorial" price="250" Book_Width="A"/>  

I tried with sed:

sed '/<book "[^>]*>/ a Book_Width="A"'  

but it gives:

<book name="Sed tutorial" price="250"/>  Book_Width="A"  

convert xml to csv

Posted: 15 May 2021 09:23 AM PDT

i need to convert a xml to csv using script. I found a solution with xmlstarlet but it is not available so i am returning to point 0. Here is my xml.

<root>    <record>    <id_localisation>8PJ</id_localisation>    <data>     <id_client>50C</id_client>          <mail>1@mail.com</mail>        <adress>10  </adress>        <num_tel>001</num_tel>        <key>C</key>       <contact>          <name>toto</name>          <birth>01/30/009</birth>          <city>London</city>        </contact>    </data>     <data>    <id_client>25C</id_client>         <mail>2@gmaiil.com</mail>        <adress>20</adress>        <num_tel>02200</num_tel>        <key>D1</key>        <contact>          <name>tata</name>          <birth>02/08/2004</birth>          <city>Spa</city>        </contact>    </data>   </record>    <record>    <id_localisation>ESP31</id_localisation>    <data>     <id_client>70D</id_client>                <mail>3@gmail.com</mail>            <adress>7Bcd</adress>            <num_tel>5555</num_tel>            <key>D2</key>        <contact>          <name>titi</name>          <birth>05/07/2014</birth>          <city>StMarine</city>        </contact>    </data>    <data>          <id_client>10D</id_client>            <mail>4@gmail.com</mail>            <adress>888</adress>            <num_tel>881.0</num_tel>            <key>D3</key>        <contact>          <name>awk</name>          <birth>05/08/1999</birth>          <city>Bahrein</city>        </contact>    </data>   </record>   </root>  

And the csv i need, note that the headers are output

id_localisation;id_client;key  8PJ;50C;C   8PJ;25C;D1   ESP1;70D;D2   ESP1;10D;D3  

I can't install any library but i can use awk, perl, bash so i'am open on solution.

What is $PWD? (vs current working directory)

Posted: 15 May 2021 08:26 AM PDT

So Wikipedia (link) tells me that the command pwd is short for "print working directory", and that makes sense.

But for the environment variable, the "P" has to be an acronym for something else than print.

I hear people talking about "current working directory", which sounds better and is more intuitive, but still the environment variable seems to be called $PWD, and not $CWD. Nobody ever says "Did you check the print working directory variable?".

I am currently playing around with the web application server uWSGI, and when running it tells me (on the uWSGI stats page):

"cwd":"/home/velle/greendrinks",  

so they obviously like the (more intuitive acronym) cwd over pwd.

I guess I am trying to figure out if I misunderstood something, or if it is just a matter of having given the environment variable an unintuitive name?

Why are my virtual consoles completely blank?

Posted: 15 May 2021 08:37 AM PDT

When I go from my graphical session to a virtual console by Ctrl + Alt + F i (with i in 1 - 7 and 9-12) I see a completely black screen. Only on F8 I see the GUI. Not even a blinking coursor on the others. When I enter anything, I can't see anything.

What is the problem and how do I fix it?

My system

$ uname -a  Linux pc09 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux  $ cat /etc/issue  Linux Mint 17 Qiana \n \l  $ lspci | grep VGA  01:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX Titan Black] (rev a1)  $ lspci -k | grep -A 2 -i "VGA"  01:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX Titan Black] (rev a1)  Subsystem: NVIDIA Corporation Device 1066  Kernel driver in use: nvidia  

edit: I tried the first steps suggested on http://forums.linuxmint.com/viewtopic.php?f=42&t=168108 and the problem seems to be the framebuffer.

I did this:

This has been an issue that has been an annoyance with Nvidia proprietary drivers for two or three years, and has kept me away from Ubuntu-based distros for some time. Finally, on the Nvidia forum, I found the workaround I'd been looking for. The problem arises with Nvidia proprietary drivers (Nouveau doesn't show this behavior): when you push ctrl-alt-F1, you get only a black screen or, at best, a flashing cursor that does nothing. The problem apparently, has to do with the way the framebuffer in implemented and this needs to be disabled. To see if this is the problem, first you need to make a couple of minor modifications to /etc/default/grub - but first, make a backup!

$ sudo cp /etc/default/grub /etc/default/grub.bak  

Now edit the file by entering

$ sudo pluma /etc/default/grub  

in the editor, uncomment the lines

#GRUB_TERMINAL=console  #GRUB_GFXMODE=640x480  

by removing the #. Save the file and run undate-grub to implement the changes

sudo update-grub  

Now I have (a low resultion) tty working again :-)

port being in use not displayed in netstat output

Posted: 15 May 2021 08:53 AM PDT

In what scenarios port being used by a process don't show up in netstat -a output?

I'm running jenkins on my machine. It's listening on port 8080. I'm trying to start another process that tries to bind on same port and it fails with error that port is already in use.

Now when I do netstat -a | grep 8080, it doesn't show up in output. After stopping jenkins my process successfully bound to 8080. Any clues what happening?

I'm running CentOS.

How can I find a memory leak of a running process?

Posted: 15 May 2021 08:25 AM PDT

Is there a way, I can find the memory leak of a running process? I can use Valgrind for finding memory leaks before the start of a process. I can use GDB to attach it to a running process. How could I debug a memory leaks of a running process?

No comments:

Post a Comment