Welcome!
Important information
-- Required MX 15/16 Repository Changes
-- Information on torrent hosting changes
-- Information on MX15/16 GPG Keys
-- Spectre and Meltdown vulnerabilities

News
-- Introducing our new Website
-- MX Linux on social media: here

Current releases
-- MX-18.3 Point Release release info here
-- Migration Information to MX-18 here
-- antiX-17.4.1 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

[SOLVED] su bash aliases

Help for Current Versions of MX
Post Reply
User avatar
figueroa
Forum Regular
Forum Regular
Posts: 396
Joined: Fri Dec 21, 2018 12:20 am

[SOLVED] su bash aliases

#1

Post by figueroa » Sat Jan 05, 2019 3:19 pm

When I run "su" in a terminal, root does not inherit my ~/.bashrc, and it also ignores /root/.bashrc. How do I fix this or change this behavior? I get the same results whether I run su or su - .
Last edited by figueroa on Sat Jan 05, 2019 4:37 pm, edited 1 time in total.
Andy Figueroa
Using Unix from 1984; GNU/Linux from 1993

User avatar
figueroa
Forum Regular
Forum Regular
Posts: 396
Joined: Fri Dec 21, 2018 12:20 am

Re: su bash aliases

#2

Post by figueroa » Sat Jan 05, 2019 4:35 pm

Embarrassingly, I am now self-answering my question. I can get su to inherit my user .bashrc settings by using su -p or su -m.

Just using su DOES invoke /root/.bashrc, but I'd made a typo. My original objective was to create a /root/.bash_aliases file in order to have some easy and safer command line defaults (i.e. 'rm -i') and get rid of what I considered to be unsafe and unintuitive default aliases (ag, agc, agd, and agu). For what it's worth, this is what my .bash_aliases file looks like:

Code: Select all

alias ls="ls -F --color=auto --group-directories-first"
alias ll="ls -F --color -l --group-directories-first"
alias lt='ls -Fltr'
alias lta='ls -ltra'
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias bye='exit'

#UNSET THE FOLLOWING:
unalias ag
unalias agc
unalias agd
unalias agu
Andy Figueroa
Using Unix from 1984; GNU/Linux from 1993

User avatar
BitJam
Forum Veteran
Forum Veteran
Posts: 3267
Joined: Sat Aug 22, 2009 11:36 pm

Re: [SOLVED] su bash aliases

#3

Post by BitJam » Sat Jan 05, 2019 4:57 pm

Thanks! Please don't be embarrassed by answering your own question here! It sounds like the Debian su is a little different than su in Gentoo. From Gentoo (and other systems), I'm used to inheriting the user config with "su" and getting root's config with "su -".
Will I cry when it's all over?
When I die will I see Heaven?

sunrat
Forum Regular
Forum Regular
Posts: 440
Joined: Mon Mar 28, 2016 9:54 pm

Re: [SOLVED] su bash aliases

#4

Post by sunrat » Sat Jan 05, 2019 11:18 pm

The behaviour of su changed with the upgrade to util-linux 2.32 a few months ago which is now in unstable and testing. This seems to be the same as Gentoo @Bitjam, and in line with most other distros.
https://salsa.debian.org/debian/util-li ... f9ad2f26f7
https://bugs.debian.org/cgi-bin/bugrepo ... bug=904988

Stretch still has 2.29.2-1+deb9u1. Maybe the update incorporated the new behaviour.

User avatar
Richard
Posts: 2711
Joined: Fri Dec 12, 2008 10:31 am

Re: [SOLVED] su bash aliases

#5

Post by Richard » Sat Jan 05, 2019 11:36 pm

So that's why "su -" always moved me away from the folder I was in.
Nice to know why, it dropped the "-".
Especially since it may be coming back.
LT: MX18.2: Thinkpad T430: DualCore, Intel i5-3320M, Ivy Bridge; 8GB RAM; 4.19.0-5-amd64; 119GB SSD 840PRO, Intel Graphics-Audio-Network
NB: MX18.1, antiX17.4: AsusTek EeePC 1005HA: Intel DualCore Atom N270, 1GB RAM, 4.19.0-1-686, 150GB HDD

User avatar
figueroa
Forum Regular
Forum Regular
Posts: 396
Joined: Fri Dec 21, 2018 12:20 am

Re: [SOLVED] su bash aliases

#6

Post by figueroa » Tue Jan 08, 2019 12:38 am

In the end, I made it a little easier for me to keep my aliases by adding them to root's .bash_aliases also. I spend a lot of time in a terminal.
Andy Figueroa
Using Unix from 1984; GNU/Linux from 1993

User avatar
jeanpaulberes
Forum Novice
Forum  Novice
Posts: 41
Joined: Wed Dec 19, 2018 11:56 am

Re: [SOLVED] su bash aliases

#7

Post by jeanpaulberes » Wed Jan 09, 2019 3:26 pm

figueroa wrote:
Sat Jan 05, 2019 3:19 pm
When I run "su" in a terminal, root does not inherit my ~/.bashrc, and it also ignores /root/.bashrc. How do I fix this or change this behavior? I get the same results whether I run su or su - .
The system-wide (so also su) aliases you can find in
/etc/bash.bashrc
Edit this as root (sudo or su) and put the system-wide aliases here ...

Best regards,
JP
:needcoffee:

User avatar
figueroa
Forum Regular
Forum Regular
Posts: 396
Joined: Fri Dec 21, 2018 12:20 am

Re: [SOLVED] su bash aliases

#8

Post by figueroa » Thu Jan 10, 2019 12:18 am

The system-wide configuration files /etc/profile and /etc/bash.bashrc are subject to being overwritten during upgrades.
Andy Figueroa
Using Unix from 1984; GNU/Linux from 1993

Post Reply

Return to “MX Help”