Sunday, June 13, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Printing content of file from nth line to nth line [Shell Scripting] [duplicate]

Posted: 13 Jun 2021 12:09 AM PDT

**

> Hey buddies I have a file having names of 200 countries.I want to print names of countries from 50th line to 80th line .How can i do so in bash??

**

Set Windows like default entry with efibootmgr, but showing menu

Posted: 12 Jun 2021 11:40 PM PDT

I have this menu starting my laptop. As you can see, I have multiple entries for CentOS 8. But, I want to set like default, my Windows Boot Manager (on /dev/nvme01p1) entry…

I was thinking in efibootmgr.

Reading this article https://www.lifewire.com/change-the-efi-boot-order-efibootmgr-4028027

Is it possible to keep the menu entries, changing to Windows with efibootmgr?

enter image description here

Automatic reboot after suspend

Posted: 12 Jun 2021 11:39 PM PDT

I'm a new user to Linux Mint and I've had issues with the graphic driver. I updated the kernel to 5.8 which solves the problem of adjusting the brightness or being able to wake up from suspend. But now my new problem is that after waking up from suspend, the computer automatically restarts just in a few minutes. Can anyone suggest what I should do? Thanks!

The following is what I got from

inxi -Fxxxrz          System:    Kernel: 5.8.0-55-generic x86_64 bits: 64 compiler: N/A     Desktop: Cinnamon 4.8.6 wm: muffin 4.8.1 dm: LightDM 1.30.0     Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal   Machine:    Type: Laptop System: LENOVO product: 20TA005GIV v: ThinkPad E14 Gen 2     serial: <filter> Chassis: type: 10 serial: <filter>     Mobo: LENOVO model: 20TA005GIV serial: <filter> UEFI: LENOVO     v: R1EET34W(1.34 ) date: 02/25/2021   Battery:    ID-1: BAT0 charge: 36.1 Wh condition: 45.0/45.0 Wh (100%) volts: 12.2/11.3     model: Celxpert 5B10X026 type: Li-poly serial: <filter>     status: Discharging cycles: 2   CPU:    Topology: Quad Core model: 11th Gen Intel Core i7-1165G7 bits: 64     type: MT MCP arch: Tiger Lake rev: 1 L2 cache: 12.0 MiB     flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx     bogomips: 44851     Speed: 1200 MHz min/max: 400/4700 MHz Core speeds (MHz): 1: 1200 2: 1200     3: 1200 4: 1200 5: 1200 6: 1200 7: 1199 8: 1195   Graphics:    Device-1: Intel vendor: Lenovo driver: i915 v: kernel bus ID: 00:02.0     chip ID: 8086:9a49     Display: x11 server: X.Org 1.20.9 driver: modesetting unloaded: fbdev,vesa     resolution: 1920x1080~60Hz     OpenGL: renderer: Mesa Intel Xe Graphics (TGL GT2) v: 4.6 Mesa 20.2.6     direct render: Yes   Audio:    Device-1: Intel vendor: Lenovo driver: snd_hda_intel v: kernel     bus ID: 00:1f.3 chip ID: 8086:a0c8     Sound Server: ALSA v: k5.8.0-55-generic   Network:    Device-1: Intel driver: iwlwifi v: kernel port: 4000 bus ID: 00:14.3     chip ID: 8086:a0f0     IF: wlp0s20f3 state: up mac: <filter>     Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet     vendor: Lenovo driver: r8169 v: kernel port: 3000 bus ID: 04:00.0     chip ID: 10ec:8168     IF: enp4s0 state: down mac: <filter>   Drives:    Local Storage: total: 476.94 GiB used: 66.47 GiB (13.9%)     ID-1: /dev/nvme0n1 vendor: Samsung model: MZALQ512HALU-000L1     size: 476.94 GiB speed: 31.6 Gb/s lanes: 4 serial: <filter> rev: BL1QFXV7     scheme: GPT   Partition:    ID-1: / size: 467.96 GiB used: 66.46 GiB (14.2%) fs: ext4     dev: /dev/nvme0n1p2   Sensors:    System Temperatures: cpu: 45.0 C mobo: 42.0 C     Fan Speeds (RPM): cpu: 0   Repos:    No active apt repos in: /etc/apt/sources.list     Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list     1: deb http://packages.linuxmint.com ulyssa main upstream import backport #id:linuxmint_main    2: deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse    3: deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse    4: deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse    5: deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse    6: deb http://archive.canonical.com/ubuntu/ focal partner  Info:    Processes: 248 Uptime: 5m Memory: 15.35 GiB used: 1.36 GiB (8.9%)     Init: systemd v: 245 runlevel: 5 Compilers: gcc: 9.3.0 alt: 9 Shell: bash     v: 5.0.17 running in: gnome-terminal inxi: 3.0.38   

The weird order when concating variables and string with '_' [duplicate]

Posted: 12 Jun 2021 10:38 PM PDT

I tried to concat the variable and string.

while read subject;  do  pathproc=/projects/guo_lab/cbis/users/yang/DICA_result  echo  ${pathproc}/${subject}"_"weight  done < /projects/guo_lab/cbis/users/yang/Fulllist_tractography.txt  

The result shows that

_weightrojects/guo_lab/cbis/users/yang/DICA_result/609812419171

Why is this happening, the correct form in my mind is /projects/users/yang/DICA_result/609812419171_weight. How can I get this?

By the way, if I delete the _weight, it just give /projects/users/yang/DICA_result/609812419171.

Thanks so much.

Add more partition to NVMe SoftRAID

Posted: 12 Jun 2021 10:09 PM PDT

I have SoftRAID setup on CentOS on my NVMe Drive (2x1TB) . Issue is I only provisioned 80GB and I now want to provision more for additional space. Can someone please help me do this. Here is output of lsblk https://pastebin.com/6jjvqD9d

Server hang while rebooting Getting below error, what is the issue the environment is rhel 5.4?

Posted: 12 Jun 2021 09:56 PM PDT

Server hang while rebooting Getting below error, what is the issue? Environment is RHEL 5.4

umount2: device or resource busy  umount: /usr : device is busy  umount2: device or resource busy  umount: /tmp : device is busy  umount2: device or resource busy  umount: /tmp : device is busy                                [FAILED]  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  

How to enable broadcasting for loopback

Posted: 12 Jun 2021 09:19 PM PDT

I'm on a linux environment and I'm trying to send a broadcast to my loopback. I wanted to enable broadcast for my loopback interface but I can't see to get it to show on ifconfig.

For example:

eth0      Link encap:Ethernet  HWaddr 00:01:c0:1c:2f:c4            inet addr:192.168.65.100  Bcast:192.168.65.255  Mask:255.255.255.0            UP BROADCAST MULTICAST  MTU:1500  Metric:1            RX packets:71533771 errors:0 dropped:0 overruns:0 frame:0            TX packets:71186348 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:1000            RX bytes:53742272 (51.2 MiB)  TX bytes:1860694332 (1.7 GiB)            Interrupt:234    lo        Link encap:Local Loopback            inet addr:127.0.0.1  Mask:255.0.0.0            UP LOOPBACK RUNNING  MTU:65536  Metric:1            RX packets:949519134 errors:0 dropped:0 overruns:0 frame:0            TX packets:949519134 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:0            RX bytes:164243352358 (152.9 GiB)  TX bytes:164243352358 (152.9 GiB)  

eth0 displays UP BROADCAST MULTICAST where as lo displays UP LOOPBACK RUNNING how does one enable broadcast on the loopback interface. I imagine broadcast on loopback would be using address 127.255.255.255?

Extracting *full* linux headers from source

Posted: 12 Jun 2021 07:15 PM PDT

Linux kernel sources are full of quirks to support multiple architectures and scenarios. This means I cannot simply copy all *.h files and use a gcc -S -save-temps trick or anything similar to get preprocessed headers.

I was wondering how can I export full full kernel-space headers from the source tree properly?

  • make headers_install ARCH=i386 INSTALL_HDR_PATH=... builds only user-space/API headers. This will skip for example nameidata struct
  • make deb-pkg builds the kernel binary AND kernel headers (I cannot build the binary for unrelated reasons)

OpenSource Homework script

Posted: 12 Jun 2021 08:27 PM PDT

I need to make a startup script for a user with commands in the Terminal console. The orders are:

  1. Get started with the script and no information or welcome the performer.
  2. Make sure you make a choice in it (eg by means of an if statement)
  3. Make sure the selected web server is installed.
  4. Finally, install all the components you need with your web server:
  5. PHP (required for nextcloud)
  6. Mysql/Mariadb

The installation:

  1. Use the script to install your chosen web server on your linux machine.
  2. Install the necessary modules as well

Unable to validate LUKS encryption

Posted: 12 Jun 2021 11:37 PM PDT

Hello I have a question about LUKS encryption. I have used LUKS to encrypt a disk on my server but when I create a file and add content to it, and cat the file, the content is still in plain text. Even when I create a backup of the file, and put it on the non-encrypted hard drive, the data is in plain text. I'm not sure how I can say that encryption is happening. Am I missing something? Is this how LUKS is supposed to work?

/dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS"  [root@host1 ~]# cat /opt/my_encrypted_backup/test12  This is a test  [root@host1 ~]# clear  [root@host1 ~]# lsblk  NAME            MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT  sda               8:0    0    8G  0 disk  ├─sda1            8:1    0    1G  0 part  /boot  └─sda2            8:2    0    7G  0 part    ├─centos-root 253:0    0  6.2G  0 lvm   /    └─centos-swap 253:1    0  820M  0 lvm   [SWAP]  sdb               8:16   0    1G  0 disk  └─mybackup      253:2    0 1022M  0 crypt /opt/my_encrypted_backup  sr0              11:0    1 1024M  0 rom  [root@host1 ~]#  [root@host1 ~]#  [root@host1 ~]# blkid /dev/sdb  /dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS"  [root@host1 ~]#  [root@host1 ~]#  [root@host1 ~]# cat /opt/my_encrypted_backup/test12  This is a test  [root@host1 ~]# cp /opt/my_encrypted_backup/test12 /  [root@host1 ~]# cat /test12  This is a test  [root@host1 ~]#  

Ideal ratio of tcp_max_syn_backlog and net.core.somaxconn

Posted: 12 Jun 2021 05:30 PM PDT

Googling about TCP: Possible SYN flooding on port bring a lot of results, some places says to just increase somaxconn, other syn backlog

But there is little information in how those values should be calculated, and what would the ideal ratio between them.

I believe people would benefit from a answer teaching more than just tell people to use an arbitrary value.

Some places says to use 65536 on somaxconn others says only 2048, and so on...

Will this auto-respawn bash script work?

Posted: 12 Jun 2021 04:55 PM PDT

I've been having issues with my eth miner, nsfminer, crashing on me when I leave it on at night. Sometimes this occurs after 2-8 hours of mining, while sometimes it doesn't occur at all. It usually exits with a message that I can't recall off the top of my head. I did some searching on my own and threw together a bash script using an until loop and was wondering if this should work in theory. Usually I would just test it on my own because that's the best way to learn, but considering I may have to wait 8 hours for a crash or it may not even crash at all for several days, I'd like to know if this script will work before I potentially lose $5-10 of profit. It seems to work just fine when I run it, but I don't know if the autorespawn works as I've yet to leave it running for long enough to see if it crashes.

until echo PASSWORD | sudo -S ./nsfminer --cu-block 256 --cu-streams 4 -P stratum+tcp://USERNAME:PWDARGS@domain:PORT; do      echo "nsfminer crashed with exit code $?" >&2      sleep 1  done  

I understand the security implications involved in passing a root password via a bash script, but it's the only way to get the miner to work as it requires root privileges and I have the system partitioned in a way that the installation I use for crypto mining only has mining stuff and i3 installed on it and doesn't have any passwords stored in plaintext in any files. It's otherwise a minimal ubuntu install with most of the applications stripped away. I intend in the future to perhaps go the debian stable route, or maybe start from ubuntu server which I have tried before but I just haven't had the time to get everything working with nvidia drivers being a pain and all. Thanks for any help from anyone more knowledgeable than me.

How networking works with forwarding disabled?

Posted: 12 Jun 2021 04:54 PM PDT

I think on most systems the network forwarding is disabled by default - so the computer cannot act as a router. I wonder, how then does networking inside of the computer work? A few examples:

  • hosting a website locally - when we host the site locally and try to access it locally, we have to send an HTTP request - this request needs to be forwarded back to lo interface
  • virtualization - virtual machines add additional virtual adapters to the computer. It is possible to communicate between various NICs - isn't that also forwarding?

What is then really disabled when network forwarding is disabled in the system?

So, I need to display the total number of files in a directory, so how can I use "ls -la" command in vi editor using functions

Posted: 13 Jun 2021 12:49 AM PDT

Here is the code I have so far:

#! /bin/sh  Hello()  echo "Enter the directory"  read dir  {   echo "The directory $dir has a total of:"  }  Hello()  

Does sudo apt install command also update an already installed app?

Posted: 13 Jun 2021 12:52 AM PDT

I'm new to Linux OS distributions and I came up with a question when I had to update my Visual Studio Code today. I've searched for some solutions to update it through my terminal and every solution involved applying the command sudo apt install code. So here is my question, if I already have the application installed I can simply "install it again"?

How do I extract the digits from a line and save it into a variable?

Posted: 12 Jun 2021 10:40 PM PDT

I feel like this is a really easy question, and when I Google, I find lots of answers for part of the problem, but when I try to put them together, it doesn't work and I can't figure out why.

Here's the scenario:

  1. I have a file with a lot of text in it.
  2. One of those lines matches this pattern: foo = 1700;
  3. I want to extract 1700
  4. I want to save it into a bash script variable so I can refer to it later in the script.

I cannot get past step 3. Here's what I've tried:

sed -nE 's/^foo = //p' file | sed -nE 's/;//p'  

This prints out:

1700  

Great, but what if I need to trim white space or something? If I can't use */+, I wouldn't know how to do that. I learned that you can't use */+ in a substitution on another answer, so I can't figure out how to do this. I looked into the man page of grep, and I didn't see any option for groups when I search for that word. I think I know how to solve this in awk, but I've always found its regex functions to be a little clunky and for the commandline scripts to require too many escapes, so ideally that's not the only way to solve this.

Correcting .zshrc to ~/.zshrc

Posted: 12 Jun 2021 05:45 PM PDT

Is there a way to set some kind of an alias so that when I do:

cd some/directory  vim .zshrc  

It does vim ~/.zshrc?

Question regarding awk 'NF {p=1} p'

Posted: 12 Jun 2021 05:19 PM PDT

Searching for a way to remove blank lines from the beginning and the end of a file, I've stumbled across this one:

awk 'NF {p=1} p'  

How / why does this work?

I understand NF is only true if there are any fields (if the line is not a blank line).

Is it possible to execute commands outside of a rule using GNU Make?

Posted: 12 Jun 2021 07:59 PM PDT

Is it possible to execute commands outside of a rule using GNU Make?

Consider the following Makefile:

x = foo bar baz    ifdef x      @echo $(x)  endif  

This results in Makefile:4: *** commands commence before first target. Stop.

However, if I add a rule, it works:

x = foo bar baz    ifdef x  t:      @echo $(x)  endif  

Is it really necessary to add rules for outputting variables for debugging, etc.?

Bonus:

Why does the removal of ifdef result in Makefile:3: *** missing separator. Stop.?

x = foo bar baz    @echo $(x)  

I can’t get to my CentOS 8, Failed to switch root, '/sysroot'

Posted: 12 Jun 2021 10:46 PM PDT

I have only pictures. And I can't write the Question well.

I was starting my laptop (I have Windows 10 Pro and CentOS8).

systemctl status initrd-switch-root.service

https://i.stack.imgur.com/fuGRU.jpg

https://i.stack.imgur.com/CAQ7Y.jpg

The last image Failed to Start Switch Root. And

Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree. os-release file is missing.  

https://i.stack.imgur.com/onWbr.jpg

Doing a ls -al /sysroot the directory is empty.

With dmesg i got:

enter image description here

any idea why this failure occurs?

And obviously, how I can solve it?

In the image, the only entry working is Rescue The CentOS entry that is above the Windows entry CentOS Linux (0-rescue-***) enter image description here

Please help.

EDIT 1 Using described on https://unix.stackexchange.com/a/212710/117555

  1. Check dev -> ls -al /dev/s*
  2. Insert the USB stick
  3. Check Again -> ls -al /dev/s*
  4. Create Mounting Directory -> mkdir -p /mnt/logError_SwitchRoot
  5. Mount the stick -> mount /dev/sd[letter][number] /mnt/logError_SwitchRoot
  6. Copy the File -> cp /run/initramfs/rdsosreport.txt /mnt/logError_SwitchRoot
  7. Umount the stick -> umount /mnt/logError_SwitchRoot

I have now on rdsosreport.txt file on https://drive.google.com/file/d/1vMK0QAoyMZ7xTibDqn8Y_Y9nohUStN-6/view?usp=sharing

Checking the File:

    /dev/nvme0n1p1: LABEL="SYSTEM_DRV" UUID="5464-19F2" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="31ebd6ef-ec98-42c7-a57b-7855c2c9a1f3"      /dev/nvme0n1p5: LABEL="WINRE_DRV" UUID="C2EC6975EC69651F" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="51363955-3d66-4f95-92de-732ccff36936"      /dev/nvme0n1p6: LABEL="boot_efi" UUID="6E91-210B" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="5291c15b-2f5c-42a0-b3e3-2c69f27b801b"      /dev/nvme0n1p7: UUID="7471a525-f8c8-4a77-819e-65b40c04eaaf" TYPE="ext4" PARTUUID="13b3a31b-193f-4ef5-9076-a083cdc857de"      /dev/nvme0n1p8: UUID="d1ee8d12-37a1-43e7-9f13-0f97544864aa" TYPE="ext4" PARTUUID="88cd29e2-3b20-44e4-bdf4-0ce02d9008d6"      /dev/nvme0n1p9: UUID="54f24598-4a21-4875-bacd-61c060de891f" TYPE="ext4" PARTUUID="d1126852-240f-4e03-a8f3-86f769b3fd77"      /dev/nvme0n1p10: UUID="3fc5f4f8-566b-48e2-85e1-59f5dccdcb57" TYPE="ext4" PARTUUID="b2190e39-3ee8-4a41-a156-6a866ee8ee14"      /dev/nvme0n1p11: UUID="42640b78-ce32-403c-8705-8c12e2d02855" TYPE="swap" PARTUUID="acc07fc2-4876-42c0-9d02-b066c04cfd4f"      /dev/sda1: LABEL="EFI" UUID="67E3-17ED" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="5cd547d2-a0ef-4c51-8a00-9877055342bb"      /dev/nvme0n1: PTUUID="e24c5cda-1faa-490b-b677-7c4792194960" PTTYPE="gpt"      /dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" PARTUUID="b692aa4c-0d83-40f0-8707-cd0b49290b00"      /dev/nvme0n1p3: PARTLABEL="Basic data partition" PARTUUID="72f573a8-4b1d-40ab-900c-5b2b608fa964"      /dev/nvme0n1p4: PARTLABEL="Basic data partition" PARTUUID="50badba8-609d-4a24-b957-c8f90b8d7d80"      /dev/sda2: PARTUUID="f704e2d2-a0b9-4fa4-9b19-cef07c8b6668"  

And

BOOT_IMAGE=(hd1,gpt7)/vmlinuz-5.8.0-1.el8.elrepo.x86_64  

EDIT 2:

I found some pictures of my installation (5 July 2020 15:05, for my reference)!

DATA      /home      nvme0n1p8    SYSTEM      /boot/efi      nvme0n1p6        /var      nvme0n1p10        /      nvme0n1p9        /boot      nvme0n1p7        swap      nvme0n1p11  

Here my info (After the restart)

[root@centos /]# lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,UUID,MOUNTPOINT  NAME         MAJ:MIN RM   SIZE RO FSTYPE   UUID                                 MOUNTPOINT  loop0          7:0    0  29.8M  1 squashfs                                      /var/lib/snapd/snap/snapd/8140  loop1          7:1    0    55M  1 squashfs                                      /var/lib/snapd/snap/core18/1754  loop2          7:2    0  29.9M  1 squashfs                                      /var/lib/snapd/snap/snapd/8542  loop3          7:3    0    55M  1 squashfs                                      /var/lib/snapd/snap/core18/1880  loop4          7:4    0    97M  1 squashfs                                      /var/lib/snapd/snap/core/9665  loop5          7:5    0  62.1M  1 squashfs                                      /var/lib/snapd/snap/gtk-common-themes/1506  nvme0n1      259:0    0   477G  0                                                 ├─nvme0n1p1  259:1    0   260M  0 vfat     5464-19F2                              ├─nvme0n1p2  259:2    0    16M  0                                                 ├─nvme0n1p3  259:3    0 115.7G  0                                                 ├─nvme0n1p4  259:4    0   104G  0                                                 ├─nvme0n1p5  259:5    0  1000M  0 ntfs     C2EC6975EC69651F                       ├─nvme0n1p6  259:6    0     1G  0 vfat     6E91-210B                            /boot/efi  ├─nvme0n1p7  259:7    0     1G  0 ext4     7471a525-f8c8-4a77-819e-65b40c04eaaf /boot  ├─nvme0n1p8  259:8    0   174G  0 ext4     d1ee8d12-37a1-43e7-9f13-0f97544864aa /home  ├─nvme0n1p9  259:9    0    32G  0 ext4     54f24598-4a21-4875-bacd-61c060de891f /  ├─nvme0n1p10 259:10   0    24G  0 ext4     3fc5f4f8-566b-48e2-85e1-59f5dccdcb57 /var  └─nvme0n1p11 259:11   0    24G  0 swap     42640b78-ce32-403c-8705-8c12e2d02855 [SWAP]  [root@centos /]#   

I have this list...

/tmp/nvme0n1p6/:  total 16  drwxr-xr-x 4 root root 4096 Jan  1  1970 .  drwxr-xr-x 6 root root  120 Jun 11 02:11 ..  drwxr-xr-x 4 root root 4096 Jul  5  2020 EFI  -rwxr-xr-x 1 root root 4096 Jan  1  1980 FSCK0000.REC  drwxr-xr-x 2 root root 4096 Jul 22  2020 System Volume Information    /tmp/nvme0n1p6/EFI:  total 16  drwxr-xr-x 4 root root 4096 Jul  5  2020 .  drwxr-xr-x 4 root root 4096 Jan  1  1970 ..  drwxr-xr-x 2 root root 4096 Jul  5  2020 BOOT  drwxr-xr-x 3 root root 4096 Aug 23  2020 centos    /tmp/nvme0n1p6/EFI/BOOT:  total 1544  drwxr-xr-x 2 root root    4096 Jul  5  2020 .  drwxr-xr-x 4 root root    4096 Jul  5  2020 ..  -rwxr-xr-x 1 root root 1211224 May  7  2020 BOOTX64.EFI  -rwxr-xr-x 1 root root  356800 May  7  2020 fbx64.efi    /tmp/nvme0n1p6/EFI/centos:  total 5360  drwxr-xr-x 3 root root    4096 Aug 23  2020 .  drwxr-xr-x 4 root root    4096 Jul  5  2020 ..  -rwxr-xr-x 1 root root     134 May  7  2020 BOOTX64.CSV  drwxr-xr-x 2 root root    4096 Apr 14  2020 fonts  -rwxr-xr-x 1 root root    5502 Jul  5  2020 grub.cfg  -rwxr-xr-x 1 root root       0 Aug 23  2020 grubenv  -rwxr-xr-x 1 root root 1877384 Apr 14  2020 grubx64.efi  -rwxr-xr-x 1 root root 1160136 May  7  2020 mmx64.efi  -rwxr-xr-x 1 root root 1205152 May  7  2020 shimx64-centos.efi  -rwxr-xr-x 1 root root 1211224 May  7  2020 shimx64.efi    /tmp/nvme0n1p6/EFI/centos/fonts:  total 8  drwxr-xr-x 2 root root 4096 Apr 14  2020 .  drwxr-xr-x 3 root root 4096 Aug 23  2020 ..    /tmp/nvme0n1p6/System Volume Information:  total 8  drwxr-xr-x 2 root root 4096 Jul 22  2020 .  drwxr-xr-x 4 root root 4096 Jan  1  1970 ..  

And this another List

/tmp/nvme0n1p7/:  total 360344  dr-xr-xr-x 7 root   root      4096 Aug 11  2020 .  drwxr-xr-x 7 root   root       140 Jun 11 02:17 ..  -rw-r--r-- 1 root   root       166 Dec  4  2019 .vmlinuz-4.18.0-147.el8.x86_64.hmac  -rw-r--r-- 1 root   root       172 Jun 10  2020 .vmlinuz-4.18.0-193.6.3.el8_2.x86_64.hmac  drwxrwxrwx 2 nobody 65534     4096 Sep  7  2020 System Volume Information  -rw------- 1 root   root   3838259 Dec  4  2019 System.map-4.18.0-147.el8.x86_64  -rw------- 1 root   root   3910484 Jun 10  2020 System.map-4.18.0-193.6.3.el8_2.x86_64  -rw------- 1 root   root   4654688 Jul  7  2020 System.map-5.7.8-1.el8.elrepo.x86_64  -rw------- 1 root   root   4714527 Aug  2  2020 System.map-5.8.0-1.el8.elrepo.x86_64  -rw-r--r-- 1 root   root    184613 Dec  4  2019 config-4.18.0-147.el8.x86_64  -rw-r--r-- 1 root   root    187643 Jun 10  2020 config-4.18.0-193.6.3.el8_2.x86_64  -rw-r--r-- 1 root   root    197087 Jul  7  2020 config-5.7.8-1.el8.elrepo.x86_64  -rw-r--r-- 1 root   root    201589 Aug  2  2020 config-5.8.0-1.el8.elrepo.x86_64  drwxr-xr-x 2 root   root      4096 Jul  5  2020 efi  drwx------ 2 root   root      4096 Apr 14  2020 grub2  -rw------- 1 root   root  71713525 Jul  5  2020 initramfs-0-rescue-fb78af0a9247484aad9831a10a928084.img  -rw------- 1 root   root  49320247 Jul  6  2020 initramfs-4.18.0-147.el8.x86_64.img  -rw------- 1 root   root  18223920 Jul  6  2020 initramfs-4.18.0-147.el8.x86_64kdump.img  -rw------- 1 root   root  49864041 Jul  6  2020 initramfs-4.18.0-193.6.3.el8_2.x86_64.img  -rw------- 1 root   root  18642820 Jul  6  2020 initramfs-4.18.0-193.6.3.el8_2.x86_64kdump.img  -rw------- 1 root   root  50414753 Jul 15  2020 initramfs-5.7.8-1.el8.elrepo.x86_64.img  -rw------- 1 root   root  50395127 Aug 11  2020 initramfs-5.8.0-1.el8.elrepo.x86_64.img  drwxr-xr-x 3 root   root      4096 Jul  5  2020 loader  drwx------ 2 root   root     16384 Jul  5  2020 lost+found  -rwxr-xr-x 1 root   root   8106744 Jul  5  2020 vmlinuz-0-rescue-fb78af0a9247484aad9831a10a928084  -rwxr-xr-x 1 root   root   8106744 Dec  4  2019 vmlinuz-4.18.0-147.el8.x86_64  -rwxr-xr-x 1 root   root   8913656 Jun 10  2020 vmlinuz-4.18.0-193.6.3.el8_2.x86_64  -rwxr-xr-x 1 root   root   8558528 Jul  7  2020 vmlinuz-5.7.8-1.el8.elrepo.x86_64  -rwxr-xr-x 1 root   root   8742176 Aug  2  2020 vmlinuz-5.8.0-1.el8.elrepo.x86_64    /tmp/nvme0n1p7/System Volume Information:  total 12  drwxrwxrwx 2 nobody 65534 4096 Sep  7  2020 .  dr-xr-xr-x 7 root   root  4096 Aug 11  2020 ..  -rw-rw-rw- 1 nobody 65534   76 Sep  7  2020 IndexerVolumeGuid    /tmp/nvme0n1p7/efi:  total 8  drwxr-xr-x 2 root root 4096 Jul  5  2020 .  dr-xr-xr-x 7 root root 4096 Aug 11  2020 ..    /tmp/nvme0n1p7/grub2:  total 8  drwx------ 2 root root 4096 Apr 14  2020 .  dr-xr-xr-x 7 root root 4096 Aug 11  2020 ..  lrwxrwxrwx 1 root root   25 Apr 14  2020 grubenv -> ../efi/EFI/centos/grubenv    /tmp/nvme0n1p7/loader:  total 12  drwxr-xr-x 3 root root 4096 Jul  5  2020 .  dr-xr-xr-x 7 root root 4096 Aug 11  2020 ..  drwx------ 2 root root 4096 Aug 11  2020 entries    /tmp/nvme0n1p7/loader/entries:  total 28  drwx------ 2 root root 4096 Aug 11  2020 .  drwxr-xr-x 3 root root 4096 Jul  5  2020 ..  -rw-r--r-- 1 root root  395 Jul  5  2020 fb78af0a9247484aad9831a10a928084-0-rescue.conf  -rw-r--r-- 1 root root  323 Jul  5  2020 fb78af0a9247484aad9831a10a928084-4.18.0-147.el8.x86_64.conf  -rw-r--r-- 1 root root  353 Jul  6  2020 fb78af0a9247484aad9831a10a928084-4.18.0-193.6.3.el8_2.x86_64.conf  -rw-r--r-- 1 root root  356 Jul 15  2020 fb78af0a9247484aad9831a10a928084-5.7.8-1.el8.elrepo.x86_64.conf  -rw-r--r-- 1 root root  356 Aug 11  2020 fb78af0a9247484aad9831a10a928084-5.8.0-1.el8.elrepo.x86_64.conf    /tmp/nvme0n1p7/lost+found:  total 20  drwx------ 2 root root 16384 Jul  5  2020 .  dr-xr-xr-x 7 root root  4096 Aug 11  2020 ..  

How I know what is /sysroot?

I haven't /boot/efi mounted, neither /boot directory!

How I can mount /boot/efi?

grub commands aren't working!

EDIT 3

In order to solve this problem

# grub2-editenv list  grub2-editenv: error: invalid environment block.  # grub2-editenv set  grub2-editenv: error: invalid environment block.  #   

I follow https://access.redhat.com/solutions/5622731

# mv /boot/grub2/grubenv /boot/grub2/grubenv.bak  # grub2-set-default 1  # grub2-editenv list  saved_entry=1  # grub2-editenv set  #  

EDIT 4:

https://www.golinuxcloud.com/update-grub2-grubby-grub2-editenv-rhel-8/ Checking https://www.techbrown.com/change-default-grub-entries-timeout-centos-rhel/ Works for me

# grub2-editenv - set "kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro"  

After Restart

[root@centos /]# grub2-editenv list  saved_entry=1  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   [root@centos /]#   

EDIT 5:

[root@centos /]# grub2-editenv list  saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=1  [root@centos /]#   

For me it's estrange this line:

saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64  

EDIT 6:

[root@centos /]# ls -al /boot/efi/EFI/centos/  total 5820  drwx------. 3 root root    4096 Jun 11 13:50 .  drwx------. 4 root root    4096 Nov 16  2020 ..  -rwx------. 1 root root     134 Jul 31  2020 BOOTX64.CSV  drwx------. 2 root root    4096 Mar  2 16:03 fonts  -rwx------. 1 root root    5502 Jul  5  2020 grub.cfg  -rwx------. 1 root root       0 Aug 23  2020 grubenv.bak  -rwx------. 1 root root 2285336 Mar  2 16:03 grubx64.efi  -rwx------. 1 root root 1162400 Jul 31  2020 mmx64.efi  -rwx------. 1 root root 1238416 Jul 31  2020 shimx64-centos.efi  -rwx------. 1 root root 1244496 Jul 31  2020 shimx64.efi  [root@centos /]# ls -al /boot/grub2/  total 20  drwx------. 2 root root 4096 Jun 12 22:20 .  dr-xr-xr-x. 7 root root 4096 Jun 11 13:58 ..  -rw-r--r--. 1 root root 5503 Jun 11 05:01 grub.cfg  -rw-------. 1 root root 1024 Jun 12 22:20 grubenv  lrwxrwxrwx. 1 root root   25 Apr 14  2020 grubenv.bak -> ../efi/EFI/centos/grubenv  [root@centos /]# cat /boot/grub2/grubenv  # GRUB Environment Block  saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=1  #################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#  

enter image description here

Obviously something wrong!!! The /efi/EFI/centos/grubenv file does not exist and /boot/grub2/grubenv seems that is malformed.

According to this link https://bugzilla.redhat.com/show_bug.cgi?id=1435435 The physical file must be located in /efi/EFI/centos/grubenv and a symlink /boot/grub2/grubenv should be pointing to /efi/EFI/centos/grubenv.

How can I create the /efi/EFI/centos/grubenv file, without editing it directly?

And

[root@centos /]# awk -F\' '/^menuentry/ {print $2}' /boot/grub2/grub.cfg  Windows Boot Manager (on /dev/nvme0n1p1)  System setup  [root@centos /]#    [root@centos /]# awk -F\' '/^menuentry/ {print $2}' /boot/efi/EFI/centos/grub.cfg  Windows Boot Manager (on /dev/nvme0n1p1)  System setup  [root@centos /]#    [root@centos /]# grub2-mkconfig -o /boot/grub2/grub.cfg.bck  Generating grub configuration file ...  Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi  Adding boot menu entry for EFI firmware configuration  done  [root@centos /]#    [root@centos /]# awk -F\' '/^menuentry/ {print $2}' /boot/grub2/grub.cfg.bck  Windows Boot Manager (on /dev/nvme0n1p1)  System setup  [root@centos /]#  

Why are the Linux entries not appearing? I follow this link

# ls -al /boot/loader/entries  total 36  drwx------. 2 root root 4096 Jun 11 13:57 .  drwxr-xr-x. 3 root root 4096 Jul  5  2020 ..  -rw-r--r--. 1 root root  395 Jul  5  2020 fb78af0a9247484aad9831a10a928084-0-rescue.conf  -rw-r--r--. 1 root root  358 Jun 11 11:36 fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64.conf  -rw-r--r--. 1 root root  353 Jul  5  2020 fb78af0a9247484aad9831a10a928084-4.18.0-193.6.3.el8_2.x86_64.conf  -rw-r--r--. 1 root root  336 Jun 11 13:57 fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64.conf  -rw-r--r--. 1 root root  366 Jun 11 12:05 fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64.conf  -rw-r--r--. 1 root root  356 Jul 15  2020 fb78af0a9247484aad9831a10a928084-5.7.8-1.el8.elrepo.x86_64.conf  -rw-r--r--. 1 root root  356 Aug 11  2020 fb78af0a9247484aad9831a10a928084-5.8.0-1.el8.elrepo.x86_64.conf  [root@centos /]#  

And following this answer https://stackoverflow.com/a/64637392

I list all # grubby --info=ALL

I view a specific # grubby --info 0

Check what was my default

[root@centos /]# grubby --info DEFAULT  index=3  kernel="/boot/vmlinuz-4.18.0-305.3.1.el8.x86_64"  args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"  root="UUID=54f24598-4a21-4875-bacd-61c060de891f"  initrd="/boot/initramfs-4.18.0-305.3.1.el8.x86_64.img $tuned_initrd"  title="CentOS Linux (4.18.0-305.3.1.el8.x86_64) 8"  id="fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64"  [root@centos /]#  

I was trying to change the default with # grubby --args amd_iommu=on --update-kernel=/boot/vmlinuz-$(uname -r) and with grubby --args amd_iommu=on --update-kernel 2 But it does not work (using # grubby --info DEFAULT)!

Reviewing 0 Entry

[root@centos /]# grubby --info 0  index=0  kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"  args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"  root="UUID=54f24598-4a21-4875-bacd-61c060de891f"  initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"  title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"  id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"  [root@centos /]#  

And following https://unix.stackexchange.com/a/394889/400726

Selecting by title:

[root@centos /]# grub2-editenv - set saved_entry='Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)'  [root@centos /]#   

Apparently it changed.

[root@centos /]# grubby --info DEFAULT  index=0  kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"  args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"  root="UUID=54f24598-4a21-4875-bacd-61c060de891f"  initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"  title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"  id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"  [root@centos /]#  

Restarting, But it doesn't work either!

Reviewing

[root@centos /]# cmp /boot/efi/EFI/centos/grubenv /boot/grub2/grubenv  /boot/efi/EFI/centos/grubenv /boot/grub2/grubenv differ: byte 38, line 2  [root@centos /]#   

The files has been changed, are different!!

[root@centos /]# cat /boot/efi/EFI/centos/grubenv  # GRUB Environment Block  saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64  boot_success=0  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=0  #################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#       [root@centos /]# cat /boot/grub2/grubenv  # GRUB Environment Block  saved_entry=Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=1  #########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#   

I was trying

[root@centos /]# rm /boot/grub2/grubenv.bak  rm: remove symbolic link '/boot/grub2/grubenv.bak'? y  [root@centos /]#  [root@centos /]# rm /boot/efi/EFI/centos/grubenv.bak  rm: remove regular empty file '/boot/efi/EFI/centos/grubenv.bak'? y  [root@centos /]#    [root@centos /]# ln -s /boot/grub2/grubenv /boot/efi/EFI/centos/grubenv  ln: failed to create symbolic link '/boot/efi/EFI/centos/grubenv': Operation not permitted  [root@centos /]#  

I would have preferred a symlink (But, I undersa tood the situation https://www.linuxquestions.org/questions/suse-opensuse-60/boot-is-not-allowing-symbolic-link-creation-4175682262/#post6166967)!

[root@centos /]# cp /boot/grub2/grubenv /boot/efi/EFI/centos/  [root@centos /]#  

Is there some work around?

[root@centos /]# ls -al /boot/grub2/  total 28  drwx------. 2 root root 4096 Jun 12 23:07 .  dr-xr-xr-x. 7 root root 4096 Jun 11 13:58 ..  -rw-r--r--. 1 root root 5503 Jun 11 05:01 grub.cfg  -rw-r--r--. 1 root root 6956 Jun 12 22:59 grub.cfg.bck  -rw-------. 1 root root 1024 Jun 12 22:59 grubenv  [root@centos /]#    [root@centos /]# ls -al /boot/efi/EFI/centos/  total 5824  drwx------. 3 root root    4096 Jun 12 23:09 .  drwx------. 4 root root    4096 Nov 16  2020 ..  -rwx------. 1 root root     134 Jul 31  2020 BOOTX64.CSV  drwx------. 2 root root    4096 Mar  2 16:03 fonts  -rwx------. 1 root root    5502 Jul  5  2020 grub.cfg  -rwx------. 1 root root    1024 Jun 12 23:06 grubenv  -rwx------. 1 root root 2285336 Mar  2 16:03 grubx64.efi  -rwx------. 1 root root 1162400 Jul 31  2020 mmx64.efi  -rwx------. 1 root root 1238416 Jul 31  2020 shimx64-centos.efi  -rwx------. 1 root root 1244496 Jul 31  2020 shimx64.efi  [root@centos /]#  

date - how to get next weekday (ignore weekends)

Posted: 12 Jun 2021 06:06 PM PDT

I'm setting up a cron job to suspend and wake a server at certian times.

I'm using two commands. One to be run from mondays to thursdays:

rtcwake -m mem -t $(date +%s -d "08:00")  

And another one to be run on fridays:

rtcwake -m mem -t $(date +%s -d "monday 08:00")  

I wonder if it's possible to make this separation unnecessary. If date could understand a statement like next weekday 08:00, it'd simplify things a lot.

I wasn't able to find if this is actually possible or what syntax should I use.

I basically want to avoid my server waking up on saturdays and sundays.

Accessing qemu multicast networks (from Docker containers)

Posted: 13 Jun 2021 12:01 AM PDT

QEMU allows to connect different VMs by using a virtual network based on a common multicast address by specifying -netdev socket,mcast=230.0.0.1:1234 on startup.

This way I can easily connect multiple VMs and join new VMs on the fly.

Is it possible to join that network without using QEMU? Especially is it possible to connect a docker container to that network?

Aws ec2 - How to rsync files between two remotes?

Posted: 12 Jun 2021 07:01 PM PDT

I'm setting up a crontab server to run several jobs to copy files from prod servers to lower environment servers.

I need the cron server job to copy files from one server to another. Here is what I have.

the ip's have been modified

ssh -v -R localhost:50000:1.0.0.2:22 -i host1key.pem ec2-user@1.0.0.1 'rsync -e "ssh -i /home/ec2-user/host2key.pem -p 50000" -vuar /home/ec2-user/test.txt ec2-user@localhost:/home/ec2-user/test.txt'  

I'm using two different pem keys and users. I would think this command would work but I get this error in the debug log. Here is more to it and only show the portion that is erroring. It connects to ec2-user@1.0.0.1 successfully. But errors on the 1.0.0.2:

debug1: connect_next: host 1.0.0.2 ([1.0.0.2]:22) in progress, fd=7  debug1: channel 1: new [127.0.0.1]  debug1: confirm forwarded-tcpip  debug1: channel 1: connected to 1.0.0.2 port 22  Host key verification failed.  debug1: client_input_channel_req: channel 0 rtype exit-status reply 0  debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0  rsync: connection unexpectedly closed (0 bytes received so far) [sender]  rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]  debug1: channel 0: free: client-session, nchannels 2  debug1: channel 1: free: 127.0.0.1, nchannels 1  Transferred: sent 5296, received 4736 bytes, in 0.9 seconds  Bytes per second: sent 5901.2, received 5277.2  debug1: Exit status 12  

How do i make guake start with tmux?

Posted: 12 Jun 2021 06:04 PM PDT

i am using i3wm and guake. I always use tmux inside guake to have split functionality detach function etc is there a way to start guake by default tmux running ?

Postfix does not check "From:" address with sender_login_maps

Posted: 12 Jun 2021 11:04 PM PDT

I am trying to set up a postfix configuration where (virtual) users are allowed to only send with "From:"-addresses they own. So I put reject_authenticated_sender_login_mismatch into smtpd_sender_restrictions.

Using

query = SELECT goto FROM alias WHERE address='%s' and active=1;  

in my sender_login_maps.cf I can send mails with any sender address I want, even something like madeup@not_my_domain.com.

However,

postmap -q "madeup@not_my_domain.com" mysql:/etc/postfix/sql/sender_login_maps.cf   

returns nothing as expected.

Now if I change the query to

SELECT goto FROM alias WHERE address='notinthedatabaseforsure' and active=1;   

I am not able to send any mails at all. So far so good. But the log says

postfix/smtps/smtpd[11683]: NOQUEUE: reject: RCPT from...: 553 5.7.1 <user@domain.com>:     Sender address rejected: not owned by user user@domain.com; from=<user@domain.com> to=<user2@domain.com> proto=ESMTP helo=<[192.168.2.103]>  

even if I try to send from madeup@not_my_domain.com. user@domain.com is the login name, user2@domain.com the recipient.

In a proper setup i would expect something like

postfix/smtps/smtpd[11683]: NOQUEUE: reject: RCPT from ...: 553 5.7.1 <madeup@not_my_domain.com>:     Sender address rejected: not owned by user user@domain.com; from=<madeup@not_my_domain.com> to=<user2@domain.com> proto=ESMTP helo=<[192.168.2.103]>  

So it looks like postfix uses the login name to search for the login name regardless of the sender address, which explains why I can send with any sender address using the query I mentioned first.

Update: I checked my sql logs and indeed, the MySQL server never sees madeup@not_my_domain.com. It only gets queries for the login address and the recipient address user2@domain.com.

Here are the smtps part from master.cf and my main.cf:

  smtps inet n - - - - smtpd    -o syslog_name=postfix/smtps    -o smtpd_tls_wrappermode=yes    -o tls_preempt_cipherlist=yes    -o smtpd_tls_security_level=encrypt    -o smtpd_sasl_auth_enable=yes    -o smtpd_client_restrictions=permit_sasl_authenticated,reject    -o milter_macro_daemon_name=ORIGINATING    -o smtpd_sasl_type=dovecot    -o smtpd_sasl_security_options=noanonymous    -o smtpd_relay_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_mynetworks,permit_sasl_authenticated,reject    -o milter_macro_daemon_name=ORIGINATING    -o cleanup_service_name=submission-header-cleanup  
  mynetworks = 127.0.0.0/8  inet_interfaces = all  mydomain = domain.com  myhostname = mail.domain.com  myorigin = $mydomain  mydestination =  relayhost =      smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_recipient    smtpd_recipient_restrictions =   permit_mynetworks,   permit_sasl_authenticated,   reject_non_fqdn_hostname,   reject_non_fqdn_sender,   reject_non_fqdn_recipient,   reject_unauth_destination,   reject_unauth_pipelining,   reject_invalid_hostname    smtpd_sender_restrictions =   reject_non_fqdn_sender,   reject_unknown_sender_domain,   reject_unauth_pipelining,   reject_authenticated_sender_login_mismatch,   permit_sasl_authenticated    smtpd_helo_required = yes  smtpd_helo_restrictions =   permit_mynetworks                              reject_invalid_helo_hostname                              reject_non_fqdn_helo_hostname                              reject_unknown_helo_hostname    smtpd_data_restrictions = reject_unauth_pipelining    smtpd_sasl_auth_enable = yes  smtpd_sasl_security_options = noanonymous, noplaintext  smtpd_sasl_type = dovecot  smtpd_sasl_path = private/auth    postscreen_access_list =        permit_mynetworks                                  cidr:/etc/postfix/postscreen_access  postscreen_blacklist_action = drop  postscreen_greet_action = drop    postscreen_dnsbl_threshold = 2  postscreen_dnsbl_sites = dnsbl.sorbs.net*1, bl.spamcop.net*1, ix.dnsbl.manitu.net*2, zen.spamhaus.org*2  postscreen_dnsbl_action = drop    virtual_alias_maps = mysql:/etc/postfix/sql/aliases.cf  virtual_mailbox_maps = mysql:/etc/postfix/sql/accounts.cf  virtual_mailbox_domains = mysql:/etc/postfix/sql/domains.cf  relay_domains = mysql:/etc/postfix/sql/relay_domains.cf  smtpd_sender_login_maps = mysql:/etc/postfix/sql/sender_login_maps.cf      virtual_uid_maps = static:3000  virtual_gid_maps = static:3000  virtual_mailbox_base = /home/vmail    # Disable NIS lookup warning  alias_maps=hash:/etc/aliases    append_dot_mydomain = no  recipient_delimiter = +  

How to use EXPECT in a loop foor ssh

Posted: 12 Jun 2021 05:04 PM PDT

Our Linux setup doesn't have keygen configured for password less authentication. Hence I am supposed to use only EXPECT for password less authentication in a shell script.

   /usr/bin/expect<<EOF >> ${LOG_FILE}    set timeout 60  spawn   sftp ${EWS_USER}@${EWS_HOST}:${TGT_DIR}  expect "*?assword:"  send "$password\r"  expect "sftp>"  send "put $local_dir/$line\r"  expect "sftp>"  send "bye\r"  expect EOF  EOF            filename=$(basename "$line")          # echo "File Name: $filename"          #Calculate the MD5Sum locally.          local_md5sum=$(md5sum "$line")          #echo "Local MD5Sum: ${local_md5sum}"          #Calculate the MD5sum in remote machine          remote_md5sum=$(ssh ${EWS_USER}@${EWS_HOST} "cd '$TGT_DIR' ; find -name '$filename'  -exec md5sum {} \;" < /dev/null)          #echo "Remote MD5Sum: ${remote_md5sum}"    LOCAL_SUM=`echo ${local_md5sum} | awk {'print $1'}`  REMOTE_SUM=`echo ${remote_md5sum} | awk {'print $1'}`  echo $LOCAL_SUM  echo $REMOTE_SUM  if [ "${LOCAL_SUM}" != "${REMOTE_SUM}" ]  then          echo "SFTP Successfull"  else          echo "SFTP Unsuccessfull"  fi  

I know how to use EXPECT in the below place

sftp ${EWS_USER}@${EWS_HOST} << EOF >> ${LOG_NAME}  put ${LOCAL_DIR}/${line} ${TGT_DIR}/${line}  EOF  

But any idea how to use EXPECT here in the below scenario to make the connection password less?

remote_md5sum=$(ssh ${EWS_USER}@${EWS_HOST} "cd '$TGT_DIR' ; find -name '$filename'  -exec md5sum {} \;" < /dev/null)  

proxify a custom program to proxychains

Posted: 12 Jun 2021 10:06 PM PDT

After some research, I didn't find any solutions. So I post here.

My goal: redirected the HTTPs traffic from my custom program to BurpSuite in order to analyse the server response and debug my program.

  • I have Debian 4.4.3
  • I have two network interfaces : eth0 and tap0, I work on tap0.
  • I have a php program that just send an HTTPS request to a local server (tap0). My php code use CURL to send the request (curl_init(), curl_setopt() etc.)

In a debugging goal, I have thought to send my flows via BurpSuite in order to see the HTTPS requests. So:

  • I launch Burp that listen on all interfaces port 8080
  • I configure /etc/proxychains.conf and in my ProxyList there are:

    socks4 127.0.0.1 8080  socks5 127.0.0.1 8080  socks4 XX.XX.XX.217 8080  socks5 XX.XX.XX.217 8080  

And when I use proxychains:

prochychains php myProgramme.php  

My program is executed but proxychains doesn't "proxify" the flow and so Burp doesn't see nothing...

I think that's because I am in my local network ?

What do you think about the best solution to intercept and see the HTTPS flows to my php program ?

How to disable Wifi Power Save on Kali Linux

Posted: 12 Jun 2021 09:09 PM PDT

I am running kali with virtualbox and my wifi receiver is a usb adapter which is Asus N10 Nano. I made the settings on virtualbox for making the vb recognize my usb wifi adapter. It works but after like 5min my internet drops. Especially during the updates. I figured it out its because the "Wifi Power Save" option is on. I turned it off and tried again. When i turned it off my wifi turned off at the same time. I tried to turn my wifi on but the Wifi Power Save option turned on itself automatically. The usb icon on bottom is like red-green. It needs to be blinking green to work correctly. If i can turn off the Wifi Power Save mod permamently hopefully its gonna be blinking green. I searched for it, I did almost everything like creating directory as /etc/pm/power.d/wireless and editing the file wireless by these commands:

#!/bin/sh  /sbin/iwconfig wlan0 power off  

Then i gave the permission -x for it. It didnt work. Sorry if I had mistake while I was writing this. Thanks for helping!

lspci output:

00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)  00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]  00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)  00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter  00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service  00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)  00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB  00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)  00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)  

It didn't work. In the end sudo depmod rtl8192cu output was: depmod: FATAL: rtl8192cu: not absolute path.

How to detect the incoming httpd Connection Counts of each VHOSTS?

Posted: 12 Jun 2021 08:10 PM PDT

With RHEL and Apache (httpd), is there a way to:

  • Detect which v.host (domain) is gaining how many incoming connections?

Because in this few days, I got a lot of incoming connections on the server being acknowledged by using:

  • ps aux | grep httpd -c

    734

That means I have 734 incoming connections currently being handled by Apache but the problem is I have (lets say) 10 Vhosts (domains).

  • So which domain is getting the high loads?

Read and confirm shell script before piping from curl to sh (curl -s [url] | sh)

Posted: 12 Jun 2021 08:25 PM PDT

Whenever I have to execute a shell script from the web curl -s [url] | sh, I first open url in my web browser to make sure the script isn't malicious and is safe to run.

I remember seeing a command line trick that made it was possible to read the script from the command line and then confirm execution after reading the script. If I recall correctly, it looked something like curl -s [url] | something...here | sh and didn't require any software install.

Does anyone know this trick?

No comments:

Post a Comment