rndes

Q: Help Clarifying Terminal Questions?

Hi,

 

I am learning how to navigate terminal so that I can gain and exercise greater control over my computers at home. I am very new, just started learning things about 3 days ago. I've noticed several things that seem off (I wouldn't know for sure as I do not have any frame of reference; it would be helpful to see what a "normal" system looks like or, rather, should look like) and I can't find any answers anywhere else so I thought I would bring the questions here.

 

Also, forgive my lack of correct verbiage and terminology as I said, I am very new and just now learning the rudimentary things such as lexicon and proper protocols and syntax.

 

--I ran verify permissions on disk utility and got back a log file that said the permissions for ARDAgent & VNC (Remote Man and Remote Desk) were not correct. It also said that the SUID for for the ARDAgent had changed and would not be repaired and that the ACL was not found in "Volumes".

 

I ran permissions repair and got the message that permissions had been repaired and that ACL found but not expected on "private/var/root/Library/Preferences" and that it was repaired.

 

So then I ran a disk verify again and it came back green and okay. I re-ran the verify permissions and it came back with a bunch of permission errors in the same areas plus one more (Java). In Terminal when I type ls -l t lists me as drwx (d in this case is "directory" which means I have permission to rwx all the files in my main directory?) for most of them and the root as lrwx. The disk utility logfile lists the proposed changes to permissions for me without either an "l" (ell) or "d" in front...is this normal?

 

I thought I might either go in manually to change the permissions to what they should be or permanently remove remote desktop and remote manager as a sudo user since I will never use them anyway. Any advice as to how to "fix" this "problem"?

 

The second thing I wanted to do that's not working out is checking sudo user/password privileges in Terminal...I typed /etc/passwd and got the message back: "Permission Denied" without any options offered to login in under sudo.

 

However, when I type sudo -l I am offered the option to type in my Password, which I do, and a list of default entires on the sudo host comes up...underneath this I am listed as (ALL) ALL, meaning I can run all commands on the host, which is, presumably, as sudo user in the root directory.

 

may run.jpg

 

Is this (ALL) ALL message meaning to say that I have sudo privileges? I am including a screenshot of what I am referring to. And if I do have privileges as a sudo user, then why can I not access the /etc/passwd file? Do I need to first enable root in the directory utility in order to read that file and make any necessary adjustments to privileges?

 

I am also being denied permission to run net <cmd>s.

 

I do know about the man and have been referencing it routinely, but the language and manner of communication in the man is really very different. What I need is a text book to help me to learn the proper form of writing commands etc. I still do not know how to call up a specific file though I have spent a lot of time on the man reading up on various commands.

 

Internet searches are tedious, though I have found several docs. Any suggestions would be more than welcome!

 

Thanks for any help you can offer

MacBook Pro, Mac OS X (10.6.8)

Posted on Apr 17, 2013 2:05 AM

Close

Q: Help Clarifying Terminal Questions?

  • All replies
  • Helpful answers

  • by a brody,

    a brody a brody Apr 17, 2013 2:43 AM in response to rndes
    Level 9 (66,899 points)
    Classic Mac OS
    Apr 17, 2013 2:43 AM in response to rndes

    Ignore permissions errors.  They are normal.  The rest I would have to take time to read to give a good answer.

  • by rndes,

    rndes rndes Apr 22, 2013 2:07 AM in response to a brody
    Level 1 (0 points)
    Apr 22, 2013 2:07 AM in response to a brody

    so why does disk utility keep reading these permissions errors and not fixing them when i run repair permissions?

     

    also, why did the SUID change itself?

     

    im concerned because this happened after i visited a website....my laptop froze and i got that  grey transparent curtain telling me to restart now.

  • by a brody,Helpful

    a brody a brody Apr 22, 2013 2:38 AM in response to rndes
    Level 9 (66,899 points)
    Classic Mac OS
    Apr 22, 2013 2:38 AM in response to rndes

    http://support.apple.com/kb/TS1448 tells you which permissions may be ignored.  That gray curtain telling you to restart is either due to a directory, driver, or hardware issue.  See http://www.macmaps.com/kernelpanic.html about those gray screen telling you to restart errors.  Links to macmaps.com may give me compensation.

  • by BobHarris,Helpful

    BobHarris BobHarris Apr 22, 2013 6:36 AM in response to rndes
    Level 6 (19,682 points)
    Mac OS X
    Apr 22, 2013 6:36 AM in response to rndes

    Ignore the repair permissions errors.  They never go away, and you will just drive yourself crazy trying to make them go away, or worse make your system unusable.

     

    While running repair permissions may clean up some permission problems, especially after some 3rd party installer messed with some standard permissions, it is generally not that useful on a regular basis.


    Besides repair permissions ONLY looks at a small subset of files, so it is not going to look at everything, nor even know what many files should be set to.

     

    In Terminal when I type ls -l t lists me as drwx (d in this case is "directory" which means I have permission to rwx all the files in my main directory?) for most of them and the root as lrwx. The disk utility logfile lists the proposed changes to permissions for me without either an "l" (ell) or "d" in front...is this normal?

     

    'l' and 'd' are NOT permissions, they are the type of file object.

    l - symbolic link

    d - directory

    space - regular file

    b - block device

    c - character device

     

    there are others, but they are just the ls commands way to hinting at the type of file object.

     

    See "man ls", "man chmod" for more information about ls output and file permissions.

     

    NOTE:  Be very VERY careful about changing permissions on ANY file not in your home directory tree, as you can very easily make your system unbootable.  If you want to play then I strongly suggest you have a recent full backup (a clone via SuperDuper or Carbon Copy Cloner would allow the fastest restore after destroying your system).

     

    I typed /etc/passwd and got the message back: "Permission Denied" without any options offered to login in under sudo.

     

    At the command prompt disk you actually enter

     

    /etc/passwd
    

     

    Then of course you are going to get a permission error.  /etc/passwd is not an executable file, so it is execute permission bit is not set, so you get a permission error.  But even if you set its execute permission bit, it does not have code to execute, so it wouldn't anything useful if you tried to exeucte it.

     

    However, if I'm just reading what you wrote wrong, and you really did

     

    cat /etc/passwd
    

     

    then I would expect that you would see the contents of the passwd file.  It is not protected from viewing.  However, NOT everthing on Mac OS X is kept in the passwd file.  For example your account is not listed there.  Mac OS X has other ways of managing user accounts.

     

    And if I do have privileges as a sudo user, then why can I not access the /etc/passwd file?

     

    Because you are using it wrong.

     

    sudo cat /etc/passwd
    

     

    But then again, since /etc/passwd is not normally restricted from viewing, you do not really need sudo anyway.

     

    The basic form of sudo is

     

    sudo command options arguments
    

     

    where command is something that needs elevated privileges to run.

     

    You are in the sudoers file because you are using an Admin account, which give you the right to use the sudo command, and through the sudo command you can elevate your privileges when executing commands.  But since you do not want to run around with elevated privileges all the time, you exeucted sudo on an as needed basis.

     

    Do I need to first enable root in the directory utility in order to read that file and make any necessary adjustments to privileges?

     

    You DO NOT need to enable root, and that is just an invitation for someone to try hacking into your system using a well known account so they only need to guess root's password, were as to get into your account they have to guess you name and password, which increases the difficulty.

     

    Besides with the sudo command you can have all of root's privs without the hacking risk.

     

    I am also being denied permission to run net <cmd>s.

     

    What 'net' commands?  I do not even have 'net' command on my system

     

    net
    bash: net: command not found
    
    man net
    No manual entry for net
    

     

    so I would need to know more about what command you were trying to run.  Like where is it located on the system, what is it suppose to do?

     

    Internet searches are tedious, though I have found several docs. Any suggestions would be more than welcome!

     

    Internet searches can also be very useful, and waiting for the right person to see then get around to asnwering your question can also be tedious

     

    Learning Unix for Mac OS X Mountain Lion

    <http://shop.oreilly.com/product/0636920025870.do>

    would be a good start.

     

    Or going to a book store and browsing books on the 'bash' shell (the command line shell used by Mac OS X), as well as some other Unix/Linux introduction books. While general Unix/Linux books are not exactly the same as Mac OS X, they have enough of a cross section that you still will learn some basic things by reading them.

     

    You can also search for tutorials on 'bash' via Google and find very good references you can read on-line for free.  They will get you started on using the command line.

     

    But I am going to again strongly suggest that if you are going to use the sudo command, or go around changing permissions, that you have that recent backup (maybe 2 or 3) because unless you are very VERY careful or lucky, you will need to get stuff back from those backups.  NOTE:  I'm speaking from years of personal experience, not saying anything about you personally.

     

    Message was edited by: BobHarris

  • by rndes,

    rndes rndes Apr 22, 2013 9:36 AM in response to BobHarris
    Level 1 (0 points)
    Apr 22, 2013 9:36 AM in response to BobHarris

    wow, thanks BobHarris! this was very helpful.

     

    i am, in fact, going to be purchasing a desktop/new laptop combo soon and i have decided to wait until then to do more involved things on my old laptop. ive become veru intrigued with the innards of my mac and i am going to use the laptop for learning and the desktop for work.

     

    that being said, i have learned some things:

     

    --how to activate sudo password in network account server. in fact, i changed some permissions as root just to get a feel for it, then changed them back to what they were without any boot problems.

     

    --how to switch directories and get to files from inside the terminal shell including the /etc/passwd file which i looked at...there were some funny (to me anyway) users like 95-update_sharing, nobody: *:-2:-2 Unprivileged user, unknown : *99:99 Uknown user....

     

    --how to find and kill processes from inside the shell, which is essentially doing manually what the activity monitor does.

     

    i downloaded a bunch of developer guides from apple including a glossary and one on mac os x script and an introduction to linux which is really nice because it has visuals of the various relationships that helps me a lot as i am a visual hands-on learner. also have some unix pdfs and one on applescripting.

     

    to respond to your wonderful and informative post:

     

    the net commands i was referring to are shown in this screen shot. i am finally able to type net -l and others and get net .jpga response, for others like net status i need to type in my password. taking your advice, im not going to go too far into anythign while this is my primary laptop.

     

    once i get a visual of the anatomy of the operating system it will be much easier for me to understand the relationships and thus the role of each function. right now i just dont have a clear picture in my head and its kinda like trying to walk through a dark house.

     

    where i eventually want to be is to be able to monitor my own system and write scripts....and make apps. i have a lot of ideas for apps, but not the knowledge for making them.

     

    this stuff is really addicting....it's like a really elaborate video game with not-so-fancy graphics.

  • by rndes,

    rndes rndes Apr 22, 2013 9:48 AM in response to a brody
    Level 1 (0 points)
    Apr 22, 2013 9:48 AM in response to a brody

    i clicked on your links. the information was helpful. one page showed me where the kernel logs were kept /Library/Logs/DiagnosticReports but it was empty. according to the one site about kernel panics, it was in PRAM until i did a restart. so now there is no way to recover that log huh? that *****, it would have been nice to check it out.

     

    the page that i was on when the curtain came down was a fishy page loaded with a ton of pop ups and flashing ads etc....so when i restarted who was the other user login for? root?

  • by BobHarris,

    BobHarris BobHarris Apr 22, 2013 10:28 AM in response to rndes
    Level 6 (19,682 points)
    Mac OS X
    Apr 22, 2013 10:28 AM in response to rndes

    Most logs are accessible via the Applications -> Utilities -> Console application.

     

    Logs can be in many places.  Many kernel level logs are kept in /var/log