UNIX newbie question

Discussion in 'Mac Help/Tips' started by cleo, Mar 14, 2002.

  1. macrumors 65816

    cleo

    Joined:
    Jan 21, 2002
    Location:
    Florida, USA
    #1
    In the terminal, how do I navigate to a directory folder that has a name with more than one word? For example, I have a folder in my home directory called "School stuff." How do I get in there from the command line? I tried dragging the window icon into the terminal, because that usually works, but then it tells me that I don't have permission. Help!
     
  2. macrumors regular

    Joined:
    Mar 1, 2002
    #2
    Since I'm not a mac techie, I'm not sure exactly what MacOS X is up to...

    But from a UNIX perspective, assuming you're using bash and MacOS X is acting like other UNIX clones, there are two things here.

    First, you get into a multiword directory by using quotes. If you have a directory named "School Stuff", it would be:

    cd "School Stuff"

    Second, file/folder permissions determine what user gets to view, modify, and execute the item (ie, view the contents of a folder, run an app, etc).
     
  3. macrumors 65816

    Taft

    Joined:
    Jan 31, 2002
    Location:
    Chicago
    #3
    Space character.

    A space character is represented by a '\ ' on the command line. Thats a \ then a space character. Like this:

    %ls
    Dir1/
    Dir2/
    Dir Three/
    The Bomb/
    %cd Dir\ Three/

    Also note that you can just type 'cd The' on the command line and then hit the tab key and it will auto complete '\ Bomb' for you. Sweet.

    Matthew
     
  4. macrumors 65816

    Joined:
    Jan 22, 2002
    Location:
    SFBA
    #4
    I just use quotes..worked for me

    cd "/root folder with spaces in it/another folder"
     
  5. macrumors regular

    Joined:
    Mar 1, 2002
    #5
    Quotes are a string designator to the console. Anything inside of quotes is one group of characters. A space character works, but since I like the logical breakup of things like

    mv "/home/x user/my folder" "/home/x user/old stuff/my folder"

    I use quotes.
     
  6. Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #6
    Another cool feature is auto-complete.
    Since I'm lazy and I don't want to type in "My Folder", I can just type:
    cd My and then the "tab" key, and Terminal will fill in the rest for me:
    cd My\ Folder/

    If you have several directories that start with "My", it will list them and you will then have to provide some more characters for it to choose from. For instance:
    %ls
    Music Folder
    Musty Underpants
    cd Mus
    Music Folder/ Musty Underpants/
    cd Musi "tab"
    cd Music\ Folder/
     
  7. macrumors regular

    Joined:
    Mar 1, 2002
    #7
    An easy way to tell who has "permissions" for a file/folder in the console is to type

    ls -l

    That will list the permissions of each file/folder, which user owns it, and which group the user belongs to.

    To see hidden files/folders as well, type "ls -a". Type "ls -a -l" to see all files/folders and their permissions.

    That should tell you who owns "School stuff".
     
  8. Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #8
    Wow this is turning into a whole "Intro to the Terminal" thread.

    You can actually just type "l" and it will do the same thing as "ls -l".
    Or type "tab" at the prompt for the same funtion as "ls".

    I'm all about the shortcuts! :D
     
  9. macrumors regular

    Joined:
    Mar 1, 2002
    #9
    Hehe. I've noticed. :)

    I'm expecting that the user won't have permissions for the folder, so we'll probably have to send them to root to change that (chmod and chown and all that jazz)...

    In MacOS X, can you get into the root by the UNIX command "su"?
     
  10. Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #10
    Yup, as long as you have already setup the password.

    sudo passwd root
     
  11. macrumors 65816

    Joined:
    Jan 22, 2002
    Location:
    SFBA
    #11
    ah finally!! every time I wanted to get into root I kept typing sudo -s cuz it seems root password wasn't set

    also I find it kinda odd that it doesnt match password length. my old pass was very long and it works even if i leave off a character a the end or something. the 'max' is like 8 characters right? well you'd think it would at least try to check for extra characters
     
  12. Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #12
    Yeah, I've been kind of surprised by that myself. When you create a new user it only gives you 8 characters for the passwd. Although OS X Server does allow for longer ones.
    I guess they figure 8 is enough for client machines that won't be *as* open to the internet. Plus people are less likely to forget if it's shorter. ;)
     
  13. macrumors 65816

    evildead

    Joined:
    Jun 18, 2001
    Location:
    WestCost, USA
    #13
    passwords

    Think you can use longer passwords by using the passwd command at the termnal. I think you have to be root to run it... or at least an admin. Just type
    #passwd username

    it will prompt you for the new one.
     
  14. macrumors 65816

    Taft

    Joined:
    Jan 31, 2002
    Location:
    Chicago
    #14
    No quotes.

    I don't use quotes because its generally one more character I have to type. Most of the time I just have to type part of the first word then tab complete the rest. I figure I need to type the space character once every 5-10 times I hit a file with a space. No need to type more for the rest of the cases.

    Plus if I have several folders with a common start to the name, like:

    Folder A 1
    Folder A 2
    Folder A 3

    The shell will fill in all of the name it can. So I type:

    %cd Fol

    then hit the tab key and it fills:

    Folder A 1/
    Folder A 2/
    Folder A 3/
    %cd Folder\ A\

    Then I just have to type the number of the folder I want.

    Its simple key economics.

    Screw organization. If I need to do anything complicated, I use a shell script and then worry about good code. The command line is for getting stuff done fast.

    Matthew
     
  15. Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #15
    Re: No quotes.

    Yes, I'm all for shortcuts too. See my similar post above...:D
     
  16. thread starter macrumors 65816

    cleo

    Joined:
    Jan 21, 2002
    Location:
    Florida, USA
    #16
    Wow, thanks for all of the help! Since all of you seem to know so much, can anyone point me in the direction of a good (easy for newbies) book to learn this stuff? I'm finding myself wanting to do things in OS X that require using the terminal (such as "compiling" - whatever the heck that is - for programs like, for example, MacGIMP), but I just don't know how. I catch on really quick, but I need step-by-step instructions the first time, you know?

    Oh, and about the original problem... the issue, minor though it may seem, was that damned k.d. lang song's genre being "unclassifiable" in iTunes. So I actually found a thing that told me how to login as root (which I had never done before) and I got it sorted out really fast. I think I like root a lot :)

    So yeah, if anyone knows of any "How to use Terminal if you're smart but just un-initiated in Unix"-type books/sites/whatever, please let me know. Or if someone wants to walk me through setting up MacGIMP... :D
     
  17. macrumors 65816

    Joined:
    Jan 22, 2002
    Location:
    SFBA
    #17
    to compile you will first need the developers' kit from apple. to get their dev kit you have to become an ADC member (which is easy and free, see connect.apple.com) and download it (which may take a long time-> usually its over 100 megs or so)...not to mention it take a long time to install. before devkit my drive had 120,000 items. after it had 189,000 he he :D

    compiling is taking written code (like C/C++, somethig you can read and write if you learn it) and then transforming it into code that your machine can understand (binary code, all those 1's and 0's). for this you need the compilers in the mac dev kit. also a helper book (which i've been looking for too actually) will help you do basic terminal things, but it seems install instructions change every time a new OS version comes out....well at least it does for PHP and Apache. I'm still looking for OS 10.1.3 install instructions for apache, PHP and mysql because the ones for 10.1 don't work.....well I've been able to get PHP in but had *many* errors during the installation
     
  18. Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #18
    Are you trying to update to newer versions of Apache and PHP? They're already included in OS X, and they work great!
     
  19. macrumors 6502a

    Joined:
    Jan 5, 2002
    Location:
    CA
    #19
  20. Moderator emeritus

    Rower_CPU

    Joined:
    Oct 5, 2001
    Location:
    San Diego, CA
    #20
    Re: Did anyone try this yet?

    OMG! :eek: :eek: :eek: That is friggin' incredible! I can't wait to pass this around to all my geek friends.

    Rock on! Mad props to whoever did that!
     
  21. thread starter macrumors 65816

    cleo

    Joined:
    Jan 21, 2002
    Location:
    Florida, USA
    #21
    Am I blind, or is the only way to get the developer tools to buy a cd for $20? I don't see a download anywhere in the ADC area. Bleh, $20 for tools I don't know how to use to compile free software... no thanks.

    That Star Wars thing was cool!
     
  22. macrumors 6502a

    Joined:
    Jan 5, 2002
    Location:
    CA
    #22
    Developer tools option

    Here is the menu options for ADC to select Developer Tools
     

    Attached Files:

    • adc.jpg
      adc.jpg
      File size:
      9.1 KB
      Views:
      104
  23. macrumors 68020

    Beej

    Joined:
    Jan 6, 2002
    Location:
    Buffy's bedroom
    #23
  24. thread starter macrumors 65816

    cleo

    Joined:
    Jan 21, 2002
    Location:
    Florida, USA
    #24
    Re: Developer tools option

    Doh! I didn't realize I could scroll down.

    Thanks for helping me through that brainfart :)

    I'll let you all know if/how MacGimp does :)
     
  25. macrumors 68020

    Beej

    Joined:
    Jan 6, 2002
    Location:
    Buffy's bedroom
    #25
    Hey, someone should probably point out that if you hit 'tab' the file name will be completed automatically. ;)

    Some people need to read the thread before repeating things for the third time...
     

Share This Page