Friday, April 16, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Windows 10 suddenly gives "no bootable device" screen

Posted: 16 Apr 2021 10:52 AM PDT

I have Windows 10 dual boot with linux mint 20.

The problem is that when using windows 10 it works fine but after random some time it stops and give me the "no bootable device" screen

configure vim to use both tmux and system clipboard

Posted: 16 Apr 2021 10:43 AM PDT

I'm fairly new to vim (I'm using nvim) so forgive my lack of knowledge, many questions are similar to mine, but not quite the same.

I would like this:

  • vim by default should cut/copy to a buffer, not system clipboard.
  • vim's other register (I think its +, please correct me if its *!) should go to the system clipboard.

I have done some research but nothing (so far) is working for me.

Info:

  • I use tmux so pushing to tmux buffers.
  • I'm away from home, so currently using termux so termux-clipboard-get/set

Here is what I thought would work in my case:

let g:clipboard = {    \   'name': 'TmuxTermux',    \   'copy': {    \      '*': ['tmux', 'load-buffer', '-'],    \      '+': ['termux-clipboard-set'],    \    },    \   'paste': {    \      '*': ['tmux', 'save-buffer', '-'],    \      '+': ['termux-clipboard-get'],    \   },    \   'cache_enabled': 1,    \ }  

Now when I cut/copy, tmux buffers share vim's content, PERFECT! (almost...), I cannot use the + buffer to use the system clipboard though, if I press '+' its just moves my cursor down by one line, if I swap the above order (make termux-clipboard-get/set the * register, instead of +), when I press * it highlights all instances of the word my cursor is on.

From reading, I expected:

  • By default, vim use * register, this seems to be true as it successfully registers to tmux buffers with dd/yy and pastes with p (or in tmux with my bind of [PREFIX]+[p]
  • If I want to cut/copy/paste to my other register + (system clipboard), then I would use +dd/+yy and then paste with +p (or even *dd/*yy/*p) but this isnt working for me.

Problem:

As explained above, + will move my cursor down one line, when changing it to the * register, * highlights the current word and any other occurance of it

Apologies to those with more experience, I'm fresh from emacs (with a very sore pinky finger!:)

Delete files of specfic type between two dates

Posted: 16 Apr 2021 10:26 AM PDT

We are trying to write some code in PeopleSoft to delete certain files in a remote server of a type between certain dates where all are specified by a PeopleSoft page. User enters a path, file type and date range through the page.

PeopleSoft has a FindFile command which works great for local servers, but does not seem to work remotely.

PeopleSoft also has an EXEC function which will issue Linux commands. But I'm not sure what the command should be.

Can anybody help me with the Linux command?

e2fsck error - fsck.ext2: no such file or directory while trying to open /dev/root

Posted: 16 Apr 2021 10:51 AM PDT

I am working with embedded Linux build with Yocto. My goal is to enforce file checking during each system booting. I've modified the /etc/default/rcS file and I've set ENABLE_ROOTFS_FSCK=yes and FSCKFIX=yes. fsck tries to check a rootfs but I get the following error:

e2fsck 1.46.2 (28-Feb-2021)  fsck.ext2: No such file or directory while trying to open /dev/root  Possibly non-existent device?    fsck failed. Please repair manually and reboot. Please note that the root filesystem is currently mounted read-only. To remount it read-write:     # mount -n -o remount,rw /  CONTROL-D will exit from this shell and REBOOT the system.  

I see two problems here. First, why e2fsck cannot check the file system? Second, why e2fsck calls fsck.ext2 to check the ext4 filesystem? When I use fsck -n <partition> after normal boot, it works fine. I get the following log:

e2fsck 1.46.2 (28-Feb-2021)  Warning! <partition> is mounted.  Warning: skipping journal recovery because doing a read-only filesystem check.  <partition> clean  

Thank you in advanced for any help.

EDIT: I use Linux built with Yocto with kernel 3.18 and systemVinit. There are some more methods to force fsck during boot process but they seem to work on systems with systemd. I suppose that e2fsck doesn't know which partition it should check. It tries to check /dev/root instead of my physical partition /dev/mmcblk0p2.

Understanding of rpm commands(-ivh vs -uvh)

Posted: 16 Apr 2021 09:57 AM PDT

Just want to know how different rpm -ivh <packagename> is from rpm -uvh <packagename>.

Replacig text inside multiple repeating patterns in same line

Posted: 16 Apr 2021 09:54 AM PDT

I have something like this;

I like reading **books** and taking **notes**  

I was trying to get something like this;

I like reading <b>books</b> and taking <b>notes</b>  

Tried doing;

sed 's/\*\*\(.*\)\*\*/<b>\1<\/b>/g' a.txt  

This returns;

I like reading <b>books** and taking **notes</b>  

It wraps around the whole line. Any way to get around it?

note: I'm using a GNU version of sed

Is there a way to match history entries on multiple words/tokens of the command, when performing history expansion?

Posted: 16 Apr 2021 09:33 AM PDT

I'm working with a command-line tool that provides a number of subcommands that all use the same binary, e.g. tool foo, tool bar, etc, and as I work, these commands are placed into my Bash shell history, for example:

 7322  [2021-04-16 15:37:45 +0000] tool foo .   7323  [2021-04-16 15:37:47 +0000] tool bar   7324  [2021-04-16 15:37:50 +0000] tool baz   7325  [2021-04-16 15:38:01 +0000] tool qux -a -b asdf -c=100 /var/lib/foo/...   7326  [2021-04-16 15:38:15 +0000] htop   7327  [2021-04-16 15:38:21 +0000] tool foo . -x  

The exact tool is proprietary (its exact functionality is irrelevant) and doesn't have specific features to help with tracking and recalling its own commands.

For example, I'd like to recall command 7325, tool qux -a -b asdf -c=100 /var/lib/foo/... (suppose that it's not recent enough to just hit the up arrow a bunch of times). The commands and parameters vary often enough that establishing a Bash alias doesn't seem practical or convenient (either I edit .bashrc or I lose the alias when the shell closes). I'm pretty confident that the last time I ran tool qux, it had the correct parameters that I would want to use, or a reasonably safe set that I would need to edit anyway.

I know I could run history | grep qux to look for the history index and then run !7325. Is there a way I can directly recall it with one set of keystrokes typed into the Bash prompt? !tool qux doesn't work because in this scenario it will run tool foo . -x qux instead. I tried quoting it, but it looks like expansion happens earlier.

How to download a table with records and header included sql unix

Posted: 16 Apr 2021 08:45 AM PDT

I have a table called students which is composed as follows

student ID, first name, last name, age  

It has the following records:

student ID, first name, last name, age  1           Jhon        Alva        25  2           Micaela     Bresh       22  

What I want to do is that when downloading in txt, not only the records are downloaded, but also the titles (student ID, first name, last name, age)

I am using the following code unload to students.txt select * from students;, but it only downloads the records, how can I make it download the titles as well?

zip outputs in the wrong place when used in a loop

Posted: 16 Apr 2021 09:03 AM PDT

I have many directories and I want to zip them all.

$ mkdir -p one two three  $ touch one/one.txt two/two.txt three/three.txt  $ ls -F  one/  three/  two/  

I use zip and it works as intended:

$ zip -r one.zip one    adding: one/ (stored 0%)    adding: one/one.txt (stored 0%)  $ ls -F  one/  one.zip  three/  two/  

But when I used this in a loop using zsh, zip files are created elsewhere.

$ for dir in */; do  for> echo "$dir";     for> zip -r "$dir.zip" "$dir";  for> done     one/    adding: one/ (stored 0%)    adding: one/one.txt (stored 0%)  three/    adding: three/ (stored 0%)    adding: three/three.txt (stored 0%)  two/    adding: two/ (stored 0%)    adding: two/two.txt (stored 0%)  
$ find . -name "*.zip"  ./three/.zip  ./two/.zip  ./one/.zip  $ ls -F  one/  three/  two/  

I expected an output like this:

$ ls -F  one/  one.zip  three/  three.zip  two/  two.zip  

What's going on?

How do I ip route add automatically when I connect to a VPN

Posted: 16 Apr 2021 08:43 AM PDT

I am connecting to a VPN. When I connect to that VPN I need to run the following command to get it to work:

sudo ip route add {ip}/24 dev ppp0  

How do I run this command automatically when I connect to a VPN or set that route in the GUI? I am using Ubuntu MATE 20.04

How to grep inside a specific file in tar.gz without extracting?

Posted: 16 Apr 2021 08:12 AM PDT

I'm looking for a command that can perform a grep operation in a specific file contained in a tar.gz archive.

Example:

file: archive.tar.gz, which ​contains:

fileA.txt  fileB.txt  fileC.txt  

I want to grep only inside fileA.txt, not in the other two, without extract the files from the original archive, with only one command.

Is it possible?

I have tried:

for f in /path/*.gz; do tar -xzf "$f" --to-command='grep -Hn --label="$TAR_ARCHIVE/$TAR_FILENAME" pattern || true'; done

This command performs the grep in all files included in the archive, but this is not exactly what I need: I need a command that grep only in the file I want to search in.

Is there a Bash command or series of commands which will identify and remove replicated directories?

Posted: 16 Apr 2021 07:49 AM PDT

I'm working on a developing a script which will, inside of a directory, verify the existence of a sub-directory, then locate and delete replicated copies in the same directory. For example:

A directory has the following sub-directory added:

FLDR6544_8765  

Other copies of the folder are replicated, such as:

FLDR6544_8765-0  FLDR6544_8765-1  FLDR6544_8765-2  

Is there a command or scripted series of commands which will verify the existence of the original folder (in the example FLDR6544_8765), then remove the replicated folders (FLDR6544_8765-0, FLDR6544_8765-1, FLDR6544_8765-2)

I can use

find -type d -name "-0" exec rm -r {} \; -prune  

to find the directories with the replicated endings (-0, -1, etc), but that doesn't ensure the original file exists before deleting the replicated copies.

Thanks in advance for any ideas you might have!

apt-get --fix-broken install giving a error

Posted: 16 Apr 2021 08:33 AM PDT

So today i tried installing xubuntu-desktop and when i was installing it, it gave a error so i tried installing it again and after i installed it again it gave a error

root@pc:~# sudo apt-get install xubuntu-desktop  Reading package lists... Done  Building dependency tree         Reading state information... Done  xubuntu-desktop is already the newest version (2.225).  You might want to run 'apt --fix-broken install' to correct these.  The following packages have unmet dependencies:   xubuntu-core : Depends: xubuntu-default-settings but it is not going to be installed   xubuntu-desktop : Depends: xubuntu-default-settings but it is not going to be installed                     Recommends: xfce4-quicklauncher-plugin but it is not going to be installed  E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).  

and if i run apt --fix-broken install it also gives a error

root@pc:~# sudo apt --fix-broken install  Reading package lists... Done  Building dependency tree         Reading state information... Done  Correcting dependencies... Done  The following additional packages will be installed:    xubuntu-default-settings  The following NEW packages will be installed:    xubuntu-default-settings  0 upgraded, 1 newly installed, 0 to remove and 30 not upgraded.  188 not fully installed or removed.  Need to get 0 B/35.7 kB of archives.  After this operation, 205 kB of additional disk space will be used.  Do you want to continue? [Y/n] Y  (Reading database ... 460197 files and directories currently installed.)  Preparing to unpack .../xubuntu-default-settings_18.04.6_all.deb ...  Unpacking xubuntu-default-settings (18.04.6) ...  dpkg: error processing archive /var/cache/apt/archives/xubuntu-default-settings_18.04.6_all.deb (--unpack):   trying to overwrite '/etc/skel/.config/libreoffice/4/user/registrymodifications.xcu', which is also in package zorin-os-default-settings 15.6.6  Errors were encountered while processing:   /var/cache/apt/archives/xubuntu-default-settings_18.04.6_all.deb  E: Sub-process /usr/bin/dpkg returned an error code (1)  

and if i try to uninstall it it also gives a error saying to run apt --fix-broken install does anyone know how to fix it? and i use zorinos which is based on ubuntu 18.04

How to change the text beside the text that I found after grep?

Posted: 16 Apr 2021 10:03 AM PDT

In Linux environment, for example I have a file test1 that contains these text:

DB_UP  sqlplus DB_UP test1.sql  DB_UP  

I want only to remove the DB_UP beside the sqlplus. How to do it in multiple files with indefinite number of DB_UP before and after the line I really want to edit?

I tried using xarg -i but it also removes the DB_UP that is before and after the sqlplus.

I want the output to be:

DB_UP  sqlplus test1.sql  DB_UP  

How to compare two files to get matched records?

Posted: 16 Apr 2021 09:49 AM PDT

I have 2 files with * delimiter, each file with 3k records.

There are common fields in different positions. In file1(count=1590) the position is 1 and in file2(2707) the position is 2. file2 count and output count should be same. Note: in file2 2nd position numbers will be present in file1 we need to take corresponding $3 value which is 1 or 0

In both files total count was 3k, both files were * delimter, in that file1 $1 and file2 $2 was common field for both files, we need check whether common field has 0 or 1 which present in file1 $3. we need to write the file like 1==>000000001D0560020011 2==>000000003D0792917850, $1=seqno,$2=matched9digit value follwed byD and $3 whether is 0 or 1

All $2 values from file2 will be present as $1 values in file1.

file1:

D056002001**1  D005356216**1  D079291785**0  D610350290**1  

file2:

000000001*D056002001  000000002*D610350290  000000003*D079291785  

output:

000000001*D056002001*1  000000002*D610350290*1  000000003*D079291785*0  

I tried using the following awk commands:

awk -F'*' 'NR==FNR{c[$1]++;next};c[$2]' file1 file2 > output  awk -F"*" '{ OFS="*"; if (NR==FNR) { a[$1+0]=$0;} else { if (a[$1+0]) { print $1, a[$2+0]}}}' file1 file2 > output  awk -F"*" '{ OFS="*"; if (NR==FNR) { a[$1+0]=$0;NEXT; } else { if (a[$2+0]) { print $0,a[$2+0]; } else { print $0,"***"; }}}' file1 file2 > output  awk -F"*" '{ OFS="*"; if (NR==FNR) {a[$1]=1; b[$1]=$2;next;} else { if ( a[$1]==1) { print $0,b[$1]} else { print $0,"0";}}}' file1 file2 > output  

Please help on that?

Errno28 "No space left on device" during pip install

Posted: 16 Apr 2021 09:47 AM PDT

I am trying to execute pip install tensorflow on my Raspberry but I'm getting an Errno 28 "No space left on device". I've read from multiple sources that it means that the folder used by pip install during the unzip is too small, but I don't know how to know if it's because it's really too small (I don't know how to know the size of my RAM but I think it's 512MB) or if it's because the number of allocated bytes is too small.

df produces :

enter image description here

I received the hardware without any documents to refer to, but I will provide you any informations you need using console.

(I tried to change the TMPDIR but it had no effect.)

Why is the output of the “*” command boot?

Posted: 16 Apr 2021 09:58 AM PDT

I used the * command and I seen this error:

bash: boot: command not found  

Why did this error occur?

How do I replace a certain pattern in multiple files?

Posted: 16 Apr 2021 09:44 AM PDT

My goal to update version number in multiple XML file like following

<?xml version="1.0" encoding="UTF-8"?>  <Component xmlns="http://soap.sforce.com/2006/04/metadata">      <apiVersion>51.0</apiVersion>      enter code here  

The version in the xml files might be different,

<?xml version="1.0" encoding="UTF-8"?>  <Component xmlns="http://soap.sforce.com/2006/04/metadata">      <apiVersion>27.0</apiVersion>      enter code here  

I tried several options like this

find force-app -type f -name "*-meta.xml" -exec sed -i '' -e 's/\(<apiVersion>\)\([0-9]+\.0\)\(<\/apiVersion>\)/<apiVersion>52.0<\/apiVersion>/' {} \;  

and this

find force-app -type f -name "*-meta.xml" -exec sed -i '' -e '/<apiVersion>/s/\(\d\+\)/52.0/' {} \;  

but they didn't work

change menu key behaviour for xfce-terminal

Posted: 16 Apr 2021 09:10 AM PDT

I use the menu key a lot in my text editor bindings, but that does not work in terminal mode, because the xfce-terminal I use responds to menu button by opening the context menu.

So I'd like to change that behaviour for the terminal, without remapping the menu key if possible.

But I really don't know where to start.

cifs mount error(2): No such file or directory

Posted: 16 Apr 2021 08:22 AM PDT

I believe I am not the first one encountered this issue and I read tons of "solutions" but none of them answered my question. So I post this one:

I have a Buffalo Neworkstorage (NS) installed.

I am able to mount the NS from my Rock Pi N10 running Debian (buster) using the following command:

sudo mount.cifs //<<ip.address>>/SHARE /mnt/lspro

But on my PC running ubuntu 18.04, using the exactly the same command as above, I got an error:

 mount error(2): No such file or directory Refer to the mount.cifs(8)   manual page (e.g. man mount.cifs)" issue? Thanks a lot for your help!  

tried all the "solutions" found on the internet and none of them solved my problem. Anyone have the same situation and found a solution? Please help! Thanks a lot for your sharing ;))

Redirect packets to server on other interface

Posted: 16 Apr 2021 09:04 AM PDT

Alright, little complex but here's what I need:

I have a Minecraft server in a ZeroTier network with an IP of 172.24.229.62, accepting connections on port 25565. The fact that it's ZeroTier doesn't particularly matter, just pretend it's a normal LAN.

On that same network, I have a general purpose Azure server with an IP of 172.24.229.65 on the LAN (ZeroTier) side. This LAN has no connection to the internet and no other devices. The general purpose server is running Ubuntu Server 20.10, and is exposed to the internet on another interface, accepting connections on port 25565.

I need this general purpose server to redirect incoming packets on port 25565 on the internet side to port 25565 of the Minecraft server on the LAN side and send packets back as well.

I found this script on SE, and tried it, but it didn't work. What am I doing wrong?

#!/bin/sh    echo 1 > /proc/sys/net/ipv4/ip_forward    iptables -F  iptables -t nat -F  iptables -X    iptables -t nat -A PREROUTING -p tcp --dport 25565 -j DNAT --to-destination 172.24.229.62:25565  iptables -t nat -A POSTROUTING -p tcp -d 172.24.229.62 --dport 25565 -j SNAT --to-source 172.24.229.65  

How to get string between starting with X to ending with Y using Shell

Posted: 16 Apr 2021 09:52 AM PDT

I have dynamic string which are mentioned below, where I want to get ABCXXX.XXX.XXX string till , character. Starting character is fix (ABC)CAPITAL ONLY and ending also fix com or Xcom.

String can be like :

S1= "10.10.10.10 (XXXX,ABC123.sub.domain.Xcom,XXX,XX - abc123 ) ANY  S2= "10.10.10.10 (ABC567.subd.domain.com, - ) ANY  

Output want :

S1= ABC123.sub.domain.com  S2= ABC567.subd.domain.Xcom  

I tried :

 $1=ABC  # argument   echo $S1| grep -o -P '(?=<$1).*(?=com,)'   

Output get :

123.sub.domain.X   # But it should be ABC123.sub.domain.Xcom  

Can anyone help to cut it with shell script?

php call multple mysql values using the same formatting code

Posted: 16 Apr 2021 09:31 AM PDT

I'd like use php to to recall multiple mysql values keeping the same formatting code, sometihng like

<h2>[genre]</h2>  <h3>[title]</h3>  <p>[contents]</p>  

With many "titles" (films), and matching "contents", under each of the several (8) kind of "genre".

first attempt (with "function")

I tried to replace $genus in $query1 with the below different variables.
The database connection in my php file works correctly.
My code, not working, was

`function genus($genus) {  $query1 = "SELECT * FROM films__olon WHERE genere like '$genus' ORDER by date";  $result = mysqli_query($db, $query1);  return $result;  while ($row = mysqli_fetch_array($result)){   echo "<h2>$row[title]</h2>";  echo "<p>date:<b>$row[date]</b> - director: $row[director]</p>";  echo "<blockquote lang=\""."$row[lang]\"><p>"."$row[contents]</p></blockquote>";  }  genus("fantasy");  genus("comic");  genus("historical");  genus("biographical");   }`  

I read several posts about this question, but unsuccessfully.

second attempt (with "prepared statements")

Consider that

  • the table films__olon is connected in the php file
  • the field "genere" is a "set" type (but changing it to varchar didn't work), with values such as fantasy,comic,historical,biographical and so on.
  • all the recalled fields ("genere","titolo" and "contenuti") are in the same table (films__olon).

I tried this code, but unsucceffully:

if(isset($_GET['genere'])){  $genus =$_GET['genere'];  }    $stmt = $db->prepare("SELECT * FROM films__olon WHERE genere like ?");  $stmt->bind_param("s", $genus);  $stmt->execute();  $result = $stmt->get_result();  if($result->num_rows === 0) exit('No rows');  while ($row = $result->fetch_assoc()) {  echo "<h2>$genus</h2>";  echo "<h3>$row[titolo]</h3>";  echo "<p>$row[contenuti]</p>";  }  

Force folder permissions in Linux

Posted: 16 Apr 2021 09:59 AM PDT

Normally I'm a Mac User, but now I installed a file server with Debian and OpenMediaVault. The Disks are set up as a ZFS pool. Everything works fine, just iTunes on Mac has a little problem with downloading new podcast episodes. iTunes first creates a temporary folder and only writes the file to the actual podcast folder at the end. But this temporary folder gets the permissions 675 and iTunes can't work with this. If I change the permissions very quickly to 777, the episode gets loaded.

It's not that iTunes has a general problem with the server. Starting with an empty drive, iTunes writes all needed libraries and folders with 755 and also copies music files correctly. It's only this temporary folder that gets the wrong permissions.

I tried all different versions I could imagine, even giving the user root status. It's always the same.

Is it possible to enforce 777 permissions when creating a folder, no matter who creates the folder? I read something about /etc/profile, but have no idea how to set that. Or is it possible to let the permissions be ignored? As I am the only user, that would not be a big problem.

This is the smb.conf:

load printers = no    disable spoolss = yes    printing = bsd    printcap name = /dev/null    unix extensions = yes    wide links = no    create mask = 0777    directory mask = 0777    use sendfile = yes    aio read size = 16384    aio write size = 16384    time server = no    wins support = no    multicast dns register = no    #Special configuration for Apple's Time Machine    fruit:aapl = yes    #======================= Share Definitions =======================    [musik]    path = /HansRAID/musik/    guest ok = no    guest only = no    read only = no    browseable = yes    inherit acls = yes    inherit permissions = no    ea support = no    store dos attributes = no    vfs objects =  fruit streams_xattr    printable = no    create mask = 0664    force create mode = 0664    directory mask = 0775    force directory mode = 0775    hide special files = yes    follow symlinks = yes    hide dot files = yes    valid users = "musik"    invalid users =    read list =    write list = "musik"  

ls -ld /HansRAID/musikgives this:

drwxrwsrwx+ 2 root users 2 Apr 14 22:31 /HansRAID/musik  

What Linux application can read PDX files?

Posted: 16 Apr 2021 09:21 AM PDT

I use openSUSE LRAP 15.2 with a KDE desktop, and I want to download some collections of PDF files that include an index (IDX and PDX files) for each collection. I'd like to be able to search and view the index files, and view PDF files from the hit list. The Adobe PDF Reader is very old and doesn't handle the latest formats. What packages are available for this?

How do Bash and Zsh handle collation in patterns and regexes?

Posted: 16 Apr 2021 09:33 AM PDT

Consider the following example:

$ bash --version  GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)  Copyright (C) 2016 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>    This is free software; you are free to change and redistribute it.  There is NO WARRANTY, to the extent permitted by law.  $ LC_COLLATE=C bash --norc -c '[[ B == [a-z] ]] && echo yes || echo no'  no  $ LC_COLLATE=en_GB bash --norc -c '[[ B == [a-z] ]] && echo yes || echo no'  yes  $ LC_COLLATE=C bash --norc -c '[[ B =~ [a-z] ]] && echo yes || echo no'  no  $ LC_COLLATE=en_GB bash --norc -c '[[ B =~ [a-z] ]] && echo yes || echo no'  no  

It seems that when matching against a pattern (i.e., using = or ==), Bash collates according to LC_COLLATE; however, when matching against a regex (i.e., using =~) Bash collates according to POSIX or something similar.

Zsh—at least zsh 5.8.0.2-dev (x86_64-pc-linux-gnu)—prints no in all cases.

Is there any guarantee as to what exactly [a-z] will match when used in a pattern or a regex?

ping displays "Name or service not known"

Posted: 16 Apr 2021 09:45 AM PDT

I am running Arch Linux on a Raspberry Pi.

Suddenly:

  1. I am unable to ping to a website.
  2. I am unable to access a website from the browser.

I have two more computers (all running Arch Linux) connected to the Internet, where I can ping and use the Internet. Also, /etc/resolv.conf is identical on the other computers:

nameserver 10.230.252.252  nameserver 203.147.88.2  nameserver 8.8.8.8  search domain.name  

I can use VNC. I can also ping to 8.8.8.8. When trying to access DuckDuckGo on Chromium I get:

This site can't be reached  duckduckgo.com's server IP address could not be found.  DNS_PROBE_FINISHED_NXDOMAIN  

I have an active Internet connection. What's wrong?

make json from SQL query output

Posted: 16 Apr 2021 08:43 AM PDT

I have this query:
select hostname,size from tableinfo
output is like this:

  hostname                   size  ------------------------- -----------    host1                        28    host2                        13    host3                        79    host4                        28    host5                        17    

or i can make it like this:

  host1                        28    host2                        13    host3                        79    host4                        28    host5                        17  

I want to write a shell script that convert its output to json but i really dont know where to begin or what to do. the json must be like this:

 {      "data":[      {  "{#HOSTNAME}":"host1",  "{#SIZE}":"28"  } ,      {  "{#HOSTNAME}":"host2",  "{#SIZE}":"13"  } ,      {  "{#HOSTNAME}":"host3",  "{#SIZE}":"79"  } ,      {  "{#HOSTNAME}":"host4",  "{#SIZE}":"28"  } ,      {  "{#HOSTNAME}":"host5",  "{#SIZE}":"17"  }      ]  }  

What are the contents of /bin/bash, and what do I do if I accidentally overwrote them

Posted: 16 Apr 2021 08:19 AM PDT

I accidentally overwrote the /bin/bash file with a dumb script that I intented to put inside the /bin folder.

How do I get the contents of that file back? Is there a way I can find the contents on the web, and just copy them back in? What are my options here, considering that terminal gives an error talking about "Too many Symbolic Links?"

I'm still a newcomer to this kind of thing, and I appreciate all the help I can get.

Edit: I forgot to mention I'm on Kali 2.2 Rolling, which is pretty much debian with some added features.

Edit 2: I also restarted the machine, as I didn't realize my mistake until a few days ago. That makes this quite a bit harder.

Can lftp read netrc for sftp-connections

Posted: 16 Apr 2021 09:01 AM PDT

I am trying to create a script to upload some files to a server via SFTP. I can do that manually by opening an interactive lftp-session and providing username and password there. For the script, I would like to

  • not hardcode credentials in the script (for obvious reasons)
  • not mention them on the commandline (I want the command in my .bash_history, but of course not the credentials)
  • have lftp read the credentials from .netrc or something similar

I cannot seem to get this working. My current workaround is a wrapper-script that parses the .netrc for the credentials and adds them to a lftp-script which I delete afterwards. This simulates the steps I perform manually, but seems like re-implementing existing functionality poorly. While this works, the question remains:

Can lftp read .netrc for SFTP-connections?

If so, are there special syntax-requirements if customs ports are part of the setup? I need to connect to sftp://username:password1@example.com:12322.

No comments:

Post a Comment