Serious question, what exactly does do do? In my terminal I can see that do is a command but all I get is bash: syntax error near unexpected token do’and obviously with such a common name it's hard to find information on google about whatdo` actually does.
But then why is it available in my command line terminal as a command that I can use? Like when I type do and then hit TAB twice to list commands that match the output is dodone dofsck etc... but when I just enter do in the command line or do --help I get bash: syntax error near unexpected token 'do'
I would assume that since I can run sudo apt update that I could also run do apt update where it would run it not as a super user. I know just apt update would do that too, but I’m just so curious if it’s possible to use do as a user-level sudo or what else it might be able to do.
No do is not the “none superuser” version of sudo.
As the comment above stated it’s part of loops. But since loop syntax are built in to bash they are actually seperate built-in commands. Because it’s an available builtin autocompletion offers it to you.
The do command here is just a special command that expects a certain set of parameters and a done at the end this is why you get an error trying to run do alone because it’s not adhering to the syntax properly.
i use doas and it has a -u user argument. by default the user is root but you could do doas -u another_user i guess. i don’t know if sudo has the same but it probably doas*.
Serious question, what exactly does
dodo? In my terminal I can see that do is a command but all I get isbash: syntax error near unexpected tokendo’and obviously with such a common name it's hard to find information on google about whatdo` actually does.It’s used in loops in bash, like:
for i in 1 2 3 do echo "$i" doneor
while true do echo "o/" doneBut then why is it available in my command line terminal as a command that I can use? Like when I type
doand then hitTABtwice to list commands that match the output isdo done dofsck etc...but when I just enterdoin the command line ordo --helpI getbash: syntax error near unexpected token 'do'I would assume that since I can run
sudo apt updatethat I could also rundo apt updatewhere it would run it not as a super user. I know justapt updatewould do that too, but I’m just so curious if it’s possible to usedoas a user-levelsudoor what else it might be able to do.No do is not the “none superuser” version of sudo.
As the comment above stated it’s part of loops. But since loop syntax are built in to bash they are actually seperate built-in commands. Because it’s an available builtin autocompletion offers it to you.
The do command here is just a special command that expects a certain set of parameters and a done at the end this is why you get an error trying to run do alone because it’s not adhering to the syntax properly.
i use
doasand it has a-u userargument. by default the user is root but you could dodoas -u another_useri guess. i don’t know if sudo has the same but it probably doas*.*i misspelled “does” but i’m keeping it