EzDevInfo.com

mac-osx interview questions

Top mac-osx frequently asked interview questions

How do I create user accounts from the Terminal in Mac OS X 10.5?

I would like to be able to create new users in Mac OS X 10.5 remotely after ssh'ing into the machine. How do I do this?


Source: (StackOverflow)

how to set global PATH on OS X?

I'd like to append to the global PATH variable on OS X so that all user shells and GUI applications get the same PATH environment.

I know I can append to the path in shell startup scripts, but those settings are not inherited by GUI applications.

The only way I found so far is to redefine the PATH environment variable in /etc/launchd.conf:

setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/my/path

I coulnd't figure out a way to actually append to PATH in launchd.conf.

I'm a bit worried about this method, but so far this is the only thing that works. Does anyone know of a better way?


Source: (StackOverflow)

Advertisements

How to start/stop/restart launchd services from the command line?

How do I restart, say for example my httpd or afpd, running any Mac OS X >= 10.5 (Leopard-), without having to use the GUI and go to System Preferences -> Sharing and unchecking/checking "Web Sharing"?

I'm looking for the canonical equivalent to Debian's invoke-rc.d apache2 restart.

EDIT: The question is about launchd controlled services in general, not specifically Apache (-which was simply an example).


Source: (StackOverflow)

Learning to compile things from source (on Unix/Linux/OSX)

While I install software from packages (MacPorts / apt-get) where-ever possible, I often find myself needing to compile packages from source. ./configure && make && sudo make install is usually enough, but sometimes it doesn't work - and when it doesn't, I frequently get stuck. This almost always relates to other library dependencies in some way.

I'd like to learn the following:

  • How do I figure out what arguments to pass to ./configure?
  • How shared libraries work under OS X / Linux - where they live on the filesystem, how ./configure && make finds them, what actually happens when they are linked against
  • What are the actual differences between a shared and a statically linked library? Why can't I just statically link everything (RAM and disk space are cheap these days) and hence avoid weird library version conflicts?
  • How can I tell what libraries I have installed, and what versions?
  • How can I install more than one version of a library without breaking my normal system?
  • If I am installing stuff from source on a system that is otherwise managed using packages, what's the cleanest way of doing so?
  • Assuming I manage to compile something fiddly from source, how can I then package that up so other people don't have to jump through the same hoops? Particularly on OS X....
  • What are the command line tools I need to master to get good at this stuff? Stuff like otool, pkg-config etc.

I'm willing to invest quite a bit of time and effort here - I don't necessarily want direct answers to the above questions, I'd much rather get recommendations on books / tutorials / FAQs that I can read which will give me the knowledge I need to understand what's actually going on and hence figure out problems on my own.


Source: (StackOverflow)

How to reload default Mac OSX routing table without rebooting

Greetings,

I'm using vpnc for a VPN client. I'm also doing some tricky things with route to make sure I can still access my local network, etc. etc. (the particulars here are not very important).

Sometimes I get the routing table so jacked up I get ping: sendto: Network is unreachable for urls that should otherwise resolve.

Currently, if I restart Mac OS X then everything is back to normal. What I'd like to do is reset the routing tables to the "default" (e.g. what it is set to at boot) without a whole system reboot.

I think that step 1 is route flush (to remove all routes). And step 2 needs to reload all of the default routes.

Any thoughts on how to do this? (e.g. what is step 2?)

EDIT Also, I'm noticing another symptom is traceroute also fails on the address in question. For instance:

traceroute the.good.dns.name

traceroute: bind: Can't assign requested address


Source: (StackOverflow)

How to sort ps output by process start time?

Is there a way to sort ps output by process start time, so newest are either at the top or bottom ?

On Linux ?

On SysV5 ?

On Mac ?


Source: (StackOverflow)

iptables equivalent for mac os x

I want to forward requests from 192.168.99.100:80 to 127.0.0.1:8000. This is how I'd do it in linux using iptables:

iptables -t nat -A OUTPUT -p tcp --dport 80 -d 192.168.99.100 -j DNAT --to-destination 127.0.0.1:8000

How do I do the same thing in MacOS X? I tried out a combination of ipfw commands without much success:

ipfw add fwd 127.0.0.1,8000 tcp from any to 192.168.99.100 80

(Success for me is pointing a browser at http://192.168.99.100 and getting a response back from a development server that I have running on localhost:8000)


Source: (StackOverflow)

What are .DS_Store files and why does OSX leave them on Windows shares?

Whenever I access windows shares from OSX 10.5 it leaves .DS_Store files on the remote filesystem. What are they used for, and are they necessary, and can they be prevented from being created?


Source: (StackOverflow)

How to restart postgres on OS X?

After a reboot, postgres on my machine hasn't restarted. What command should I use in Terminal to get it going again?


Source: (StackOverflow)

Can I specify a port in an entry in my /etc/hosts on OS X? [duplicate]

Possible Duplicate:
How to use DNS to redirect domain to specific port on my server

I want to trick my browser into going to localhost:3000 instead of xyz.com. I went into /etc/hosts on OS X 10.5 and added the following entry:

127.0.0.1:3000 xyz.com

That does not work but without specifying the port the trick works. Is there a way to do this specifying the port?


Source: (StackOverflow)

A better "top" command for Mac OS X? [closed]

The top command on OS X is pretty crappy.. The one included with most Linux distros allows you to change the sort-by column using < and >, there is a coloured mode (by pressing the z key), and a bunch of other useful options.

Is there a replacement command line tool? Ideally I would like htop for OS X, but because it relies on the /proc/ filesystem (see this thread) it has not been ported (and probably will never be)

The obvious answer is "Activity Monitor", but I'm looking for a command line tool!


Source: (StackOverflow)

How to restart Nginx on Mac OS X?

I just installed Nginx on Mac OS X (thanks http://www.kevinworthington.com/nginx-mac-os-snow-leopard-2-minutes/), but how do I restart Nginx on Mac OS X?

Thanks!


Source: (StackOverflow)

How can I tell which config file Apache is using?

I'm trying to set up virtual hosts on Mac OS X. I've been modifying httpd.conf and restarting the server, but haven't had any luck in getting it to work. Furthermore, I notice that it's not serving files in the DocumentRoot mentioned in httpd.conf (Libraries/WebServer/Documents), but in a different directory (/usr/local/apache2/htdocs). I don't see this folder mentioned anywhere in httpd.conf. Furthermore, PHP works, but the "LoadModule php5_module" line is commented out. This makes me think it's using another .conf file. How can I figure out which config is actually being loaded?

Update: I just deleted that httpd.conf and apache behaves the same after restart, so it definitely wasn't using it!


Source: (StackOverflow)

How can I find the path to an executable in OSX

Is there a command I can use to easily find the path to an executable? I'm looking for identify on my local machine - something like pwd?

pwd identify
=> /usr/local/bin/identify

Source: (StackOverflow)

Where are the default ulimits specified on OS X (10.5)?

The default nofile limit for OS X user accounts seems to be about 256 file descriptors these days. I'm trying to test some software that needs a lot more connections than that open at once.

On a typical debian box running the pam limits module, I'd edit /etc/security/limits.conf to set higher limits for the user that will be running the software, but I'm mystified where to set these limits in OS X.

Is there a GUI somewhere for it? Is there a config file somewhere for it? What's the tidiest way to change the default ulimits on OS X?


Source: (StackOverflow)