Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Installing DJBDNS UNIX
If you want to serve DNS off an OS X machine, I successfully ported djbdns to OS X and wrote up a helpful HOWTO for anyone interested.

[Sudo Editor's Warning: This install is not for those faint of heart or Unix knowledge.]
  Post a comment  •  Comments (1)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[2,476 views] Email Article To a Friend View Printable Version
Converting Mac linefeeds to Unix linfeeds UNIX
I go back and forth between Darwin (and Linux at my workplace) and OS X all the time. The problem is that the convention for linefeeds is different between Unix and Mac. I know new version of MacArmyKnife can fix it, but here is the free solution.

Open the file with xemacs. As the bundled emacs does not work for this purpose, I've installed a copy through fink.

Now type:
Meta-x replace-string
^Q^M
^Q^J
This changes ^M (Mac linefeeds) to ^J (Unix linefeeds) for the entire buffer.

Save it:
^X^S
and you're done.
  Post a comment  •  Comments (19)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,795 views] Email Article To a Friend View Printable Version
IP Firewall UNIX
I found this great article on how to create your own firewall, with no software to install.

It is at: http://wopr.norad.org/articles/firewall.

[Sudo Editor's Note: A firewall can be a very important thing, especially if you have a full-time internet connection via DSL or cable modem. Although we have covered Firewalls on MacOSXHints.com before, I felt it worth while posting this article which explains what a firewall is, and how to use OS X's built-in tools to help protect your system. I think it is well worth reading this older article also, before you try to modify your current settings. After all, the security of your machine could be at risk.]
  Post a comment  •  Comments (8)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[3,973 views] Email Article To a Friend View Printable Version
Monitor system calls UNIX
As a transplant from other *nix operating systems, I'm used to system call monitoring tools like truss (on Solaris) and strace (on Linux).

While I haven't found anything quite like these for Darwin, sc_usage comes close. It provides a running statistical breakdown of system calls for any process ID (pid) specified on the command line. Although I haven't yet figured out how to parse its output, I expect it'll aid in figuring out where a particular app is getting hung up. In conjunction with fs_usage (mentioned in a previous hint by Ben Hines), you can also track down what files are being called. Note that this must be run in a Terminal window as root (generally via 'sudo').

Usage is:
sudo sc_usage [pid]
Apple has a developer note describing the tool, with some examples, and you can always type man sc_usage in Terminal for typically laconic Unix documentation.

(Thanks go to Fred S., Apple's Open Source Engineering Lead, who posted about these utilities in a MacPerl thread.)

[Sudo Editor's caution: f you're not comfortable with the terminal and root privileges, I would recommend holding off on this hint. ]
  Post a comment  •  Comments (7)  
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[6,414 views] Email Article To a Friend View Printable Version
Create multiple soft links with one command UNIX
I recently had to make soft links to about 50 files. The shell was not expanding the wildcard (*) symbol as expected. The syntax for doing this with the 'ln' command is:
ln -s source_file target_file
After some experimentation I found the following works perfectly.
ln -s /path/to/source/* /path/to/target/directory/
This resulted in the wildcard being expanded into each of the file names and a soft link being made to each of the files in my target directory.
  Post a comment  •  Comments (1)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,395 views] Email Article To a Friend View Printable Version
Securing Webmin using OpenSSL UNIX
Webmin is a great tool for Unices, just OK for OS X client and server. I use it to manage my Sun Solaris 8 servers at work rather than SMC. The big caveat is that using it as-is over http is unsecure. Anyone using snoop or a packet sniffer can compromise your machine(s). Using OpenSSL under MacOS X secures this wonderful and free tool.

Until recently, the headers for ssl were not available, but now they are. Apple has released the "Darwin Development Environment" which includes these headers.

For a Step-by-Step on securing Webmin via SSL, read on...
read more (278 words)   Post a comment  •  Comments (5)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[10,851 views] Email Article To a Friend View Printable Version
Speed up perl operations on large files UNIX
Yesterday I was faced with a 21 megabyte text file that needed several find/replace operations. Tex-Edit would open the file, but not change it. BBEdit would chug through the changes, but it was taking forever. I dropped into a Terminal window and used:
perl -pi -e 's/find/replace/g' filename
However, this too was slow -- much slower than I expected.

Because I was checking the file in Tex-Edit after each find/replace, the process was taking some time, until on a whim I used Tex-Edit to change the line endings from "Mac" to "Unix" style.

From that point on, the 'perl s/' command ran blazingly fast.
  Post a comment  •  Comments (8)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,691 views] Email Article To a Friend View Printable Version
Two keystroke 'ls -F' shortcut UNIX
A very silly hint, but one I haven't seen anywhere else and which might prove useful to someone...

In a terminal window, hit ESC twice to perform an ls -F. Saves typing a few characters.

[Editor's note: Wow, it works! Is this a bug or a feature??]
  Post a comment  •  Comments (10)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[2,292 views] Email Article To a Friend View Printable Version
SSH configuration change with 10.1.3 UNIX
The upgrade to 10.1.3 also included OpenSSH 3.0.2p1.

I found out that there is a change in how authentication with other servers is handled in this version. When I connect to one of my OpenBSD boxen, I get asked for my S/key password before I have a chance to enter my normal password. That's of course very unfortunate if you have not set up your s/key passwords, or do not carry them with you.

The fix was for me to add one line to the /etc/ssh_config file:
PreferredAuthentications publickey,password,
keyboard-interactive
[Shown on two lines; enter as one]

If you do not intend to use S/key password authentication, you could leave away the keyboard-interactive part.
  Post a comment  •  Comments (1)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[2,228 views] Email Article To a Friend View Printable Version
A simple command-line calculator UNIX
tc is yet-another-calculator. This time written in tcl, and it's very easy to personalize. It has a few symbols showing the ways you can customize it. With this script (I put it in ~/bin/tc; chmod +x and rehash), you can write arithmetic expressions in a natural way, avoiding the use of the * and () signs that are preinterpreted by the shells. It is also very easy to add symbols that are replaced before the expression is evaluated. I use it also as a euroconverter, showing how easy it is to expand its behaviour. For example:
  % tc sin 3 eu
sin(3) * 166.386 = 23.480393661
% tc 2 2
2 * 2 = 4
% tc 2 x 2
2 * 2 = 4
Read the rest of the article for the script...
read more (71 words)   Post a comment  •  Comments (5)  
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[6,642 views] Email Article To a Friend View Printable Version