Tuesday, October 19, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Linux Mint 20 - Switch users doesn't work correctly

Posted: 19 Oct 2021 10:45 AM PDT

When the Account Switch is made, Linux Mint collapses, as shown in the figure below.

enter image description here

Often it is necessary to restart the computer in a forced way. I used Ubuntu and had no such problem.

Facing problem while updating Kali Linux

Posted: 19 Oct 2021 10:33 AM PDT

I was facing slow updating speed in kali terminal so I change my Kali repo then I update again so don't know how my speed increased.

Pakage I used to install: sudo apt-get install apt-transport-https -y

Kali repo which I installed : deb http://kali.cs.nctu.edu.tw/kali kali-rolling main contrib non-free

deb-src http://kali.cs.nctu.edu.tw/kali kali-rolling main contrib non-free

But after using this Repo my kali machine is throwing an error like:

ERROR :(

Get:2 http://packages.microsoft.com/repos/code stable InRelease [10.4 kB]                                                                 Hit:3 http://deb.anydesk.com all InRelease                                                                                                Hit:4 http://linux.teamviewer.com/deb stable InRelease                                                                                    Ign:5 http://ppa.launchpad.net/mc3man/xerus-media/ubuntu jammy InRelease                                                                  Ign:6 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu impish InRelease                                                                      Hit:7 https://debrepo.freedownloadmanager.org bionic InRelease                                                                            Err:8 http://ppa.launchpad.net/mc3man/xerus-media/ubuntu jammy Release                                             404  Not Found [IP: 2001:67c:1560:8008::19 80]  Err:10 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu impish Release                    404  Not Found [IP: 2001:67c:1560:8008::19 80]  Hit:9 https://kali.itsec.am/kali kali-rolling InRelease       Reading package lists... Done  E: The repository 'http://ppa.launchpad.net/mc3man/xerus-media/ubuntu jammy Release' does not have a Release file.  N: Updating from such a repository can't be done securely, and is therefore disabled by default.  N: See apt-secure(8) manpage for repository creation and user configuration details.  E: The repository 'http://ppa.launchpad.net/openjdk-r/ppa/ubuntu impish Release' does not have a Release file.  N: Updating from such a repository can't be done securely, and is therefore disabled by default.  N: See apt-secure(8) manpage for repository creation and user configuration details.   

Note : I replace my these repo with original kali repo.

deb http://http.kali.org/kali kali-rolling main non-free contrib

But still facing same error. anyone help me out with this problem

Thank you

Comparison between Texmaker, Texstudio and Texworks [closed]

Posted: 19 Oct 2021 10:50 AM PDT

Has anyone used Texmaker, Texstudio and Texworks? How do they compare? I am particularly interested in rapidly constructing mathematical expressions (e.g. Texmacs provides rapid insertion of mathematical expressions but is fully wysiwyg, so cannot actually see the commands that have been inputted).

Two other considerations are

  1. How good are they on the most recent versions of tex (e.g. latex).

  2. How often are they updated and released

Can't see mounted drive under lsblk, blkid or mount

Posted: 19 Oct 2021 10:19 AM PDT

I have mounted an external hard drive via /etc/fstab with the following entry:

UUID=a8286fc9-5b08-41d9-8c4e-cb993a8976d1 /home/bu/safe-heaven-2/ ext4 defaults 0  

I can read/write from this disk but I have some issues related to making backups via backintime (see below). So I started to poke around and see if I can find out anything but for some reason, I cannot see this drive with any of the commands mount, blkid or lsblk. So I am stuck. What can be the reason for this?

The 'actual' issue at hand: This is a new 2TB drive I use for making backups but for some reason backintime keeps telling me that the disk is full at some point. This can't be true as I am trying to (partially) back up a disk that is only 1TB big and by no means full.

When I try to do a fsck /home/bu/safe-heaven-2 on this disk, I get the following error:

fsck.ext4: Unable to resolve 'UUID=a8286fc9-5b08-41d9-8c4e-cb993a8976d1'  

But as I wrote, I can read / write to this disk. I am totally confused :D Please help!

Edit: Output of fdisk -l as requested:

Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes      Disk /dev/mmcblk0: 14,9 GiB, 15931539456 bytes, 31116288 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  Disklabel type: dos  Disk identifier: 0x1ddfbf63    Device         Boot  Start      End  Sectors  Size Id Type  /dev/mmcblk0p1        8192   532479   524288  256M  c W95 FAT32 (LBA)  /dev/mmcblk0p2      532480 31116287 30583808 14,6G 83 Linux      Disk /dev/sdb: 931,5 GiB, 1000170586112 bytes, 1953458176 sectors  Disk model: Elements 10A8     Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disklabel type: dos  Disk identifier: 0x07e93288    Device     Boot Start        End    Sectors   Size Id Type  /dev/sdb1        2048 1953458175 1953456128 931,5G 83 Linux  

Enable GNU Fortran 7.xy on CentOS 7.9: scl command not found

Posted: 19 Oct 2021 10:58 AM PDT

I'm trying to enable GNU Fortran ver 7.xy on a CentOS 7.9 image in a Singularity container. According to various sources on the internet I need to install the following packages with yum:

yum install centos-release-scl scl-utils-build devtoolset-7-gcc*`  

After the installation I try to enable this toolchain with

scl enable devtoolset-7 bash  

However, I obtain the error

scl: command not found  

I tried to find scl, starting my search from /, but it is not found either:

sudo find / -name "scl"  

Also whereis scl returns nothing. Did anyone encounter this error before? What would be the remedy?

HAProxy No server is available to handle this request

Posted: 19 Oct 2021 09:38 AM PDT

I have HAProxy setup on 192.46.209.80, on port 541 I bound the HAProxy frontend. And on the same server I am running my apache server as well.

This is my /etc/haproxy/haproxy.cfg

 #HAProxy for web servers      frontend web-frontend        bind 192.46.209.80:541        mode http        default_backend web-backend            backend web-backend        balance roundrobin        server server1 192.46.209.80 check port 80        server server2 192.46.209.82 check port 80  

But I am getting 503 service not available.

Note : My question is different from the one already asked because I am serving apache and HAProxy on the same machine. 192.46.209.80

enter image description here

How do i get three screens working at the same time?

Posted: 19 Oct 2021 10:11 AM PDT

I have a work-laptop, HP Pavilion g6, that uses arch with i3wm, and i would like to have three screens working at the same time (internal display, one connected via HDMI and one via VGA).

when trying to set it up i run: xrandr

which has the output:

LVDS-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm     1366x768      60.01*+     1280x720      60.00    59.99    59.86    59.74     1024x768      60.04    60.00     960x720       60.00     928x696       60.05     896x672       60.01     1024x576      59.95    59.96    59.90    59.82     960x600       59.93    60.00     960x540       59.96    59.99    59.63    59.82     800x600       60.00    60.32    56.25     840x525       60.01    59.88     864x486       59.92    59.57     700x525       59.98     800x450       59.95    59.82     640x512       60.02     700x450       59.96    59.88     640x480       60.00    59.94     720x405       59.51    58.99     684x384       59.88    59.85     640x400       59.88    59.98     640x360       59.86    59.83    59.84    59.32     512x384       60.00     512x288       60.00    59.92     480x270       59.63    59.82     400x300       60.32    56.34     432x243       59.92    59.57     320x240       60.05     360x202       59.51    59.13     320x180       59.84    59.32  VGA-1 connected (normal left inverted right x axis y axis)     1920x1080     60.00 +     1600x1200     60.00     1680x1050     59.95     1280x1024     60.02     1440x900      59.89     1280x960      60.00     1280x720      60.00     1024x768      60.00     800x600       60.32     640x480       59.94     720x400       70.08  HDMI-1 connected (normal left inverted right x axis y axis)     1920x1080     60.00 +  50.00    59.94     1920x1080i    60.00    50.00    59.94     1600x1200     60.00     1680x1050     59.88     1400x1050     59.95     1280x1024     75.02    60.02     1440x900      59.90     1280x960      60.00     1152x864      75.00     1280x720      60.00    50.00    59.94     1440x576      50.00     1024x768      75.03    70.07    60.00     1440x480      60.00    59.94     832x624       74.55     800x600       72.19    75.00    60.32    56.25     720x576       50.00     720x576i      50.00     720x480       60.00    59.94     720x480i      60.00    59.94     640x480       75.00    72.81    66.67    60.00    59.94     720x400       70.08  DP-1 disconnected (normal left inverted right x axis y axis)  

I then run the commands:

xrandr --output HDMI-1 --auto --left-of LVDS-1

and:

xrandr --output VGA-1 --auto --right-of LVDS-1

The first command works fine, the second though yields:

xrandr: cannot find crtc for output VGA-1

A coworker told me that it was because i only have 2 providers as he showed me with xrandr --listproviders which yielded:

Provider 0: id: 0x45 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 4 associated providers: 1 name:modesetting  Provider 1: id: 0xb6 cap: 0x5, Source Output, Source Offload crtcs: 6 outputs: 0 associated providers: 1 name:modesetting  

I don't generally trust this guy, so I wanted to ask here whether there is a way of getting these 3 screens to work, and if so how to get them to work?

Bash profile file not sourcing

Posted: 19 Oct 2021 10:01 AM PDT

I am trying to add a cool smiley when my previous command was success and angry smiley if the command was not success in my terminal.

    21:26:30 user@mymachine:~ $ cat ~/.bash_profile  export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home"  export PATH="/usr/local/mysql/bin:$PATH"  export PATH="/usr/local/opt/python@3.7/bin:$PATH"  alias python=/usr/local/opt/python@3.7/bin/python3  alias pip=/usr/bin/pip3    highlightExitCode(){        if [[ $? -eq 0 ]]; then          echo -e '\xf0\x9f\x98\x8e ';      else          echo -e '\xf0\x9f\xa4\xa8 ';      fi  }    export PS1="\[\033[1m\]\t\[\033[m\] \[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\] \$(highlightExitCode)\$ "  

Added this code in my .bash_profile and trying to source it. But getting this error.

21:30:45 user@mymachine:~ $ source ~/.bash_profile  -bash: /Users/user/.bash_profile: line 9: syntax error near unexpected token `then'  -bash: /Users/user/.bash_profile: line 9: `    if [[ $? -eq 0 ]]; then'  

line number 9 is the if condition. I tried many combinations of removing the square bracket or the ';' but no luck. What am I missing here ?

I am running bash shell

21:30:46 user@mymachine:~ $ echo $0  -bash  

shift; shift versus shift 2 when using bash

Posted: 19 Oct 2021 11:00 AM PDT

Have encountered some statements that shift; shift is better than shift 2 when using bash, but I need some convincing explanation. What happens with shift; shift and how does it handle things better in case of problems with how positional arguments are passed?

Multiple concurrent X/Wayland users on different monitors?

Posted: 19 Oct 2021 08:57 AM PDT

Scenario: I'm running KDE5 on OpenSUSE Tumbleweed with separate "work" and "personal" accounts. I'm logging into these concurrently on TTY7 and TTY8 and can switch between them with C-M-F7/8. On a single screen this is fine, but with multiple monitors, it would be nice to be able to have one screen mapped to each session.

Is this possible?

What is the canonical way to run a .sh from file manager?

Posted: 19 Oct 2021 08:57 AM PDT

Hope, this belongs here and not e.g. on SU. I would like to make my life a bit easier and therefore want to be able to run a script.sh from file manager. This is possible in other distributions (or their software/presets), but I don't want to switch to another FM just for this. The file is executable as per chmod +x script.sh. I'm using openSUSE Leap version 15.1 with Plasma, Gnome or IceWM as a window-manager if this is important. The kernel is 4.12.14-lp151.28.91-default and I have Files (Gnome) 3.26.2, but I'm sure that this also applies to many other configurations. Dolphin would also be an option for File Management.

I also tried to configure a .desktop-file like suggested here, but didn't get it right.

Recover content of text file that has been replaced with another text file which has the same name

Posted: 19 Oct 2021 08:50 AM PDT

I have saved a text file using Gedit text editor in my /home/Desktop directory. Unfortunately there was already a text file with the same name there, so its content has been lost. I use Ubuntu 16.04 and ext4 filesystem.

This question explains how to recover its content if you remember some text of the file that has been replaced: Can overwritten files be recovered?

It uses this command: grep -i -a -B100 -A100 'text in the deleted file' /dev/sda1 > recovered-text.txt

The problem is that I can not remember some of the text of the lost file. It was an old file which I had not opened in a long time.

Is there a way to retrieve it if I only know the name of that text file? Is there a chance that the filename is saved as metadata in disk next to the file content which I could grep? Any suggestions?

Multiple IFS variables

Posted: 19 Oct 2021 08:49 AM PDT

I have recently been dumped onto a project that requires the use of bash script. The programme reads a csv file and produces a transaction record based on the data inside csv. I will apologise now as my understanding of this language is limited. Basically the problem I am having is with IFS = -r. When I started on this project, this programme had been written for a single transaction, however, I now need to expand this to read multiple transactions. What I have so far is this.

recordcount =0  while IFS=, read -r rectype common1 common2 common3  do    if [ $recordcount -eq 0 ] then  trblank = "000 000 000"  echo $trblank > $outputto  else  if [ $rectype = "1000" ] then  printf -v common1 "%05g" $common1  printf -v common2 %5.5s "$common2"  printf -v common3 %2.2s "$common3"  printf -v var1 "05g "$var1"  else      if [ $rectype = "1001" ] then  printf -v common1 "%05g" $common1  printf -v common2 %5.5s "$common2"  printf -v common3 %2.2s "$common3"  printf -v var2 %3.3s "%var2"  printf - var3 %2.2s "%var3"  fi  fi  recordcount=$((recordcount+1))  done < $inputfile  printf -v rc "%xd"  $((recordcount))  tlr="trailer record"  echo "$tlr" >> $outputto  

In reality there are dozens of transactions with multiple variables in each. If I add the variables after the common variables in the IFS= they are picking up blanks because they are expecting all variables to follow on from the common ones.

For the transactions to be picked up it would need to read:

IFS=, read -r rectype common1 common2 common3 var1 - transaction 1  IFS=, read -r rectype common1 common2 common3 var2 var3 - transaction2  

I have tried adding these transactions into separate functions with their own while IFS loop but it causes conflicts and the programme freezes. I have tried to add an array for each, adding it under the if statement, but it isn't picking it up. Any help with this would be much appreciated.

Apologies again for my ignorance when it comes to bash.

Sed can not replace when string contains double quotes

Posted: 19 Oct 2021 10:00 AM PDT

Output error from the execution of sed command:

sed: -e expression #1, char 14: unterminated `s' command  

command file that I am trying to execute:

#!/bin/sh    old_version='\"version\": \"0.0.0\"'    year=$(date +%y)  dayOfYear=$(date +%j)    version=$year'.'$dayOfYear'.''3434'  echo $version    filepath="/opt/vsts-agent-linux/_work/5/s/projects/tl-angular-map/package.json"    echo $filepath    replace="s/"$old_version"/"$version"/g"    echo $replace    sed -i -e $replace $filepath  

The problem is that the string that I am buiding from concatenation is not properly closed because of the double quotes in it.

I don't understand `cat` behaviour when running `</dev/stdin cat | ls`

Posted: 19 Oct 2021 08:36 AM PDT

I know this is a useless command but I would like to understand why, wether in bash or zsh, when I enter </dev/stdin cat | ls, cat will prompt me for input but only but will return after just one line whereas for example </dev/stdin tr -d 'e' | ls will let me input various line until I hit Ctrl + D ?

How to set python 3 as default interpreter in Linux

Posted: 19 Oct 2021 09:18 AM PDT

I have python 2.x and 3.x installed on my Linux box. but to run the python 3.x I have to type command python3 <cmd> . But i want to update the alias python to point python3 so I don't have to use python3 in command.

I tried to update the ~/.bashrc but it does not reflect for all the the users who logged in to same Linuxbox using their own id

other option is to run this command alias python=python3 but this has to run every time whenever I login to box. I want permanently set the alias and it should available for all the users.

How can I download specific files recursive, while maintaining folder structure?

Posted: 19 Oct 2021 08:18 AM PDT

So, I just downloaded a several folders using rsync, it went something like this:

rsync -rzP user@domain:/mnt/file_direction /mnt/Downloads/Files  

This worked well for a massive download, however, now I need to just download certain files with a strucutre similar to these:

folder_a/folder_1/func/some_file.gz  folder_a/folder_2/func/some_file.gz  folder_b/folder_1/func/some_file.gz  folder_b/folder_2/func/some_file.gz  

As you can see, these are files within concatenated folders. All files I need to download have the same format, so there should be no issues there.So, the gist of it is that I need to download just the "some_file.gz" while maintaining folder structure recursive.

Any and all help is much appreciated!

How to parse through the SQL output stored in a Shell variable in Bash

Posted: 19 Oct 2021 08:54 AM PDT

This is the shell script I have written to get data from report_data table from "merlin" database.

data=$(mysql merlin -BNe 'select * from report_data')  echo "$data"  

The Output produced is

1   1634036113  701 NULL    NULL    monitor-localhost-616569842d586 Service latency 0   1   1   0   OK: service latency min/avg/max = 0.00/0.00/0.20    NULL  2   1634036123  701 NULL    NULL    monitor-localhost-616569842d586 Zombie process  0   1   1   0   OK: 0 zombie process(es)    NULL  3   1634036131  701 NULL    NULL    monitor-localhost-616569842d586 Host orphans    0   1   1   0   OK: Orphaned host checks:   NULL  

These are the columns present in the table -

| id  | timestamp  | event_type | flags | attrib | host_name                       | service_description                 | state | hard | retry | downtime_depth | output                                                                                                                                                                                                                                                                                                                                                                                                           | long_output |  

I want to use every row as individual entity and want to parse through it.

TTY pre-login in QWERTY instead of AZERTY

Posted: 19 Oct 2021 09:58 AM PDT

I am french and usually types with AZERTY layout.

My TTYs virtual consoles (Ctrl+Alt+fN) are in QWERTY before and after login. It's painful, because I have to log each time in QWERTY.

Once logged in I can run loadkeys en (in reality I type loqdkeys en) and it works, I am then in AZERTY until the next reboot. This is very annoying !

In other hand on my graphical session under X (XFCE4 as DE) I am in AZERTY.

My distro is a Debian Buster.

What I tested :

user@host:~$ localectl list-keymaps  Failed to read list of keymaps: Aucun fichier ou dossier de ce type  

but apparently this is a false positive

user@host:~$ localectl   System Locale: LANG=fr_FR.UTF-8     VC Keymap: fr    X11 Layout: fr     X11 Model: pc105   X11 Variant: oss_latin9  

all seems OK.

 root@host:~# grep -r loadkeys /etc  

no launches in /etc

A fresh install of Debian Buster runs correctly in pre-login I type in AZERTY.

I'm running out of ideas ...

Unable to mount HDD and concerns over the partition setup

Posted: 19 Oct 2021 09:03 AM PDT

I recently bought an internal 4TB HDD to add to a Ubuntu machine. This is my first attempt at adding an HDD to an established machine and mounting it to a specific location. Unfortunately, I'm running into some problems and all similar posts I've seen haven't quite resolved my issue. Therefore, I will try and give a complete breakdown of the steps I understood, followed and the errors I'm facing.

My version of Ubuntu:

Distributor ID: Ubuntu  Description:    Ubuntu 20.04.3 LTS  Release:    20.04  Codename:   focal  

Firstly, after many failed efforts at adding a partition to the HDD and mounting the HDD I've killed the table so consider this as my baseline:

sudo dd if=/dev/zero of=/dev/sdc bs=1M count=10  

The disk is /dev/sdc

When I use lsblk this is the output (sdc is at the bottom):

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT  loop0    7:0    0  55.5M  1 loop /snap/core18/2074  loop1    7:1    0     4K  1 loop /snap/bare/5  loop2    7:2    0  55.4M  1 loop /snap/core18/2128  loop3    7:3    0   219M  1 loop /snap/gnome-3-34-1804/66  loop4    7:4    0   219M  1 loop /snap/gnome-3-34-1804/72  loop5    7:5    0  65.1M  1 loop /snap/gtk-common-themes/1515  loop6    7:6    0  65.2M  1 loop /snap/gtk-common-themes/1519  loop7    7:7    0    51M  1 loop /snap/snap-store/542  loop8    7:8    0    51M  1 loop /snap/snap-store/547  loop9    7:9    0  32.3M  1 loop /snap/snapd/13170  loop10   7:10   0  32.4M  1 loop /snap/snapd/13270  sda      8:0    0 465.8G  0 disk   ├─sda1   8:1    0   512M  0 part /boot/efi  ├─sda2   8:2    0     1K  0 part   └─sda5   8:5    0 465.3G  0 part /  sdb      8:16   0 931.5G  0 disk   ├─sdb1   8:17   0   116M  0 part   ├─sdb2   8:18   0   506M  0 part   └─sdb3   8:19   0 930.9G  0 part   sdc      8:32   0   3.7T  0 disk   sr0     11:0    1  1024M  0 from   

And with sudo fdisk -l

Disk /dev/sdc: 3.65 TiB, 4000787030016 bytes, 7814037168 sectors  Disk model: TOSHIBA MG03ACA4  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  

I then use gdisk (I have tried using parted) to assign a partition table with type and name etc.

Adding a new partition:

Command (? for help): n  Partition number (1-128, default 1): 1  First sector (34-7814037134, default = 2048) or {+-}size{KMGTP}: 2048  Last sector (2048-7814037134, default = 7814037134) or {+-}size{KMGTP}: 7814037134  Current type is 8300 (Linux filesystem)  Hex code or GUID (L to show codes, Enter = 8300):   Changed type of partition to 'Linux filesystem'  

Let's look at it with p (print)

Number  Start (sector)    End (sector)  Size       Code  Name     1            2048      7814037134   3.6 TiB     8300  Linux filesystem  

I want to call it store:

Command (? for help): c store  Using 1  Enter name: store  

(after a print)

Number  Start (sector)    End (sector)  Size       Code  Name     1            2048      7814037134   3.6 TiB     8300  store  

Finally write the partition table to disk and exit (with w):

Command (? for help): w    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING  PARTITIONS!!    Do you want to proceed? (Y/N): Y  OK; writing new GUID partition table (GPT) to /dev/sdc.  The operation has completed successfully.  

Let's look at the drives and mount points again (lsblk):

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT  loop0    7:0    0  55.5M  1 loop /snap/core18/2074  loop1    7:1    0     4K  1 loop /snap/bare/5  loop2    7:2    0  55.4M  1 loop /snap/core18/2128  loop3    7:3    0   219M  1 loop /snap/gnome-3-34-1804/66  loop4    7:4    0   219M  1 loop /snap/gnome-3-34-1804/72  loop5    7:5    0  65.1M  1 loop /snap/gtk-common-themes/1515  loop6    7:6    0  65.2M  1 loop /snap/gtk-common-themes/1519  loop7    7:7    0    51M  1 loop /snap/snap-store/542  loop8    7:8    0    51M  1 loop /snap/snap-store/547  loop9    7:9    0  32.3M  1 loop /snap/snapd/13170  loop10   7:10   0  32.4M  1 loop /snap/snapd/13270  sda      8:0    0 465.8G  0 disk   ├─sda1   8:1    0   512M  0 part /boot/efi  ├─sda2   8:2    0     1K  0 part   └─sda5   8:5    0 465.3G  0 part /  sdb      8:16   0 931.5G  0 disk   ├─sdb1   8:17   0   116M  0 part   ├─sdb2   8:18   0   506M  0 part   └─sdb3   8:19   0 930.9G  0 part   sdc      8:32   0   3.7T  0 disk   └─sdc1   8:33   0   3.7T  0 part   sr0     11:0    1  1024M  0 rom    

I now want to mount my drive to a location called /store (yes, the same name as the partition on sdc1 - I hope that isn't confusing). This is where I run into an error:

(base) anthony@Shodan:/dev$ sudo mount -o rw /dev/sdc1 /store  mount: /store: wrong fs type, bad option, bad superblock on /dev/sdc1, missing codepage or helper program, or other error.  

I am really not sure what to do from here. I've repeated the same process above but using parted. The steps are successful but again it fails when I try mounting.

EDIT #1 Thanks for the comments. Turns out I didn't create a filesystem so I executed the following but had an error:

(base) anthony@Shodan:~$ sudo mkfs.ext4 /dev/sdc1  [sudo] password for anthony:   mke2fs 1.45.5 (07-Jan-2020)  Creating filesystem with 976754385 4k blocks and 244195328 inodes  Filesystem UUID: d6b2219f-b4fe-490b-bf21-513fec50c625  Superblock backups stored on blocks:       32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,       4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,       102400000, 214990848, 512000000, 550731776, 644972544    Allocating group tables: done                              Writing inode tables: done                              Creating journal (262144 blocks): done  Writing superblocks and filesystem accounting information: mkfs.ext4: Input/output error while writing out and closing file system  

I then install smartmodtools and used smartctl to test the new drive but I ran into a further problem:

(base) anthony@Shodan:~$ sudo smartctl --smart=on -T permissive /dev/sdc  smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.11.0-37-generic] (local build)  Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org    Short INQUIRY response, skip product id  === START OF ENABLE/DISABLE COMMANDS SECTION ===  unable to fetch IEC (SMART) mode page [scsi response fails sanity test]  A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.  

I'm not sure where to go from here.

How to remove text between two keywords in a textfile

Posted: 19 Oct 2021 09:11 AM PDT

Context : GNU/Linux Ubuntu.

I've a file made of thousands of lines and I'd like to have a script that will remove some lines between 2 specific keywords.
Initial file is like:

bla bla  ...  bla bla  keyword1  bla bla  ...  bla bla  keyword2  bla bla  ...  bla bla  

I would like to keep all file except the part between keyword1 and keyword2.

Let's consider that keyword1 and keyword2 appear once and only once in the file; these keywords may be preceded or followed by other characters on their lines like spaces or < or >

The lines with the keywords on them look like this (they are actually XML-based files):

<keyword2>    

The keywords can be kept in the file or be removed along with the enclosed text, I'm fine with both outcomes.

I did not find out how to proceed using grep. I'm not familiar with awk; could it make it?

How do I close an SSH connection with a background process without killing it?

Posted: 19 Oct 2021 10:32 AM PDT

I would like to know how I can close an ssh connection to a linux server where I started a process brought to background (by adding & at the end of it) without killing the process.
If I simply do exit, this seems to kill the process.

Is there a way to recover from "Detected Tx Unit Hang" network errors?

Posted: 19 Oct 2021 10:24 AM PDT

After waking from suspend, my Ubuntu 21.04 system had network issues. I'd guess about 50% of IP sockets failed. This included failures of both ssh and ping. By "fail" I mean that a connection attempt blocks, and then eventually times-out. (Aside: maybe ping doesn't use sockets?) I believe all programs that attempted network access encountered the same failure rate.

I've been suspending the system every night for several weeks. Today was the first time I had any problems after resuming.

I rebooted the system, which seems to have solved the problem (at least until it happens again).

After rebooting, I discovered various messages in syslog.

I see the below two lines on every suspend:

Sep  4 09:00:18 hostname kernel: [896165.908582] igc 0000:b0:00.0: no suspend buffer for PTM  Sep  4 09:00:18 hostname kernel: [896165.908589] igc 0000:af:00.0: no suspend buffer for PTM  

(Aside: While the above lines refer to events that happened prior to the suspend, I believe the log entries were only created after the system resumed. Consequently, the events actually happened hours before the indicated times.)

And two identical lines on every resume:

Sep  4 09:00:18 hostname kernel: [896166.257107] igc 0000:af:00.0: no suspend buffer for PTM  Sep  4 09:00:18 hostname kernel: [896166.257177] igc 0000:b0:00.0: no suspend buffer for PTM  

(Aside: Maybe there are two lines because the system has two built-in NICs?)

And here are the log entries that only occurred on my most recent resume, which is when the network problems started:

Sep  4 09:00:19 hostname kernel: [896168.214463] igc 0000:b0:00.0 enp176s0: Register Dump  Sep  4 09:00:19 hostname kernel: [896168.214467] igc 0000:b0:00.0 enp176s0: Register Name   Value  Sep  4 09:00:19 hostname kernel: [896168.214478] igc 0000:b0:00.0 enp176s0: CTRL            081c0641  Sep  4 09:00:19 hostname kernel: [896168.214481] igc 0000:b0:00.0 enp176s0: STATUS          40380401  Sep  4 09:00:19 hostname kernel: [896168.214483] igc 0000:b0:00.0 enp176s0: CTRL_EXT        10000040  Sep  4 09:00:19 hostname kernel: [896168.214486] igc 0000:b0:00.0 enp176s0: MDIC            18017949  Sep  4 09:00:19 hostname kernel: [896168.214488] igc 0000:b0:00.0 enp176s0: ICR             00000001  Sep  4 09:00:19 hostname kernel: [896168.214490] igc 0000:b0:00.0 enp176s0: RCTL            04408022  Sep  4 09:00:19 hostname kernel: [896168.214497] igc 0000:b0:00.0 enp176s0: RDLEN[0-3]      00001000 00001000 00001000 00001000  Sep  4 09:00:19 hostname kernel: [896168.214504] igc 0000:b0:00.0 enp176s0: RDH[0-3]        00000000 00000000 00000000 00000000  Sep  4 09:00:19 hostname kernel: [896168.214511] igc 0000:b0:00.0 enp176s0: RDT[0-3]        000000ff 000000ff 000000ff 000000ff  Sep  4 09:00:19 hostname kernel: [896168.214518] igc 0000:b0:00.0 enp176s0: RXDCTL[0-3]     02040808 02040808 02040808 02040808  Sep  4 09:00:19 hostname kernel: [896168.214525] igc 0000:b0:00.0 enp176s0: RDBAL[0-3]      2e35d000 51576000 337b2000 29a5b000  Sep  4 09:00:19 hostname kernel: [896168.214532] igc 0000:b0:00.0 enp176s0: RDBAH[0-3]      00000001 00000001 00000002 00000001  Sep  4 09:00:19 hostname kernel: [896168.214534] igc 0000:b0:00.0 enp176s0: TCTL            a50400fa  Sep  4 09:00:19 hostname kernel: [896168.214541] igc 0000:b0:00.0 enp176s0: TDBAL[0-3]      2e35d000 51576000 337b2000 29a5b000  Sep  4 09:00:19 hostname kernel: [896168.214548] igc 0000:b0:00.0 enp176s0: TDBAH[0-3]      00000001 00000002 00000001 00000001  Sep  4 09:00:19 hostname kernel: [896168.214555] igc 0000:b0:00.0 enp176s0: TDLEN[0-3]      00001000 00001000 00001000 00001000  Sep  4 09:00:19 hostname kernel: [896168.214562] igc 0000:b0:00.0 enp176s0: TDH[0-3]        00000007 00000009 00000004 00000000  Sep  4 09:00:19 hostname kernel: [896168.214568] igc 0000:b0:00.0 enp176s0: TDT[0-3]        0000000d 00000011 00000004 00000001  Sep  4 09:00:19 hostname kernel: [896168.214575] igc 0000:b0:00.0 enp176s0: TXDCTL[0-3]     02100108 02100108 02100108 02100108  Sep  4 09:00:19 hostname kernel: [896168.214576] igc 0000:b0:00.0 enp176s0: Reset adapter  

And then there were many (over 19,000) entries like the below:

Sep  4 09:01:22 hostname kernel: [896231.189109] igc 0000:b0:00.0 enp176s0: Detected Tx Unit Hang  Sep  4 09:01:22 hostname kernel: [896231.189109]   Tx Queue             <1>  Sep  4 09:01:22 hostname kernel: [896231.189109]   TDH                  <9>  Sep  4 09:01:22 hostname kernel: [896231.189109]   TDT                  <9>  Sep  4 09:01:22 hostname kernel: [896231.189109]   next_to_use          <9>  Sep  4 09:01:22 hostname kernel: [896231.189109]   next_to_clean        <9>  Sep  4 09:01:22 hostname kernel: [896231.189109] buffer_info[next_to_clean]  Sep  4 09:01:22 hostname kernel: [896231.189109]   time_stamp           <10d596f4c>  Sep  4 09:01:22 hostname kernel: [896231.189109]   next_to_watch        <000000002b25478e>  Sep  4 09:01:22 hostname kernel: [896231.189109]   jiffies              <10d59ad90>  Sep  4 09:01:22 hostname kernel: [896231.189109]   desc.status          <0>  

My question is, other than a full system reboot, is there some way I can manually reset/reboot the network interface from the command line?

The system is a desktop workstation, so I have keyboard access.

After rebooting, I realized that maybe I should try re-suspending and re-waking the system. But I only thought of that after doing the full reboot.

Docker 20.10.x keeps system waiting for several minutes before shutdown or reboot

Posted: 19 Oct 2021 10:38 AM PDT

I have successfully upgraded my Debian buster to latest version (Bullseye) and after that, whenever I want to reboot or shut it down, it takes several minutes to complete while waiting for some process to finish with these messages:

watchdog: watchdog0: watchdog did not stop!  systemd-shutdown[1]: Syncing filesystem and block devices.  systemd-shutdown[1]: Sending SIGTERM to remaining process...  systemd-journald[372]: Received SIGTERM from PID 1 (systemd-shutdown).  systemd-shutdown[1]: waiting for process: containerd-shim.  

I've got docker installed on my system which seems to be the cause of problem.

$ ps aux | grep containerd-shim  root        3420  0.0  0.1 1451744 21876 ?       Sl   11:07   0:00 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 0dd6b89a62d...66cc5c0a44b6f01d77c -address /run/containerd/containerd.sock    $ dpkg -S /usr/bin/containerd-shim-runc-v2   containerd: /usr/bin/containerd-shim-runc-v2    $ aptitude why containerd  i   docker.io Depends containerd  

I've tried stopping dockers' service/socket before rebooting the system. Nothing changed.

Any idea how to resolve this?


$ docker version  Client:   Version:           20.10.5+dfsg1   API version:       1.41   Go version:        go1.15.9   Git commit:        55c4c88   Built:             Wed Aug  4 19:55:57 2021   OS/Arch:           linux/amd64   Context:           default   Experimental:      true    Server:   Engine:    Version:          20.10.5+dfsg1    API version:      1.41 (minimum version 1.12)    Go version:       go1.15.9    Git commit:       363e9a8    Built:            Wed Aug  4 19:55:57 2021    OS/Arch:          linux/amd64    Experimental:     false   containerd:    Version:          1.4.5~ds1    GitCommit:        1.4.5~ds1-2   runc:    Version:          1.0.0~rc93+ds1    GitCommit:        1.0.0~rc93+ds1-5+b2   docker-init:    Version:          0.19.0    GitCommit:          

Nmap 7.8 Assertion failed: htn.toclock_running == true

Posted: 19 Oct 2021 09:12 AM PDT

All of a sudden, nmap throws the following error after executing the canonical sudo nmap -sP 192.168.109.* :

nmap: Target.cc:503: void Target::stopTimeOutClock(const timeval*): Assertion `htn.toclock_running == true' failed.

Tried to reboot PC, restart switch, router and grandma but none worked.

Nmap version is 7.8 on Ubuntu 20.

How does /proc/cpuinfo detect the CPU model?

Posted: 19 Oct 2021 10:05 AM PDT

I have a server which displays the following information in dmidecode output for CPU:

Handle 0x000D, DMI type 4, 35 bytes                              Processor Information                    Socket Designation: CPU 1                                        Type: Central Processor                                          Family: Xeon                     Manufacturer: GenuineIntel                                       ID: FB 06 00 00 01 03 00 00                                      Signature: Type 0, Family 6, Model 15, Stepping 11               Flags:                                   FPU (Floating-point unit on-chip)                                CX8 (CMPXCHG8 instruction supported)                             APIC (On-chip APIC hardware supported)                   Version: Intel Xeon              Voltage: 1.2 V                   External Clock: 266 MHz                                          Max Speed: 3733 MHz              Current Speed: 2000 MHz                                          Status: Populated, Enabled                                       Upgrade: ZIF Socket              L1 Cache Handle: 0x0009                                          L2 Cache Handle: 0x000A                                          L3 Cache Handle: Not Provided                                    Serial Number: Not Specified                                     Asset Tag: Not Specified                                         Part Number: Not Specified     

Based on Max Speed, I would guess that it is a Xeon 5080 CPU. However, according to /proc/cpuinfo, it is Xeon E5335:

# grep "model name" /proc/cpuinfo  model name      : Intel(R) Xeon(R) CPU           E5335  @ 2.00GHz  model name      : Intel(R) Xeon(R) CPU           E5335  @ 2.00GHz  model name      : Intel(R) Xeon(R) CPU           E5335  @ 2.00GHz  model name      : Intel(R) Xeon(R) CPU           E5335  @ 2.00GHz  #   

When I check the flags/features listed in /proc/cpuinfo, then it shows ssse3, which is supported in Xeon 5080 and not in Xeon E5335. How does /proc/cpuinfo detect the CPU model?

Sum multiple columns

Posted: 19 Oct 2021 10:01 AM PDT

I need to do multiple sums; my input file is:

DATE|NATION|CITY|FILES|REVENUE|FREQUENCY|INVESTMENT  20170807|USA|VIRGINIA|TIMES|1919150|1779|282075  20170807|USA|NYC|ROADS|92877|41|1599  20170808|USA|PENS|ROADS|133001|7|1  20170808|USA|NYC|TIMES|361625|1592|0  
  1. Sum $5 in every uniq of $1 (date)
  2. sum $5 in every uniq where $4=="TIMES"
  3. sum $5 in every uniq where $4=="ROADS"
  4. sum $5 in every uniq where $4=="ROADS" and $3=="NYC"
  5. arrange based on column $1

my expected output

DATE|REV|TIMES|ROADS|ROADS&NYC  20170807|2012027|1919150|92877|92877  20170808|494626|361625|133001|0  

I only know how to sum based on 1 column

awk -F"|" '{FS=OFS="|"}{col[$1]+=$5} END {for (i in col) print i, col[i]}'  

Apache - Allow access for folders starting with /

Posted: 19 Oct 2021 08:09 AM PDT

I'm running apache in a linux environment. I've to serve files whose directory structure have "/." in it. Now, apache by default won't allow files with /. To remove the constraint, I've included the following entry in httpd conf.

  <DirectoryMatch "^.|/.">      Order allow,deny      Allow from all  </DirectoryMatch>  
But,this opens up all hidden directories under apache root. I'm trying to use a directory pattern so that it'll only allow files under this directory. For e.g. the directory path always start with /content/. The occurrence of /. can be anywhere. For e.g.
  /content/url/test/.NET/sample/abc.html  /content/xyz/.BETA/sample/test.html  
As you can see, I'm trying to create a pattern where the rule would allow directories starting with "/content" and can having "/." in its path. Just wondering if it's possible to have a rule like this in option.

Serve Internet to remote machine via SSH session?

Posted: 19 Oct 2021 10:32 AM PDT

The machine via which I'm SSHing to the remote/host machine (same network/LAN) has access to the Internet but the host doesn't.

Running updates and installing packages on the host gets quite inconvenient because then I have to start a proxy locally and then configure the remote machine to use it.

So I was wondering if there is a easier way of doing this via, maybe, SSH or something else?

I have a realization of the complexities that lie within, but was curious to know.

Using plink through Emacs (if it matters).

No comments:

Post a Comment