Wednesday, April 6, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


bashrc + why source not refresh the .bashrc file

Posted: 06 Apr 2022 01:58 AM PDT

we add the following line to bashrc file

alias reboot="echo you not allowed to do reboot on this machine - sorry"  

so we get

more ~/.bashrc    # .bashrc    # User specific aliases and functions    alias rm='rm -i'  alias cp='cp -i'  alias mv='mv -i'    # Source global definitions  if [ -f /etc/bashrc ]; then          . /etc/bashrc  fi      alias reboot="echo you not allowed to do reboot on this machine - sorry"  

then we did

source ~/.bashrc  

and indeed when we do

reboot  

we got

you not allowed to do reboot on this machine - sorry  

but when we want to back to real reboot , we removed the line --> alias reboot="echo you not allowed to do reboot on this machine - sorry"

as the following:

# .bashrc    # User specific aliases and functions    alias rm='rm -i'  alias cp='cp -i'  alias mv='mv -i'    # Source global definitions  if [ -f /etc/bashrc ]; then          . /etc/bashrc  fi  

and we refresh the bashrc

source ~/.bashrc  

but we still get the old alias when we try to reboot:

 you not allowed to do reboot on this machine - sorry  

what we are missing here?

another example with function

echo '  function reboot  {  echo "ERROR reboot command not allowed on this machine"  return 1  }  ' >>/root/.bashrc  

with example above we cant to do unalias

How to configure similar to do-ip6 setting (unbound) in coredns of kubernetes

Posted: 06 Apr 2022 12:50 AM PDT

do-ip6 is an option in unbound dns where we can enable or disable whether ip6 queries are answered or issued.

do-ip6: yes or no. Default is yes. If disabled, queries are not answered on IPv6, and queries are not sent on IPv6 to the internet nameservers.

How this is by default in coredns of kubernetes? Is the queries are answered on Ipv6 or Ipv4 by default in coredns? Incase the queries are answered on Ipv6 by default, can we able to configure this to answer queries on Ipv4 via Corefile of coredns in kubernetes?

It would be really grateful if someone helps me to clear out this. Thanks in advance!!!

Why does my sytem have muptiple addresses on interface wlo1?

Posted: 06 Apr 2022 12:15 AM PDT

I tried to init docker swarm

Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on interface wlo1   

Ok,I will advertis address.

ip a  

shows

2: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000      link/ether c8:94:02:93:05:e1 brd ff:ff:ff:ff:ff:ff      altname wlp3s0      inet 192.168.0.16/24 brd 192.168.0.255 scope global dynamic noprefixroute wlo1         valid_lft 600563sec preferred_lft 600563sec      inet6 2a06:7d14:17fe:6900::1/128 scope global dynamic noprefixroute          valid_lft 2587763sec preferred_lft 859763sec      inet6 2a06:7d14:17fe:6900:d3d8:7e5b:daab:7941/64 scope global temporary dynamic          valid_lft 600564sec preferred_lft 81950sec      inet6 2a06:7d14:17fe:6900:8849:3581:5e29:1a15/64 scope global dynamic mngtmpaddr noprefixroute          valid_lft 2591987sec preferred_lft 863987sec      inet6 fe80::f7eb:ac02:1d60:c4f5/64 scope link noprefixroute          valid_lft forever preferred_lft forever  

Can someone explain muliple interafaces?

Why is the bash completion setting in root's .bashrc is commented out in Ubuntu?

Posted: 06 Apr 2022 01:32 AM PDT

I'm on Ubuntu 20.04 and I found that in root's .bashrc file, the bash completion setting is commented out by default:

# enable programmable completion features (you don't need to enable  # this, if it's already enabled in /etc/bash.bashrc and /etc/profile  # sources /etc/bash.bashrc).  # if [ -f /etc/bash_completion ] && ! shopt -oq posix; then  #     . /etc/bash_completion  # fi  

When I uncomment it, the completion works again. Why it was commented by default? Is this related to any security considerations?

rsync / mv how to skip empty files

Posted: 06 Apr 2022 12:03 AM PDT

I am new to linux. I have a requirement to copy files from source1 directory to destination1 directory and move from source1 directory to destination2 directory. It is working fine. But script is copying even empty files also. rsync / mv should not pick empty files. How can i do that.Currenlty I am using below script.

#!/bin/bash    echo '------Files Copy------'  rsync -av /public/src1/ /public/dst1    echo '-------Files Move--------'  mv /public/src1/* /public/dst2  

How to stream the linux framebuffer as video over http

Posted: 05 Apr 2022 11:05 PM PDT

I have an embedded linux system (yocto based) with a framebuffer UI (no X11) and a running web server.

Now I'm asking how to "mirror" the screen contents to a web page. Think of it like a web cam, except the stream is not coming from a camera, but from /dev/fb0.

Sounds like a quite obvious thing to do, but my web search didn't throw any matches. Do you have an idea on how to proceed?

Why do package managers require root priveleges?

Posted: 06 Apr 2022 02:02 AM PDT

The default package manager for mainstream Linux distros (deb/apt, yum/dnf, pacman, etc) do global-installation by default and require root. I am curious about in the rationale for this design choice.

It seems better to install as user or group and not need root, because one would run less untrusted code as root (as Nix, Guix, Cargo, Pip, Gem, Cabal, Stack, CPAN). On shared systems, one could install packages to directory which is readable by users but writable by admins, but this doesn't have to be root, and it should still permit users to install their own packages.

Package that modify protected files like Grub or provide services would need to modify the root system, but everything else should be doable from user-side.

This question says that packages may assume they are installed to specific locations in the Filesystem Hierarchy, but I thought this could be fixed by setting $PATH, $LD_LIBRARY_PATH, and friends. And otherwise, why not just have a wrapper that runs the program in a chroot?

systemd debug (embedded case)

Posted: 05 Apr 2022 11:36 PM PDT

How to trace systemd unit files, to be specific, device unit files? I use 3.18 version of linux kernel. On my board after systemd has started, (mypartition).device runs and, I suppose, remounts the rootfs and it takes about 2 seconds to complete as systemd-analyze plot shows. I want to know what it does during those 2 seconds, because remounting of rootfs takes not so much time (usually few milliseconds). How I can understand systemd-analyze plot, there are so many unit files, is it possible to know which unit causes running of the others? I tried to find .device unit file in my system, but I could not find anything.

Gnome 3 finger gestures not working well when tap to click is enabled

Posted: 05 Apr 2022 11:48 PM PDT

I've just switched to fedora (fedora 35) and i noticed that when i enable the tap to click, three finger gestures not working well. If i disable it the gestures work just fine but if i enable it the sensitivity is not as good, i have to do the gestures very slowly for gnome to pick up. So what is the reason for this and is there a solution?

PS. My pc is Lenovo Thikpad E495 and i have windows 10 installed on my computer besides fedora.

How to prevent child process to interfere with bash prompt?

Posted: 06 Apr 2022 01:52 AM PDT

The application in question is DaVinci Resolve. I start it from terminal. And when I close it, the message "Socket Disconnected" from the app is written to the terminal output. Then the bash prompt appears as normal. I start typing the new command, and suddenly another message appears in terminal "Socket Disconnected". And this interferes with the input I made. It looks like this:

[andrew@unihost ~]$ davinci-resolve  ... # Now I exit the application.  Host 'Fusion' Removed  FusionScript Server [37457] Terminated  Socket disconnected  [andrew@unihost ~]$ ls ls Socket disconnected  wtf!!!^C  [andrew@unihost ~]$  

Video demo: https://youtu.be/arcCOjrN7kw

Why this is happening and is there a way to prevent this?

My guess is that there is subprocess of the main process, which still is alive even after main process dies. I have found this answer. Is that the developer's fault? Can I workaround this somehow (maybe nohup for child process)?

cant create a choice selector in bash

Posted: 06 Apr 2022 01:18 AM PDT

I am trying to make a bash choice selector from https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script but it doesn't work I also installed Dialog but it still don't work. help me debug it. thank you

#!/bin/bash  HEIGHT=15  WIDTH=40  CHOICE_HEIGHT=4  TITLE="Title here"  MENU="Choose one of the following options:"    OPTIONS=(1 "Option 1"           2 "Option 2"           3 "Option 3")    CHOICE=$(dialog --clear \                  --title "$TITLE" \                  --menu "$MENU" \                  $HEIGHT $WIDTH $CHOICE_HEIGHT \                  "${OPTIONS[@]}" \                  2>&1 >/dev/tty)    clear  case $CHOICE in          1)              echo "You chose Option 1"              ;;          2)              echo "You chose Option 2"              ;;          3)              echo "You chose Option 3"              ;;  esac  

Here's what it shows

root@archiso ~/Arch-Install (git)-[main] # bash test.sh  root@archiso ~/Arch-Install (git)-[main] # S  

String searching with grep

Posted: 06 Apr 2022 01:07 AM PDT

I'm just searching in emacs some strings with following pattern:

^*DEFUN*event*$  

So i've used grep:

grep -nR "^*DEFUN*event*$" *  

but got no match, instead there's a lot of them for example:

DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers,  

What's wrong?

How can I remove the portion between the ">" and the word "Bacteria" for each occurrence in a file?

Posted: 05 Apr 2022 10:13 PM PDT

I want to remove the portion between the > and the word Bacteria for each occurrence in a file.

  • Here is an example of the input:
    >AADV02000003.105686.107093 Bacteria;Cyanobacteria;Cyanobacteriia;Cyanobacteriales;  
  • The result should look like this:
    >Bacteria;Cyanobacteria;Cyanobacteriia;Cyanobacteriales;  

This is a FASTA file (a common file format in bioniformatics), so the > will always be the first non-whitespace character on the line, and there will be only one such character on the line.

I was thinking about using sed but I am not sure how to set up the command. Thank you for the help.

Forcing the failover to a hot spare in a degraded ZFS pool

Posted: 06 Apr 2022 01:55 AM PDT

I have a simple 5x1TB RAIDz1 configuration (tank? pool? vdev?), with a global spare assigned to it. One of the 5 drives in the array is listed in a FAULTED state (corrupted data), and the spare is listed as AVAIL. The array lists as DEGRADED. Clearly there is no mechanism for the array to gracefully failover to the spare, so how do I force the failover?

I have read many forum posts from many locations, discussing detaching the drive, replaceing the drive with the spare, physically removing the drive, moving the spare to the same slot etc.

The replace command tells me it cannot replace the drive because the spare is in a spare or replacing config and to try detach.

The detach command tells me it is only compatible with mirrors and vdev replacement.

There is no indication that the spare is being used to rebuild the array.

I am not keen to start physically moving drives around, neither the current array member nor the functioning hot spare - I'd prefer not to interrupt anything.

I'd also prefer to not bring the array down, restratt he server etc. The system is designed to transparently recover without this, I want to learn how. The data is backed up so I have free reign.

Linux Kernel: 3.10.0-1160

ZFS Version: 5

Update:

Output from replace function:

[root@localhost ~]# zpool replace <name> 4896358983234274072 ata-WDC_WD10EFRX-68PJCN0_WD-<serial>  cannot replace 4896358983234274072 with ata-WDC_WD10EFRX-68PJCN0_WD-<serial>: already in replacing/spare config; wait for completion or use 'zpool detach'  

Output from detach function:

[root@localhost ~]# zpool detach <name> 4896358983234274072  cannot detach 4896358983234274072: only applicable to mirror and replacing vdevs  

ZFS version:

[root@localhost ~]# zfs upgrade  This system is currently running ZFS filesystem version 5.    All filesystems are formatted with the current version.    [root@localhost ~]# modinfo zfs | grep version  version:        0.8.2-1  rhelversion:    7.9  srcversion:     29C160FF878154256C93164  vermagic:       3.10.0-1160.49.1.el7.x86_64 SMP mod_unload modversions  

zpool status:

[root@localhost ~]# zpool status <name>    pool: <name>   state: DEGRADED  status: One or more devices could not be used because the label is missing or          invalid.  Sufficient replicas exist for the pool to continue          functioning in a degraded state.  action: Replace the device using 'zpool replace'.     see: http://zfsonlinux.org/msg/ZFS-8000-4J    scan: scrub repaired 0 in 0h18m with 0 errors on Mon Apr  4 13:29:39 2022  config:            NAME                                               STATE     READ WRITE CKSUM          <name>                                                 DEGRADED     0     0     0            raidz1-0                                         DEGRADED     0     0     0              pci-0000:01:00.0-sas-0x443322110c000000-lun-0  ONLINE       0     0     0              ata-WDC_WD10EFRX-68FYTN0_WD-<serial>       ONLINE       0     0     0              pci-0000:01:00.0-sas-0x4433221109000000-lun-0  ONLINE       0     0     0              4896358983234274072                            FAULTED      0     0     0  corrupted data              pci-0000:01:00.0-sas-0x443322110b000000-lun-0  ONLINE       0     0     0          spares            ata-WDC_WD10EFRX-68PJCN0_WD-<serial>         AVAIL  

Unmount /boot after booting

Posted: 05 Apr 2022 10:57 PM PDT

For some highly secure bastion VMs I'll implement soon, I am considering to unmount /boot after booting - among other measures of course. Will be mounted only for updating kernel.

  • Testing this, no problems seem to appear; can it have any side effects I'm missing?
  • The systems will be probably based on Debian Linux (other scenario, on Redhat). Both are systemd. What is the proper way to unmount /boot on a systemd system after reboot? For testing I just sudo umount /boot.
  • I'm debating myself if I'm going to use BIOS or UEFI. As they will be VMs, it's a matter of choice. UEFI appears to be a more sane choice as more modern. But I'm not sure regarding security benefits, if any. On the contrary, because it's more complicated, more chances of vulnerabilities perhaps.
  • In case of UEFI, what about efi partition? It's mounted inside /boot by default, although I think /efi can be used (I haven't tried it), to separate them and handled more transparently, administrator side. Can /boot/efi or /efi be unmounted as well after boot without side effects?

Use umask to set permission

Posted: 06 Apr 2022 01:21 AM PDT

The task: use umask to define the permisson

Create a directory (say /demo) and set its permissions with the following requirements:

  1. Each user is allowed to create files and directories under the /demo folder
  2. Each user can only delete the files/directories created by himself/herself under /demo
  3. The group ownership of newly created files/directories should belong to the group named student.

Thank you.

That's is what I did already, I'm not sure about the permission for delete files/dir.

student@access-control: umask 051    student@access-control: mkdir demo  

Giving files in batches to a script

Posted: 06 Apr 2022 01:44 AM PDT

I have many files, and the naming convention is as follows:

file1_d, file2_d, file3_d, ..., fileN_d

I want to provide the first k files into a script as input, then the following k files as a second batch, and so on. Is there an easy way to do this in shell-script, such as using arrays for example?

Remove the matching pattern from grep's output?

Posted: 06 Apr 2022 12:07 AM PDT

With bash, I'm running this: declare -p | grep 'declare -- ' That prints whole lines. I want to print those same lines, but I wanted to exclude the match itself. i.e., Can I do ... | grep pattern | sed 's/pattern//' as a single command? It would be like the opposite of the -o option.

My command outputs this:

...  declare -- MAX_CONNECTIONS_PER_SERVER="6"  declare -- OPTERR="1"  declare -- OSTYPE="linux-gnu"  ...  

But I want to output this:

...  MAX_CONNECTIONS_PER_SERVER="6"  OPTERR="1"  OSTYPE="linux-gnu"  ...  

Normally, I would just pipe this to sed, but coincidentally, I've wanted to do this twice today. I looked at the man page, but I didn't see any option that could do this.

Return only the portion of a line after a matching pattern is a very similar question. Perhaps it's even a duplicate. One could argue mine is a little bit more narrow: it's guaranteed that the pattern I'm grepping and the pattern I'm removing will be the same. I want to remove x. The question wants to remove .*x.

Sorting lines based on certain digit pattern

Posted: 05 Apr 2022 11:33 PM PDT

Assume I have a text file with the following lines:

192.168.1.1.55555  192.168.1.1.55555  192.168.1.1.5555  192.168.1.1.555  192.168.1.1.55  192.168.1.1.55  192.168.1.1.5  8.8.8.8.4433  8.8.8.8.443  8.8.8.8.443  8.8.8.8.25  192.168.1.2.99  

as you can see above, each line will have the following pattern (I couldn't write all possible variations since there are 9.9599603594104e+16 possible lines)

[number composed of 1 to 3 digits].[number composed of 1 to 3 digits].[number composed of 1 to 3 digits].[number composed of 1 to 3 digits].[number composed of 1 to 5 digits]  

I want a grep/sort statement that counts the lines where the first four numbers matched and print that count.

The expected output for the example above is:

192.168.1.1 7  8.8.8.8 4  192.168.1.2 1  

Side notes:

  1. I'm trying to sort netstat output, the lines I'm dealing with in reality are IP addresses followed by port numbers.

  2. My unix system where this needs be executed doesnt have uniq or cut tools, it has operating system from some networking vendor which is built on freebsd.

one of the commenters on this post suggested to use:

awk -F. '{c[$1 FS $2 FS $3 FS $4]++} END {for (i in c) print i, c[i]}'   

which seems to work well.

Automatically source a file when `cd` into a specific directory

Posted: 06 Apr 2022 01:19 AM PDT

I have couple of utility commands-and-aliases that are generic enough in any directory for my own requirement. But there are certain directory e.g. 'build', where I need a custom behaviour.

To do this, I have created a different file in those directories, that contain the modifications with same name of functions and aliases (so that I don't need to remember, new names).

Currently I manually source the files, after cd'ing into the specific directory

source custom_aliases_n_fns  

This is working well, but I'm looking to automate this sourcing of file.

Is there a way to source a file on cd'ing into specific directory?

Note: I went with this approach, as I don't want to change the system wide user-aliases.

Is it possible to have systemd open a program running in a clean terminal automatically after startup?

Posted: 06 Apr 2022 01:02 AM PDT

First off apologies for the simple question- there is more to it that I will explain below.

I am new to Linux style systems and evidently I have A LOT to learn.

With that said...

My System

I am running a program on a Raspberry Pi 4 Model B. My operating system is Raspbian GNU/Linux 10 (buster).

What I Have

I have produced a working program in C++ that is stored in home/pi/Dev. The program has no GUI but prints information into the terminal. The program infinitely loops (using an empty for loop).

When launching the program through Geany (an editor on the pi), I can make and run the program which opens a new terminal window and prints the output there.

When clicking on the executable file in the folder I'm asked to choose between 'Execute' and 'Execute in terminal'.

  • Selecting to 'Execute' seemingly has no effect (I have looked for the process in the task manager?)

  • Selecting to 'Execute in Terminal' brings up an error: Failed to execute child process "xterm" (No such file or directory)

When using the terminal and running ./myprogram The program runs, printing the output in the already open terminal window.

What I Want

I would like the program to run automatically on startup.

The Pi will be used 'headless' but with the graphical interface enabled so I can see the desktop using VNC; when I open the VNC connection I would like a terminal to be running and displaying the program output.

What I Have Tried

I have been attempting to use systemd to launch the program.

At first I tried launching the program directly but got absolutely nowhere; I couldn't find any good info or examples online and most examples were using bash or Python scripts... If you can't beat them join them...

So next I created (copied) a simple bash script in usr/local/bin/ called procamStartup.sh:

#!/bin/bash  echo test  cd /home/pi/Dev/  ./Procam  

and when running this script using ./procamStartup.sh, "test" was printed in the terminal and then the program started printing below that.. so the script in my eyes is functional.

Next I created a service file in /etc/systemd/system/ called procamStartup.service:

[Unit]   Description=Procam Startup Script   After=graphical.target     [Service]   Type=idle   ExecStart=/usr/local/bin/procamStartup.sh     [Install]   WantedBy=graphical.target  

I chose Type = idle so the system would wait for all processes to finish before launching.

I chose WantedBy=graphical.target so the program would only launch after the graphical interface has started.

I set execute permissions for both script and service folders using:

  • sudo chmod +x /usr/local/bin/procamStartup.sh

  • sudo chmod +x /etc/systemd/system/procamStartup.service

I next told systemd to reload the files:

sudo systemctl daemon-reload

and then enabled the script to be ran at boot:

sudo systemctl enable procamStartup.service

after that I ran sudo reboot.

Continued

So.. before sending this post I followed my own instruction and at the end ran:

sudo systemctl status procamStartup.service

Which reported the service was successfully running and printing the program output into a log.

This is semi-ok: I can use the Pi as intended as the program is running- just with no output showing by default.

So to redo my question:

Is it possible to have systemd open a program running in a clean terminal automatically after startup?

I also think I need to change the service file; since its running a script that runs the program I might be launching several instances of the same program?

Thank you for reading.

Continued continued

I have now installed xterm

I have changed my script to the following:

#!/bin/bash  xterm -hold -e /home/pi/Dev/Procam  

When running this script through the Pi GUI terminal, I get exactly what I want: a new window outputting correctly.

When running this from startup or through SSH I get the following errors:

xterm: Xt error: Can't open display: %s

xterm: DISPLAY is not set

I'm currently looking into resolving this.

Why root user is not getting "Device or resource busy" response?

Posted: 06 Apr 2022 01:26 AM PDT

I am working with GSM modem and using /dev/ttyUSB2 device.

Device is having proper rights:

$ ls -alh /dev/ttyUSB2  crw-rw---- 1 root dialout 188, 2 May 25 19:44 /dev/ttyUSB2  

I am in dialout group and I can send AT command to this modem only once. After sending "ATD" command (echo -e -n "ATD ...;\r" > /dev/ttyUSB2), according to lsof /dev/ttyUSB2 process ModemManager opens this very file and if I send another AT command I get message:

bash: /dev/ttyUSB2: Device or resource busy  

OK, so for some reason ModemManager is holding this file busy, but when this happens I can still send commands the same way, but from root user.

I've got two questions:

  1. Why root user can override this "Device or resource busy" lock?
  2. What rights / other settings regular user should have to bypass it like root user.

How to enable an Ethernet interface at boot on CentOS 8?

Posted: 06 Apr 2022 02:00 AM PDT

I have a VM which is connected to a network with DHCP etc.

Whenever I boot the VM the virtual Ethernet connection is DOWN. I need to log in by console and run dhclient eth0 to enable it. Every time. I wish to enable eth0 upon boot.

This is /etc/sysconfig/network-scripts/ifcfg-eth0:

TYPE=Ethernet  PROXY_METHOD=none  BROWSER_ONLY=no  BOOTPROTO=dhcp  DEFROUTE=yes  IPV4_FAILURE_FATAL=yes  IPV6INIT=yes  IPV6_AUTOCONF=no  IPV6_DEFROUTE=yes  IPV6_FAILURE_FATAL=no  IPV6_ADDR_GEN_MODE=stable-privacy  NAME=eth0  UUID=11111111-2222-3333-4444-5555555555555555  DEVICE=eth0  ONBOOT=yes  HOTPLUG=yes  NM_CONTROLLED=no  DHCPV6C=yes  IPV6_PRIVACY=no  USERCTL=no  GATEWAY=10.0.0.1  DNS1=9.9.9.9  DNS2=1.1.1.1  

I thought that ONBOOT=yes was the important bit here but it is ignored completely. Who reads this file? Perhaps that's the culprit.

The HOTPLUG=yes I only added in the hope that this would help (perhaps interface coming up late...) but it does not.

I set NM_CONTROLLED=no because I have no NetworkManager service (server, no user-management allowed or needed).

My question is: What is wrong with my config file or what setting would help?

TFTP: cannot send/recive file, showing Error: TFTP, Opcode: Error Code(5)

Posted: 05 Apr 2022 11:01 PM PDT

I am trying to send/receive a file using TFTP from the network switch to ubuntu(VirtualBox on Windows 10 Pro), but getting an error code 5

By following the steps mentioned below it seems like my localhost is working with TFTP server, I can send and receive the file using localhost:

/home/abc# tftp localhost    tftp> put test    Sent 16 bytes in 0.0 seconds    tftp> get test    Received 16 bytes in 0.0 seconds    root@abc:/home/abc# ls -l /var/lib/tftpboot/  total 4  -rwxrwxrwx 1 root root 14 Sep  6 18:03 test  

When I used the command in the switch to send/receive the file then I get the error message:

Trivial File Transfer Protocol

Opcode: Error Code (5)

[Destination File: test]

Error code: Access violation (2)

Error message: Access violation

[Expert Info (Warning/Response): TFTP ERROR packet]

[TFTP ERROR packet]

[Severity level: Warning]

[Group: Response]

Would you please guide me on how to fix this issue?

https://icesquare.com/wordpress/how-to-setup-tftp-on-ubuntu/

First, let's install all the necessary packages:

sudo apt-get install xinetd tftpd tftp -y  

Next, we need to create a configuration file:

sudo nano /etc/xinetd.d/tftp  

Put the following content into the file.

service tftp  {     protocol = udp     port = 69     socket_type = dgram     wait = yes     user = nobody     server = /usr/sbin/in.tftpd     server_args = var/lib/tftpboot -s     disable = no  }  

In the server_args, I have var/lib/tftpboot, which represents the location of the tftp root, i.e., /var/lib/tftpboot. Notice that I skip the root /.

Now let's change the ownership of the directory:

sudo mkdir /var/lib/tftpboot  sudo chown -R nobody:nobody /var/lib/tftpboot  sudo chmod -R 777 /var/lib/tftpboot  

and start the TFTP service:

sudo service xinetd stop  sudo service xinetd start  

Verify the TFTP is running correctly or not:

netstat -na | grep LIST | grep 69  You should see something like this:  tcp        0      0 0.0.0.0:69              0.0.0.0:*     LISTEN  

Test: Upload a file to TFTP Server Now let's test the TFTP server by logging into the server first:

tftp localhost and upload a file:

tftp> put myfile.jpg  Sent 56733279 bytes in 5.7 seconds  Quit:  q  

Make sure that file has been uploaded:

ls -l /var/lib/tftpboot  

Test: Download a file from TFTP Server Now, let's go to a different directory and download the file we just upload.

cd some_other_directory  

and log in to the tftp server again:

tftp localhost  

and get the file:

tftp> get myfile.jpg  Received 56733279 bytes in 5.7 seconds  

How to change default text editor for virsh edit?

Posted: 05 Apr 2022 10:37 PM PDT

I recently installed virt-manager on Arch Linux, and unlike under Ubuntu, I was not prompted to choose a text editor on the first launch of virsh-edit. Instead, the XML file was opened in vi (or vim, not sure).

From this thread in the RedHat archives, I thought that if I just added to ~/.bashrc:

export EDITOR=/usr/bin/nano  

that would solve the problem. But setting EDITOR environment variable didn't work.

Also, launching it with EDITOR=geany sudo virsh edit myWINVM gave the same result, as did trying to use a different editor: EDITOR=geany sudo virsh edit myWINVM as described here

and I see that the variable has in fact been set:

[~]$ printenv  SHELL=/bin/bash  SESSION_MANAGER=local/virtland:@/tmp/.ICE-unix/5451,unix/virtland:/tmp/.ICE-unix/5451  WINDOWID=27262979  COLORTERM=truecolor  XDG_CONFIG_DIRS=/etc/xdg  XDG_MENU_PREFIX=xfce-  SSH_AUTH_SOCK=/tmp/ssh-j36TZui4fOt5/agent.5457  DESKTOP_SESSION=Xfce Session  SSH_AGENT_PID=5458  EDITOR=/usr/bin/nano  ...  

However virsh edit MYVM still opens the XML in vi.

Is there something different I need to do in Arch? Has the method of changing this setting been changed in recent updates of virsh?

How to is the system proxy configured in Tails OS?

Posted: 06 Apr 2022 12:02 AM PDT

How is tails system wide proxy configured in tails?

Tails have non-null variables SOCKS5_SERVER, SOCKS_SERVER set to 127.0.0.1:9050 but I guess this is not enough to force all connection to be proxied.

what is the function of "ip link" command?

Posted: 06 Apr 2022 01:45 AM PDT

I've installed putty, and I'm trying to write

ip link  

For what is it used??

Swap: Better to create a dedicated swap partition or to create a swap file?

Posted: 06 Apr 2022 01:18 AM PDT

Is there a rationale when to create a dedicated swap partition vs. creating a swap file, for example like /tmp/swap?

In my certain case, memory is kind of low (1GB), disk space on a SSD is pretty huge (256GB). Thus, swapping will happen pretty regularly.

Any comments appreciated!

Carsten

Cron job to run every minute from 11PM to 6AM

Posted: 05 Apr 2022 10:40 PM PDT

I have a python program which I need to run every minute from 11PM (EDT) to 06AM (EDT). How can I schedule a cron job to do this?

* 23-6 * * 1-5 python my_program.py  

will this work? or do I have to write 2 separate cron jobs for this?

What is the meaning of ls -d?

Posted: 06 Apr 2022 01:57 AM PDT

I entered the man page of ls, the entry for the -d option is as follows:

-d, --directory list directory entries instead of contents, and do not dereference symbolic links

So, I thought ls -d will display all directories within a given directory. However I entered one directory and tried two different commands:

  1. obtaining directories with: ls -l | grep ^d
    This one worked, all 7 directories being displayed

  2. obtaining directories with ls -d This does not display the 7 directories, only a point .

I do not understand if I am using the option wrongly or if I am misunderstanding its meaning, what is the actual meaning and usage for the -d option ?

No comments:

Post a Comment