Question to the (few) linux wizards here | FerrariChat

Question to the (few) linux wizards here

Discussion in 'Technology' started by EnzymaticRacer, Oct 4, 2013.

This site may earn a commission from merchant affiliate links, including eBay, Amazon, Skimlinks, and others.

  1. EnzymaticRacer

    EnzymaticRacer F1 Veteran

    Feb 27, 2005
    5,367
    I have a question regarding some hard-core terminal command behavior on my Ubuntu 13.04 installation, was hoping anyone with solid linux terminal knowledge may be able to help.

    Last night I was trying to run a command related to re-flashing my android phone with a stock OS image.

    Doing so requires installing the Android-SDK and JDK, which I have installed. Installing the SDK gives me two terminal commands for interfacing with my phone via USB.
    I had the USB drivers installed for both modes, and the adb command was readily able to detect my phone.

    I have also verified the export paths to both tools to my .bashrc file so that the command s can be run in any folder

    For instance: inputting this string from anywhere would output the ID and mode info when my phone was in normal operating mode

    However, after entering fastboot mode on my phone and running this command from any folder:
    If I ran 'sudo fastboot devices' from any folder I would get something like this:

    Which confused the crap out of me, because shouldn't I be getting that same error if/when I didn't use sudo?


    If I navigated to the folder where 'fastboot' is found (ie /home/android-sdk/android-platform-tools) and ran 'fastboot devices' there was no output again.

    When I tried
    on a whim, I got an output saying I didn't have permission.

    So I finally tried
    and I finally got the output similar to the adb output above.



    So my questions are these:

    1) What could be the reason why I need to run ./fastboot to get it to work instead of just "fastboot"

    2) Is there something else I need to do to enable the fastboot command in any location?

    3) A script provided by google in order to flash all the partitions on my phone failed because it assumed that the fastboot command just worked. I had to modify the script to call "./fastboot" and then I had to copy the entire 'android-platform-tools' folder into the folder with that .sh in order to get it to finally work. Did this happen because I don't have my fastboot setup right?



    I hope this makes sense to you linux guys out there. Thanks for reading through my questions.
     
  2. Far Out

    Far Out F1 Veteran

    Feb 18, 2007
    9,768
    Stuttgart, Germany
    Full Name:
    Florian
    One of the things that has always irritated me with Linux is that behaviour. FWIW, it's not particular to fastboot, adb etc, it's a general thing about executable files. My layman understanding is:

    1) If the executable is in a path that the system knows as a path for executables (like /usr/bin), you can just enter "fastboot" (or whatever the name is)

    2) If you are in any other folder and want to execute a file or script, you do it with the ./, i.e. "./fastboot".

    I hope that was correct and eagerly await further explanation by the local gurus :)

    Edit: Have you tried putting a symbolic link to fastboot into your /usr/bin (or whatever applies to your distribution) folder?
     
  3. EnzymaticRacer

    EnzymaticRacer F1 Veteran

    Feb 27, 2005
    5,367
    I have not tried that... I'll take a look into how to do symlinks in linux... unless you can tell me off the top of your head.
     
  4. Fast_ian

    Fast_ian Two Time F1 World Champ

    Sep 25, 2006
    23,397
    Campbell, CA
    Full Name:
    Ian Anderson
    Because, by default at least, roots path is very limited (for some very good security reasons) It's typically something like "/bin;/usr/bin;/usr/local/bin". IIRC, sudo reads roots ".bashrc" file to get its path.

    Modify roots .bashrc 'PATH=' line to be the same as yours. Or, specify the complete path to it; The "./" is just telling it to look in the current directory.

    That will only work if you're already "in" (as echoed by "pwd") the directory that contains the utility. Either;

    - Modify roots path
    - Edit the script & specify the complete path
    - As Florian suggested, pop a symlink in (eg) /bin. [Or just move the executable to, eg, /bin of course.]

    HTH,
    Cheers,
    Ian
     
  5. Fast_ian

    Fast_ian Two Time F1 World Champ

    Sep 25, 2006
    23,397
    Campbell, CA
    Full Name:
    Ian Anderson
    Thinking more....

    Alternatively, and certainly safer than messing with roots path is;

    - To change the owner to you; chown is your friend here.
    - Change permissions; chmod is your friend.

    Are you the only user of the machine?

    Cheers,
    Ian
     
  6. Fast_ian

    Fast_ian Two Time F1 World Champ

    Sep 25, 2006
    23,397
    Campbell, CA
    Full Name:
    Ian Anderson
    ln [-Ffhinsv] source_file [target_file]

    Usually you want a sym link, not a hard link, so, something like;

    ln -s /path/to/fastboot /usr/bin/fastboot

    Cheers,
    Ian
     
  7. EnzymaticRacer

    EnzymaticRacer F1 Veteran

    Feb 27, 2005
    5,367
    Thanks for the thoughts Ian.

    I am the only user of the machine (Linux was installed specifically to run some scientific software, so I'm dual booting it).

    Since rooting/flashing/etc android phones supposedly works better on Linux I decided to try it in Linux since I had it installed.

    I did chmod 777 the fastboot file, which was one of the reasons why I was so confused... the permissions should have been correct.

    Sent from my Transformer Prime TF201 using Tapatalk 4
     
  8. wkumari

    wkumari Karting

    Jul 15, 2011
    169
    Northern Virginia
    Full Name:
    Warren
    Running it as sudo -E might work for you -- this should keep your original environment intact.

    You probably have 'Defaults env_reset' in your /etc/sudoers.

    Basically this config (which I find annoying) is designed to prevent path spoofing issues.
     
  9. Fast_ian

    Fast_ian Two Time F1 World Champ

    Sep 25, 2006
    23,397
    Campbell, CA
    Full Name:
    Ian Anderson
    OK, Roger that.

    Permission 777 is certainly gonna allow anyone to not just run it, but write to it too.... Given you're the only user, no big deal but from a security perspective it's a bad idea - Better to chown it to you & leave permissions at 755 - Anyone can then run it, but only you can write to it.

    You see now that permissions weren't your problem, rather the $PATH set for root.

    As an aside, how's the original tasks progressing? [Is it a "good" environment for messing with Android stuff?]

    Cheers,
    Ian
     
  10. EnzymaticRacer

    EnzymaticRacer F1 Veteran

    Feb 27, 2005
    5,367
    I never did quite figure out what was wrong with the $PATH string... like I said, I had gotten it to work by just copying files to all be in the same folder.

    After a while I gave up on trying to toy with it and just reinstalled the tool using a different method.

    That seems to have done the trick.

    In any case, using Linux for playing around with android is actually fairly nice. Although a little rough around the edges, things just work "better". Adb works great, don't have to worry about driver issues nearly as much. And Linux appears to handle errors better than when I was doing it in windows.

    Once I finally got the fastboot working, it just ran faster.

    The one downside is there aren't as many scripts out there for automatically doing stuff on Linux (all the toolboxes are for windows/dos command prompt). But that's OK, making me learn these things is helping me get a better grasp of not just fastboot commands but Linux commands in general.



    Sent from my Transformer Prime TF201 using Tapatalk 4
     

Share This Page