.bashrc does not load automaticly after update from SFOS 3.4 to 4.1.28

REPRODUCIBILITY (% 100):
BUILD ID = OS VERSION (4,1,28):
HARDWARE (Xperia X):
UI LANGUAGE: DE
REGRESSION: ( NO):

DESCRIPTION:

Autoload after ssh login into Phone does not work. Manually loading via “source .bashrc” does not work too. Loading via command “source /home/nemo/.bashrc” does work. PATH var is set correctly. .bash_profile :

.bash_profile

Get the aliases and functions

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

include .bashrc if it exists // absolute path does not work

#if [ -f ~/.bashrc ]; then

source /home/nemo/.bashrc

#fi

User specific environment and startup programs

PATH=$PATH:$HOME/bin
export PATH

[nemo@Sailfish ~]$ source .bashrc
-bash: source: .bashrc: not found
[nemo@Sailfish ~]$ pwd
/home/nemo
[nemo@Sailfish ~]$ source /home/nemo/.bashrc
nemo@Sailfish:~>

STEPS TO REPRODUCE:

EXPECTED RESULT:

ACTUAL RESULT:

ADDITIONAL INFORMATION:

(Please ALWAYS attach relevant data such as logs, screenshots, etc…)

Hello
Similar to [4.1.0.23] New shell does not execute aliases

…and solved there by @nephros !

edit: There is a new shell (busybox) in use after update to 4.1.0.24.

@nephros told me: Busybox sh does not read /etc/bashrc or ~/.bashrc, but it does read /etc/profile and ~/.profile. Put your aliases in there. Myself I keep a file ~/.aliases and source that from whatever shell rc files are applicable.

I figured out, that the .profile file was read from the OS ( that was my first try when other files does not work ). I Use different prompts and aliases for root and nemo. Creating a .profile file and execute via this file my .bashrc work fine for normal user nemo. But for the root User no file is read ( no .profile .bash_profile or andy other files ) This is really bad for me. Why doesnt the root account processing file which were proccessend as normale user ? I also checked the $PATH var.

Souring the root .profile oder root .bashrc manually works :

nemo@Sailfish:~> sudo su
root@Sailfish:/home/nemo> cd
root@Sailfish:~> cat .profile
echo “test”
. /root/.bashrc
root@Sailfish:~> source /root/.profile
test
root@Sailfish:~>

Use “sudo su -” or “sudo -i” and you are fine.

Well, to my understanding bashrc and profile are designed to hold user scripts. but root is not a real user account, e.g. it has no userspace home directory. I might be wrong but I.think both BASH and Busybox won’t load any scripts when logging in as root (apart from the system wide configuration)

When working with elevated privileges on Linux you’re supposed to use one-shot commands only (as @adekker posts, only sudo does not exist on SFOS - the equivalent would be devel-su).

edit
wait a sec, has the switch to Busybox introduced sudo by any chance ?
Sudo now is available, see my post below.

"sudo su - " works only for root login - directly command executions is not working.
"sudo -i " works fine

both commands execute the .profile and the bashrc commands including bash_aliases and colored prompts.

i added an alias in the users .bashrc: alias sudo=‘sudo -i’

now sudo su and sudo works fine :wink:

devel-su doesnt read the .profile file. " wait a sec, has the switch to Busybox introduced sudo by any chance ?" => can sudo configured as “no busybox execution” programm ?

Ok, let’s elaborate on this a bit. At least for me this is prone to cause confusion (I had to do a bit of research - read: look into MAN pages - to refresh what I had learned about the usage of root).

Side note: sudo used to be not officially available on SFOS, only as custom build from user repositories on OpenRepos. At some point Jolla has introduced an official build to the Jolla repos, it seems. A detail I had missed

  1. The command su is short for supplement user. It let’s you switch to another user’s session. That includes non-root users.
    When executed without any arguments, that user defaults to root. Your system will have to have a root password configured for this command to work by itself

  2. The command sudo is short for superuser do. It allows you to execute a specific command with elevated privileges while using your non-root username’s password for authorization.

    • running sudo su lets you switch to root while using your regular user’s password for authentication instead of a dedicated password for root itself. That would be pure vanilla root with no environment adjustments from user scripts taken into account
    • When provided with the flag -i (long form: --login) any user specific scripts (i.e. .bashrc, .profile) will be sourced by sudo upon execution

This in effect makes the reported behaviour not a bug but a feature (classic! :grin: )
One can either adjust script file names and command switches for the correct sourcing of all desired files or switch back to BASH as default shell.

1 Like