Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [EN] doas  (Read 802 times)

Offline titan

  • User
  • Posts: 306
[EN] doas
« on: 2023/09/24, 19:54:50 »
Just looking through siduction manual as you do and saw the entry on doas, I am now using  it and it looks to be an improvement on sudo but the instructions to add an alias   for sudo in .bashrc looks to be wrong  alias sudo="doas" should be alias sudo='doas'
« Last Edit: 2023/09/24, 23:01:29 by titan »

Offline edlin

  • User
  • Posts: 450
Re: doas
« Reply #1 on: 2023/09/25, 11:22:31 »
In the concrete case, it makes no difference whether " or ' is used. In both cases doas is interpreted as a string.
With variables, for example, the situation is different:
echo "$HOME" returns the current home directory, while echo '$HOME' returns the string $HOME.
echo "doas" and echo 'doas', on the other hand, return the string doas in both cases.
Code: [Select]
edlin@Devil:~$ echo '$HOME' "and" "$HOME"
$HOME and /home/edlin
edlin@Devil:~$


Code: [Select]
edlin@Devil:~$ echo 'doas' "and" "doas"
doas and doas
edlin@Devil:~$
My entry in ~/.bashrc is alias sudo="doas ". The check returns
Code: [Select]
edlin@Devil:~$ alias
alias ls='ls --color=auto'
alias sudo='doas '
edlin@Devil:~$

edlin
Der Kluge lernt aus allem und von jedem,
der Normale aus seinen Erfahrungen
und der Dumme weiß alles besser.

Sokrates

Offline eriefisher

  • User
  • Posts: 221
Re: doas
« Reply #2 on: 2023/09/25, 13:12:24 »
I am now using  it and it looks to be an improvement on sudo

I have to ask, why are you using it? Personally I hated using sudo. Way too much repetitive typing. I would sudo su just to avoid it all. It was also one of the several reasons I hated *buntu many years ago, along with it's instability.

Offline edlin

  • User
  • Posts: 450
Re: doas
« Reply #3 on: 2023/09/25, 16:44:57 »
I think one reason for this is that sudo has been used for ages in all sorts of tutorials etc. when applications are to be run with root rights.
With doas there is a lightweight, configurable alternative.
I myself use doas or su -. With alias and/or espanso you can of course also make your work easier.
For me, doas is not a big typing task, as I mostly use it for recurring tasks and thus use the bash history.
If I have several things to do as root, I use su -; after work is done, the environment is exited with exit.

And there are a lot of reasons not to like Ubuntu, but that's another topic.

edlin
Der Kluge lernt aus allem und von jedem,
der Normale aus seinen Erfahrungen
und der Dumme weiß alles besser.

Sokrates

Offline titan

  • User
  • Posts: 306
Re: doas
« Reply #4 on: 2023/09/25, 17:41:45 »
I tried alias sudo="doas" but it didn't work but I noticed that all the other alias in  .bashrc  used  '  so I changed to  alias sudo='doas' and it worked. I only wanted to see if it worked, I won't be using the alias.

I only use sudo/doas for one purpose, starting my vpn with wireguard otherwise I would have to leave a root terminal open

Offline scholle1

  • User
  • Posts: 76
Re: doas
« Reply #5 on: 2023/09/26, 13:21:37 »
I tried alias sudo="doas" but it didn't work [...]

Hi titan
Both variants work for me. Tested with logout-login and reboot.
IMHO there is no need to change the manual.

System:
Code: [Select]
Debian GNU/Linux trixie/sid
siduction 2023.1.0 Standing_on_the_Shoulders_of_Giants - xfce - (202308151323)
Je mehr Bürgerinnen und Bürger mit Zivilcourage ein Land hat, desto weniger Helden wird es einmal brauchen.
(Franka Magnani)

Offline edlin

  • User
  • Posts: 450
Re: doas
« Reply #6 on: 2023/09/26, 17:28:19 »
There is no reason to change the manual at this point. I have already explained why alias sudo="doas" and alias sudo='doas' are equivalent in our case. If @titan comes to different results, then there must be a reason.
The easiest way is to set up your own file with the aliases:
Code: [Select]
touch ~/.bash_aliasesThis file is read in via ~/.bashrc if it exists.
Different aliases can now be entered in the file. Here is an example file ~/.bash_aliases for the test:
Code: [Select]
alias test1="doas nala upgrade"
alias test2="df -h"
alias test3='ls -al'
alias test4="grep "
After saving, there is no need to log in again or reboot; it is sufficient to start a new bash.
To check which aliases the bash knows, let's display them:
Code: [Select]
edlin@Devil:~$ bash
edlin@Devil:~$ alias -p
alias ls='ls --color=auto'
alias test1='doas nala upgrade'
alias test2='df -h'
alias test3='ls -al'
alias test4='grep '
edlin@Devil:~$

One more hint: Only the first word of a command line is checked to see if it is an alias. If the other words of the command line are also to be checked, the alias must end with a space!

edlin
Der Kluge lernt aus allem und von jedem,
der Normale aus seinen Erfahrungen
und der Dumme weiß alles besser.

Sokrates

Offline titan

  • User
  • Posts: 306
Re: doas
« Reply #7 on: 2023/09/26, 18:01:12 »
I just thought I was being helpful and reporting what I found, maybe I made a mistake but as I said the other alias in .bashrc use '  so for continuity would it not be best to keep them the same

I have now just tried using " and it works OK so you are right either " or ' both work .  I have also just removed the entry as I won't be using it