LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch
User Name
Password
Arch This Forum is for the discussion of Arch Linux.

Notices


Reply
  Search this Thread
Old 08-13-2022, 05:49 PM   #1
AKM512
Member
 
Registered: May 2022
Posts: 37

Rep: Reputation: 0
"su: authentication failure" after attempting to fix "bash: bad interpreter: Permission denied" error


I'm trying to learn bash shell scripting, and I've run into a series of related issues. I can't execute the
Code:
mkfile.sh
script in this Wikibook course, leading to this sequence of issues:

Code:
[austin@archlinux bash]$ ./mkfile.sh filetocreatetext.txt 'line to put in file'
bash: ./mkfile.sh: /home/austin/bash: bad interpreter: Permission denied
[austin@archlinux bash]$ chmod +x mkfile.sh
[austin@archlinux bash]$ ./mkfile.sh filetocreatetext.txt 'line to put in file'
bash: ./mkfile.sh: /home/austin/bash: bad interpreter: Permission denied
[austin@archlinux bash]$ sudo chmod +x mkfile.sh
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[austin@archlinux bash]$ bash for3.sh
bash: for3.sh: No such file or directory
[austin@archlinux bash]$ bash for_2.sh
1
3
5
7
9
11
[austin@archlinux bash]$ sudo chmod +x mkfile.sh
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[austin@archlinux bash]$ sudo pkexec chmod 4755 /usr/bin/sudo
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[austin@archlinux bash]$ sudo --help
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[austin@archlinux bash]$ man sudo
[austin@archlinux bash]$ chmod +x mkfile.sh
[austin@archlinux bash]$ emacs mkfile.sh
[austin@archlinux bash]$ ./mkfile.sh file-to-create.txt line to put in file
bash: ./mkfile.sh: /home/austin/bash: bad interpreter: Permission denied
Though I was extremely weary of trying the solution here because of the dangers of working as root with
Code:
su
, I couldn't find any other obvious alternatives that didn't require logging in as root online.

Quote:
austin@archlinux bash]$ su
Password:
su: Authentication failure
[austin@archlinux bash]$ su
Password:
su: Authentication failure
[austin@archlinux bash]$ sudo -i
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[austin@archlinux bash]$ su austin
Password:
su: Authentication service cannot retrieve authentication info
[austin@archlinux bash]$ sudo -s
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
I know I must have the correct root password, because I used it to put myself in the sudoers file when I installed my Arch system. I'm not very experienced, so I'm very hesitant to try this solution using
Code:
sudo su
from AskUbuntu (plus, I'm obviously not running Ubuntu or even a Debian-based distro.)

Would it even be possible to reset my root password using
Code:
sudo su
? I'm pretty sure my password is correct, if nothing else because it's identical to my regular user (e.g.
Code:
austin
) password. (Yes, I know that's insecure and probably foolish, but I am where I am now; I don't intend to do it again.)
 
Old 08-13-2022, 10:24 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
The two errors are unrelated to each other. The bad interpreter is probably due to a bad shebang line i.e. #!/bin/bash. Without seeing your script it is difficult to say what is wrong. Did you write the script using windows and copied to linux?
 
Old 08-13-2022, 11:41 PM   #3
AKM512
Member
 
Registered: May 2022
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
The two errors are unrelated to each other. The bad interpreter is probably due to a bad shebang line i.e. #!/bin/bash. Without seeing your script it is difficult to say what is wrong. Did you write the script using windows and copied to linux?
Here is the contents of
Code:
mkfile.sh
, located under
Code:
/home/austin/bash
:

Code:
#!/home/austin/bash

file="$1" # save the first argument as "$file"
shift # drop the first argument from "$@"
echo "$@" > "$file" # write the remaining arguments to "$file"
I cut and pasted the code from the Wikibooks course here.

Is the shebang line wrong? I've used an identical line for every script I've written so far, located at
Code:
home/austin/bash
.

No Windows computer was involved in the construction/copying of this script or any files; all of this was done on my Arch Linux laptop.
 
Old 08-14-2022, 12:26 AM   #4
suramya
Member
 
Registered: Jan 2022
Location: Earth
Distribution: Debian
Posts: 249

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by AKM512 View Post
Code:
#!/home/austin/bash

file="$1" # save the first argument as "$file"
shift # drop the first argument from "$@"
echo "$@" > "$file" # write the remaining arguments to "$file"
The first line should point to the Bash executable. On my system it is at: /usr/bin/bash You can run 'whereis bash' (without the quotes) to get the location on your system.

/home/austin/bash is a directory and thus not an interpreter.
 
Old 08-14-2022, 01:29 AM   #5
AKM512
Member
 
Registered: May 2022
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by suramya View Post
The first line should point to the Bash executable. On my system it is at: /usr/bin/bash You can run 'whereis bash' (without the quotes) to get the location on your system.

/home/austin/bash is a directory and thus not an interpreter.
Ah, my misunderstanding. I thought the shebang was supposed to be the path to the file on the file system.

That seems to have done the trick (I don't get an error message anymore); I changed the shebang to
Code:
#!/usr/bin/bash
.

Code:
[austin@archlinux bash]$ ./mkfile.sh file-to-create.txt line to put in file
[austin@archlinux bash]$ emacs mkfile.sh
I will mark as solved. Thanks!
 
Old 08-14-2022, 02:00 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
just a comment: you must not use sudo and su together, that is not a good advice.
 
Old 08-14-2022, 10:35 AM   #7
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546

That entire "mkfile.sh" script is plain stupid - if the rest of the guide uses similar examples, I'd recommend a different guide.

Here's one: https://mywiki.wooledge.org/BashGuide

 
1 members found this post helpful.
Old 08-14-2022, 10:43 AM   #8
AKM512
Member
 
Registered: May 2022
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by boughtonp View Post
That entire "mkfile.sh" script is plain stupid - if the rest of the guide uses similar examples, I'd recommend a different guide.

Here's one: https://mywiki.wooledge.org/BashGuide

Thanks for the link; I'll use it instead.
 
  


Reply

Tags
authentication failure, bash, root password, setuid, uid



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
initrc_t bash: /etc/init.d/network: /bin/bash: bad interpreter: Permission denied sluge Linux - Security 2 02-04-2022 08:49 AM
-bash: ./configure: /bin/sh: bad interpreter: Permission denied cwwilson721 Slackware 28 12-25-2010 04:11 AM
Bash: bad interpreter, permission denied jpantone Linux - General 22 05-27-2010 06:05 AM
/bin/bash: bad interpreter: Permission denied cap_ahab Linux - General 4 01-17-2006 08:11 AM
bash: ./ms-stop: bad interpreter: Permission denied thamarsol Linux - Software 14 05-19-2003 05:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch

All times are GMT -5. The time now is 10:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration