The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   feedback on Unix FAQ (http://hintsforums.macworld.com/showthread.php?t=40649)

hayne 06-07-2005 06:34 PM

feedback on Unix FAQ
 
This thread is intended for feedback on the "Unix FAQ" sticky thread that is listed at the top of the "UNIX - Newcomers" forum thread listing:
http://forums.macosxhints.com/showthread.php?t=40648

Please use this thread to suggest additions or corrections to the FAQ.

nkuvu 06-07-2005 06:44 PM

Add: "What's an easy way to tell what shell I'm running?"
I'd write up an answer for this, but I don't know it. Which is why I wanna see it. :)

Expand: "Why do I get "command not found" when I try to run a command?"
If you're in the same directory as the command you're trying to run (for example, a script you just wrote) you'll need to add ./ before the command. Most shells don't include the current directory in the path for security reasons. So if you're trying to run a shell script named foo.sh you would enter ./foo.sh

(feel free to use this text, or write it up more eloquently, whichever)

macmath 06-07-2005 07:02 PM

It would be very valuable to explain about the differences between various types of shells. For instance: login shell vs non-login shells, interactive shells, etc.

Also, an explanation of the uses of these shell-related files would be nice.
.login, .profile, .bashrc, .bash_profile, .bash_login

Granted, one could search here and find information on this, but early on you sometimes don't know enough to understand the bits and pieces which you find in individual threads.

mark hunte 06-07-2005 07:08 PM

Maybe an explanation of how and why to make/restore a .bak file when trying out some of the hints here when they affect some of the files like

.login, .profile, .bashrc, .bash_profile, .bash_login

Also maybe an explanation on chmod and what all those numbers mean.
like 777, 755, ...et.

elmimmo 06-09-2005 05:02 PM

> How do I set up my shell execution PATH?

Some binaries installers which put files in /usr/local/bin also install man pages at /usr/local/man. There is no mention in the FAQ about how to access those man pages (since "man xxxx", xxxx being a command in /usr/local/bin will return "No manual entry for xxxx" even if /usr/local/bin is in the path).

Should I add /usr/local/man to the path too in ~/.profile, or is there any other preferred place for that.

hayne 06-09-2005 05:14 PM

Quote:

Originally Posted by elmimmo
Some binaries installers which put files in /usr/local/bin also install man pages at /usr/local/man. There is no mention in the FAQ about how to access those man pages (since "man xxxx", xxxx being a command in /usr/local/bin will return "No manual entry for xxxx" even if /usr/local/bin is in the path).

Should I add /usr/local/man to the path too in ~/.profile, or is there any other preferred place for that.

The MANPATH variable (not the PATH variable) is what is used to specify where to look for man pages. (See 'man man' for details)
Try doing:
echo $MANPATH
and then I think you will understand what you need to do.

elmimmo 06-09-2005 07:22 PM

Quote:

Originally Posted by hayne
See 'man man' for details

Quote:

Originally Posted by man man
In addition, for each directory in the command search path (we'll call it a "command directory") for which you do not have a MANPATH_MAP statement, man automatically looks for a manual page directory "nearby" namely as a subdirectory in the command directory itself or in the parent directory of the command directory.

Shouldn't it be finding, then, all man pages in /usr/local/man that correspond to a command in /usr/local/bin if /usr/local/bin was added to the path in ~./profile, without the need to expand the MANPATH?

fat elvis 06-09-2005 08:09 PM

perhaps also some basic navigation tips would help

i.e. relative vs absolute paths, changing dirs ../../../where/I/Want\ to\ go/, basic vi nagivation (I think up, down, left, right, insert, replace, delete line, new line, save, and exit with/without saving would be enough)

hayne 06-09-2005 10:35 PM

Quote:

Originally Posted by elmimmo
Shouldn't it be finding, then, all man pages in /usr/local/man that correspond to a command in /usr/local/bin if /usr/local/bin was added to the path in ~./profile, without the need to expand the MANPATH?

That's what it sounds like to me too - but I haven't tested this (I just add things to the MANPATH). Your experience seems to indicate that it isn't working - or that we don't understand what the man page is trying to tell us.

fyrefiend 06-09-2005 11:04 PM

Quote:

Originally Posted by nkuvu
Add: "What's an easy way to tell what shell I'm running?"
I'd write up an answer for this, but I don't know it. Which is why I wanna see it. :)
<snip>

'ps' (without quotes) will show you. It should be the only thing returned.

hayne 06-10-2005 12:38 AM

Quote:

Originally Posted by fyrefiend
'ps' (without quotes) will show you. It should be the only thing returned.

Actually the 'ps' command will show you all the processes that are running from any of your Terminal windows. I.e. if you have several Terminal windows, you will see at least that many entries in the output from 'ps'.
It is difficult to figure out which one is associated with the Terminal that you are looking at.

But I have now supplied an answer to this question in the FAQ - so go and look and see if it is sufficient.

pmccann 06-10-2005 12:40 AM

Give me, give me, give me...
 
Quote:

Originally Posted by hayne
That's what it sounds like to me too - but I haven't tested this (I just add things to the MANPATH). Your experience seems to indicate that it isn't working - or that we don't understand what the man page is trying to tell us.

Just have a peek at

/usr/share/misc/man.conf

and you'll see (about 2/3rds of the way through) that there's a hard-coded set of mappings of paths to associated manpath entries. So, for example, /usr/local/bin maps to /usr/local/share/man, rather than the thing you might guess (/usr/local/man).

Cheers,
Paul

nkuvu 06-10-2005 12:56 AM

It's so uncommon that I'm looking solely for my processes with ps... I entered the command twice as ps -ax

And every time I used to type in solely ps I'd be irritated, because that wasn't ever what I was looking for. *sigh* I wonder how many other things I haven't noticed in life because I was looking for something else...

nkuvu 06-10-2005 01:01 AM

Quote:

Originally Posted by hayne
But I have now supplied an answer to this question in the FAQ - so go and look and see if it is sufficient.

Tried that -- works great. Tested in bash, csh, ksh, sh, tcsh, zsh (all of the shells installed on my system).

fyrefiend 06-10-2005 01:53 AM

Quote:

Originally Posted by hayne
Actually the 'ps' command will show you all the processes that are running from any of your Terminal windows. I.e. if you have several Terminal windows, you will see at least that many entries in the output from 'ps'.
It is difficult to figure out which one is associated with the Terminal that you are looking at.

But I have now supplied an answer to this question in the FAQ - so go and look and see if it is sufficient.

Oops! You are right. I only had one terminal open when I tried that. The 'echo $0' trick works like a charm

fyrefiend 06-10-2005 01:56 AM

Quote:

Originally Posted by nkuvu
It's so uncommon that I'm looking solely for my processes with ps... I entered the command twice as ps -ax

And every time I used to type in solely ps I'd be irritated, because that wasn't ever what I was looking for. *sigh* I wonder how many other things I haven't noticed in life because I was looking for something else...

I have the same problem. Things like 'ps -ax' are programmed into my hands. My brain says ps and the hands fill in the rest

sao 06-10-2005 02:45 AM

hayne,

You may also want to add in setting PATH, in the note about fink, that 'init.sh' will also add /usr/X11R6/bin and /usr/X11R6/man to your PATH so you can use X11 when it is installed.

.

voldenuit 06-10-2005 06:46 AM

Quote:

Originally Posted by fyrefiend
I have the same problem. Things like 'ps -ax' are programmed into my hands. My brain says ps and the hands fill in the rest

If you can re-program, for the same key-count you can get the owning user of each process for free:

ps aux

It is also pretty handy to have an alias (I use psg) to look out for a specific process:

ps aux | grep -v grep | grep

Then you add the name of the process you're looking for after the last grep.

hayne 06-10-2005 07:06 AM

Quote:

Originally Posted by voldenuit
It is also pretty handy to have an alias (I use psg) to look out for a specific process:

ps aux | grep -v grep | grep

Then you add the name of the process you're looking for after the last grep.

You'll want to add "ww" to the 'ps' options in order to catch processes with long invocation paths - e.g. "WindowServer"

Raven 06-10-2005 01:41 PM

Another thing that should go in, especially since it a recommended step mentionned in the new WebKit instructions for Safari is how to add directories in the shell path since its something that could be very practical for new unix users (less typing is always better :) )

hayne 06-10-2005 02:43 PM

Quote:

Originally Posted by Raven
Another thing that should go in, especially since it a recommended step mentionned in the new WebKit instructions for Safari is how to add directories in the shell path since its something that could be very practical for new unix users (less typing is always better :) )

Maybe I don't understand what you mean, but isn't this what is covered by question #2 ?

Raven 06-10-2005 02:48 PM

I guess it is implicitly indicated yes.

Raven 06-13-2005 02:07 PM

Ok ok... Shame on me for the last post... I looked at post 2 in this thread instead of the Unix FAQ one... Yeah your right... Its very nicely put in that proper thread :rolleyes:

nkuvu 06-13-2005 02:49 PM

Quote:

Originally Posted by nkuvu
Tried that -- works great. Tested in bash, csh, ksh, sh, tcsh, zsh (all of the shells installed on my system).

Interesting side note. On Solaris, csh doesn't like "echo $0". It complains that "no file was found for $0". The ps trick worked fine, though.

Now if I could get the chsh command to work, I'd actually be able to change to a useful shell. (Which is a whole long thread in itself, and not really important)

hayne 06-18-2005 01:56 AM

Thanks for the suggestions for the FAQ.
I have now added in sections that respond (at least partially) to all of the suggestions to this point.
Don't hesitate to point out errors or parts that are unclear.

mandehu 01-03-2006 01:36 AM

unix vs gui
 
Quote:

Originally Posted by hayne
This thread is intended for feedback on the "Unix FAQ" sticky thread that is listed at the top of the "UNIX - Newcomers" forum thread listing:
http://forums.macosxhints.com/showthread.php?t=40648

Please use this thread to suggest additions or corrections to the FAQ.

I wonder how to open a window in the OSX GUI for any given "exotic" Unix folder, eg ~/monza/ps-files (monza is a folder in my Home).
Thank you for your work.

hayne 01-03-2006 02:26 AM

Quote:

Originally Posted by mandehu
I wonder how to open a window in the OSX GUI for any given "exotic" Unix folder, eg ~/monza/ps-files (monza is a folder in my Home).

I'm not sure what you mean. If you mean how to open a Finder window from the command-line (in Terminal), you can do that with the 'open' command:

open ~/monza/ps-files

But thanks for the reminder - I forgot about the 'open' command when I was making that list of commonly used commands. I'll go add it now.

mark hunte 01-03-2006 09:37 AM

Hi Hayne, I noticed in the Faq
How can I redirect the output from a command into a file? you mention
Quote:

To do this, you append the command with the ">" symbol (think of it like a funnel) and a filename
I wonder if it worth also mentioning the use of >> which as you know will append to a file.

Also in a reply to one of my posts, you reminded me of a useful command option for searching the Man pages.

man -k foo

which maybe handy for others to know.

Thanks

hayne 01-03-2006 01:06 PM

Quote:

Originally Posted by mark hunte
I wonder if it worth also mentioning the use of >> which as you know will append to a file.

Also in a reply to one of my posts, you reminded me of a useful command option for searching the Man pages.

man -k foo

which maybe handy for others to know.

Thanks for the suggestions - I'll add these to the FAQ soon.

Oops 04-11-2006 03:16 PM

Adapt old questions/include a new one about using Standard accounts.
 
Several questions are very nicely addressed, but assume that the user is operating from an Administrator's account. For example, the use of 'sudo' in:
----------
7) What's the deal with permissions? How do I change them?
and
8) How do I gain "root" privileges? Do I need to enable the "root" user?
----------
This is no doubt a good assumption, given that people are operating from the command line, but now that recommendations are to operate from a Standard account, the beginner might run into a roadblock with these.

You probably know the best way to approach this, but possibilities would be:
(1) to say to make sure you're operating from an administrator's account before doing this;
or
(2) to tell how to 'su adminusername' to get administrator's command line privileges temporarily.
or
(3) there is something else I don't know about.

Granted, (3) is guaranteed to be true as a general idea, but I meant that there is another way of operating from a Standard account with all its benefits, and still using 'sudo' from the command line.

Thanks for this wonderful resource.

hayne 04-11-2006 05:35 PM

Quote:

Originally Posted by Oops
Several questions are very nicely addressed, but assume that the user is operating from an Administrator's account. For example, the use of 'sudo' in:
----------
7) What's the deal with permissions? How do I change them?
and
8) How do I gain "root" privileges? Do I need to enable the "root" user?

Good point.
I'll try to add some explanation along the lines you suggested.
Thanks.

Quaresti 06-07-2006 10:38 AM

Re: How can I tell what shell I am running?

How about using
Code:

finger `whoami`
or
Code:

finger $USER
instead? There's a chance of picking up a similar username when grepping passwd.

hayne 06-07-2006 02:01 PM

Quote:

Originally Posted by Quaresti
Re: How can I tell what shell I am running?

How about using
Code:

finger `whoami`
or
Code:

finger $USER
instead? There's a chance of picking up a similar username when grepping passwd.

That is true, but you'd still be able to pick out which one was yours.
But I added your suggestion of using 'finger' as an alternative way of seeing what shell is assigned to your account.
Note, however, that some corporate installations will have disabled 'finger' on their Macs.


All times are GMT -5. The time now is 10:20 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.