Friday, August 13, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to get rid of Konsole toolbar

Posted: 13 Aug 2021 10:38 AM PDT

It happened to me after an update to Konsole.

How can I remove the icons in the red box below?

enter image description here

Ubuntu test user hogging CPU normal?

Posted: 13 Aug 2021 10:27 AM PDT

Under Ubuntu 20.x, when I run top, I get this test user hogging my CPU running ./krn

95391 test      20   0 3441736   2.3g   8048 S 901.7   8.0  51061:35 krn  

htop breaks it down even further by showing several cores at 100%, but the point is this doesn't seem correct.

What does ./krn do, and can I get rid of this user? I did recently add a cron job. Is this related to that?

If else condition to check if count has incremented

Posted: 13 Aug 2021 10:40 AM PDT

I have a awk command:

awk '/a|b|c/{sum+=1} {if($NF=="e" && sum) count++} END {print sum, count}' file  

so assume we apply this to a file letter:

a e  b d  c e  c f  d e  

This means sum should be 4, and count should be 2 since last column is e for 2 rows that matches the pattern.

But I'm getting 4 3 instead, I think it may be reading $NF=e only, but unsure of how to fix it.

Error in script to check(or wait) for availability of file in directory

Posted: 13 Aug 2021 10:16 AM PDT

I want to write a shell script that checks if trigger file is available in my directory or not. If not available I want the code to wait for, say 1 hour, and check again for availability until found. Once found, the script should complete successfully.

The trigger file name has a constant component and then a variable datetime component. E.g. Transfer-20210813061635681177 wherein Transfer- is constant and rest varies everyday.

Below is what I have tried, I put it in a Test.ksh file and tried to execute by giving ksh Test.ksh on unix server command line:

#!/bin/ksh    if [ ! -f /data/source/Transfer-* ] ; then       sleep 3600  # wait 60 minutes    fi    [ -f /data/source/Transfer-* ]  && echo 'trigger found' || echo 'trigger not found'    exit 0  

It gives the following error:

Test.ksh :Line 6: syntax error at line 6: 'if' unmatched

What could I be doing wrong here? Or how can this be further improvised and corrected. Request help.

Installing Ubuntu 21.04 with LVM on LUKS2 with integrity check returns errors when generating initramfs

Posted: 13 Aug 2021 09:36 AM PDT

TL;DR: I'm unable to generate initramfs after encrypting volumes with LUKS2 with integrity option and LVM on top of those volumes:

cryptsetup: ERROR: first: Source mismatch  cryptsetup: WARNING: target 'first_dif' not found in /etc/crypttab  cryptsetup: ERROR: second: Source mismatch  cryptsetup: WARNING: target 'second_dif' not found in /etc/crypttab  cryptsetup: WARNING: Couldn't determine cipher modules to load for first       (kernel crypto API format isn't supported yet)  cryptsetup: WARNING: Couldn't determine cipher modules to load for second       (kernel crypto API format isn't supported yet)  
root@ubuntu:/# cat /etc/crypttab  first UUID=857883dc-7f1d-470f-9ed7-a06f3624b677 none luks,discard  second UUID=4ca53199-307f-4503-a042-c6bb62ea5a47 none luks,discard  
root@ubuntu:/# fdisk -l    Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors  Disk model: Samsung SSD 970 EVO Plus 500GB            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: 8DF308CC-B48D-4834-8B1F-EDE77A831CC7    Device           Start       End   Sectors   Size Type  /dev/nvme0n1p1    2048   1050623   1048576   512M EFI System  /dev/nvme0n1p2 1050624   2099199   1048576   512M Linux filesystem  /dev/nvme0n1p3 2099200 976773134 974673935 464.8G unknown      Disk /dev/nvme1n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors  Disk model: SAMSUNG MZVLB512HBJQ-000H1                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: 03D068B8-37FA-4B26-A8BF-A67455D9AED3    Device         Start        End    Sectors   Size Type  /dev/nvme1n1p1  2048 1000215182 1000213135 476.9G unknown      Disk /dev/mapper/first_dif: 437.35 GiB, 469598490624 bytes, 917184552 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/first: 437.35 GiB, 469598490624 bytes, 917184552 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/second_dif: 448.81 GiB, 481905954816 bytes, 941222568 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/second: 448.81 GiB, 481905954816 bytes, 941222568 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/system-swap: 36 GiB, 38654705664 bytes, 75497472 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/system-root: 850.15 GiB, 912844128256 bytes, 1782898688 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  

And here's full info on how I installed the system:

My disk layout is this (unknown to fdisk is 8309, Linux LUKS):

root@ubuntu:~# fdisk -l  Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors  Disk model: Samsung SSD 970 EVO Plus 500GB            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: 8DF308CC-B48D-4834-8B1F-EDE77A831CC7    Device           Start       End   Sectors   Size Type  /dev/nvme0n1p1    2048   1050623   1048576   512M EFI System  /dev/nvme0n1p2 1050624   2099199   1048576   512M Linux filesystem  /dev/nvme0n1p3 2099200 976773134 974673935 464.8G unknown      Disk /dev/nvme1n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors  Disk model: SAMSUNG MZVLB512HBJQ-000H1                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: 03D068B8-37FA-4B26-A8BF-A67455D9AED3    Device         Start        End    Sectors   Size Type  /dev/nvme1n1p1  2048 1000215182 1000213135 476.9G unknown  

I have used this command to create a LUKS2 volume and used it for 2 volumes: /dev/nvme0n1p3 and /dev/nvme1n1p1

cryptsetup luksFormat --type luks2 /dev/nvme0n1p3 --integrity hmac-sha256  cryptsetup luksFormat --type luks2 /dev/nvme1n1p1 --integrity hmac-sha256  

Then I opened the volumes:

cryptsetup luksOpen /dev/nvme0n1p3 first  cryptsetup luksOpen /dev/nvme1n1p1 second  

cryptsetup created 4 volumes:

Disk /dev/mapper/first_dif: 437.35 GiB, 469598490624 bytes, 917184552 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/first: 437.35 GiB, 469598490624 bytes, 917184552 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/second_dif: 448.81 GiB, 481905954816 bytes, 941222568 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes      Disk /dev/mapper/second: 448.81 GiB, 481905954816 bytes, 941222568 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  

Then I created 2 physical volumes, added them to the volume group, created 2 logical volumes swap and root:

root@ubuntu:~# pvs    PV                 VG     Fmt  Attr PSize    PFree    /dev/mapper/first  system lvm2 a--   437.34g    0     /dev/mapper/second system lvm2 a--  <448.81g    0   root@ubuntu:~# vgs    VG     #PV #LV #SN Attr   VSize   VFree    system   2   2   0 wz--n- 886.15g    0   root@ubuntu:~# lvs    LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert    root system -wi-ao---- 850.15g                                                        swap system -wi-ao----  36.00g  

After that I formatted the partitions and installed Ubuntu 21.04 through graphical installer (no errors occured during the installation):

/dev/nvme0n1p1 as EFI, FAT32  /dev/nvme0n1p2 as /boot, ext4  /dev/system/root as /, ext4  /dev/system/swap as swap  

Then I did this and chrooted into /mnt:

mount /dev/system/root /mnt  mount /dev/nvme0n1p2 /mnt/boot  mount /dev/nvme0n1p1 /mnt/boot/efi  mount --bind /dev /mnt/dev  mount --bind /run/lvm /mnt/run/lvm  

After chrooting:

mount -t proc proc /proc  mount -t sysfs sys /sys   mount -t devpts devpts /dev/pts  

Then I looked up the UUIDs of those LUKS partitions:

root@ubuntu:~# blkid | grep LUKS  /dev/nvme0n1p3: UUID="857883dc-7f1d-470f-9ed7-a06f3624b677" TYPE="crypto_LUKS" PARTLABEL="Linux LUKS" PARTUUID="ca894a49-5867-4a3a-bff1-fc1a0affaa18"  /dev/nvme1n1p1: UUID="4ca53199-307f-4503-a042-c6bb62ea5a47" TYPE="crypto_LUKS" PARTLABEL="Linux LUKS" PARTUUID="35ce7fcd-2c76-45cf-884a-6c9a8a2439ef"  

And created the following /etc/crypttab:

first UUID=857883dc-7f1d-470f-9ed7-a06f3624b677 none luks,discard  second UUID=4ca53199-307f-4503-a042-c6bb62ea5a47 none luks,discard  

And after all this the update-initramfs does not work:

root@ubuntu:/# update-initramfs -u -k all  update-initramfs: Generating /boot/initrd.img-5.11.0-25-generic  cryptsetup: ERROR: first: Source mismatch  cryptsetup: WARNING: target 'first_dif' not found in /etc/crypttab  cryptsetup: ERROR: second: Source mismatch  cryptsetup: WARNING: target 'second_dif' not found in /etc/crypttab  cryptsetup: WARNING: Couldn't determine cipher modules to load for first       (kernel crypto API format isn't supported yet)  cryptsetup: WARNING: Couldn't determine cipher modules to load for second       (kernel crypto API format isn't supported yet)  

What should I do in order to fix this?

mkstemp failing with RHEL 8 OS non-root user

Posted: 13 Aug 2021 09:36 AM PDT

I have small script which creates a tmp files using mkstemp. My script was created using root user , but if I logged in as someother user other than root then my scripts runs but msktemp fails and says permission denied

sh: /tmp/tmpFile-khB5hH: Permission denied

Same thing while doing in RHEL 7 works and no Permission denied error, what is changed in RHEL 8. looks like RHEL 8 is checking logged on user vs effective user.

I tested this up in RHEL 7.5 and RHEL 8.4.

If someone know change in RHEL 8 which leads to permission problems please suggest. Thanks

How can I delete a rEFInd boot entry?

Posted: 13 Aug 2021 10:33 AM PDT

I'd like to remove the first entry to leave only the Debian entry, with GRUB I know how to do it but how can I with rEFInd?

enter image description here

how to change grub for doing the script

Posted: 13 Aug 2021 09:07 AM PDT

after cloning my HDD on an OPEN SUSE 13.1 PC with Acronis True Image 2021 I followed the advices written on the Acronis pages. ATI-CLONE_LINUX-INFO But when I start now I come in the GRUB2 CLI. when I do

    set root=(hd0,1)      cofnigfile /boot/grub2/grub.cfg  

I can boot. What need I to do that this is done automatically at boottime? SOrry to ask this simply question, but I am novice to GRUB and GRUB2.

Thanks Walter

I need a Linux GUI distro which is lightweight and supports Python 3.7+

Posted: 13 Aug 2021 08:16 AM PDT

I am in search of a Linux "GUI" distro which also has python

the distro must be under these criterion:

1. Be able to run on Virtual Box  2. ISO under 250mb  3. Total OS disk space: below 2.5gb  4. RAM needed: under 500mb  5. Have sudo, etc.. pre-installed  6. be able to run python 3.7 or above  7. it is a GUI OS  8. it doesn't matter if it is x86 or arm or x64  9. have basic necessary softwares:     + terminal     + code editor     + nothing more  

Does swap out of memory pages belonging to a process pauses or stop the process itself?

Posted: 13 Aug 2021 09:51 AM PDT

I have a real-time networking application that is extremely sensitive to any kind of "blocking" and needs to be extremely responsive most of the time with perfect latency.

The app (multithreaded) itself is unfortunately quite memory hungry, it needs about 6GB of RAM.

The system had 8GB RAM with 2GB swap. I observed some performance issues with increased app latency that I connected to swapping events (OS is monitored using grafana and node_exporter every 15 seconds), exactly in same time as bad latency happened, the OS was swapping out some pages (while still having 2GB available memory).

I understand Linux kernel VM subsystem fairly well (I read Mel Gorman's "Understanding the Linux® Virtual Memory Manager" book) so I am associating this with the OS proactively swapping out inactive pages to get more space for FS cache / buffers, which I wouldn't really mind, if it wasn't crippling the latency of this application.

I set vm.swappiness = 0 in order to get kernel to use swap only as last resort when low mem watermark is reached, but to no avail - it keeps swapping out tiny chunks of memory approx. every 30 minutes, crippling the latency of application.

Only thing that helped was disabling swap entirely - ever since I did that latency issues never reoccurred. But that is also a bit of problem, because if some unfortunate situation happened when app would temporarily need more memory approaching the 8GB of total usage, OOM killer would now kill it, instead of swapping out portion of inactive pages, which would be even worse scenario than crippled latency.

So I have 2 questions:

  • Why are these small swapout events crippling the latency of application? My understanding is that swapper is evicting inactive memory pages anyway - is the process frozen when swapper moves its memory, even if it doesn't try to access the pages that aren't in RAM or that are being moved?
  • Is there any way to enforce kernel to swap ONLY when necessary? Eg. - don't swap when > 1GB of RAM is still available?

Manjaro Flash Drive not booting

Posted: 13 Aug 2021 09:50 AM PDT

What is my problem?

I tried to install Manjaro on a Flash drive but it was not bootable for some reason.

The thing is, that I still want to be able to use it as a normal drive. For this reason, I went with the manual partitioning option. I selected my USB device, and created these partitions:

Size - Filesystem - Mountpoint - Flags

1GB - FAT32 - /boot/efi - boot, bios-grub

32GB - NTFS - /mnt/usb - msft-data

10GB - ext4 - /home - no flags

all the space left - ext4 - / - root

To create these partitions I selected manual partitioning. On the screen, where I could select the way to partition the drive (override, install alongside, manual) It neyt to the drive dropdown menu "EFI" (I guess, that this meams, that my pc has a UEFI and not a BIOS) and GPT.

After the installation I went into the bios and set my drive as the number one in the boot hierachy. I also disabled all other options. After saving the changes it showed me the infamous "Reboot ans Select proper boot device"-screen.

I suspect it has something do with the partitioning but I'm not sure.

Help would be very much appreciated. Sincerely yours, Trqhxrd

How do I log all commands executed by all users

Posted: 13 Aug 2021 10:06 AM PDT

I'd like to get the logs in the following format in one log line:

user_x executed command_y  

I have found the following solutions:

but here it is saving only the commands executed by the root user.

I have tried using audit rules as well, but the above solutions are more accurate regarding my use case.

Audit Rules save the logs in different lines with different types: SYSCALL (user info), EXECVE (executed command args), etc. Instead, I need this information in one log line.

I have followed these steps:

  1. Edit /etc/rsyslog.d/bash.conf:

    vim /etc/rsyslog.d/bash.conf  

    and add the following:

    local6.*    /var/log/commands.log  
  2. Open /root/.bashrc:

    vim /root/.bashrc  

    and enter the following:

    # Enable CLI Logging  whoami="$(whoami)@$(echo $SSH_CONNECTION | awk '{print $1}')"export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$whoami [$$] $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" )"'  
  3. Restart rsyslog service:

    sudo service rsyslog restart  

With the above, the logs are saved in /var/log/commands.log in the following format:

Aug 13 10:10:31 ip-172-31-3-192 ec2-user: root [19399] cat /var/log/commands.log  

and the commands are saved only if I use sudo su (root). If I exit from sudo su and execute any command, then the commands don't get saved in /var/log/commands.log.

Hope this is clear.

Looping through the directories

Posted: 13 Aug 2021 08:16 AM PDT

paths=$1  files=$2  for dir in ${paths[@]}  do      newdir=${dir##*/}      newpath=(/pathname)      val=`mkdir -p ${newpath}/${newdir}`      echo ${val}        for file in "${dir}"/*; do          if [[ -f $file && $file = *.@(c|cc|cpp|h) ]]; then              cp ${file} ${val}          fi      done  done  

I want to loop through the directories and copy the filenames in the newly created val directory..but I am unable to print the value of val. What am I doing wrong?

I cant wrap command inside watch

Posted: 13 Aug 2021 08:33 AM PDT

I have got this perfectly working command:

netstat -tuplean | awk '{NR>1; if( $6 ~ /ESTABLISHED/ ) print "\033[0;31m" $5  "   \033[01;31m"$6;if ($6 ~ /_WAIT/ ) print "\033[0;34m"$5  "   \033[01;32m"$6}'  

I cannot wrap it into a watch command. Here is what I tried:

  1. escape all single quotes (')

    watch 'netstat -tuplean | awk '\''{NR>1; if( $6 ~ /ESTABLISHED/ ) print "\033[0;31m" $5  "   \033[01;31m"$6    if ($6 ~ /_WAIT/ ) print "\033[0;34m"$5  "   \033[01;32m"$6}'\'''    

    output:

    ^[0;31m34.210.39.83:443   ^[01;31mESTABLISHED  ^[0;31m34.107.221.82:80   ^[01;31mESTABLISHED  ^[0;31m34.107.221.82:80   ^[01;31mESTABLISHED  ^[0;34m34.117.59.81:80   ^[01;32mTIME_WAIT  ^[0;34m34.117.59.81:80   ^[01;32mTIME_WAIT  ^[0;31m192.168.0.1:67   ^[01;31mESTABLISHED  
  2. escape both single and double quotes (' and ")

    watch 'netstat -tuplean | awk '\''{NR>1; if( $6 ~ /ESTABLISHED/ ) print '\'"\033[0;31m'\'" $5  "   \033[01;31m'\'"$6    if ($6 ~ /_WAIT/ ) print '\'"\033[0;34m'\'"$5  '\'"   \033[01;32m'\'"$6}'\'''  

    output:

     bash: syntax error near unexpected token `print'  
  3. export the command and then call it back this way:

     while : do ...<cmd>...; sleep 2;done   watch -n 3 -x bash -c "$cmd"   

    it does not work neither because the same pb occurs when defining the variable.

  4. I tried to make a script using while : do ...<cmd>...; sleep 2;done

    it does not work because it looks like the sleep delay is not taken into account so the output comes out so fast there is no way to read something.

How to log these 5 minutes with awk and then convert the output to another file

Posted: 13 Aug 2021 09:53 AM PDT

I have a log file whose name is listlog, the content is:

2021-08-12 16:09:17 textsp sdgg  reponse:success  prams:invalid  line 3  2021-08-12 16:10:17 textdfdfdlfs sfdfs  reponse: failed  prams:valid  line 3  

I want to filter the logs recorded between t1 and t2 and print the log line with 2 consecutive lines. I wrote using awk with if condition and grep. But I got the error:

This is the content I want to filter and write to a new file assuming t1 < (16:09:17, 16:19:17) < t2 :

2021-08-12 16:09:17 textsp sdgg  reponse:success  prams:invalid  2021-08-12 16:10:17 textdfdfdlfs sfdfs  reponse: failed  prams:valid  

here is the awk script i wrote:

t1=$(date -d "$min_change minutes ago" +"%F %T")  t2=$(date +"%F %T")  cat $listlog | awk -v t1="$t1" -v t2="$t2" -v listlog="$listlog" '{          if (match($0 ~ /^[0-9]{4}(-[0-9]{2}){2}))          {                  if ( $0 > t1 && $0 < t2 | $0 ~ t2 )                  {                          grep -A 2 $0 $listlog >> /tmp/temp.txt                  }          }          }'  

This is the error I get:

awk: cmd. line:2:       if (match($0 ~ /^[0-9]{4}(-[0-9]{2}){2}))  awk: cmd. line:2:                       ^ unterminated regexp  awk: cmd. line:3:       if (match($0 ~ /^[0-9]{4}(-[0-9]{2}){2}))  awk: cmd. line:3:                                                ^ unexpected newline or end of string  awk: cmd. line:4:               if ( $0 > t1 && $0 < t2 | $0 ~ t2 )  awk: cmd. line:4:                                         ^ syntax error.  awk: cmd. line:5:               if ( $0 > t1 && $0 < t2 | $0 ~ t2 )   awk: cmd. line:5:                                                   ^ unexpected newline or end of string  awk: cmd. line:6:                       grep -A 2 $0 $listlog >> /temp/temp.txt  awk: cmd. line:6:                                             ^ syntax error  awk: cmd. line:7:                       grep -A 2 $0 $listlog >> /temp/temp.txt.  awk: cmd. line:7:                                                                ^ unexpected newline or end of string  

Possible causes of PCI nic card and motherboards eth ports not available for use by os?

Posted: 13 Aug 2021 09:22 AM PDT

hi all so I have an old linux server that was resurrected for a particular reason and I flashed the server with the image of redhat 6 that was previously used for these servers. after doing so though the os does not make the pci nic card placed in a pci expansion slot available I cant even see it as a device using ifconfig, now I can see the 2 ports attached to the motherboard in ifconfig but these too are not available or managed by the network manager service. This is what I am seeing from my end.

>ifconfig  eth4      Link encap:Ethernet  HWaddr B4:96:91:4E:13:F1              UP BROADCAST MULTICAST  MTU:9000  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:1000             RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)            Memory:fb100000-fb200000     eth5      Link encap:Ethernet  HWaddr B4:96:91:4E:13:F0              inet addr:192.9.200.11  Bcast:192.9.200.255  Mask:255.255.255.0            UP BROADCAST MULTICAST  MTU:9000  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:1000             RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)            Memory:fb200000-fb300000   

this is what I pulled from dmesg that looked relevant

pci 0000:09:00.0: [8086:1533] type 0 class 0x000200  pci 0000:09:00.0: reg 10: [mem 0xce800000-0xce87ffff]  pci 0000:09:00.0: reg 18: [io  0x5000-0x501f]  pci 0000:09:00.0: reg 1c: [mem 0xce880000-0xce883fff]  pci 0000:09:00.0: PME# supported from D0 D3hot D3cold  pci 0000:09:00.0: PME# disabled  pci 0000:00:1c.2: PCI bridge to [bus 09-09]  pci 0000:00:1c.2:   bridge window [io  0x5000-0x5fff]  pci 0000:00:1c.2:   bridge window [mem 0xce800000-0xce8fffff]  pci 0000:0a:00.0: [8086:1533] type 0 class 0x000200  pci 0000:0a:00.0: reg 10: [mem 0xce700000-0xce77ffff]  pci 0000:0a:00.0: reg 18: [io  0x4000-0x401f]  pci 0000:0a:00.0: reg 1c: [mem 0xce780000-0xce783fff]  pci 0000:0a:00.0: PME# supported from D0 D3hot D3cold  pci 0000:0a:00.0: PME# disabled      pci 0000:81:00.0: [8086:1521] type 0 class 0x000200  pci 0000:81:00.0: reg 10: [mem 0xfb200000-0xfb2fffff]  pci 0000:81:00.0: reg 1c: [mem 0xfb304000-0xfb307fff]  pci 0000:81:00.0: PME# supported from D0 D3hot D3cold  pci 0000:81:00.0: PME# disabled  pci 0000:81:00.0: reg 184: [mem 0x00000000-0x00003fff 64bit pref]  pci 0000:81:00.0: reg 190: [mem 0x00000000-0x00003fff 64bit pref]  pci 0000:81:00.1: [8086:1521] type 0 class 0x000200  pci 0000:81:00.1: reg 10: [mem 0xfb100000-0xfb1fffff]  pci 0000:81:00.1: reg 1c: [mem 0xfb300000-0xfb303fff]  pci 0000:81:00.1: PME# supported from D0 D3hot D3cold  pci 0000:81:00.1: PME# disabled  pci 0000:81:00.1: reg 184: [mem 0x00000000-0x00003fff 64bit pref]  pci 0000:81:00.1: reg 190: [mem 0x00000000-0x00003fff 64bit pref]    NET: Registered protocol family 10  igb 0000:81:00.1: changing MTU from 1500 to 9000  ADDRCONF(NETDEV_UP): eth4: link is not ready  igb 0000:81:00.0: changing MTU from 1500 to 9000  ADDRCONF(NETDEV_UP): eth5: link is not ready  type=1400 audit(1628863781.555:4): avc:  denied  { sys_tty_config } for  pid=6008 comm="kexec" capability=26  scontext=system_u:system_r:kdump_t:s0 tcontext=system_u:system_r:kdump_t:s0 tclass=capability  type=1400 audit(1628863781.556:5): avc:  denied  { write } for  pid=6008 comm="kexec" path="/dev/pts/0" dev=devpts ino=3 scontext=system_u:system_r:kdump_t:s0 tcontext=syste      dca service started, version 1.12.1  Intel(R) Gigabit Ethernet Network Driver - version 3.2.10-k  Copyright (c) 2007-2011 Intel Corporation.  igb 0000:81:00.0: PCI INT A -> GSI 50 (level, low) -> IRQ 50  igb 0000:81:00.0: setting latency timer to 64  igb 0000:81:00.0: irq 110 for MSI/MSI-X  igb 0000:81:00.0: irq 111 for MSI/MSI-X  igb 0000:81:00.0: irq 112 for MSI/MSI-X  igb 0000:81:00.0: irq 113 for MSI/MSI-X  igb 0000:81:00.0: irq 114 for MSI/MSI-X  igb 0000:81:00.0: irq 115 for MSI/MSI-X  igb 0000:81:00.0: irq 116 for MSI/MSI-X  igb 0000:81:00.0: irq 117 for MSI/MSI-X  igb 0000:81:00.0: irq 118 for MSI/MSI-X  igb 0000:81:00.0: Intel(R) Gigabit Ethernet Network Connection  igb 0000:81:00.0: eth0: (PCIe:5.0Gb/s:Width x4) b4:96:91:4e:13:f0  igb 0000:81:00.0: eth0: PBA No: H47819-003  igb 0000:81:00.0: Using MSI-X interrupts. 8 rx queue(s), 8 tx queue(s)  igb 0000:81:00.1: PCI INT B -> GSI 52 (level, low) -> IRQ 52  igb 0000:81:00.1: setting latency timer to 64  igb 0000:81:00.1: irq 119 for MSI/MSI-X  igb 0000:81:00.1: irq 120 for MSI/MSI-X  igb 0000:81:00.1: irq 121 for MSI/MSI-X  igb 0000:81:00.1: irq 122 for MSI/MSI-X  igb 0000:81:00.1: irq 123 for MSI/MSI-X  igb 0000:81:00.1: irq 124 for MSI/MSI-X  igb 0000:81:00.1: irq 125 for MSI/MSI-X  igb 0000:81:00.1: irq 126 for MSI/MSI-X  igb 0000:81:00.1: irq 127 for MSI/MSI-X  igb 0000:81:00.1: Intel(R) Gigabit Ethernet Network Connection  igb 0000:81:00.1: eth1: (PCIe:5.0Gb/s:Width x4) b4:96:91:4e:13:f1  igb 0000:81:00.1: eth1: PBA No: H47819-003  igb 0000:81:00.1: Using MSI-X interrupts. 8 rx queue(s), 8 tx queue(s)  

so I can see they are all there as well as the pci id I also checked to make sure the device driver was present and it is and is loaded

lsmod | grep igb  igb                   113015  0   dca                     6877  1 igb    

I saw that the igb kernel driver was being used for the expansion card but not the onboard ethernet ports on the motherboard could this cause them all to be inaccessible? any advice on how to correct the issue of my ports not being available to the os would be greatly appreciated

Delete X lines after and Y lines before matching line

Posted: 13 Aug 2021 10:22 AM PDT

I have the following string:

core1@pci0:2:0:1:  class=0x020000 rev=0x00 hdr=0x00 vendor=0x1453      vendor     = 'MicSystem'      device     = 'controller'      class      = network      subclass   = ethernet  none65@pci0:2:0:2:      class=0x080100 rev=0x00 hdr=0x00 vendor=0x1453      vendor     = 'MicSystem'      device     = 'interface'      class      = base peripheral      subclass   = DMA controller  core1@pci0:2:0:1:  class=0x020000 rev=0x00 hdr=0x00 vendor=0x1453      vendor     = 'MicSystem'      device     = 'controller'      class      = network      subclass   = ethernet  

I have to remove 3 lines before and 1 line after where 'class = base peripheral', for example:

core1@pci0:2:0:1:  class=0x020000 rev=0x00 hdr=0x00 vendor=0x1453      vendor     = 'MicSystem'      device     = 'controller'      class      = network      subclass   = ethernet  core1@pci0:2:0:1:  class=0x020000 rev=0x00 hdr=0x00 vendor=0x1453       vendor     = 'MicSystem'      device     = 'controller'      class      = network      subclass   = ethernet  

I didn't manage to do that, this is done in FreeBSD OS.

Linux Mint Live & Ubuntu ISO's failing to boot (failed to execute /init)

Posted: 13 Aug 2021 09:41 AM PDT

Tested ISO's:

  • ubuntu-20.04.2.0-desktop-amd64
  • linuxmint-20-cinnamon-64bit
  • linuxmint-20.1-cinnamon-64bit
  • linuxmint-20.2-cinnamon-64bit

All of these images fail to boot with No working init found on one specific system (i tested the images and usb stick on other systems, there they booted fine)

I had also extracted the initrd.lz file and verified that an /init script is available

Somehow about ~7 months ago, i could install image linuxmint-20.1-cinnamon-64bit successfully on the system, but now i need to reinstall the system to have an clean install (same iso (verified with sha256sum and option Integrity Check), same USB stick, same system trying to run), but now all of these images fail with the same error

I also tried adding the boot option init=/init which failed with Requested init /init failed (error -2)

Screenshot (literally) with the normal live option: kernel Panic Screenshot

I am not experienced enough to make my own installer (or actually to extract the iso and make it bootable in hybrid mode, while not breaking the installer itself)

System (where its failing):

  • Intel Atom D425 (in 64bit mode)
  • 2GB DDR 3 ram (tested that nothing is corrupt)
  • BIOS supporting UEFI (though no specific partition boot is available)

Note: i tried all 3 options in the mint grub menu (normal live, compat live, oem install), but none of them worked

Note: nothing physical can have happened to the system and not really any "software" changes either, because since the last mentioned successfully install, it has been sitting in an shelf without being powered on in the meantime

PS: i also tried manjaro-kde-21.0.5-minimal-210519-linux510 which failed at pacman-keyring because of an invalid opcode

Grub problem with fresh install of Ubuntu 20.04

Posted: 13 Aug 2021 09:48 AM PDT

I have just installed Ubuntu 20.04 on my thinkpad. Everything work but when I boot the PC, the grub command line appears. I can login into the system following the steps described here: https://www.linux.com/training-tutorials/how-rescue-non-booting-grub-2-linux/ .

My problem is that I cannot make those changes persist. I have followed the instructions but they do not work. I have algo generated a boot-repair report, in case you need it: https://paste.ubuntu.com/p/T6XQCyX2CF/

To add more information, I executed these commands:

enter image description here

Just to clarify, I do not have dual boot, before trying to install Ubuntu 20.04 I had Ubuntu 18.04.

Any idea what's going on?

Installing centos, error - failed to find suitable stage1 device

Posted: 13 Aug 2021 09:04 AM PDT

On my machine i already have windows. On free space of 100gb, I created 3 partitions for new centos installation - /boot 500mb, swap 8gb, and / of remaining 90gb. All are of type standard partition, and file system type ext4(except swap which is of type swap)

Its giving me error checking storage configuration - failed to find suitable stage1 device:Efi system partition must be mounted on one of /boot/efi

Whats the reason for this? Also will it interfere in dual boot?

awk search and replace string in a specific column of CSV file

Posted: 13 Aug 2021 08:10 AM PDT

I have a csv file with 17 columns and million rows. I want to search for a specific string in the 16th column and replace all the instances of that string with another string. Since my rest of the program uses bash script, I thought using awk instead of Python search & replace. My current OS is Rhel6.

The following is the sample output of my data:

SUBSCRIBER_ID|ACCOUNT_CATEGORY|ACCOUNT_ACTIVATION_DATE|PACKAGE_NAME|PACKAGE_TYPE|DURATION|ACTIVE_DATE|INACTIVE_DATE|STB_NO|PRIMARY_SECONDARY|MODEL_TYPE|VC_NO|MULTIROOM|STB_TYPE|IPKG|SERVICE_STATE|CURRENT_STATUS  1001098068|ResidentialRegular|01/20/2007|Annual package 199 May17 pack|Basic Package|Annual|08/28/2017||027445053518|Primary|Pace - 31|000223871682|Yes|AMP|Package 199 pack|Market1|Active  1001098068|ResidentialRegular|01/20/2007|Annual Pack|Premium Package|Annual|08/28/2017||027445053518|Primary|Pace - 31|000223871682|Yes|AMP|English Movies pack|Market1|Active  1001098068|ResidentialRegular|01/20/2007|Annual SingleUnit Jun17 Pack|Secondary Pack|Annual|08/28/2017||032089364015|Secondary|Kaon|000017213968|Yes|AMP|SingleUnit|Market2|Active  

In this the 16th column is Market, wherein I want to change the Market1 to MarketPrime. The name of the file is marketinfo_2018-06-26.csv

I tried the following code:

awk -F '| +' '{gsub("Market1","MarketPrime",$16); print}' OFS="|" marketinfo_2018-06-26.csv > marketinfo_2018-06-26.csv  

This runs without any output, but the string Market1 still remains.

How to create a permanent symlink to a device?

Posted: 13 Aug 2021 09:05 AM PDT

I want to create a symlink to a device.When i tried the command

ln -s /dev/sr0 /dev/scd0  

it looked everything well.But when i restarted the server,i found /dev/scd0 is disappered. How can i create a permanent link?

Shell Script: creating a variable with options inside

Posted: 13 Aug 2021 09:15 AM PDT

I have a rsync command with following parameters:

rsync -avz --{partial,stats,delete,exclude=".*"}  

I want to put that parameters inside a variable to reuse it after in the script. Something like this:

#!/bin/bash  VAR=rsync -avz --{partial,stats,delete,exclude=".*"}  $VAR /dir1 /dir2  

I've tried with quotes, single quotes, brackets, without any success.

One prompt pkexec - two command

Posted: 13 Aug 2021 09:57 AM PDT

Someone could answer me how make one prompt via pkexec when I've to use two command with authentication? My easy sample script:

pkexec virsh net-start default;  pkexec "/home/user/program";  

I'm new in linux environmen, Thanks :)

How to use variables in a filename?

Posted: 13 Aug 2021 10:03 AM PDT

How do I use variables in a filename correctly? This is what I'm doing, but it seems the underline makes some problems:

domain="example"  sub="foo"    if [ -f /opt/nginx/conf.d/com_$domain_$sub.conf ]    cat <<EOF > /opt/nginx/conf.d/com_$domain_$sub.conf  some multiline  content  EOF  fi  

Re-encoding video with ffmpeg including all subtitles but not all audio

Posted: 13 Aug 2021 10:16 AM PDT

I'm trying to re-encode video streams from a Matroska file to save space, while keeping all the subtitles as-is, using ffmpeg. I want to write a generic command that works without me having to specify exact stream numbers. Now I can't figure out how to let ffmpeg pick its default video stream and default audio stream and then all subtitles.

The current input file I'm working with has these streams, but other files will have different streams.

    [lavf] stream 0: video (mpeg2video), -vid 0      [lavf] stream 1: audio (ac3), -aid 0, -alang eng, Surround 5.1      [lavf] stream 2: audio (ac3), -aid 1, -alang fre, Surround 5.1      [lavf] stream 3: audio (ac3), -aid 2, -alang ita, Surround 5.1      [lavf] stream 4: audio (ac3), -aid 3, -alang spa, Surround 5.1      [lavf] stream 5: audio (ac3), -aid 4, -alang eng, Stereo      [lavf] stream 6: subtitle (dvdsub), -sid 0, -slang eng      [lavf] stream 7: subtitle (dvdsub), -sid 1, -slang fre      [lavf] stream 8: subtitle (dvdsub), -sid 2, -slang ita      [lavf] stream 9: subtitle (dvdsub), -sid 3, -slang spa      [lavf] stream 10: subtitle (dvdsub), -sid 4, -slang ara      [lavf] stream 11: subtitle (dvdsub), -sid 5, -slang dan      [lavf] stream 12: subtitle (dvdsub), -sid 6, -slang dut      [lavf] stream 13: subtitle (dvdsub), -sid 7, -slang fin      [lavf] stream 14: subtitle (dvdsub), -sid 8, -slang ice      [lavf] stream 15: subtitle (dvdsub), -sid 9, -slang nor      [lavf] stream 16: subtitle (dvdsub), -sid 10, -slang por      [lavf] stream 17: subtitle (dvdsub), -sid 11, -slang swe      [lavf] stream 18: subtitle (dvdsub), -sid 12, -slang fre      [lavf] stream 19: subtitle (dvdsub), -sid 13, -slang ita      [lavf] stream 20: subtitle (dvdsub), -sid 14, -slang spa  

Commands I have tried:

ffmpeg -i IN.mkv -c:v libx264 -threads 4 -speed 1 -f matroska OUT.mkv

Result: One video stream, one audio stream, no subtitle streams.

ffmpeg -i IN.mkv -c:v libx264 -threads 4 -speed 1 -f matroska -c:s copy OUT.mkv

Result: One video stream, one audio stream, one subtitle stream.

ffmpeg -i IN.mkv -c:v libx264 -threads 4 -speed 1 -f matroska -map 0 OUT.mkv

Result: All video, all audio, all subtitles.

ffmpeg -i IN.mkv -c:v libx264 -threads 4 -speed 1 -f matroska -c:s copy -map 0:s OUT.mkv

Result: No video, no audio, all subtitles.

As far as I can tell from the manual, -c:s copy is supposed to copy all the streams, not just the default one, but it won't. Perhaps it's a bug?

To clarify, what I'm after is the result: one video, one audio and all subtitles.

Directory permissions for web server

Posted: 13 Aug 2021 10:00 AM PDT

I'm experiencing a problem having to do with permissions to a directory on my server. The file permissions initially read drwx--S--- and I was able to connect with an FTP client signed in as the directory owner and manage the directory, but when I tryed to view them from a browser I get the "Forbidden" message saying I don't have permission to view the files. I noticed if I use

sudo chmod -R 644 my_directory  

which changes the directory's permissions to drw-r-Sr-- and then use

sudo chmod g+x my_directory  

to change the directory's permissions to drw-r-sr--, I can read the files from any browser, but can no longer transfer or view files via FTP to that directory.

Mounting Directory - Connection Refused

Posted: 13 Aug 2021 10:07 AM PDT

I am trying to mount a Directory from my server to my local machine. This is because I want to edit the directory and execute the files without having the manually push the files to the server after each edit.

I am using NFS and currently getting: 'Connection refused' when I try to mount from a machine on the same network.

My server ip is 192.168.0.12.
My local machine ip is 192.168.0.2. And in /etc/exports I have:

/mnt/export 192.168.0.0/24(rw,async,no_subtree_check)  /mnt/export *(rw)  

where /mnt/export is the directory I want to mount and I have chmod 777 -r the directory

On my local machine I execute this command:

mount 192.168.0.12:/mnt/export /Desktop/tes  

But get this error:

can't mount /mnt/export from 192.168.0.12 onto /Desktop/tes:  Connection refused  

Does anyone have any idea to where I am going wrong?

How can I remove duplicates in my .bash_history, preserving order?

Posted: 13 Aug 2021 09:57 AM PDT

I really enjoying using control+r to recursively search my command history. I've found a few good options I like to use with it:

# ignore duplicate commands, ignore commands starting with a space  export HISTCONTROL=erasedups:ignorespace    # keep the last 5000 entries  export HISTSIZE=5000    # append to the history instead of overwriting (good for multiple connections)  shopt -s histappend  

The only problem for me is that erasedups only erases sequential duplicates - so that with this string of commands:

ls  cd ~  ls  

The ls command will actually be recorded twice. I've thought about periodically running w/ cron:

cat .bash_history | sort | uniq > temp.txt  mv temp.txt .bash_history  

This would achieve removing the duplicates, but unfortunately the order would not be preserved. If I don't sort the file first I don't believe uniq can work properly.

How can I remove duplicates in my .bash_history, preserving order?

Extra Credit:

Are there any problems with overwriting the .bash_history file via a script? For example, if you remove an apache log file I think you need to send a nohup / reset signal with kill to have it flush it's connection to the file. If that is the case with the .bash_history file, perhaps I could somehow use ps to check and make sure there are no connected sessions before the filtering script is run?

How to get the char at a given position of a string in shell script?

Posted: 13 Aug 2021 10:06 AM PDT

How to get the char at a given position of a string in shell script?

No comments:

Post a Comment