Monday, May 17, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Linux shell command pasting issue

Posted: 17 May 2021 10:54 AM PDT

I frequently need to run a script and provide it several lines of STDIN. When doing this, I'll typically prepare the invocations, and then copy & paste them from one terminal window to another. Ideally, I'd like to be able to paste blocks of text such as:

<script name> <script args>  <STDIN line 1>  <STDIN line 2>  ...  

after which I'll hit control-d to indicate to the script that STDIN has reached the end of input.

If I do this in bash (as a single paste), the script executes, none of the STDIN echos in the session, an extra <cr> must be hit before ^d is handled, and the first line of the script's STDIN is lost. So, I typically paste the script invocation as its own paste, then all the lines of STDIN as a second paste. Doing it this way, the lines pasted echo, and I can hit control-d to indicate end of input.

If I do this under zsh, most of the STDIN lines don't echo (if there are a lot of them, some of the last lines will echo, the first of which may only echo a trailing fragment of the line), and again, an extra <cr> is needed before ^d is recognized.

It doesn't matter if the script in question is python or perl...both behave the same, which leads me to believe this is a shell issue.

The question is, what's the issue, and is there a fix that would allow doing each execution as a single paste?

remove lines that contain some string from another file

Posted: 17 May 2021 11:08 AM PDT

grep -v -x -f f2 f1  

I tried this but not work cause I have

f2:

test 141.1.11.1  test2 8.18.8.8  4.4.4.4  

f1:

test 1.1.1.1  test2 8.8.8.8  test3 4.4.4.4  

The idea is to remove the line test3 4.4.4.4 because contains 4.4.4.4, but this is not working. Where is wrong with my command?

It removes when I just typed exactly but not if contains that only 4s.

Start VM with Script with a delay and reset the vm once?

Posted: 17 May 2021 10:44 AM PDT

Can Someone help me make a simple script to start a vm and reset the vm after 10 seconds of delay in the background while the VM Running in Virt manager in Arch linkux (manjaro)

How to get all files that are denied for a user by using getfacl

Posted: 17 May 2021 10:30 AM PDT

How to get all files that are denied for a user by using getfacl.

I've used /bin/setfacl to deny a user access to certain executable files. and I would like to know which files that the user cannot access.

example: /bin/setfacl -m u:usernamehere:--- /bin/sh

using Ubuntu 20.04 LTS

How can I use both PKI and Kerberos Authentication for login

Posted: 17 May 2021 10:29 AM PDT

I am trying to implement PKI and Kerberos authentication when using PuttyCAC to ssh into a Linux VM using my smart card. What configuration files do I need to configure and what should I add to those files? Kerberos is already implemented and works with ad accounts with passwords. When I enter using PuttyCAC I have to enter a pin and then it unlocks the private ssh key to the Linux VM but it's not verifying my user to the AD with Kerberos.

Arch Linux error when running startx

Posted: 17 May 2021 10:35 AM PDT

I have an Arch Linux setup running BSPWM, I don't use a login manager, but instead just run startx (with xinit). When I exit BSPWM and go back to the tty, I see the following error:

xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)  

I have an NVIDIA GPU (RTX 2070 Super) and have installed the (latest) proprietary drivers.

I'm not sure what is relevant to the issue, but I'll gladly include more info.

I did find this question, I didn't try the solution because frankly I'm not entirely sure what the impact of this would be (it's not really explained).

EDIT

I ended up trying the linked suggestion and it didn't work.

When using Spice and remote-viewer with multiple virtual monitors, stuck on "Waiting for display 2" indefinately

Posted: 17 May 2021 09:52 AM PDT

Following some research, I learned that the proper method to setup multiple virtual monitors with virt-manager, libvirtd, and qemu is to use spice (link, link, link). At first, I added three total Video QXL instances, and then connected to Spice via remote-viewer. This did not work because I saw a window such as this when opening a VM's second or third virtual display (the primary one works fine): Remote viewer showing second monitor with "Waiting for display 2..." displayed in place of the monitor's contents

The extra monitors also were not shown the virtual machine. As such, I tried removing the extra Video QXL hardwares, and instead set the one that was there by default to have three heads:

<video>    <model type="qxl" ram="65536" vram="65536" vgamem="16384" heads="3" primary="yes"/>    <alias name="video0"/>    <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>  </video>  

This unfortunately produced the same error when opening the additional virtual displays, except not when I do so graphical artifacts appear in the primary display and it becomes unusable as a result.

What did I do incorrectly here? How can I enable multiple displays with this VM software stack?

Main spice XML:

<graphics type="spice" port="5900" autoport="yes" listen="127.0.0.1">    <listen type="address" address="127.0.0.1"/>    <image compression="off"/>    <gl enable="no"/>  </graphics>  

Both the host and guest are Linux (Pop OS and Debian 10 respectively). I tried upping the video ram from 16MBs to 256MBs, which ends the graphical glitches, but it does not enable interaction with the primary monitor after the second is enabled nor does it allow the second to progress past the above screenshot. I also have spice-vdagent installed in the guest.

How can I make this work?

How to add and change display resolution in (Wayland)Gnome 34?

Posted: 17 May 2021 09:51 AM PDT

In display settings I am getting any other resolution but 1920 x 1080. I want to change it to 1920 x 1080 resolution mode. How can I add it and change the resolution? I am running Fedora 34 in VMware.

Cannot connect to serial port after reboot

Posted: 17 May 2021 09:35 AM PDT

I've a USB to serial converter plugged into my device and it comes up as /dev/ttyUSB0. I run my microservice (through docker container, with privileged true) and my service can connect to the port and read the data that is coming on the port.

If I unplug the USB and plug it back in, can connect back to port /dev/ttyUSB0 and read the data.

If I unplug the USB and reboot the device and then plug in the USB, my service still cannot connect to the port, "no such file or directory" error. At this point, if I restart just my service, still see same error. However, if I restart my docker container (service also restarts when container restarts), my service can again connect back to port.

Following are some outputs when the service says it cannot connect to /dev/ttyUSB0:

  • dmesg output

dmesg | grep FTDI

[ 71.034074] usbserial: USB Serial support registered for FTDI USB Serial Device

[ 71.034488] ftdi_sio 1-1.1:1.0: FTDI USB Serial Device converter detected

[ 71.035662] usb 1-1.1: FTDI USB Serial Device converter now attached to ttyUSB0

  • List output

ls -l /dev/ttyUSB0

crw-rw---- 1 root dialout 188, 0 May 17 16:14 /dev/ttyUSB0

  • Screen command "screen /dev/ttyUSB0 57600" shows some data coming in every few seconds as expected

Field extraction in fixed width file and validating format

Posted: 17 May 2021 10:03 AM PDT

I am writing a poc for a fixed width file to extract a particular field and checking its format . But the both giving me validation failed . can you please help me to point out the issue

in code i am trying to substr the email id and trimming for space and validating the format

code

awk -v m=16 -v p=13 -v 'n=[a-z]+@gmail.com' '  {     c=substr($0,m,p)    sub(" +$", "", c)    c !~ "^" n "$"    printf "%s:%s:%s\n", FILENAME, FNR, $0> "/dev/stderr"    count++  }  END {print count}' BNC_fixedwidth.txt  

Input file

10027  20033t  abc@gmail.com 19519  11/18/2021 12:06:10.260 PM BNC HardB 5 User Unk 125  

Most popular, trusted rpm dnf repos for CentOS Stream 8 ans RedHat 8 Enterprise Linux

Posted: 17 May 2021 09:24 AM PDT

Could you please point me to several rpm repositories that hold binary compatible packages for CentOS Stream 8 and / or RHEL 8 so I can use dnf to find newer versions of standard packages or software that is not available from official IBM Red Hat repositories?

How do I get a list of screen session names for a loop

Posted: 17 May 2021 09:11 AM PDT

I have used a loop to create a set of screens using Bash that are connected to a set of serial ports:

for i in $(ls /dev/ttyACM*)  do      screen -S ${i##*/} -L -d -m $i  done  

Subsequently, I want to send reset commands to all of these screens repeatedly until they are all closed (some of the devices require several resets in order to reboot). For this I need a list of the active screen session names.

Unfortunately, a command like for j in $(screen -ls); do echo $j; done returns this:

There  are  screens  on:  33097.ttyACM6  (17.05.2021  18.53.46)  (Detached)  33085.ttyACM0  (17.05.2021  18.53.46)  (Detached)  2  Sockets  in  /run/screen/S-keir.finlowbates.  

What I'd like is a command like that, which returns:

ttyACM6  ttyACM0  

Then I'd be able to run:

for i in $(<<magic stuff here>>)      screen -S ${i##*/} -X stuff 'reset^M'  done  

until there are no more screens left.

Can anyone help me with the <<magic stuff here>>?

dd: writing to Invalid argument with 4k blocksize on iSCSI LUN

Posted: 17 May 2021 09:03 AM PDT

Why can't use oflag=direct on the 4k blocksize iSCSI disk? Could other applications also have a problem with the cause?

root@testvm02:~# dd if=/root/speedtest of=/mnt/8k_512/speedtest oflag=direct  51200+0 records in  51200+0 records out  26214400 bytes (26 MB, 25 MiB) copied, 59,4312 s, 441 kB/s    root@testvm02:~# dd if=/root/speedtest of=/mnt/8k_4k/speedtest oflag=direct  dd: writing to '/mnt/8k_4k/speedtest': Invalid argument  1+0 records in  0+0 records out  0 bytes copied, 0,000790648 s, 0,0 kB/s    root@testvm02:~# dd if=/root/speedtest of=/mnt/4k_4k/speedtest oflag=direct  dd: writing to '/mnt/4k_4k/speedtest': Invalid argument  1+0 records in  0+0 records out  0 bytes copied, 0.000139662 s, 0.0 kB/s  

my environment @storage server:

/usr/sbin/zfs create -s -V 50GiB STORAGE01/4af1a9b7-0592-4707-a875-986d91fceac4 #<-- / & vda on testvm02  /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --lun 1 -b /dev/zvol/STORAGE01/4af1a9b7-0592-4707-a875-986d91fceac4  #  /usr/sbin/zfs create -s -V 50GiB STORAGE01/209afd7c-bdd6-4125-a899-b98758fcc6c0 #<-- /mnt/8k-512 & vdb on testvm02  /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --lun 2 -b /dev/zvol/STORAGE01/209afd7c-bdd6-4125-a899-b98758fcc6c0  #  /usr/sbin/zfs create -s -V 50GiB STORAGE01/6ae21fa3-df76-4843-ab65-0700af4f04f7 #<-- /mnt/8k-4k & vdc on testvm02  /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --blocksize 4096 --lun 3 -b /dev/zvol/STORAGE01/6ae21fa3-df76-4843-ab65-0700af4f04f7  #  /usr/sbin/zfs create -s -o volblocksize=4k -V 50GiB STORAGE01/24d38989-b47b-4e3c-b5ea-5d9a30d611f6 #<-- /mnt/4k-4k & vdd on testvm02  /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --blocksize 4096 --lun 4 -b /dev/zvol/STORAGE01/24d38989-b47b-4e3c-b5ea-5d9a30d611f6  #  # default zvol blocksize = 8k, default iSCSI LUN blocksize = 512  

VM:

virt-install --name 'testvm02.domain.de' --description 'desc' --os-type 'Linux' --os-variant 'debian9' --ram 2048 --vcpus 2 --cdrom '/var/lib/libvirt/boot/firmware-10.9.0-amd64-netinst.iso' --graphics vnc,password=foobar --network 'bridge:br540,model=virtio,virtualport_type=openvswitch' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:1,logical_block_size=512,physical_block_size=512' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:2,logical_block_size=512,physical_block_size=512' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:3,logical_block_size=4096,physical_block_size=4096' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:4,logical_block_size=4096,physical_block_size=4096'  

all disks formatted with ext4

root@testvm02:~# fdisk -l  Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 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: 0x50172cb2    Device     Boot  Start       End   Sectors  Size Id Type  /dev/vda1  *      2048    999423    997376  487M 83 Linux  /dev/vda2       999424 104855551 103856128 49,5G 83 Linux      Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 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: 0x5e831f4b    Device     Boot Start       End   Sectors Size Id Type  /dev/vdb1        2048 104855551 104853504  50G 83 Linux      Disk /dev/vdc: 50 GiB, 53687091200 bytes, 13107200 sectors  Units: sectors of 1 * 4096 = 4096 bytes  Sector size (logical/physical): 4096 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes  Disklabel type: dos  Disk identifier: 0x791f5094    Device     Boot Start      End  Sectors Size Id Type  /dev/vdc1         256 13106943 13106688  50G 83 Linux      Disk /dev/vdd: 50 GiB, 53687091200 bytes, 13107200 sectors  Units: sectors of 1 * 4096 = 4096 bytes  Sector size (logical/physical): 4096 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes  Disklabel type: dos  Disk identifier: 0x6de2b945    Device     Boot Start      End  Sectors Size Id Type  /dev/vdd1         256 13106943 13106688  50G 83 Linux  

How to build & install Debian package from source on Ubuntu 18.04

Posted: 17 May 2021 11:04 AM PDT

What is the most convenient way to build and install packages that are found from Debian Tracker on Ubuntu 18.04 Bionic Beaver?

For example I am interested in this unstable version of gdal.

So I would need to build the package from source and install it's dependencies.

apt update  apt install -y build-essential devscripts equivs  dget https://deb.debian.org/debian/pool/main/g/gdal/gdal_3.2.2+dfsg-1.dsc  dpkg-source -x gdal_3.2.2+dfsg-1.dsc  cd gdal-3.2.2+dfsg/  mk-build-deps -i  

Problem at the moment is that some of the dependencies are not found from Ubuntu repositories. Is it somehow possible to have them installed from the debian source also?

Broken gdal-build-deps:amd64 Depends on libdeflate-dev:amd64 < none @un H >    Removing gdal-build-deps:amd64 because I can't find libdeflate-dev:amd64  

move all files except one that matches filename

Posted: 17 May 2021 10:54 AM PDT

I want to move all files in my current directory to a directory named NewDir that end with *.bam, except for a specific file named special.file.bam.

I have found this command that removes all files, but not sure how to move them, not deleting them:

find . ! -name 'special.file.bam' -type f -exec rm -f {} +  

How to display the content of a file using pipe?

Posted: 17 May 2021 09:28 AM PDT

I have a text file and I should display its content using pipe in a C program. I have made something like this but isn't exactly what I need.

#include <unistd.h>    #define MSGSIZE 16    char *msg1 = "hello, world #1";  char *msg2 = "hello, world #2";  char *msg3 = "hello, world #3";    int main() {    char inbuf[MSGSIZE];      int p[2], i;      if (pipe(p) < 0)      exit(1);      /* continued */    /* write pipe */      write(p[1], msg1, MSGSIZE);    write(p[1], msg2, MSGSIZE);    write(p[1], msg3, MSGSIZE);      for (i = 0; i < 3; i++) {      /* read pipe */      read(p[0], inbuf, MSGSIZE);      printf("% s\n", inbuf);    }    return 0;  }  

Here I gave the messages that I want to display. I really do not know how to do it for a file.

Is there a way to disable all write access for a specific user in a directory?

Posted: 17 May 2021 10:59 AM PDT

I recently learned about ACL and setfacl for setting per-user access rights. But there is one thing that I cannot figure out how to pull off, and that is restricting all write(*) access for a specific user in a specific directory and everything inside it.

To put it another way, consider a user some_user and a directory some_dir (suppose chmod 777 some_dir has been used). Is there a way to restrict some_user's write access - without altering any other access right - in some_dir and all of its content?

What I have tried/thought of:

  • setfacl -R -m u:some_user:rx some_dir/ won't do the trick as it would give some_user read access to files that the user might have not been able to read before, as well as execute access to files the user might have not been able to execute before.
  • Setting a r-x mask to some_dir recursively (again with setfacl) also won't do it, as there is no way to make a mask specific to one user (as far as I know)

Having skimmed through ACL documentation, I haven't come across anything that points to this direction, so just to be clear, I am not necessarily looking for a way to do this with ACL.

(*) or read, or execute access - I guess it shouldn't matter which one it is, but I will stick with write access to keep it simple

Command works in terminal, but not in crontab

Posted: 17 May 2021 10:01 AM PDT

I'm testing to set up some backup. I set up my crontab to run every minute. I have a disk that is mounted on machine2 that I will upload the backup to.
I'm compressing the content of folder /home/user/important to important.tar.gz and moving the tar.gz file to machine2's /mnt/backup2 folder.

cron tab entry:

* * * * * tar -czvf /home/user/important/important.tar.gz /home/user/important &&   rsync -vzhe ssh /home/user/important/*.tar* machine2:/mnt/backup2  

This will not run with crontab.

I'm running the same command in terminal. Then it works:

/home/user/important/  /home/user/important/a.txt  /home/user/important/test.txt  /home/user/important/this.txt  /home/user/important/is.txt  /home/user/important/important.tar.gz  /home/user/important/important.txt  /home/user/important/test1/  important.tar.gz    sent 9.85K bytes  received 35 bytes  19.76K bytes/sec  total size is 9.75K  speedup is 0.99  

And file is received on machine2 in the /mnt/backup2 folder.

Any suggestions why it doesn't work with crontab? Im running Ubuntu.

Linux 64-bit SSH port numbers?

Posted: 17 May 2021 09:09 AM PDT

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

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

and practically

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

How to sort files based on barcode and bubble forms?

Posted: 17 May 2021 11:11 AM PDT

I need to setup a process for easily sorting worksheets completed by students. The basic idea is, I'll collect their work, run it through a feed scanner, which sends me a PDF of all of the pages. Using ImageMagick, I'll split the PDF, during then into JPEGs. All of these steps above I can achieve. The next is where I need help:

First, it needs to scan something I placed on EVERY page. The script must check a barcode (or similar marking) at the top of each JPEG, indicating the page number. E.g. if it sees page 1a, it sends that to a directory called "1a". This could be displayed as a barcode, or maybe there is software that can recognize the page number?

Next, it would need to scan something students placed on their page, identifying which student filled in the worksheet. The script needs to identify which students completed the worksheet, and sort them. For this, the students will indicate their name or perhaps an assigned number. Since I doubt any software can perform hand-recognition on students with many different hand-writings, this might be some kind of scan-tron like area where students fill in bubbles. E.g. I assigned a student as #130, so they fill in bubbles indicating 130, and then the script sends that JPEG to directory "1a/130/".

Does anyone have any ideas what tools I can use for scanning the information off the page?

No matching VNC server running for this user!

Posted: 17 May 2021 10:59 AM PDT

I'm using Kali Nethunter, and I need help to fix this.  I've been using the command nethunter -r kex & and I'm getting this error:

vncserver: No matching VNC server running for this user!  vncserver: No matching VNC server running for this user!  Error starting the KeX server.  Please try "nethunter kex kill" or restart your termux session and try again.  

This happened after I gave the command apt upgrade.  How can I fix this?

To answer the follow-up questions (in comments):

  • Yes, I tried nethunter kex kill.
  • No, I did not get any yes/no prompts like "Do you want to continue? [Y/n]".

Can't set DisplayPort output to 4k@60hz on the new Huawei Matebook 14 AMD

Posted: 17 May 2021 09:40 AM PDT

Just this week I got the newest Matebook 14 2020 AMD with the 4800H. On windows I'm using an UtechSmart USB-C hub to output 4K@60Hz to my monitor so physically I know it's possible.

Linux, however, is another story. I installed Kubuntu 20.04 LTS, but I could only boot to it (kernel 5.4 I believe) by going into recovery mode, and then selecting continue boot. Otherwise it would just hang on the Huawei logo. I installed the 5.8.15 kernel and everything seems to work fine, except I can't seem to set the display output to 60Hz, even though it's available in the settings, confirmed also by xrandr:

> Screen 0: minimum 320 x 200, current 3840 x 3600, maximum 16384 x 16384  eDP connected primary 2160x1440+783+2160 (normal left inverted right x axis y axis) 296mm x 197mm    2160x1440     60.00*+    1920x1200     60.00       1920x1080     60.00       1600x1200     60.00       1680x1050     60.00       1280x1024     60.00       1440x900      60.00       1280x800      60.00       1280x720      60.00       1024x768      60.00       800x600       60.00       640x480       60.00     HDMI-A-0 disconnected (normal left inverted right x axis y axis)  DisplayPort-0 disconnected (normal left inverted right x axis y axis)  DisplayPort-1 disconnected (normal left inverted right x axis y axis)  DisplayPort-2 disconnected (normal left inverted right x axis y axis)  DisplayPort-3 disconnected (normal left inverted right x axis y axis)  DisplayPort-4 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 600mm x 340mm    3840x2160     60.00 +  30.00*      2560x1440     59.95       1920x1080     60.00    59.94       1600x900      60.00       1280x1024     60.02       1280x800      59.81       1280x720      60.00    59.94       1024x768      60.00       800x600       60.32       720x480       60.00    59.94       640x480       60.00    59.94  

However, running xrandr --output DisplayPort-4 --mode 3840x2160 --rate 60, I get xrandr: Configure crtc 1 failed

I assumed this has something to do with the amdgpu drivers, so I went ahead and downloaded the latest 20.30 version, however, I get the following error:

Loading new amdgpu-5.6.5.24-1109583 DKMS files...  Building for 5.8.15-050815-generic  Building for architecture x86_64  Building initial module for 5.8.15-050815-generic  ERROR (dkms apport): kernel package linux-headers-5.8.15-050815-generic is not supported  Error! Bad return status for module build on kernel: 5.8.15-050815-generic (x86_64)  Consult /var/lib/dkms/amdgpu/5.6.5.24-1109583/build/make.log for more information.  

I even tried installing it on the 5.8.1 kernel with no luck.

This is where I'm stuck right now, and I'm pretty sure I wrecked the whole installation. Any insight on how to fix my problems?

How to remove newline character within a column in a tsv file?

Posted: 17 May 2021 11:00 AM PDT

enter image description here

I need "This contains newline" in one row, newline from the column2 and column4 need to remove.

nb: For your understanding the data I upload an image if you want I will upload the text content

"column1"   "column2"          "column3"    "column4"           " column5"  "DATA"       "THIS                 "DATA"   "THIS                "DATA"               CONTAIN NEWLINE"                 CONTAIN NEWLINE"    I need to remove the newline and output looks like:  "column1"   "column2"                "column3"  "column4"                " column5"  "DATA"      "THIS CONTAIN NEWLINE"    "DATA"    "THIS CONTAIN NEWLINE"     "DATA"  

Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)

Posted: 17 May 2021 11:06 AM PDT

I'm trying to update to node 7.x through the terminal on my raspberry pi and I keep encountering this error. The command I'm using is:

sudo curl -sL https://deb.nodesource.com/setup_7.x | bash -  

Running this command as root doesn't work so I tried to see if apt-get was being used by any other processes.

ps aux | grep apt  pi        1295  0.0  0.1   4272  1848 pts/0    S+   06:24   0:00 grep --color=auto apt  

This is all I get. Ultimately, (although it was initially advised not to do so), I tried removing the files and running the command again.

sudo rm /var/lib/apt/lists/lock && sudo rm /var/lib/dpkg/lock  

Now neither one of these files no longer exists and I still receive the same error when trying to use curl. I also tried to kill that one process and I still get the error.

Finding and deleting files with a specific date

Posted: 17 May 2021 09:33 AM PDT

how to delete the files that created on Aug 7 with the name DBG_A_sql* under /tmp

as the following example:

-rw-r--r-- 1 root    root   51091 Aug  7 11:22 DBG_A_sql.2135  -rw-r--r-- 1 root    root   15283 Aug  7 11:22 DBG_A_sql.2373  -rw-r--r-- 1 root    root   51091 Aug  7 11:22 DBG_A_sql.2278  -rw-r--r-- 1 root    root    9103 Aug  7 11:22 DBG_A_sql.2485  -rw-r--r-- 1 root    root    9116 Aug  7 11:22 DBG_A_sql.2573  -rw-r--r-- 1 root    root    9140 Aug  7 11:22 DBG_A_sql.2679  -rw-r--r-- 1 root    root   15695 Aug  7 11:22 DBG_A_sql.2897  

Logging in with 'su' without entering a password

Posted: 17 May 2021 10:01 AM PDT

How can I log in with the su command in one line in the terminal? I know that the sudo command can do that:

echo [password] | sudo -S [command]  

But when I try to imply it in the su command :

echo [password] | su [username]  

I get an error:

standard in must be tty  

I don't have access to the sudo account (so I can't access and edit the sudoers file).

I know that the right syntax is basically:

su [username]  

What I want to do is to add a su command to aliases without being needed to enter password every time

How can I configure Postfix to silently drop/discard/reject mails that were sent from specific users to an external address?

Posted: 17 May 2021 09:01 AM PDT

How can I configure Postfix to silently drop/discard/reject mails that were sent from specific users to an external address? It should work only for specific users

E.g:

  1. abc@localdomain can send mail to only @localdomain users.
  2. abc@localdomain can only receive from @localdomain users.

Create a tar archive split into blocks of a maximum size

Posted: 17 May 2021 09:15 AM PDT

I need to backup a fairly large directory, but I am limited by the size of individual files. I'd like to essentially create a tar.(gz|bz2) archive which is split into 200MB maximum archives. Clonezilla does something similar to this by splitting image backups named like so:

sda1.backup.tar.gz.aa  sda1.backup.tar.gz.ab  sda1.backup.tar.gz.ac  

Is there a way I can do this in one command? I understand how to use the split command, but I'd like to not have to create one giant archive, then split it into smaller archives, as this would double the disk space I'd need in order to initially create the archive.

SSH not landing in the home directory

Posted: 17 May 2021 09:29 AM PDT

I have recently installed Raspbian into a Raspberry Pi. As part of the installation process I changed the user name and group from the default (pi) to my own (let's call it user) using usermod and groupmod. I also moved the home directory (/home/pi) to the new user name (/home/user) using usermod. Everything works fine except that when I login using SSH instead of landing the new user directory (/home/user) I end up at the home directory (/home). Any idea why this may be happening? Any solution? It's not a big deal but it is confusing me.

The directory /home/user exists with permissions 755. In addition to that the /etc/passwd file contains an entry that looks like the following:

user:x:1000:1000:User:/home/user:/bin/bash  

To me everything looks fine, but still when I login from ssh I get a prompt that looks like user@raspberrypi /home $.

No comments:

Post a Comment