The officially official Devuan Forum!

You are not logged in.

#1 2021-07-30 00:14:30

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 644  

how do I set the default directory to / when I use su?

Hi, when ever I change to root for admin purposes the console returns me to /home/glenn/... (whatever directory i was in before su'ing.)

How do I configure su to always start at / ?

Thank you


pic from 1993, new guitar day.

Offline

#2 2021-07-30 01:48:53

Altoid
Member
Registered: 2017-05-07
Posts: 1,581  

Re: how do I set the default directory to / when I use su?

Hello:

GlennW wrote:

How do I configure su to always start at / ?

See https://files.devuan.org/devuan_beowulf … _notes.txt

Best,

A.

Offline

#3 2021-07-30 03:48:27

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 644  

Re: how do I set the default directory to / when I use su?

Thank you for your responce, Altoid.

I see the mention of 'su' and setting the "PATH" when changing, and I have no problem with that as such, I use an alias in ~/.bashrc

And I didn't know that I could change it in /etc/... , Thank you, I may use that.

Actually, I do use that, my alias is commented in ~/.bashrc

And this question is no big deal, but I thought it would look tidy if when 'su'ing if it showed the root directory in the bash prompt.

I use konsole as a terminal mostly when using a GUI.

Could the fix be among the PS1 statements in ~/.bashrc?

this is what I have...

glenn@GamesBox ~ $ su
Password: 
root@GamesBox:/home/glenn# 

pic from 1993, new guitar day.

Offline

#4 2021-07-30 10:24:45

Altoid
Member
Registered: 2017-05-07
Posts: 1,581  

Re: how do I set the default directory to / when I use su?

Hello:

GlennW wrote:

Thank you ...

You're welcome.

GlennW wrote:

this is what I have...

glenn@GamesBox ~ $ su
Password: 
root@GamesBox:/home/glenn# 

Open a terminal and do ...

~ $ cat /etc/default/su

Please post the output.

Best,

A.

Offline

#5 2021-07-30 11:10:42

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 644  

Re: how do I set the default directory to / when I use su?

glenn@GamesBox ~ $ cat /etc/default/su
ALWAYS_SET_PATH yes
glenn@GamesBox ~ $ 

Thank you, but the PATH is not the problem, it's just the look and being in the user directory when I have su'd to root.

I've been looking and hacking the .bashrc file, /etc/profile and /etc/bash.bashrc files and I was mistaken thinking the /w in PS1 may have been the key, but that's not it either.

w.i.p.

Thanks again. regards Glenn


pic from 1993, new guitar day.

Offline

#6 2021-07-30 13:28:25

Altoid
Member
Registered: 2017-05-07
Posts: 1,581  

Re: how do I set the default directory to / when I use su?

Hello:

GlennW wrote:
glenn@GamesBox ~ $ cat /etc/default/su
ALWAYS_SET_PATH yes
glenn@GamesBox ~ $ 

Right ...
Now, open the terminal and do ...

~ $ su -

That should get you to /root.

And from there you can cd / to /.

Is that what you meant to do?

Best,

A.

Offline

#7 2021-07-30 15:34:54

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 644  

Re: how do I set the default directory to / when I use su?

No, that's what I have to do. But thank you for trying to help me.

Because it's a one user system I only have to cd {enter} to get to /

I was looking or a shorter short cut. :-)

Cheers


pic from 1993, new guitar day.

Offline

#8 2021-07-30 15:49:18

Altoid
Member
Registered: 2017-05-07
Posts: 1,581  

Re: how do I set the default directory to / when I use su?

Hello:

GlennW wrote:

No, that's what I have to do.

I see.

So ...
You want to do su - and be sent directly to / without the cd / bit.
Sorry, it seems that I've reached my pay grade limit.  8^|

GlennW wrote:

... thank you for trying ...

You're welcome.

Best,

A.

Offline

#9 2021-07-30 17:05:42

berni51
Member
From: Middle of Germany
Registered: 2018-12-20
Posts: 95  
Website

Re: how do I set the default directory to / when I use su?

Why not simply use a mini script which only contains one line: cd / && su
Calling that script will bring you to / as root.


The good ol' days will not return, and the rocks might smelt and the sea may burn.

Offline

#10 2021-07-30 17:20:10

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: how do I set the default directory to / when I use su?

Or add this line to /root/.profile:

cd /

But you would have to call su - to ensure that the file is read.


Brianna Ghey — Rest In Power

Offline

#11 2021-07-30 18:18:41

andyprough
Member
Registered: 2019-10-19
Posts: 327  

Re: how do I set the default directory to / when I use su?

Head_on_a_Stick wrote:

Or add this line to /root/.profile:

cd /

But you would have to call su - to ensure that the file is read.

So many different ways to avoid simply typing "cd /" each time. Ain't Linux great!?!

Offline

#12 2021-07-30 22:02:06

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: how do I set the default directory to / when I use su?

andyprough wrote:

Ain't Linux great!?!

Meh.


Brianna Ghey — Rest In Power

Offline

#13 2021-07-30 22:12:13

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 644  

Re: how do I set the default directory to / when I use su?

I know, right. :-)

Thank you for your advise, I got it working.

I added the cd / to /root/.profile
and used

source /root/.profile

but that didn't work, then I tried again with su - and it works.

So, I went back into my ~/.bashrc and uncommented my alias

alias su='su -'

and now it's working.

This box is fully-updated devuan_chimaera_4.0.a

Thank you everybody.

Last edited by GlennW (2021-07-30 22:12:53)


pic from 1993, new guitar day.

Offline

#14 2021-07-30 22:27:43

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 644  

Re: how do I set the default directory to / when I use su?

Head_on_a_Stick wrote:
andyprough wrote:

Ain't Linux great!?!

Meh.

I'm loving it! Thanks again, see you 'round the posts.


pic from 1993, new guitar day.

Offline

#15 2021-07-31 04:02:44

andyprough
Member
Registered: 2019-10-19
Posts: 327  

Re: how do I set the default directory to / when I use su?

Head_on_a_Stick wrote:
andyprough wrote:

Ain't Linux great!?!

Meh.

But the author didn't say GNU/Linux sucks. I think they're just referring to systemd/Linux sucking.

Last edited by andyprough (2021-07-31 04:03:05)

Offline

#16 2021-07-31 08:25:42

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: how do I set the default directory to / when I use su?


Brianna Ghey — Rest In Power

Offline

#17 2021-07-31 13:57:54

Altoid
Member
Registered: 2017-05-07
Posts: 1,581  

Re: how do I set the default directory to / when I use su?

Hello:

Yes, I know ...

But old habits die hard, very.  8^/

But thanks for the heads up.
Eventually, I guess.

Best,

A.

BTW:
I see a chap by the name of Andy Tanenbaum has an entry there.
I have not ever been around Unix and have only 10 years or so in Linux.

But reading the page made me wonder: Is this Tanenbaum (genetically or otherwise) related to systemd's Poettering?
Just curious ...

A.

Offline

#18 2021-08-01 00:18:18

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 644  

Re: how do I set the default directory to / when I use su?

Hi, I wanted to do this because I don't have sudo enabled and I use su a lot, packaging updates... checking net and kernel logs and such.

I do it a lot and it was just something I thought I could do with my systems, laptop and desktops that would streamline the process for me.

I am very grateful to this community for all the support I get when I can't find a solution to a hack I want to implement.
I don't know much (anything, ... no motive) about real hacking) but try to keep my system as secure as possible and stay current as possible.

But this is mostly because I have disabled sudo that I use su so frequently.

Thank you again (I'll read that link now ...GNU...)


pic from 1993, new guitar day.

Offline

#19 2021-08-01 08:51:17

rolfie
Member
Registered: 2017-11-25
Posts: 1,171  

Re: how do I set the default directory to / when I use su?

I have created my own root terminal according to this description: https://dev1galaxy.org/viewtopic.php?id=2717. This ends up in /root as working directory. The example is for Mate, but it also works with Cinnamon/Gnome terminal.

I guess you can easily set the path to /.

rolfie

Online

Board footer