PDA

View Full Version : UNIX newbie question


cleo
Mar 14, 2002, 04:12 PM
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!

PCUser
Mar 14, 2002, 04:59 PM
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).

Taft
Mar 14, 2002, 05:16 PM
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

Choppaface
Mar 14, 2002, 06:43 PM
I just use quotes..worked for me

cd "/root folder with spaces in it/another folder"

PCUser
Mar 14, 2002, 07:49 PM
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.

Rower_CPU
Mar 14, 2002, 08:17 PM
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/

PCUser
Mar 14, 2002, 08:35 PM
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".

Rower_CPU
Mar 14, 2002, 08:39 PM
Originally posted by PCUser
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".

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

PCUser
Mar 14, 2002, 08:50 PM
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"?

Rower_CPU
Mar 14, 2002, 08:54 PM
Originally posted by PCUser
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"?

Yup, as long as you have already setup the password.

sudo passwd root

Choppaface
Mar 15, 2002, 01:07 AM
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

Rower_CPU
Mar 15, 2002, 01:46 AM
Originally posted by Choppaface
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

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. ;)

evildead
Mar 15, 2002, 03:03 PM
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.

Taft
Mar 15, 2002, 05:21 PM
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

Rower_CPU
Mar 15, 2002, 05:24 PM
Originally posted by mrtrumbe
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

Yes, I'm all for shortcuts too. See my similar post above...:D

cleo
Mar 16, 2002, 06:11 PM
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

Choppaface
Mar 16, 2002, 06:29 PM
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

Rower_CPU
Mar 16, 2002, 06:35 PM
Originally posted by Choppaface
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

Are you trying to update to newer versions of Apache and PHP? They're already included in OS X, and they work great!

jaykk
Mar 16, 2002, 07:54 PM
Did any one try this trick from OSXfaq ?
Dumb Terminal Tricks - Part 1
http://www.osxfaq.com/tips/dumb_terminal_tricks/index.ws

Rower_CPU
Mar 16, 2002, 08:01 PM
Originally posted by jaykk
Did any one try this trick from OSXfaq ?
Dumb Terminal Tricks - Part 1
http://www.osxfaq.com/tips/dumb_terminal_tricks/index.ws

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!

cleo
Mar 16, 2002, 08:19 PM
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!

jaykk
Mar 16, 2002, 09:12 PM
Here is the menu options for ADC to select Developer Tools

Beej
Mar 16, 2002, 09:27 PM
Originally posted by jaykk
Did any one try this trick from OSXfaq ?
Dumb Terminal Tricks - Part 1
http://www.osxfaq.com/tips/dumb_terminal_tricks/index.ws OMG. That is sad. Cool, but sad.

cleo
Mar 16, 2002, 09:41 PM
Originally posted by jaykk
Here is the menu options for ADC to select Developer Tools

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 :)

Beej
Mar 16, 2002, 09:42 PM
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...

Rower_CPU
Mar 16, 2002, 10:01 PM
Originally posted by Beej
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...

LOL :p

Maybe we can all go through the "Bill Gates" thing again, too! :rolleyes:

Choppaface
Mar 17, 2002, 04:50 AM
Originally posted by Rower_CPU


Are you trying to update to newer versions of Apache and PHP? They're already included in OS X, and they work great!

well, OS X doesnt come with the newest version of PHP, so if you want to be safe from those recent problems you gotta patch it or update...

as to apache, ya I ended up using the one copy installed in the OS