Sunday, April 18, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Can't access with ssh any more with or without ssh key (digital ocean)

Posted: 18 Apr 2021 09:52 AM PDT

Initially i have problem with: ssh_host_rsa_key invalid format...

i fixed with

I use cent os 8.

I start delete some project whos actually was running.

After desconnection i cant any more to connect with ssh . I already have key host implemented.

On connect :

ssh: connect to host MYDOMAIN.com port 22: Connection timed out  

On the end i remove from digital ocean setting security keys… I also change in sshd_config PasswordAuthentication no ir yes and PubkeyAuthentication yes or no

Still no connect with ssh ....

My only alive options is recovery digital ocean web console...

Headphones recognized as Headset

Posted: 18 Apr 2021 09:18 AM PDT

When I plug in my headphone into the (only, so pobably combined out/in) jack in my laptop in Ubuntu 20.04 the config switches output to headphone (I like that) and mic to the non-existing headphone mic (not so).

I can switch the mic back to internal laptop mic in the settings, but it's quite tiring since I plug/unplug them often.

The jack of the headphone has three sections (not four as proper headsets have).

How do I prevent switching to the non-existing mic?

I tried Changing PulseAudio Source port: 'availability=no' and priority but to no avail.

RAID1 as a personal desktop backup system, pros and cons

Posted: 18 Apr 2021 09:05 AM PDT

I'm seriously considering ways to safeguard my data since I'm really tired of loosing files because of bad redundancy.

I was reading about RAID1 and it seems a very practical method of keeping updated backups, though I'm worried about complexity, security, flexibility and portability.

By complexity I mean that I'm adding another logical layer to the filesystem, so in case that anything goes wrong, maintaining and securing both layers may result in added complexity.

How do you rescue data from a RAID1 system? Is it more complex than a normal ext4?

By security I mean that redundancy is double sharped because an error in the upper ext4 filesystem would affect both drives simultaneously because both drives are readed and written at the same time. Is there any means to prevent this?

By flexibility I mean, what happens if one of the mirrored drives breaks up and I'm not able to afford another drive? can I maintain a RAID1 system with only one drive indefinitely? also is it possible to simplify a raid1 system back to a normal ext4 partition?

  1. How do you rescue data from a RAID1 system? Is it more complex than a normal ext4?
  2. Is there any way to delay mirroring in a RAID1 system?
  3. can I maintain a RAID1 system with only one drive indefinitely? also is it possible to simplify a raid1 system back to a normal ext4 partition?
  4. By portability I mean how to move a RAID filesystem in between computers?

Tricky emulation of custom kernel image using QEMU

Posted: 18 Apr 2021 08:28 AM PDT

thank you for viewing this question. I have an SD image which contains 4 partitions:

  1. U-boot and sys volume info
  2. Only contains sys volume info
  3. Empty
  4. Root file system

After running file at the U-boot kernel I can tell the kernel version is 4.14.24-rt19-stable.

My question is, can I download the kernel and build a boot disk to emulate it with QEMU having only these files available? I know the original target processor is cortex-a7.

Any guidance would be appreciated!

Password manager with fingerprint support?

Posted: 18 Apr 2021 08:07 AM PDT

Is there a password manager with fingerprint support?

I use Fedora KDE.

I know that fingerprints might be somewhat insecure. Still, a password manager with fingerprint support is useful. It can be used for logins which are not too important. Like forums and StackExchange, where losing your password to a state would not be the end of the world in any sense.

which module(s) shall I unload to disable a wifi adapter?

Posted: 18 Apr 2021 09:16 AM PDT

My T400 laptop has an internal wifi adapter. It sometimes works and sometimes don't. I use an external wifi adapter, and want to disable the internal one so that it won't suddenly work again and suspiciously interfere with other things.

How can I find out which module(s) to unload?

Here is the current output, with the external wifi adapter working and the internal one not:

$ lsmod | grep -i wifi  rtlwifi                77824  3 rtl8192c_common,rtl_usb,rtl8192cu  mac80211              786432  4 rtl_usb,rtl8192cu,rtlwifi,rtl8xxxu  cfg80211              634880  2 rtlwifi,mac80211  

and

$ lspci -knn |grep Net -A2  00:19.0 Ethernet controller [0200]: Intel Corporation 82567LM Gigabit Network Connection [8086:10f5] (rev 03)      Subsystem: Lenovo 82567LM Gigabit Network Connection [17aa:20ee]      Kernel driver in use: e1000e      Kernel modules: e1000e  

and

$ lspci -knn |grep -i net -A3  00:19.0 Ethernet controller [0200]: Intel Corporation 82567LM Gigabit Network Connection [8086:10f5] (rev 03)      Subsystem: Lenovo 82567LM Gigabit Network Connection [17aa:20ee]      Kernel driver in use: e1000e      Kernel modules: e1000e  00:1a.0 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 [8086:2937] (rev 03)  

What's the difference between the "%s" in vim normal mode and regular GNU sed

Posted: 18 Apr 2021 08:58 AM PDT

I am quite new to regex, and thought markdown(custom/madeup format of maardown) to html conversion using regex would be a good way to get started. When I'm within Vim(8.1), say converting this line;

+style  #include <style.css>  -style  

to;

<link rel="stylesheet" type="text/css" href="style.css">  

I used this command in Vim;

:%s/^+style$\n\(.*\)$\n^-style/<link rel="stylesheet" type="text\/css" href="\1">/g  

And I get exactly what I was hopping for. However, when I ran the same command from my terminal using GNU sed, I get no change in output;

sed 's/^+style$\n\(.*\)$\n^-style/<link rel="stylesheet" type="text\/css" href="\1">/g'  

Also, including the -z flag doen't seem to be much of a help either, the output remains same as input.

I wonder why that is.

How to connect to VM with NAT via SSH protocol? (Qemu/KVM)

Posted: 18 Apr 2021 08:01 AM PDT

I need your advice.

Brief to my question:

I got two Linux/Ubuntu 18.04 Lts. machines. First one is the host(SSHD) and has a VM machine installed on it(virtual machine's ethernet is configured as NAT: Qemu/KVM - virtualization). Simple SSH connection between host and VM on it in NAT regime works perfectly: ssh user@ip.address > pass

First machine is connected to router via LAN and second machine is a ssh-client connected to a router via Wifi.

machine1(host machine, LAN) > Router < (wifi) machine2(SSH Client)

Is there any solution to access VM(on host machine) with machine that is connected to wifi network only? I'm pretty new with Unix/Linux, so I would really appreciate your support with this case.

ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.122.x netmask 255.255.255.0 broadcast 192.168.122.255

P.S. I would prefer not to switch NAT to bridge regime. If you need more data, I will gladly provide you with some more details.

Separete only number and display it in new line using bash command

Posted: 18 Apr 2021 08:21 AM PDT

I need to display count of number of line which content number with no including alphabet. And also display these no. in separate lines. Below given is the content of example.txt file:

Electronic mail is a method of exchanging digital messages between computer   users; such messaging first entered substantial  use in the 1960s and by the 1970s had taken the form now recognised as email.   These are spams email ids:     08av , 29809, pankajdhaka.dav, 165 .    23673 ; meetshrotriya;  221965; 1592yahoo.in  praveen_solanki29@yahoo.com  tanmaysharma07@gmail.com  kartikkumar781@gmail.com  arun.singh2205@gmail.com    sukalyan_bhakat@us.in.y.z  These are incorrect:    065  kartikkumar781r2#  1975, 123  

The output of shell file is given below, somebody suggest how can I do this...

Output  Number of lines having one or more digits are: 4  Digits found:  29809  165  23673  221965  065  1975  123  

Every time I boot into ubuntu, it shuts down immediately and restarts again itself. It goes into a loop

Posted: 18 Apr 2021 09:21 AM PDT

I got an issue that is really bugging me for the past few days.

I am trying to boot into Ubuntu system 20.04 LTS. However, every time I turn on, for about 5 seconds loading something it then suddenly shut down. It then automatically restart, loading and shutdown .. continue in a loop.. However, if I go into Grub, I can log into the recover mode and get access the root command line interface.

Can anyone help me troubleshoot this strange thing.

The following are the only things that are set up in my computer build right now:

Motherboard: Z590 MSI PRO WIFI

CPU: i9-10850k and a CPU fan

RAM: a pair of 16 gb

M2: samsung 980 pro nvme

power supply: EVGA 700 GD, 80+ GOLD 700W

UPDATE:

Currently, What I have tried which can log into the OS and even the user interface is to edit the Ubuntu option in GRUB. However, only before 5 minutes the computer shuts down itself.

Specifically, I added "$vt_handoff nomodeset". When loading, I found that it keeps saying that Bluetooth hc10: reading intel version information failed (-22)

Install Grub to USB drive with installed Linux distro inside (Kali)

Posted: 18 Apr 2021 08:50 AM PDT

I'm trying to make a usb drive with two linux distros installed inside. The idea is to carry the usb drive with me and boot the distros in the computer available at the place where I am at that moment. I know that this might be a bad practice, but just wanna give it a try.

I tried to install Kali Linux distro to my usb drive according to this video, in which a VirtualBox VM is used to install the O.S. into a usb drive.

When I first tried I didn't booted my VM in EFI mode and so the O.S. was installed in legacy mode (boot instructions written in the MBR). All was OK as long as I booted on my pc supporting legacy boot, but when I tried to boot from my Microsoft Surface (which doesn't support legacy boot), I obviously couldn't boot from the external drive.

So I tried to reinstall Kali with EFI mode activated on the VM, but I wasn't lucky this time either and didn't manage to boot the distro on my Surface. The situation was the same as when I tried to boot from my Surface having the distro installed in legacy mode: the Surface didn't recognize the bootable usb drive at all.

Googling I found a bunch of solutions to install/reinstall GRUB to an usb/external drive, but when I tried them, it seemed they were working only as long as I booted on the same device which I used to install GRUB on the usb drive. As an example, when I used the VirtualBox VM to install GRUB into my usb device, I was able to boot my Kali distro into the usb device ONLY from that VirtualBox VM.

I think I'm missing something here... Can someone give me an hand to clarify and, maybe, solve?

I attach screenshots describing the partitioning of my usb drive and the content of the ESP partition on the USB drive after the installation in EFI mode of Kali Linux, in case they can help:

Partitioning

ESP Partition content

--- UPDATE ---

I managed to boot my system on BOTH my PCs capable of EFI boot. I just moved the Kali boot loader located in my ESP from /EFI/Kali to the fallback path /EFI/BOOT and renamed the bootloader from "grubx64.efi" to the fallback name "bootx64.efi". I don't know why the boot process didn't manage to boot /EFI/Kali/grubx64.efi do someone has any clues?

Now I only got to make everything bootable in legacy mode (aka using BIOS), is it possible? It seems to be possible to boot a usb drive both UEFI and legacy mode, but is there a way I can set everything up without messing anything working in my actual EFI bootable configuration?

select data conversion based on value range

Posted: 18 Apr 2021 09:12 AM PDT

I have a text file with 3 columns of data. However at random times in the various files there is a change in the in the observed unit from ppn to ppb resulting in the need of a conversion factor and multiplication by 1000.

actual data                        needed data look  20101001,01:00,0.3                 20101001,01:00,0.3,300.000  20110103,10:00,212.67              20110103,10:00,212.670,212.670  

I have a awk command to print all original and add a fourth column with the conversion.

The only issue is it prints everything everything in the third column by 1000 and print to the fourth column. The command is below....

awk -F ',' '{printf "%s %s %.3f %.3f\n", $1,$2,$3,$3*1000}' temp7.tmp > County001-CO-0012.out  

How can I can only values between 2 and -1 in column #3 only get multiplied by 1000 and other wise print the orignal value of column 3 in column 4?

How to compare two files to get matched records?

Posted: 18 Apr 2021 09:41 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?

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

Posted: 18 Apr 2021 09:36 AM PDT

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)  

The dmesg logs are:

[48381.426142] CIFS: Attempting to mount //10.1.10.77/share  [48381.426168] No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.  [48381.440240] CIFS VFS: cifs_mount failed w/return code = -2  

/mnt/lspro exists on the Ubuntu box. I can cd /mnt/lspro and ls /mnt/lspro it's confirmed it there!

I can even mount the NS through Files other location by "smb://<ip.address>" using Anonymous without password, but I cannot mount.cifs in the Ubuntu box.

Does anyone have the same situation and found a solution?

Passing arguments to a command safely

Posted: 18 Apr 2021 09:47 AM PDT

It is well known that it's a bad idea to do something of the kind <command> $FILENAME, since you can have a file whose name is for example -<option> and then instead of executing <command> with the file -<option> as an argument, <command> will be executed with the option -<option>.

Is there then a general safe way to accomplish this? One hypothesis would be to add -- before the filename, but I'm not sure if that is 100% safe, and there could be a command that doesn't have this option.

Exclude specific IP with port from a iptable rule having range of ip and port

Posted: 18 Apr 2021 08:21 AM PDT

Need help to create an iptable rule which will redirect all request of ip range 172.16.0.1 to 172.16.0.120 with port range 20-8081 to localhost service listening on port 22215, but this rule should not catch ip 172.16.0.111 with port 443 (i.e., 172.16.0.111:443 should directly access through internet).

iptables -t nat -A OUTPUT -p tcp --match multiport --dport 20:8081 -m iprange --dst-range 172.16.0.1-172.16.0.120 -j DNAT --to-destination 127.0.0.1:22215  iptables -t filter -A INPUT -p tcp --match multiport --dport 20:8081 -m iprange --dst-range 172.16.0.1-172.16.0.120 -j ACCEPT  iptables -A OUTPUT -p tcp --dport 20:8081 -m iprange --dst-range 172.16.0.1-172.16.0.120 -j ACCEPT  

After applying the above rule all the request which has ip and port in the above range are redirected to 127.0.0.1:22215. But I am not getting how to exclude ip 172.16.0.111 having port 443.

Automatic set-up, the network can bus with Ubuntu 20.04

Posted: 18 Apr 2021 08:13 AM PDT

I want to set-up the network of the CAN bus automatically with Ubuntu 20.04.

For other distributions, it is done like this in /etc/network/interfaces:

allow-hotplug can0  iface can0 can static      bitrate 500000  

But I did not find this path etc/network/interfaces . An

How to get all paths from a website using cURL

Posted: 18 Apr 2021 08:25 AM PDT

curl //website// will get me the source code but from there how would I filter our every unique path and obtain the number of them?

the question:

Use cURL from your machine to obtain the source code of the "https://www.inlanefreight.com" website and filter all unique paths of that domain. Submit the number of these paths as the answer.

from the question, I do not know the meaning of "UNIQUE PATHS", but I think it means something similar to what you get from executing $wget -p


I used this method and it worked somehow

wget --spider --recursive https://www.inlanefreight.com    

this will show

Found 10 broken links.    https://www.inlanefreight.com/wp-content/themes/ben_theme/fonts/glyphicons-halflings-regular.svg  https://www.inlanefreight.com/wp-content/themes/ben_theme/fonts/glyphicons-halflings-regular.eot  https://www.inlanefreight.com/wp-content/themes/ben_theme/images/testimonial-back.jpg  https://www.inlanefreight.com/wp-content/themes/ben_theme/css/grabbing.png  https://www.inlanefreight.com/wp-content/themes/ben_theme/fonts/glyphicons-halflings-regular.woff  https://www.inlanefreight.com/wp-content/themes/ben_theme/fonts/glyphicons-halflings-regular.woff2  https://www.inlanefreight.com/wp-content/themes/ben_theme/images/subscriber-back.jpg  https://www.inlanefreight.com/wp-content/themes/ben_theme/fonts/glyphicons-halflings-regular.eot?  https://www.inlanefreight.com/wp-content/themes/ben_theme/images/fun-back.jpg  https://www.inlanefreight.com/wp-content/themes/ben_theme/fonts/glyphicons-halflings-regular.ttf    FINISHED --2020-12-06 05:34:58--  Total wall clock time: 2.5s  Downloaded: 23 files, 794K in 0.1s (5.36 MB/s)    

at the bottom. assuming 23 downloads and 10 broken links all add up to be the unique path I got 33 and it was the correct answer.

External Microphone not does not work on Linux Mint 20 Ulyana

Posted: 18 Apr 2021 07:20 AM PDT

Issue

I cannot capture audio using an external microphone on my Linux Mint 20 Ulyana system. In Sound Settings under the Input tab, when I select the external microphone from the Device list, the Input level shows zero/nil, irrespective of the Volume slider position.

Screenshot of Sound Settings detailing the above issue.

However, I can still use the internal microphone without any issue.

Things I have tried so far

  1. I have tried three different external microphones, including a bluetooth device. I have eliminated the possibility of an issue with Microphone jack and the microphone pin(s).
  2. Checked whether the device is muted in alsamixer. It looks like the device is unmuted, as I did not see an MM under the device.

Here's my system information: https://termbin.com/31ml

getting current script location in bash (like python __file__ variable)

Posted: 18 Apr 2021 06:56 AM PDT

How can I get the full filename of a script in bash? (Similar to python's __file__ variable)

something like

#!/bin/bash  # my-script.sh    # would evaluate to /dir/my-script.sh  thisfile=$(get-name-for-this-script)    # Do something with some other local file   cp $(dirname $thisfile)/something.txt .  

How do I install wmutils on Fedora easily?

Posted: 18 Apr 2021 09:49 AM PDT

I've tried to compile

https://github.com/wmutils/core  https://github.com/wmutils/libwm  

But I get

CC util.c  util.c:4:10: fatal error: xcb/xcb.h: No such file or directory      4 | #include <xcb/xcb.h>        |          ^~~~~~~~~~~  compilation terminated.  

I also use Homebrew but didn't see a tap for it.

How do I compile this? I tried getting the missing dev package but it wasn't available.

I try to stay within software that's simple to install so I wonder - is there an easier way I'm not seeing?

Packaging binary release on OpenBSD

Posted: 18 Apr 2021 07:07 AM PDT

I have a tiny application written in go and I've cross-compiled it to various operating systems.

Currently my Makefile generates myapp-VERSION-OS-CPUARCH.tar.gz packages to be used as a source binary packages for to be released as .deb, .rpm, PKGBUILD, FreeBSD binary release .tgz and so on with a structure like so:

bin/myapp  LICENSE  README.md  

I can't find tutorials/howtos/examples on how to package this into official OpenBSD .tgz binary release package(s). pkg_create seems to be the command, but I can't find examples.

So how you make the binary release package on OpenBSD so that there's all the metadata such as maintainer, application category, architecture and such?

The idea here is not getting the package to any official ports repository. It's to simply package a release for your own machine and learning about the packaging process on OpenBSD.

Cannot create New folder and Paste files on a drive - Ubuntu

Posted: 18 Apr 2021 09:54 AM PDT

enter image description here My Files drive is not able to modify

enter image description here

Difference between zsh-history-substring-search and up-line-or-beginning-search

Posted: 18 Apr 2021 07:35 AM PDT

Is there a practical difference between history-substring-search-up and up-line-or-beginning-search? I've tried both out and they effectively seem to do the same thing (besides some highlighting that history-substring-search does).

hplip 3.16.2: no installed HP device found (while CUPS finds it)

Posted: 18 Apr 2021 06:59 AM PDT

I was investigating further an issue already reported here. The problem is: after having upgraded the hplip driver to 3.16.2, the scanner in my all-in-one printer HP Color LaserJet Pro MFP M277dw does not work any longer (while the printer does). Today I found other oddities that seem specific to hplip rather than to sane, whereby this other post.

I use Ubuntu Linux 14.04 LTS. In all that follows the device is connected and powered-on. The hplip page for that device is here.

Evidences

a. Moving on from the sane community page on Ubuntu, I followed the suggestion to run sudo hp-setup. The answer is

warning: CUPSEXT could not be loaded. Please check HPLIP installation.

b. If run hp-doctor, the welcome message is

error: This distro (i.e ubuntu 14.04) is either deprecated or not yet supported.

This sounds utterly odd to me, because the previous hplip did not dare to complain this far of the very same distro. The complete output of hp-doctor is available from here on Paste Ubuntu.

c. Ever more puzzling, if I open the HP device manager, I am presented with the window

enter image description here

which seems a false statement to me, since the device works as a printer at the very least. If I click on Setup device... I get again the same dialogue window. And CUPS on localhost:631 indeed confirms that the printer is there ready to be found, nice and idle.

Questions

Is there a way to have the commands hp-setup and hp-doctor run smoothly so that I can fix the scanner issue down the line?

If not, how do I downgrade the hplip driver to the previous stable version? Installing 3.16.2 has led to more havoc than joy.

Keep aspect ratio true to the mode

Posted: 18 Apr 2021 08:53 AM PDT

I've recently installed Linux Mint 17, replacing my ageing Mint 13 installation. I've got a 16:9 screen. In case it matters, my graphics card is an NVidia GeForce 210.

Now back in Mint 13, if a game switched to a 4:3 mode, I got it displayed in the correct aspect ratio, with black bars left and right. However now they are deformed to fill the full screen, which is annoying because it no only looks terrible, but also destroys angles and therefore affects gameplay.

I then also checked explicitly switching to a 4:3 mode (using the "Monitors" settings dialog), and again it deformed the image. I also checked my monitor's setting that it is indeed still set to keep the aspect ratio. Indeed, going into the monitor's menu tells me that the screen still gets a 1920x1080 signal. Therefore I conclude that it's a Linux/X11/graphics driver issue.

I'm using the Nouveau driver. In Mint 13 I used the proprietary NVidia driver; that could make a difference. However I cannot imagine that there's no way to get the correct aspect ratio also with Nouveau.

Therefore my question is: What do I have to do to get 4:3 modes (or, more generally, non-16:9 modes) displayed in the correct aspect ratio on a 16:9 monitor (without affecting the 16:9 modes, obviously)?

How to view traffic over a forwarded ssh port?

Posted: 18 Apr 2021 08:09 AM PDT

It is possible to setup an SSH port forward where the ssh client prints out the traffic exchanged over the ssh port to the screen or a file.

I am trying to debug a problem and want to see what is being sent between a java process running on my local machine and a remote process running on Solaris. I am using the port forwarding via ssh so that i can step through the java program. Normally I would have to copy the .java files to the Solaris machine, build them and run and it is not very productive way to debug, thus the port forwarding. The client and server as using IIOP protocol so I can't use an http proxy to monitor the traffic.

How can I open a new terminal in the same directory of the last used one from a window manager keybind?

Posted: 18 Apr 2021 06:44 AM PDT

I'm using a tiling window manager and I switched from gnome-terminal with multiple tabs to multiple urxvt instances managed by the window manager. One of the features I miss is the ability to open a new terminal that defaults to the working directory of the last one.

In short: I need a way to open a new urxvt (bash) that defaults to $PWD of the last used one.

The only solution that comes to my mind is to save the current path on every cd with something like this:

echo $PWD > ~/.last_dir  

and restore the path on the new terminal in this way:

cd `cat ~/.last_dir`  

I can source the second command in .bashrc but I don't know how to execute the first one on every directory change :)

Any simpler solution that does not involve screen or tmux usage is welcome.

No comments:

Post a Comment