autoexecution of alias bash.bashrc

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
wepice

autoexecution of alias bash.bashrc

Post by wepice »

I am using several alias based on rsync for synchronising files on laptops with a server. Synchronizing either a laptop with the server, or the server with a laptop, is performed by executing an appropriate alias in a terminal on a laptop, with the alias stored on the laptop in /etc/bash.bashrc.

This has worked exceedingly well in the past with different Linux-distributions, but with Mint18 64 bit Cinnamon a potentially disastrous occurrences happens.

After copying the original alias as root with xed into /etc/bash.bashrc of Mint18 installed on a Toshiba Z30 and then restarting the Z30, trying to open a terminal does not yield a virgin terminal, but rather a terminal asking for the password of the server indicated for synchronization purposes in the alias. With other words, the alias has started to execute without ever being asked to do so, and if it were not for the password request, existing data would have uncontrollably been messed up.

Actions like restarting the computer do nothing to correct the situation, only removing the alias from bash.bashrc remedies it.

I am not an expert on that matter, but I suspect that the replacement of upstart by systemd might be responsable for the mess. Is there a safe way to correct the problem?

Thanks in advance for any help,

wepice
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29615
Joined: Wed Jul 06, 2011 3:58 am

Re: autoexecution of alias bash.bashrc

Post by xenopeek »

Let's see your additions to the /etc/bash.bashrc file first, before throwing blame around. Also note that /etc/bash.bashrc will be overwritten when the package from which it was installed gets updated. You should generally put your bash configuration in ~/.bashrc to avoid your file being overwritten by packages updates.
Image
atomic.kidd

Re: autoexecution of alias bash.bashrc

Post by atomic.kidd »

Consider possibly a better solution using SSH and ssh-key sharing

consider do not touch system files ie: /etc/bash.bashrc or any other /etc/ file unless its a performance tweak for whole system and not 1 account
- setup proper user and or application account and use manipulate user own account files to operate such rsync feature
- copy original files before modify to filename.org.date ie: sudo cp /etc/bash.bashrc /etc/bash.bashrc.org.Jul16
- consider ssh and ssh-keys for safer improved sync feature between machines. Fair number of documents out there.
sniffer tool might provide some tips and hints to why its not working.
script tool might help
sudo script rsyncRun
dot slash your script and or start your app!

if you have some bash shell can add -xv to debug command line execution functions - Add to top SheeBang line
top of a script:
#!/bin/bash
add debug
#!/bin/bash -xv

few ideas.. there are some examples out there for ssh key sharing and sync function.
Locked

Return to “Scripts & Bash”