Verifying whether a .sh text file is executable

Discussion in 'Mac Basics and Help' started by alec6542, Mar 17, 2013.

  1. alec6542 macrumors regular

    Jan 16, 2012
    So I am following this guide on how to set up a trap partition on my Macbook pro in the event of a stolen device. So far the instructions are very clear and everything works until halfway through where it loses me. It says to login as root using the "su <admin> sudo su commands, and then to copy and paste some text using "your favorite text editor" (I used textedit), save it as "", and to make sure that the script is "executable". How exactly do I do that? The first thing I figured I would need to do is format it as "plain text", then "save as" in the directory /usr/bin. But when I do that, I get a permissions error, despite supposedly being logged in as root (I know I am because in terminal the user has a # instead of $). So what I did is change the permission using the info window in Finder, which worked, but my file "" doesn't look like all the other files in usr/bin. Particularly, all the other ones are "Unix Executable", but mine appears to have only been saved differently as all the rest in the bin. Can anyone comment whether or not I am doing this correctly so far? I have attached a screenshot so it's clear what I am trying to do with this file.


  2. Nermal Moderator


    Staff Member

    Dec 7, 2002
    New Zealand
    To make a file executable, use:

    chmod +x /path/filename
    "+x" means "add execute"; you can use "-x" to remove the execute bit again later. You don't have to store the file in /usr/bin; indeed you shouldn't store it there at all since it's not a binary file.
  3. Stooby Mcdoobie macrumors 6502a

    Stooby Mcdoobie

    Jun 26, 2012
    Agreed with Nermal that it's not good practice to save your scripts in /usr/bin. I would create a directory at /usr/local to store your scripts (/usr/local/myscripts for example), then add it to the PATH variable.

Share This Page