Friday, May 13, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Disabling "A stop job is running" in Debian 10

Posted: 13 May 2022 04:52 AM PDT

I have a few Debian 10 systems (Proxmox) which take anywhere from 5 minutes to forever to reboot.

Sometimes I need to drive into the DC and physically hit the power button. The keyboard is always unresponsive at this point. I don't know if USB is already disabled in the reboot process or what. The holdup is always Systemd with "A stop job is running". Today it appears to be the swap partition.

15 minutes to "never" to reboot

Any way to put a kill-switch on the stop jobs? I don't care if swap gets hosed due to a dirty unmount - At this point, I'd rather just fsck -Cf after every reboot and mount swap by hand.

Nautilus only show directories with access

Posted: 13 May 2022 04:21 AM PDT

We are running a multi-user environment. Also, we have a few shared folders in /home where different groups of people have access to. Now that we have quite a few users, the /home directory is quite cluttered. Is there a way to tell Nautilus system-wide to by default only show the directories the user actually has access to? That way, everybody would just see their own home directory and the directories for that they have the correct group permission. That would be less confusing, especially for new people that haven't yet setup bookmarks for the directories they often use.

And it would have to be a solution for Nautilus since we are using GNOME and I don't know how well other file managers would integrate with the rest.

Our setup: Pop OS 22.04 with GNOME 42 (and in parts 41, but Nautilus is v42)

PCIe kernel module UIO PCI GENERIC

Posted: 13 May 2022 04:30 AM PDT

I build petalinux 18.03 for PICe application for zcu102 Xilinx card.

When I debug simple PCI read/write I get an error saying he can't load this driver from Linux file system:

uio_pci_generic  

So the segmentation error comes from this issue.

Thing is in the petalinux kernel configuration i did add

<*> Userspace I/O drivers --->  <M> Generic driver for PCI 2.3 and PCI Express cards  

Or maybe I am missing something when building petalinux?

Creation of Kernel Modules

Posted: 13 May 2022 05:04 AM PDT

I have to create a linux driver for the first time and I have some questions which I don't found convenient answer. My goal is to create a PWM driver, I already succeed to create a driver and work with him thank's to IOCTL but I want do two more things for which one I have no idea how do that.

The first thing : I want the driver be load at boot, I read a lot of things about probe function but I don't understand how it's work, some people talk about module-load.r so what is the best way to do that ?

The second thing : I have to create many drivers for each device tree declaration of device which use this drivers, but how create dynamically a file in /dev/ for each instances ?

I don't know if it's clear but I give the code and the device tree :

#define WR_DUTYCYCLE _IOW('a', 1, int32_t *)  #define WR_FREQ _IOW('a', 2, int32_t *)  #define RD_DUTYCYCLE _IOR('a', 3, int32_t *)  #define RD_FREQ _IOR('a', 4, int32_t *)    #define DEV_CLASS_MODE ((umode_t)(S_IRUGO|S_IWUGO))    /* Meta Information */  MODULE_LICENSE("GPL");  MODULE_AUTHOR("Benjamin CLEMENT");  MODULE_DESCRIPTION("Generate a PWM with chosen DUTY CYCLE and FREQUENCY");    /* Variables for device and device class */  static dev_t my_device_nr;  static struct class *my_class;  static struct cdev my_device;    static struct platform_device *pdev;  unsigned long *base_addr;  unsigned long *base_addr;    #define DRIVER_NAME "pwm"  #define DRIVER_CLASS "MyModuleClass"      /**   * @brief This function is called, when the device file is opened   */  static int driver_open(struct inode *device_file, struct file *instance) {      printk("dev_nr - open was called!\n");      return 0;  }    /**   * @brief This function is called, when the device file is opened   */    static int driver_close(struct inode *device_file, struct file *instance) {      printk("dev_nr - close was called!\n");      return 0;  }    /**   * @brief This function is called, when the module use IOCTL for write or read   */    static long int my_ioctl(struct file *file, unsigned cmd, unsigned long arg){            long int back;                                                                      //Looking for the register      char *path = "/";                                                  struct device_node *dt_node;        dt_node = of_find_node_by_path(path);      struct device_node *dt_pwm;      u32 reg[4];             //Looking for base_adress      if (!dt_node) {                                                                        printk(KERN_ERR "Failed to find node by path: %s.\n");                         } else {                                                                                   dt_pwm = of_find_node_by_name(dt_node, file->f_path.dentry->d_iname);              if (!dt_pwm) {                                                                                printk(KERN_ERR "Failed to find node pwm: %s.\n");                                 }              else{                  of_property_read_u32_array(dt_pwm, "reg", reg, 4);                  //printk("Adress GPIO1 : %x", reg[1]);                   //printk("ADRESS GPIO2 : %x", reg[1] + 8);              }      }      switch(cmd){          case WR_DUTYCYCLE:               writel(arg, ioremap(reg[1], 8));              //printk("test wrdc %lu\n", arg);              back = 0;              break;          case WR_FREQ:              writel(arg, ioremap(reg[1] + 8, 8));              back = 0;              break;          case RD_DUTYCYCLE:              back = readl(ioremap(reg[1], 8));              printk("Valeur ecrite dc : %d", back);              break;          case RD_FREQ:              back = readl(ioremap(reg[1] + 8, 8));              printk("Valeur ecrite : %d", back);              break;      }      return back;  }    static struct file_operations fops = {      .owner = THIS_MODULE,      .open = driver_open,      .release = driver_close,      .unlocked_ioctl = my_ioctl,  };    /**   * @brief This function is called at init for permit all users to call this drivers   */    static char *mydevnode(struct device *dev, umode_t *mode)    {       if (mode)           *mode = DEV_CLASS_MODE;;        return NULL;   }    /**   * @brief This function is called, when the module is loaded into the kernel   */           static int __init ModuleInit(void) {      int retval;      printk("Hello, Kernel! test2\n");        /* Allocate a device nr */      if(alloc_chrdev_region(&my_device_nr, 0, 1, DRIVER_NAME) < 0) {          printk("Device Nr. could not be allocated!\n");          return -1;      }      printk("read_write - Device Nr. Major: %d, Minor: %d was registered!\n", my_device_nr >> 20, my_device_nr && 0xfffff);        /* Create device class */      if((my_class = class_create(THIS_MODULE, DRIVER_CLASS)) == NULL) {          printk("Device class can not be created!\n");          goto ClassError;      }        //Activate for all users      my_class->devnode = mydevnode;            /* create device file */      if(device_create(my_class, NULL, my_device_nr, NULL, DRIVER_NAME) == NULL){          printk("Can not create device file!\n");          goto FileError;      }      /* Initialize device file */      cdev_init(&my_device, &fops);        /* Registering device to kernel */      if(cdev_add(&my_device, my_device_nr, 1) == -1) {          printk("Registering of device to kernel failed!\n");          goto AddError;      }            return 0;  AddError:      device_destroy(my_class, my_device_nr);  FileError:      class_destroy(my_class);  ClassError:      unregister_chrdev_region(my_device_nr, 1);      return -1;  }    /**   * @brief This function is called, when the module is removed from the kernel   */  static void __exit ModuleExit(void) {      cdev_del(&my_device);      device_destroy(my_class, my_device_nr);      class_destroy(my_class);      unregister_chrdev_region(my_device_nr, 1);      printk("Goodbye, Kernel\n");  }    module_init(ModuleInit);  module_exit(ModuleExit);  

And my concerning device tree is this :

amba_pl@0 {          #address-cells = <2>;          #size-cells = <2>;          compatible = "simple-bus";          ranges ;              pwm1@80000000 {              #gpio-cells = <3>;              clock-names = "s_axi_aclk";              clocks = <&zynqmp_clk 71>;              compatible = "pwm";              gpio-controller ;              reg = <0x0 0x80000000 0x0 0x10000>;              xlnx,all-inputs = <0x1>;              xlnx,all-inputs-2 = <0x1>;              xlnx,all-outputs = <0x0>;              xlnx,all-outputs-2 = <0x0>;              xlnx,dout-default = <0x00000000>;              xlnx,dout-default-2 = <0x00000000>;              xlnx,gpio-width = <0x20>;              xlnx,gpio2-width = <0x20>;              xlnx,interrupt-present = <0x0>;              xlnx,is-dual = <0x1>;              xlnx,tri-default = <0xFFFFFFFF>;              xlnx,tri-default-2 = <0xFFFFFFFF>;          };              pwm0@80010000 {              #gpio-cells = <3>;              clock-names = "s_axi_aclk";              clocks = <&zynqmp_clk 71>;              compatible = "pwm";              gpio-controller ;              reg = <0x0 0x80010000 0x0 0x10000>;              xlnx,all-inputs = <0x0>;              xlnx,all-inputs-2 = <0x0>;              xlnx,all-outputs = <0x1>;              xlnx,all-outputs-2 = <0x1>;              xlnx,dout-default = <0x00000000>;              xlnx,dout-default-2 = <0x00000000>;              xlnx,gpio-width = <0x8>;              xlnx,gpio2-width = <0x20>;              xlnx,interrupt-present = <0x0>;              xlnx,is-dual = <0x1>;              xlnx,tri-default = <0xFFFFFFFF>;              xlnx,tri-default-2 = <0xFFFFFFFF>;          };      };  

Thank's for any help !

Extracting torrent's file structure out of transmission

Posted: 13 May 2022 03:22 AM PDT

I screwed up my torrents' download directory (I executed mv */* . twice in it) and would like to repair it now. If you have an idea how to do this feel free to comment, but I already have an idea which makes (I think) quite a neat programming challenge, so I'd like to do it this way.

To do this I just need a list of all files with their paths before I screwed up (It doesn't matter whether not yet downloaded file are listed or not). Transmission (the torrent client I'm using) has to have a list of all torrents and Transmission can show me all files for a given torrent, so I just need to combine these two. But I weren't able to figure out how by looking in ~/.config/transmission, with a web search or by looking at it's source code.

Linux bash not working properlly [duplicate]

Posted: 13 May 2022 03:02 AM PDT

I am trying to run the following script on a OpenSuse machine:

OUR_REPO=$(git branch | grep "*" | awk '{print $2}')  THE_REPO_THAT_OURS_IS_BASED_ON="origin/$OUR_REPO"  GIT_COMMIT=$(git merge-base $OUR_REPO $THE_REPO_THAT_OURS_IS_BASED_ON)  echo "$OUR_REPO"  echo "$THE_REPO_THAT_OURS_IS_BASED_ON"  echo "$GIT_COMMIT"  

and I get the following error:

fatal: Not a valid object name release/VERSION?  release/VERSION  origin/release/VERSION  

The interesting part is that, if I am running each of those commands directly into the terminal everything works properly.

Also, if I am trying to run this script via my local machine with Fedora, I don't have any kind of issue.

The command that I use to run the script: bash my_script.sh

On the OpenSuse machine, if has any importance, I am using zsh.

Does any of you know what I am doing wrong?

RaspberryPI cannot change permission of mounted hdd due to rpi-first-boot-wizard user

Posted: 13 May 2022 03:56 AM PDT

I mounted an external hdd into /mnt/edisk on my raspberry pi. If I check ownership, strangely I see this:

drwxr-xr-x 19 rpi-first-boot-wizard rpi-first-boot-wizard 128K May 10 17:44 edisk  

I can write to this disk with sudo But I want to change permission to my user pi.

Tried to do this with chown -R pi /mnt/edisk but this is throwing Operation not permitted error.

What is rpi-first-boot-wizard? How can I change permissions?

update

This is an exFat formatted disk

gnome-terminal not work with reboot

Posted: 13 May 2022 02:26 AM PDT

i try to open a terminal using gnome-terminal after system reboot,so i used the gnome-terminal in crontab.In normal cron it works. ex : */1 * * * * export DISPLAY=:0 && gnome-terminal but used with reboot option,it doesn't work @reboot export DISPLAY=:0 && gnome-terminal Is there any way to achieve this?

Understanding of the command "apt show"

Posted: 13 May 2022 02:22 AM PDT

Usually I use the command apt show pkg_name to check the description of a package. For example, apt show apache2. I just found that I can use apt info pkg_name to do the same thing. But I can't find this in the document (man 8 apt), from which I can find the apt show command. Is apt info undocumented?

How to restrict SSH login post ssh-copy-id

Posted: 13 May 2022 01:36 AM PDT

Environment:-

Server–1  Ubuntu 18.04.6 LTS  OpenSSH_7.6p1 Ubuntu-4ubuntu0.7, OpenSSL 1.0.2n  7 Dec 2017  
Server-2  Ubuntu 18.04.6 LTS  OpenSSH_7.6p1, OpenSSL 1.0.2n  7 Dec 2017  

From Server-1 executed ssh-copy-id admin@server-2

Now from Server-1 password less ssh connection works as expected to connect server-2 using ssh admin@server-2 command.

Requirement:-

  1. I want to restrict ssh admin@server-2 login from server-1.
  2. Since I have already executed ssh-copy-id admin@server-2 in server-1, I should prevent only ssh admin@server-2 login.

Please let me know is there any way available to prevent?

Ubuntu ls doesn't show all the files, but when I "ls filename", it shows up?

Posted: 13 May 2022 01:48 AM PDT

I am using PHP 7.3 to move some files around, in a larger app. The PHP 7 is running on Ubuntu 20.04.4 in a wsl2 container in Windows 10.

On reading through other questions, it seems this is probably weirdness from windows-subsystem-for-linux, but I need to work out how to rectify it?

Once complete, there should be a group of files and a directory within. Everything works without error, and then I go to the directory and this happens:

  root@mymachine:/data/temp# ls 4583308_163*                  <---- list glob  4583308_163_master.jpg    4583308_163:  TileGroup0  TileGroup1  4583308_163.xml    root@mymachine:/data/temp# ls 4583308_163                   <---- tab completions  4583308_163/            4583308_163_master.jpg    root@mymachine:/data/temp# ls 4583308_163.jpg               <---- individual filenames show????  4583308_163.jpg    

So an ls glob shows a file that I didn't move and a directory that has been created and files that have just been moved into that directory, but there are also 3 other files moved into the top level and they aren't showing.

Tab completions don't show them either, but if I ls the filename of the file that is there, I can see it!?

The file is definitely there, and can be seen by other commands if opened directly but globbing fails (file 4583308_163.jpg is good, file 4583308_163.* gives no such file or directory error)

You'd think after over 25 years of *nix I'd have an answer for this... Anyone have an idea?

I have tried using bash and sh, and it is the same on both. find also can't "find" the files.

Restarting wsl with wsl --shutdown doesn't work - I'm not admin and it's a work computer, and I can't get admin. So my thinking is that the only way I can see those files is to restart the computer, which I just did and I still can't see the files.

How to sync two folders with the same file names but different extensions

Posted: 13 May 2022 02:47 AM PDT

Is there a means of using rsync to sync two folders?

I would like to shoot photos in JPG and RAW. Since viewing JPGs is much quicker than opening up RAWs, I'd like to do culling in the JPG folder and then sync it to the RAW folder. However they contain different extensions but the same file name.

I realize that the most likely solution is to create a sh to accomplish this and then give it an alias.

Bash: sed or awk rewrite of numerical sequence

Posted: 13 May 2022 05:08 AM PDT

How to write a sed (or awk, or both) which will rewrite the following:

echo 'v100 v201 v102 v300 v301 v500 v999 v301' | sed/awk ...  

to this output:

v1 v2 v3 v4 v5 v6 v7 v5  

i.e. each subsequent vx was rewritten to start with v1...vn and where the same v was used in the sequence (i.e. v301) the same v should be applied (as in v5).

Sidenote: the example input sequence shows all possible eventualities (i.e. duplicates, out of order originals, jumps in original numbers).

Are you the sed or awk expert who can answer this?

How to parse an escaped json string with ansible/jmespath/jq?

Posted: 13 May 2022 02:28 AM PDT

I'm using the Ansible module for Bluecat to make an authorized API call to get some information about a subnet. The response looks something like this:

"result": {          "changed": false,          "failed": false,          "json": "b'{\"id\":12345,\"name\":\"SUBNET NAME\",\"properties\":\"CIDR=10.2.2.0/24|allowDuplicateHost=enable|pingBeforeAssign=disable|inheritAllowDuplicateHost=true|inheritPingBeforeAssign=true|gateway=10.2.2.1|inheritDNSRestrictions=true|inheritDefaultDomains=true|inheritDefaultView=true|\",\"type\":\"IP4Network\"}\\n'",          "msg": "",          "status": 200  }  

As you can see, all the useful data is in that json field, but it's some string literal abomination with escaped quotes and newlines. If I run

- debug:        msg: "{{ result | json_query('json.name') }}"  

in Ansible, it gives me back the msg field instead! I can get the entire json field, but not anything inside it. If I tinker with it a little bit and trim the b at the beginning, the inner single quotes, and the extra backslash by the newline at the end, then jq .json | fromjson parses it correctly. But I'm fairly certain b'' just means byte encoding and shouldn't break the parsing, but it does. And what's with the double backslashes at the end?

Do I have any options beyond using some sed black magic to wipe out all of the escape characters? Why would a web API return a string literal like this?

How can I keep both access point and connection to wifi working simultaneously?

Posted: 13 May 2022 02:47 AM PDT

I am working on a device running Yocto Linux. A systemd service is set to create an access point at boot:

systemd unit:

[Unit]  Description=Creates access point.  After=network.target    [Service]  ExecStart=/bin/bash /usr/sbin/create_access_point.sh  Restart=on-failure  RestartSec=5s    [Install]  WantedBy=multi-user.target  

create_access_point.sh:

#!/bin/bash  modprobe brcmfmac  ifconfig eth0 down  iw dev wlan0 interface add wlan1 type __ap  ifconfig wlan1 192.168.3.1 up  udhcpd /etc/udhcpd.conf  hostapd /etc/myhostapd.conf  

udhcpd.conf:

start 192.168.3.10  end   192.168.3.100      interface   wlan1    

myhostapd.conf:

interface=wlan1  driver=nl80211  logger_syslog=-1  logger_syslog_level=0  logger_stdout=-1  logger_stdout_level=3  ctrl_interface=/var/run/hostapd  ctrl_interface_group=0    ssid=myssid  hw_mode=g  channel=6  macaddr_acl=0  auth_algs=1  ignore_broadcast_ssid=0  wpa=2  wpa_passphrase=mypasswd  wpa_key_mgmt=WPA-PSK  wpa_pairwise=TKIP  rsn_pairwise=CCMP  

So far, everything works fine. The device runs a python script that allows to connect to a wifi network if the credentials are provided:

def connect(self):      if self.check_wifi_credentials():          subprocess.Popen(['wpa_supplicant',                             '-i',                             'wlan0',                             '-c',                             WPA_CONF_PATH,                             '-B'])          subprocess.Popen(['udhcpc', '-i', 'wlan0', '-b'])    def disconnect(self):      subprocess.Popen(['killall', 'wpa_supplicant'])  

The problem is that when the device successfully connect to the wifi, it's not possible to connect to the AP anymore, even if hostapd is still running.

If I watch the status of the systemd service while a client is trying to connect to the AP, I see the message

wlan1: AP-STA-CONNECTED

but the client cannot obtain an IP.

The following is the output of ifconfig with the device connected to a wifi:

lo        Link encap:Local Loopback            inet addr:127.0.0.1  Mask:255.0.0.0            inet6 addr: ::1/128 Scope:Host            UP LOOPBACK RUNNING  MTU:65536  Metric:1            RX packets:115 errors:0 dropped:0 overruns:0 frame:0            TX packets:115 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:1000            RX bytes:17620 (17.2 KiB)  TX bytes:17620 (17.2 KiB)    wlan0     Link encap:Ethernet  HWaddr 00:25:CA:2D:37:81            inet addr:192.168.1.74  Bcast:192.168.1.255  Mask:255.255.255.0            inet6 addr: 2001:b07:6473:8baf:225:caff:fe2d:3781/64 Scope:Global            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1            RX packets:1669 errors:0 dropped:0 overruns:0 frame:0            TX packets:1712 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:1000            RX bytes:181000 (176.7 KiB)  TX bytes:369124 (360.4 KiB)    wlan1     Link encap:Ethernet  HWaddr 00:25:CA:2D:37:81            inet addr:192.168.3.1  Bcast:192.168.3.255  Mask:255.255.255.0            inet6 addr: fe80::225:caff:fe2d:3781/64 Scope:Link            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1            RX packets:1359 errors:0 dropped:0 overruns:0 frame:0            TX packets:660 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:1000            RX bytes:172677 (168.6 KiB)  TX bytes:235999 (230.4 KiB)  

Is it possible to keep both the access point and the internet connection without interferences?

UPDATE: it seems that if the connection to the wifi is performed at boot before the creation of the AP (using another systemd unit), both the wifi client and the AP work. However I want to be able to connect to the wifi after the creation of the AP. is there a woraround for this?

How to add column based in the second line match using SED or another command?

Posted: 13 May 2022 02:02 AM PDT

I have the following lines result from zcat command

1 - URL Template: https://www.test.com    2 - Response: <200 OK,{Server=[nginx], Date=[Wed, 11 May 2022 01:05:06 GMT], Content-Type=[text/html; charset=UTF-8], Transfer-Encoding=[chunked], Connection=[keep-alive], Vary=[Accept-Encoding]}>  

I want to add the line 2 result from call to first line 1 like this

URL Template: https://www.test.com <200 OK,{Server=[nginx], Date=[Wed, 11 May 2022 01:05:06 GMT], Content-Type=[text/html; charset=UTF-8], Transfer-Encoding=[chunked], Connection=[keep-alive], Vary=[Accept-Encoding]}>  

Can I do that?

How to make libreoffice headless conversion act differently on file loading error

Posted: 13 May 2022 01:49 AM PDT

I use a script via my file manager context menu to convert various document formats (e.g. *.DOC) to ODT format like this:

for filename in "${@}"; do      if [ -f "${filename%.*}.odt" ]      then          mv "${filename%.*}.odt" "${filename%.*}_$(date +"%Y%m%d%H%m%s").odt"          libreoffice --headless --convert-to odt "$filename"      else          libreoffice --headless --convert-to odt "$filename"      fi  done  

Unfortunately, this results in removing a file without conversion if it is password-protected.

Terminal output in such case is "Error: source file could not be loaded"

I guess (and hope) it would take just a little bit more shell scripting skills to improve the very basic script above so that the input file is not removed but simply skipped (perhaps with an error message or log file as well).

Cannot boot live into linux from USB on Asus ROG laptop

Posted: 13 May 2022 03:08 AM PDT

I'm trying to dual boot on my Asus ROG Flow x13 laptop. I want to dual boot Fedora Workstation, but I'm having an issue where whenever I select Start Fedora-Workstation-Live 35 the screen will just go black, then after ~20 seconds, it will 'restart' (return to POST).

My laptop has a AMD Ryzen 9 5000 series CPU, with an Nvidia RTX 3050ti GPU. (Yea, I know Nvidia and Linux don't get along well- but i know it's possible)

I have tried all of the following:

  1. Turned off secure boot
  2. Turned off fast boot, as well as #1
  3. Tried booting into 'simple graphics' mode
  4. Tried changing the boot commands: removing quiet, adding verbose, adding nomodeset, adding nvidia.modeset=0
  5. Tried booting into a different distro (Pop!_OS, still had the same issue)
  6. Turning off drive encryption (BitLocker) in Windows 10

But to no avail. Is it something related to UEFI? Or is the GPU completely screwing me over?

Flatpak: Install a Flatpak app without installing some of its dependencies

Posted: 13 May 2022 04:40 AM PDT

How do I install a Flatpak app without installing one of its dependencies which is not really required?
For instance, if you wanted to install the TexStudio App (org.texstudio.TeXstudio), Flatpak would pull in the TeX Live SDK (org.freedesktop.Sdk.Extension.texlive) as a dependency, which is about 4.8 GB in size. The TexStudio App page at flathub mentions the following:

Requires either TeX Live being installed on the system from your distribution's repositories or the TeX Live Flatpak which you can install by running 'flatpak install flathub org.freedesktop.Sdk.Extension.texlive//21.08'

But it does not explain how you can install it without installing the Flatpak's Tex Live dependency.

Since I already have TeX Live installed in my system, I do not want to install the Flatpak's version of TeX Live, is there a way to install an app using Flatpak without installing it's "dependencies"?

How to find out which key is the Sysrq

Posted: 13 May 2022 04:31 AM PDT

My Ubuntu 18.04 -whole system- freezes regurlary. It is a Dell Latitude 3510.

  • I tried the Alt+PrintScreen (5mp)+r+e+i+s+u+b (2 mp delay between keystrokes) and the same with Alt+Home at the start.
  • Also tried this two while holding down the Alt constantly.
  • My sysrq is enabled, cat proc/sys/kernel/sysrq showed a value 176 - what ever that means.
  • The only way to shut it down is to take out the integrated battery from the inside of the laptop.

Is there a way to find out which key "hides" my SysRq?

Copy file from Windows to Linux when a shell script is executed

Posted: 13 May 2022 04:33 AM PDT

I have a program on Linux server, which runs a shell script on Linux server. (say /tmp/ShellScript.sh).

Now I want to copy a file placed on my Windows Machine location C:\WindowsFolder\FileToCopy to Linux System directory /tmp, only whenever /tmp/ShellScript.sh is executed on Linux.

How can I achieve this ?

I can also manipulate the script /tmp/ShellScript.sh itself and write the logic in that, considering it is empty by default.

named[862]: resolver priming query complete: every 20 seconds

Posted: 13 May 2022 04:31 AM PDT

BIND 9.11.3 Ubuntu 18.04 kernel 4.15.0-23

I am running bind9 as my LAN DNS and it is working for all hosts and forwarding to internet through the google DNS IPs

Why does my log have many instances of this message. 3-4 entries per minute :

 named[862]: resolver priming query complete  

I have run

 named-checkconf   named-checkzone   

without errors.

terminal in Tmux is 256color but vim isn't

Posted: 13 May 2022 03:08 AM PDT

Recently I installed tmux on my Ubuntu 16.04.

The terminal screen in tmux shows 256 color correctly however when I opened vim within tmux, the color was different from what it showed when it was run directly on the terminal.

I tried to add

set -g default-terminal "screen-256color"   

in my .tmux.conf file but the problem still exists.

  • my terminal screen in tmux: Terminal screen in tmux
  • vim run directly on the terminal: vim run directly on the terminal
  • vim run within tmux: vim run within tmux

The output of

echo $TERM; tput colors; tput longname  
  • outside tmux:
    xterm-256color  256  xterm
  • with 256 colors inside tmux:
    screen-256color  256  GUN Screen with 256 colors

Prevent sourcing a bash script, in the script itself

Posted: 13 May 2022 02:42 AM PDT

At the top of a bash script, I have this:

if [[ "$npm_registry_override" != "yes" ]]; then    echo "refusing to source npm.sh script because env is not set."    exit 0;  fi  

the problem is that when I source it and the env var is not set, my terminal window simply closes.

if I do this instead:

 if [[ "$npm_registry_override" != "yes" ]]; then        echo "refusing to source npm.sh script because env is not set."        return 0;   fi  

I get an error/warning saying cannot return unless within a bash function.

So what are you suppose to do? The only thing I can think of is to wrap my entire script in the if statement.

VNC - simple test with vnc (x11vnc and ssvnc)

Posted: 13 May 2022 05:02 AM PDT

I am trying to set up a vnc connection between 2 computers, but am having trouble so far.

In order to understand the concept, I am now simply trying to start a vnc server (using x11vnc) and connect to it using ssvnc on the same computer

This page supposedly explains how to do so.

Apparently, starting a vnc server should be as simple as downloading x11vnc and using the command x11vnc -display :0

The same page also contains a link to download ssvnc, that can be used as a vnc client (link here for your convenience)

It states that in order to connect using the vnc client, suffice to unpack the tar.gz directory, then run ./ssvnc/Unix/ssvnc.

Then, I start ssvnc and type in user@localhost such as follow:

enter image description here

However when i press connect, a xterm windows appears, with the following message:

enter image description here

The x11vnc docs mentions that a common gotcha is to set the Xauth - I tried to do that by re-running the server with

x11vnc -display :0 -auth /home/user/.Xauthority  

But I received the same error message.

Anyone can help me out here with that basic test / problem?

VBox Guest Additions installation can't find headers for Kali kernal 4.14.0-kali1-amd64

Posted: 13 May 2022 04:03 AM PDT

I have installed Kali in VirtualBox and now trying to install Guest Additions to get full screen view.

I updated and installed my packages and installed dkms. When I try to install linux-headers I get the following:

# apt-get install linux-headers-$(uname -r)  Reading package lists... Done  Building dependency tree         Reading state information... Done  linux-headers-4.14.0-kali1-amd64 is already the newest version (4.14.2-1kali1).  0 upgraded, 0 newly installed, 0 to remove and 86 not upgraded.  

The headers installed are as follows:

# dpkg --get-selections | grep linux-headers  linux-headers-4.14.0-kali1-amd64        install  linux-headers-4.14.0-kali1-common       install  linux-headers-amd64             install  

When I try to run the Guest Additions CD I get the following:

Verifying archive integrity... All good.  Uncompressing VirtualBox 5.0.40 Guest Additions for Linux............  VirtualBox Guest Additions installer  Removing installed version 5.0.40 of VirtualBox Guest Additions...  Removing existing VirtualBox DKMS kernel modules ...done.  Removing existing VirtualBox non-DKMS kernel modules ...done.  update-initramfs: Generating /boot/initrd.img-4.13.0-kali1-amd64  update-initramfs: Generating /boot/initrd.img-4.14.0-kali1-amd64  Copying additional installer modules ...  Installing additional modules ...  Removing existing VirtualBox DKMS kernel modules ...done.  Removing existing VirtualBox non-DKMS kernel modules ...done.  Building the VirtualBox Guest Additions kernel modules  The headers for the current running kernel were not found. If the following  module compilation fails then this could be the reason.    Building the main Guest Additions module ...fail!  (Look at /var/log/vboxadd-install.log to find out what went wrong)  Doing non-kernel setup of the Guest Additions ...done.  Press Return to close this window...  

It appears to me that the correct linux headers for the kernal are installed. Why is VBox not able to find them?

Tried updating to VBox 5.2.2 but after removing existing version and installing 5.2.2 I was unable to launch Kali-Linux - screenshot attached .

ipsec rightsubnet to wide, cannot override routing table | IPSec route some packets 'locally', not via tunnel; ip xfrm change?

Posted: 13 May 2022 02:00 AM PDT

I'd like to override part of the (IPSec) routing table

(routing to 10.108.0.0/16 locally via eth0, not via IPSec tunnel)

my IPSEC config

conn vpc      type=tunnel      authby=secret      left=172.16.0.200      leftid=x.x.x.x      leftsubnet=172.16.0.0/16      leftfirewall=yes      right=y.y.y.y      rightsubnet=10.0.0.0/8      #pfs=yes      auto=start  

As You can see, over the tunnel the 10.0.0.0/8 is routed

# ip r s t all  10.0.0.0/8 via 172.16.0.1 dev eth0  table 220  proto static  src 172.16.0.200   default via 172.16.0.1 dev eth0   10.108.0.0/16 via 172.16.0.1 dev eth0   172.16.0.0/24 dev eth0  proto kernel  scope link  src 172.16.0.200   broadcast 127.0.0.0 dev lo  table local  proto kernel  scope link  src 127.0.0.1   local 127.0.0.0/8 dev lo  table local  proto kernel  scope host  src 127.0.0.1   local 127.0.0.1 dev lo  table local  proto kernel  scope host  src 127.0.0.1   broadcast 127.255.255.255 dev lo  table local  proto kernel  scope link  src 127.0.0.1   broadcast 172.16.0.0 dev eth0  table local  proto kernel  scope link  src 172.16.0.200   local 172.16.0.200 dev eth0  table local  proto kernel  scope host  src 172.16.0.200   broadcast 172.16.0.255 dev eth0  table local  proto kernel  scope link  src 172.16.0.200   unreachable default dev lo  table unspec  proto kernel  metric 4294967295  error -101  fe80::/64 dev eth0  proto kernel  metric 256   unreachable default dev lo  table unspec  proto kernel  metric 4294967295  error -101  local ::1 dev lo  table local  proto none  metric 0   local fe80::52:b2ff:fe65:b0fe dev lo  table local  proto none  metric 0   ff00::/8 dev eth0  table local  metric 256   unreachable default dev lo  table unspec  proto kernel  metric 4294967295  error -101    # ipsec statusall  Listening IP addresses:    172.16.0.200  Connections:       vpc:  172.16.0.200...x.x.x.x  IKEv1/2       vpc:   local:  [x.x.x.x ] uses pre-shared key authentication       vpc:   remote: [y.y.y.y] uses pre-shared key authentication       vpc:   child:  172.16.0.0/16 === 10.0.0.0/8 TUNNEL  Security Associations (1 up, 0 connecting):       vpc[3527]: ESTABLISHED 30 minutes ago, 172.16.0.200[x.x.x.x]...y.y.y.y[]       vpc{1}:   172.16.0.0/16 === 10.0.0.0/8  

I've specifically added the

    #ip r a 10.108.0.0/16 via 172.16.0.1    10.108.0.0/16 via 172.16.0.1 dev eth0  

I hoped it would catch 'before' the table 220, but
but traffic still goes through IPSec tunnel. I must be missing some layer. I know I could change rightsubnet=10.0.0.0/8 to rightsubnet=10.0.0.0/16 but I'd like to change only one route


Just checking the

# ip xfrm policy  src 10.0.0.0/8 dst 172.16.0.0/16       dir fwd priority 1955       tmpl src x.x.x.x dst 172.16.0.200              proto esp reqid 1 mode tunnel  src 10.0.0.0/8 dst 172.16.0.0/16       dir in priority 1955       tmpl src x.x.x.x dst 172.16.0.200              proto esp reqid 1 mode tunnel  src 172.16.0.0/16 dst 10.0.0.0/8       dir out priority 1955       tmpl src 172.16.0.200 dst x.x.x.x              proto esp reqid 1 mode tunnel  src 0.0.0.0/0 dst 0.0.0.0/0       socket in priority 0   src 0.0.0.0/0 dst 0.0.0.0/0       socket out priority 0   src 0.0.0.0/0 dst 0.0.0.0/0       socket in priority 0   src 0.0.0.0/0 dst 0.0.0.0/0       socket out priority 0   src ::/0 dst ::/0       socket in priority 0   src ::/0 dst ::/0       socket out priority 0   src ::/0 dst ::/0       socket in priority 0   src ::/0 dst ::/0       socket out priority 0   

maybe I can change something here


I'd like to route 10.108.0.0/16 via local eth0, not via IPSec tunnel

EDIT I've extended the policy with:

ip xfrm policy update dir in src 172.16.0.0/16 dst 10.108.0.0/16  ip xfrm policy update dir out src 172.16.0.0/16 dst 10.108.0.0/16  ip xfrm policy update dir fwd src 172.16.0.0/16 dst 10.108.0.0/16    # ip xfrm policy  src 10.0.0.0/8 dst 172.16.0.0/16       dir fwd priority 1955       tmpl src 54.77.116.107 dst 172.16.0.200          proto esp reqid 1 mode tunnel  src 10.0.0.0/8 dst 172.16.0.0/16       dir in priority 1955       tmpl src 54.77.116.107 dst 172.16.0.200          proto esp reqid 1 mode tunnel  src 172.16.0.0/16 dst 10.0.0.0/8       dir out priority 1955       tmpl src 172.16.0.200 dst 54.77.116.107          proto esp reqid 1 mode tunnel  src 172.16.0.0/16 dst 10.108.0.0/16       dir fwd priority 0   src 172.16.0.0/16 dst 10.108.0.0/16       dir out priority 0   src 172.16.0.0/16 dst 10.108.0.0/16       dir in priority 0   

another try:

ip xfrm policy add dir out src 172.16.0.0/16 dst 172.16.0.1  ip xfrm policy add dir in src 172.16.0.0/16 dst 172.16.0.1   ip xfrm policy add dir fwd src 172.16.0.0/16 dst 172.16.0.1    # ip xfrm policy   src 172.16.0.0/16 dst 172.16.0.1/32       dir fwd priority 0   src 172.16.0.0/16 dst 172.16.0.1/32       dir in priority 0   src 172.16.0.0/16 dst 172.16.0.1/32       dir out priority 0   src 10.0.0.0/8 dst 172.16.0.0/16       dir fwd priority 1955       tmpl src 54.77.116.107 dst 172.16.0.200              proto esp reqid 1 mode tunnel  src 10.0.0.0/8 dst 172.16.0.0/16       dir in priority 1955       tmpl src 54.77.116.107 dst 172.16.0.200              proto esp reqid 1 mode tunnel  src 172.16.0.0/16 dst 10.0.0.0/8       dir out priority 1955       tmpl src 172.16.0.200 dst 54.77.116.107              proto esp reqid 1 mode tunnel  

still it does not look like a good 'redirect'

Use config file for my shell script

Posted: 13 May 2022 02:54 AM PDT

I need to create a config file for my own script:
Here is an example:

script:

#!/bin/bash  source /home/myuser/test/config  echo "Name=$nam" >&2  echo "Surname=$sur" >&2  

Content of /home/myuser/test/config:

nam="Mark"  sur="Brown"  

that works!

My question: is this the correct way to do this or there're other ways?

Limits on the number of file descriptors

Posted: 13 May 2022 05:13 AM PDT

I'm trying to install 389-ds, And it gives me this warning:

WARNING: There are only 1024 file descriptors (hard limit) available, which limit the number of simultaneous connections.  

I understand about file descriptors, but I don't understand about soft and hard limits.

When I run cat /proc/sys/fs/file-max, I get back 590432. This should imply that I can open up to 590432 files (i.e. have up to 590432 file descriptors.

But when I run ulimit, it gives me different results:

$ ulimit  unlimited    $ ulimit -Hn    # Hard limit  4096    $ ulimit -Sn    # Soft limit  1024  

But what are the hard / soft limit from ulimit, and how do they relate to the number stored at /proc/sys/fs/file-max?

Can I select only one result from a bash glob?

Posted: 13 May 2022 01:54 AM PDT

I'm trying to write a script for work to automate some reporting on an output. The Log files are (currently, it's being 'standardise' in the future) stored in this sort of path structure:

/<root_path>/<process_one_path>/logs/<time_date_stamp>/<specific_log_file>

/<root_path>/<process_two_path>/logs/<different_time_date_stamp>/<specific_log_file>

Every part of the path is known except the time date stamps, which are always the latest in the folder.

If I try to use a wild card in place of the time date stamp, I get multiple results, e.g.:

> ls /<root_path>/<process_two_path>/logs/* [tab]  20130102-175103  20130118-090859  20130305-213506  

I only want it to return the latest one, is this possible with Bash?

NB (I don't have zsh, and as lovely as it sounds I doubt we'll ever get it at work)

No comments:

Post a Comment