OSX Terminal Fun II: Speeding Things Up
There are a few things you can do to make your Terminal.app run sleeker:
- Turn off transparency
- Turn off anti-aliasing
- Login directly
- A more efficient
top - Turn off security server check
- Auto-enable the sudo command
- Login as root
Turning off transparency
The first thing we'll want to do is speed things up in the terminal... one hard and fast rule is that if you aren't using a machine capable of supporting Quartz Extreme, disable all transparency.
The reason for this is that while Quartz makes things beautiful, it can also slow things way, way down especially if you are doing something that updates often, such as running "% top". To save time, basically Quartz Extreme takes the display layer of Mac OS 10.1 which was all software-based and takes one part of the process (compositing) and pipes it through OpenGL which allows it to be hardware accellerated.
For transparency, this creates a dramatic speedup and lowers the CPU load on the computer. If you don't have a machine capable of Quartz Extreme though, using transparency for your terminal windows, while pretty, means the CPU has to calculate the updates you see and that means that every time "% top" updates the screen the CPU has to figure out everything behind the window.
Try it for yourself- if you have a non-QE machine run top with and without transparency enabled and look at the "window server" process within top and see how much of the CPU it uses.
The option for turning this off/on is a sliding scale located under the Terminal.app's menu at:
Window Settings>Color
Turn off anti-aliasing
For the same reasons as above, using anti-aliasing in your terminal fonts can slow things way down if you don't have a Quartz Extreme machine.
Besides, 9 point fonts with anti-aliasing on just look kind of nasty... in actually if you're using something like Monoco as your font, a different Monoco is used if you are using anti-aliasing which is a little goofy. I don't even use Monoco anymore (more on that later) as I've found a few monospaced fonts which i prefer.
The option for turning off/on is under the Terminal.app's menu at:
Window Settings>Display
Think about it: with anti-aliasing on, and no QE, using anti-aliased fonts in a window that updates every 0.5 seconds is going to churn a lot of CPU cycles that can probably be best used elsewhere.
Login Directly
Whenever you open the Terminal.app or create a new window (shell) you see a message giving you your last login, the date, time, and a "Welcome to Darwin" message". FYI, Darwin is the name of Apple's open-source unix operating system that OSX runs on top of.
Depending on the speed of your computer (including cpu, disks, & subsystem) this message can delay you getting to the shell enough that it gets a little annoying.
To get rid of this simply (without changing any files) you simply want to login directly to "/bin/tcsh"instead of going through the normal "/usr/bin/login" app which then drops you to the shell.
To get an idea of what I'm talking about before you change anything, from the terminal menu select:
>File>New Shell
Now, in the same terminal type:
% tcsh
Depending on your machine, not having to look at the welcome messages (and having the shell generate them) can speed things up quite a bit. To change it, from the Terminal.app's menu select "Preferences" and click the radio button that says "Execute this command (specify complete path)" and type in:
/bin/tcsh
Create a new terminal window and it should now drop you directly into your shell with no messages.
A more efficient top
From the terminal, type:
% top
Look at top's CPU usage, which, if you're coming from a Solaris or Linux or freeBSD background will look insanely high. Ie, if you are on a 500MHz G4 it probably averages at around ~10% of your CPU cycles. You'll also see a bunch of memory information, and other things I won't go into now. Type the "q" key, leave that window there and create a new window for the next part.
The reason for top taking up so much more CPU than it normally does on other OS's is that Apple's OSX, while based on freeBSD, actually sort of slaps freeBSD over top of something called "Mach" which is microkernel (not monolithic, like all of the other unix's mentioned above). Microkernel's were all the rage for awhile, but for a lot of pragmatic reasons (mostly speed) there aren't very many "pure microkernels" out there, like GNU/HURD.
OSX isn't any different, and actually has the BSD layer running in the same address space as Mach for performance reasons. Unfortunately traversing the memory tree to display all that memory-related-goodness is a very expensive task (in terms of CPU time) in Mach.
While in many cases you'll want to know the memory information associated with processes, in many others you're mostly just interested in the processes' PID and CPU usage, so we want to cut out the memory information from top.
Use this command:
% top -d
And top should now be using 1/10th or so of the CPU compared to the straight "% top" command which you can see by comparing it to the other window you have open.
Turn off security server check
In 10.2, Apple changes the behavior of the "% sudo" command a bit- in that it makes a connection to the virtual security server process (not the case in 10.1). That connection unfortunately can take awhile, i.e. around 1 second. If you're using sudo a lot though, waiting on it to show you the password prompt can be pretty annoying.
Turning off this check will make using the sudo command an instant affair. This is a little more involved, but pretty easy. Type these commands exactly, and remember don't type the % character, that is your prompt.
% sudo pico -w /etc/pam.d/sudo
Enter your password, and you're not editing the sudo file as the root user. On the second line you will see:
auth sufficient pam_securityserver.so
Use your arrow keys to move the cursor down and add comment it out by adding a pound sign before it, so that it looks like this:
#auth sufficient pam_securityserver.so
Hold down the control key, and then hit the "x" key. When asked to save the unmodified buffer, type "yes" and hit return. It will show you a file name, leave it alone and hit return again.
w00t! Done.
Create a new terminal window and type:
% sudo top
...and the sudo password prompt should be immediate instead of having to wait for it.
This shouldn't hurt anything that I know of- it can cause sudo not to work if you have completely disabled netinfo on your machine for some reason... but no one really does that and I've never seen an OSX box without netinfo on it.
Auto-enable the sudo command
This speeds this up, as instead of having to type your password when you want to use the sudo command, it negates the check and auto-logs you in. Unfortunately, I'm not going to show you how to do it.
You can find info on the web if you're so inclined, however the security risk involved is just too great and there are very few reasons for needing to do it. It's a bad thing. If you really need it, you should know how to do it. However, there is a time-saver below.
Login as root
While I'm not going to show you the above, often times you need to do successive commands as the root super-user. In OSX, the root user is disabled by default (which is a good thing), so you generally use "% sudo" before your command (i.e., "% sudo ls") which runs your command as the root user after you give it your password. Very secure, but it makes you re-authenticate after a specific amount of time, which is also a good thing.
If you have a bunch of successive commands you'll be doing as root, and are getting annoyed by having to re-authenticate, simply login as a pseudo-root shell instead of going through the hassle of actually enabling the root user.
The command you will want to use is:
% sudo -s
Give it your password, and you have a root shell. Note that this is different from Linux shells, where you would normally use:
$ su -
Bash is the default shell for Linux, instead of tcsh, so you see a $ for a prompt instead of %). When you do this, notice that your prompt changes from a % to a # as a reminder that you're root and to be very careful. Although if you didn't know that and you're doing these, I hope you're being very careful.
To leave the root shell, either close the terminal window or type:
# exit
Comments (3)
Posted by: MarkOsan at November 3, 2003 06:36 PM
I always stick these two lines in my /etc/sudoers file:
Defaults passprompt="(%h) %u's password:"
Defaults timestamp_timeout=130
the top one clarifies which hostname/username password to type
the second one lengthens the timeout between password entries...
Posted by: Nathan at April 27, 2004 10:41 PM
The thing that really bugs me about Terminal.app, other than the small things you talk about, is the actual update speed. Do an ls and it jumps, not scrolls, up the screen.
The solution is not to use Terminal.app. If you don't need double byte support in the terminal, install X11 and run xterm. Its a lot faster..








removing the security check to the security server made sudo instant now just like 10.1 or my linux machine. thanks.