Problems running Applejack and Terminal

Let me start by saying I’m a novice with Unix, so bear with me.

I’m wanting to run Applejack in order to try and solve some issues with a sluggish iMac, but not having any luck. I downloaded ver 1.6 of Applejack and did a normal installation. The installation completed successfully. I then re-booted in single user mode (cmd-s). I got the typical black background with white text during the boot, however when the boot was finished I got the prompt: -sh-3.2# Is this typical, and what does this prompt indicate?

I then tried to run Applejack by typing:
+applejack auto+

To this I got the response:
+-sh: applejack: command not found+
-sh-3.2#

I tried several variations on the command , but the response is always the same, “command not found”. So it appears either applejack was not installed properly, or the –sh-3.2# prompt suggests I’m in some program within single user mode and that program doesn’t recognize applejack commands.

For what it’s worth, I also can’t run Terminal. When I try to run it I get the message, “You are not authorized to run this application. The administrator has set your shell to an illegal value.”

The really strange thing is, I am the administrator and only user of this iMac. So, what the heck is going on? I hope someone out there can help me resolve this.

20" iMac 2.16 GHz Intel Core 2 Duo (late 2006), 2.5GB RAM, Mac OS X (10.6.3)

Posted on Jul 14, 2010 9:22 PM

Reply
18 replies

Jul 15, 2010 1:51 AM in response to dbax

I guess there is a longer story behind this.

Not to being rude in any way, the best thing now is to read about unix. I don't want to say, forget about appleJack for the moment, but wait till you know the basic basics ( when the unix basics are ended? I don't know, maybe never 😉 ).

F.e did you do what, when booting into single user mode, shows up?
Like the fsck and the mount thing?
Learn about paths and PATH.
You can try to use the complete path to AppleJack

Also some advise, even when you are the only user, set up a admin account and an user account.
Use the user account for your daily businesses. It will protect you. If you do things in the admin account the impact of a wrong command could be dramatic, even not visible at the moment, but after a restart it can, because you are working at system level.

I/we don't know what happened in the past, but maybe set up a second drive or add a partition with an OS to play with, 15-25Gb will do.

Jul 15, 2010 6:32 AM in response to dbax

...I then re-booted in single user mode (cmd-s). I got the typical black background with white text during the boot, however when the boot was finished I got the prompt: -sh-3.2# Is this typical, and what does this prompt indicate?

It means you are in a command shell, which is really the shell bash running in POSIX shell mode, and it is version 3.2. The # is the indication that you are running as root. Root has full privileges.
I then tried to run Applejack by typing:
+applejack auto+

To this I got the response:
+-sh: applejack: command not found+
-sh-3.2#

Where is applejack installed? Enter the command

/path/to/where/the/program/is/installed/applejack auto

My understanding of AppleJack is that it is suppose to run from single-user mode without problems, so this makes me wonder if it was successfully installed.

The other alternative is that someone has been messing with the root account's shell initialization file ~root/.profile which is always dangerous. My root's PATH environment variable is:

echo $PATH
/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

I would expect your's to be similar
For what it’s worth, I also can’t run Terminal. When I try to run it I get the message, “You are not authorized to run this application. The administrator has set your shell to an illegal value.”

You can not run Terminal from a normal fully booted system? That is most strange.

Part of me says throw up your hands and re-install. But if you want to look further, you can try throwing away your Terminal preferences.

Your Home Folder -> Library -> Preferences -> com.apple.Terminal.plist

If that does not work, then look at what your Account has your shell set to.

System Preferences -> Accounts
Click on the padlock in the lower left corner and unlock it
Control-Click on your account name -> Advanced Options
What does Login Shell says?

The default shell is typically /bin/bash

If this is NOT your shell, then change the field to /bin/bash

DO NOT change any other field. Changing something in Advanced Options does not insure that it is changed everywhere. For example changing your UID or GID DOES NOT change the ownership of any files that already exist, and could cause you to loose access to your data. But changing your shell via Advanced Options is OK.

If this does not work, then that might say the /etc/shells list of legal shells is corrupt. My /etc/shells looks like

cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

If your /etc/shells is corrupt, then either you have been doing some really deep messing around on your system, something I would consider very strange for someone that does not understand Unix, or your system has become rather corrupt, and you should seriously consider reinstalling Mac OS X.

Jul 15, 2010 12:10 PM in response to BobHarris

BobHarris wrote:

Where is applejack installed? Enter the command

/path/to/where/the/program/is/installed/applejack auto

The response to this command was, "No such file or directory". So, in spite of Applejack appearing to install successfully, apparently it did not. I don't know what to make of this since the only indication I got was that the installation was successful.
The other alternative is that someone has been messing with the root account's shell initialization file ~root/.profile which is always dangerous. My root's PATH environment variable is:

echo $PATH
/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

I would expect your's to be similar

I haven't messed with the root account's shell init file. In my case, the response to echo $PATH came back as, /usr/bin:/bin:/usr/sbin:/sbin
For what it’s worth, I also can’t run Terminal. When I try to run it I get the message, “You are not authorized to run this application. The administrator has set your shell to an illegal value.”

You can not run Terminal from a normal fully booted system? That is most strange.

Part of me says throw up your hands and re-install. But if you want to look further, you can try throwing away your Terminal preferences.

Your Home Folder -> Library -> Preferences -> com.apple.Terminal.plist

Did this, but no luck, I still get the same message when I try to run Terminal
If that does not work, then look at what your Account has your shell set to.

The default shell is typically /bin/bash

Mine was set to /bin/tcsh, changed to /bin/bash

If this does not work, then that might say the /etc/shells list of legal shells is corrupt. My /etc/shells looks like

cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

When I type the command, cat /etc/shells, nothing is reported. i.e., I just get the next prompt: -sh-3.2#
However, I do see each of the 6 you list as options in "Login shell" when I go into System Preferences>Account>Advanced Options
If your /etc/shells is corrupt, then either you have been doing some really deep messing around on your system, something I would consider very strange for someone that does not understand Unix, or your system has become rather corrupt, and you should seriously consider reinstalling Mac OS X.

I really have not been doing any deep messing around. Perhaps I do need to reinstall Mac OS X, but before I do that (since it will be quite time-consuming), do you have any other suggestions?

Jul 15, 2010 12:43 PM in response to dbax

I haven't messed with the root account's shell init file.
In my case, the response to echo $PATH came back as,
/usr/bin:/bin:/usr/sbin:/sbin

That should be good
Mine was set to /bin/tcsh, changed to /bin/bash

Have you been upgrading from the 10.1/10.2 days?
I think Mac OS X switched from tcsh as the default shell
to bash around 10.3 (Panther).
When I type the command, cat /etc/shells, nothing is reported.
i.e., I just get the next prompt: -sh-3.2#

I assume you are looking at this from single-user mode,
since 'cat' is not going to work if you cannot start Terminal 🙂

Maybe you also want to see if /etc/shells has anything in it

/bin/ls -l /etc/shells
-rw-r--r-- 1 root wheel 179 Oct 5 2009 /etc/shells

Mine is 179 bytes long.

If you can not get to a command line prompt,
you could look at the file size information using
Finder -> Go -> Go to Folder -> /etc
Then you can select "shells", and use Finder -> File -> Get Info
to see the file size.

You could use a utility such as Smultron,
which can open hidden files, such as files in the /etc/ directory
Smultron (free download)
<http://www.versiontracker.com/dyn/moreinfo/macosx/24012>

Smultron -> File -> Open Hidden...
I really have not been doing any deep messing around.
Perhaps I do need to reinstall Mac OS X, but before I do that
(since it will be quite time-consuming),
do you have any other suggestions?

What I've suggested is weak as it is.
I'm mostly trying to diagnose what is happening.
But since this is not my system, and I'm remote,
part of me wants to throw up my hands and say
start over 🙂

That is not always the answer I would accept if
it was given to me, so feel free to ignore me.
I would 🙂

PS. If you happen to know where applejack was installed,
you can enter the full path to the utility and invoke it from
single-user mode. If you think applejack will help your
situation, then if you can find it, it might be worth giving
it a try. I'm just not an applejack user, so I cannot comment
one way or another about what it will or will not do.

Message was edited by: BobHarris

Jul 15, 2010 1:45 PM in response to dbax

You wrote
The response to this command was, "No such file or directory".

Did you really type; "/path/to/where/the/program/is/installed/applejack auto"?

applejack is original installed at

/private/var/root/Library/Scripts/

so

/private/var/root/Library/Scripts/applejack auto

should work, if of course you boot from the right partition.

Did you read the man page for applejack at the site from applejack?

It reads,
Now, type applejack at the prompt. (If you’ve installed applejack manually, or have not created an alias to applejack for the root user, you may have to enter the full path to the script at the prompt.)

If this isn't working, then your system is messed up. Some people know how to handle this, they are experts. I should do a reinstall and make a clone of the system to play with. It will save your time.

HTH

Jul 15, 2010 2:03 PM in response to BobHarris

Bob, Thanks again for your time/help.
BobHarris wrote:
When I type the command, cat /etc/shells, nothing is reported.
i.e., I just get the next prompt: -sh-3.2#

I assume you are looking at this from single-user mode,
since 'cat' is not going to work if you cannot start Terminal 🙂

That's correct, I was trying this in single-user mode
Maybe you also want to see if /etc/shells has anything in it

/bin/ls -l /etc/shells
-rw-r--r-- 1 root wheel 179 Oct 5 2009 /etc/shells

Mine is 179 bytes long.

If you can not get to a command line prompt,
you could look at the file size information using
Finder -> Go -> Go to Folder -> /etc
Then you can select "shells", and use Finder -> File -> Get Info
to see the file size.

When I use Finder>Go>Go to Folder to get to /etc, I see a file (shells~orig) with 179 bytes, and I see another file (shells) which is empty (0 bytes). Any idea why I have two such files?
PS. If you happen to know where applejack was installed,
you can enter the full path to the utility and invoke it from
single-user mode.

Any idea how I can do that? Using the Finder Find command, I don't see a applejack application anywhere. I only see the file, Applejack-1.6.dmg (installation) file. Would the application be a hidden file?

Jul 15, 2010 2:29 PM in response to dbax

Take Obj-D's applejack location information, then use the Finder -> Go -> Go to Folder trick to find that directory, or just walk down the directory path via the Finder, assuming none of those paths are hidden.

Spotlight and the Finder's Find, then to ignore files that are not typical user files, word processing documents, pdfs, text files, movies, pictures, Mac OS X GUI type appliations, etc... Something like applejack is most likely below Spotlight and Finder Find radar.
When I use Finder>Go>Go to Folder to get to /etc, I see a file (shells~orig) with 179 bytes, and I see another file (shells) which is empty (0 bytes). Any idea why I have two such files?

That TOTALLY explains why the Terminal refuses to open for you. There are no /etc/shells entries, so there is no shell that is legal.

How that happened, I do not have a clue. The good news, a corrupted file system would NOT have a shells~orig. A corrupt file system would just have a missing or totally screwed up set of files. The ~orig indicates something messed with the file. It is possible some editor uses the convention of renaming the original to ~orig, and it was a failed editing session that gave you an empty /etc/shells file.

Now getting your /etc/shells file back is going to be fun. You can do it from single-user mode, but you need to issue some commands that change the boot volume from mounted read-only to mounted read-write. I know there are commands to do this, I just do not remember what they are. Is it as simple as "mount -u /", or am I thinking of a different flavor of Unix operating system? Do a Google search on single user mode, Mac OS X, and making the boot volume writable.

The other option would be to boot the system using the installation DVD. From the installation menu, there should be an option to start a Terminal session. You should be able to make changes from that terminal.

Yet another option, my least desirable. Use the Installation DVD and from the installation menu, enable the 'root' account. Now boot your system normally, and login as 'root'. Now as root, you can use Finder -> Go -> Go to Folder -> /etc, and then remove the zero length 'shells' file, then rename the shells~orig to 'shells'. I do not like enabling the root account.

So do you have a cat that pretends to sleep on your keyboard when you are looking, but when you are NOT looking, it is trying to hack into your system? Those cats are very sneaking. There are documentaries on what Cats & Dogs do when we are not looking ("Cats & Dogs", as well as "Cats & Dogs: Revene of Kitty Galore", for example) 🙂

Message was edited by: BobHarris

Jul 15, 2010 2:27 PM in response to Obj-D

Obj-D wrote:
You wrote
The response to this command was, "No such file or directory".

Did you really type; "/path/to/where/the/program/is/installed/applejack auto"?

Yes I did
applejack is original installed at

/private/var/root/Library/Scripts/

so

/private/var/root/Library/Scripts/applejack auto

should work, if of course you boot from the right partition.

I only have one partition on my internal HD.

I used Finder>Go>Go to Folder to look at the /private/var folder. In this folder I see the folder "root", but it (the folder icon) has a little "-" at the lower right of the icon. So when I click on this to see what is in the folder, there are no other files/folders shown. i.e., no Library folder in root. Looks like a problem - no Library/Scripts folder in which to put applejack. Any thoughts on this?
Did you read the man page for applejack at the site from applejack?

No, I didn't see that. I'll go back and definitely read it.
It reads,
Now, type applejack at the prompt. (If you’ve installed applejack manually, or have not created an alias to applejack for the root user, you may have to enter the full path to the script at the prompt.)

So, any suggestion how I can find just where applejack is located? Is it a hidden file or can I use Finder's "Find" command? If it is a hidden file, can you suggest a tool I can use to locate it?

Jul 15, 2010 3:27 PM in response to dbax

It's difficult to focus on two advices here, one from a unix expert ( BH ) and somebody else.

Please follows Bob his advice carefully.
Anyway, if you get this solved, then my added advice is, if you don't want or can't add a partition on your internal drive, add a usb drive to your set and installs OSX on a 30Gb partition or so, and use that, by booting from it, for experiments and learning Unix.

Its worth the money!

Jul 15, 2010 5:56 PM in response to BobHarris

Bob,

Phew, I'm going to have to take some time and review your recommendations. (Remember, I'm a Unix novice)
BobHarris wrote:
When I use Finder>Go>Go to Folder to get to /etc, I see a file (shells~orig) with 179 bytes, and I see another file (shells) which is empty (0 bytes). Any idea why I have two such files?

That TOTALLY explains why the Terminal refuses to open for you. There are no /etc/shells entries, so there is no shell that is legal.

Now getting your /etc/shells file back is going to be fun. You can do it from single-user mode, but you need to issue some commands that change the boot volume from mounted read-only to mounted read-write. I know there are commands to do this, I just do not remember what they are. Is it as simple as "mount -u /", or am I thinking of a different flavor of Unix operating system? Do a Google search on single user mode, Mac OS X, and making the boot volume writable.

The other option would be to boot the system using the installation DVD. From the installation menu, there should be an option to start a Terminal session. You should be able to make changes from that terminal.

Yet another option, my least desirable. Use the Installation DVD and from the installation menu, enable the 'root' account. Now boot your system normally, and login as 'root'. Now as root, you can use Finder -> Go -> Go to Folder -> /etc, and then remove the zero length 'shells' file, then rename the shells~orig to 'shells'. I do not like enabling the root account.

Based on your suggestions I'm assuming the simple approach that comes to my mind: use Finder>Go to Folder>/etc, delete the empty folder "shells" and rename "shells~orig" to "shells" would not work?
So do you have a cat that pretends to sleep on your keyboard when you are looking, but when you are NOT looking, it is trying to hack into your system? Those cats are very sneaking. There are documentaries on what Cats & Dogs do when we are not looking ("Cats & Dogs", as well as "Cats & Dogs: Revene of Kitty Galore", for example) 🙂

You know, you could be on to something there... 🙂

Jul 15, 2010 7:23 PM in response to dbax

Based on your suggestions I'm assuming the simple approach that comes to my mind: use Finder>Go to Folder>/etc, delete the empty folder "shells" and rename "shells~orig" to "shells" would not work?

1st) /etc/shells is a file, NOT a folder. I suspect that was just a tiny misstatement, but I need to be sure we are properly communicating, as playing in the /etc directory is dangerous if not done properly.

2nd) DO NOT under any conditions delete /etc. I just want to make sure that when you said Folder, you were not thinking about /etc itself. I only worry about this because /etc is essential to the normal operation of your Mac. Years ago, when I was a young software developer, I accidentally deleted /etc on a Unix system. It was not a pretty site 🙂 So I just wanted to make sure you are talking about deleting /etc/shells, and NOT /etc

3rd) I am concerned that you will not be able to rename the shells~orig. I experimented renaming via the Finder, and I kept getting insufficient privilege. I could use the Finder to delete a file from /etc, I just could not rename a file in /etc.

So you might need to try one of my other suggested approaches.

And just because I suggest "Too Much", here is yet another approach. You can use a Firewire cable, Target Mode, and mount your Mac's disk on another Mac, and use that Mac to edit your messed up Mac's /etc/shells file. Or just use one of the previously suggested approaches.

Jul 15, 2010 8:32 PM in response to BobHarris

BobHarris wrote:
Based on your suggestions I'm assuming the simple approach that comes to my mind: use Finder>Go to Folder>/etc, delete the empty folder "shells" and rename "shells~orig" to "shells" would not work?

1st) /etc/shells is a file, NOT a folder. I suspect that was just a tiny misstatement, but I need to be sure we are properly communicating, as playing in the /etc directory is dangerous if not done properly.

Yes, I mis-spoke. I understand, "shells" (and "shells~orig") are files, not folders.
3rd) I am concerned that you will not be able to rename the shells~orig. I experimented renaming via the Finder, and I kept getting insufficient privilege. I could use the Finder to delete a file from /etc, I just could not rename a file in /etc.

I do have an external HD with OS X on it. I'll try rebooting to that HD, see how those files/folders compare with those on my internal HD, and play around there before trying your alternate approaches on my internal drive.

Thanks again, and feel free to offer any and all suggestions that may come to mind.

Jul 16, 2010 11:00 AM in response to BobHarris

Some progress. Here’s an update of my situation. I booted from an external HD and found that I could run Terminal there just fine. There was no /etc/shells~orig file, just /etc/shells in this OS (179 bytes).

As noted in the beginning of this topic, I am a Unix novice, so I decided to try a crude, non-unix tools approach in fixing the shells file on my internal HD: I did a copy of the /etc/shells file (on the external HD) and then pasted it into a new folder, creating new copy. I then deleted the /etc/shells file on the internal HD and moved the newly-created shells file into the /etc folder on the internal HD. In spite of the fact that this new /etc/shells file shows it is 4Kb in the Finder, “Get Info” on this file shows it contains 179 bytes, and when I rebooted from my internal HD, I found I can now run Terminal!

More good news, I found that Applejack is definitely installed. I was able to start Applejack in single user mode by typing the full path to the script:
/private/var/root/Library/Scripts/applejack.sh

The bad news is there’s some sort of root user/privilege issue, and, regarding this, I seem to be caught in a bit of a “catch 22”.

When I type in the string above, applejack comes up, but then quits with the following:
-User ID: 0, NAME: 0
* you are not authorized as the root user. Applejack must quit. *

Before booting in single user mode I had Enabled Root User via System Preferences, but clearly I’m not recognized as a root user in single user mode.

About the Catch 22: I rebooted in normal mode and brought up Terminal. I tried to set myself up as a root user by
su <acct name> (where <acct name> is the account name of the Admin account.)
ls /private/var/root
ls: root: Permission denied

Then I tried:
sudo ls /private/var/root
Password: <password> (where <password> is the password for admin AND root user)
“<acct name> not in sudoers file. This incident will be reported”

And, of course, I can’t look in the sudoers file to see what’s there since I don’t have the privilege. Aarrrgh!! I feel I must be close, but the novice in me is getting in the way. Ideas?

I may try repeating all of this (including installing applejack) after booting from the external HD, but other duties are calling first.

Jul 16, 2010 12:32 PM in response to dbax

If the /etc/sudoers files is also messed up, you can most likely do the same trick you used for getting the /etc/shells files fixed up.

HOWEVER, the /etc/sudoers file is very sensitive to its ownership and permissions, so you may need to use commands such as

# Boot from the external disk
sudo cp /etc/sudoers /Volumes/internalDisk/etc/sudoers
sudo chown root:wheel /Volumes/internalDisk/etc/sudoers
sudo chmod 440 /Volumes/internalDisk/etc/sudoers

Of course the question comes up. Why are so many /etc files messed up on your system? Is it the 'Cat'?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Problems running Applejack and Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.