Monday, November 19, 2012

Setting limits with ulimit

Administering Unix servers can be a challenge, especially when the systems you manage are heavily used and performance problems reduce availability. Fortunately, you can put limits on certain resources to help ensure that the most important processes on your servers can keep running and competing processes don't consume far more resources than is good for the overall system. The ulimit command can keep disaster at bay, but you need to anticipate where limits will make sense and where they will cause problems.

It may not happen all that often, but a single user who starts too many processes can make a system unusable for everyone else. A fork bomb -- a denial of service attack in which a process continually replicates itself until available resources are depleted -- is a worst case of this. However, even friendly users can use more resources than is good for a system -- often without intending to. At the same time, legitimate processes can sometimes fail when they are run against limits that are designed for average users. In this case, you need to make sure that these processes get beefed up allocations of system resources that will allow them to run properly without making the same resources available for everyone.

To see the limits associate with your login, use the command ulimit -a. If you're using a regular user account, you will likely see something like this:
$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 32767
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 50
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
One thing you might notice right off the bat is that you can't create core dumps -- because your max core file size is 0. Yes, that means nothing, no data, no core dump. If a process that you are running aborts, no core file is going to be dropped into your home directory. As long as the core file size is set to zero, core dumps are not allowed.

Tuesday, November 6, 2012

Learning Unix for OS X Mountain Lion

This was a perfect size book for what I needed. What I needed was a book that would get me back up to speed quickly on UNIX. I have not used UNIX since the late 80's, and I have not used Mac since the early 90's.

The book starts off with a nice introduction to you Unix and why you would want to use it. The second chapter using the Terminal, is a nice introduction to Terminal's capabilities and shows you how to customization.

After the first two chapters the book starts digging into the details of what you can do with Unix on the Mac. I have listed the chapters below.

1. Why Use Unix?
2. Using the Terminal
3. Exploring the Filesystem
4. File Management
5. Finding Files and Information
6. Redirecting I/O
7. Multitasking
8. Taking Unix Online
9. Of Windows and X11
10. Where to Go from Here

As you can see from the chapter names the author covers some of the most important topics you need to know with a chapter dedicate to each.

The only chapter that is not completely clear on what it covers is Taking Unix Online. That chapter digs into remote login, web access, and FTP.

Although the book talks about using the code samples that come with the book, I could not find any online. That did not take anything away from the book. The samples are short enough to be able to type them yourself. I found that I wanted to read this book with my Mac turned on to try the different samples that the author covered.

The author has a great writing style that makes the book an easy read. I have some other UNIX books where that is not true.

Overall I think this is a great book for getting up to speed with UNIX quickly. This book along with my Macintosh Terminal Pocket Guide have covered everything that I had to look up to date.