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

Identifying files in the terminal UNIX
Ever visited one of those sites that downloads a file with a Javascript or some other active method, and you wind up with a file named "download.asp" or "file.asp"? Ever wonder how to figure out what it is, without trying to drag-and-drop it on everything?

In the terminal, it's quite simple - you can use the file command, like this:
[xperiment:~/Documents/downloads] berto% file download.php
download.php: gzip compressed data, deflated,
last modified: Fri Feb 23 18:17:34 2001, os: Unix
(Line break added to shorten the line width!) The file command looks at the file, and compares it to a database of types, and then gives you its best guess at the filetype.

In this real-world example, I couldn't figure out how to expand the file ... the file output lets me know I need to use gzip! For full information on file, make sure you check out the manual pages by typing man file in the terminal window.
  Post a comment  •  Comments (1)  
  • Currently 3.00 / 5
  You rated: 2 / 5 (4 votes cast)
 
[5,464 views] Email Article To a Friend View Printable Version
Spaces in file and directory names UNIX
bullroarer asks:

"How do I perform Terminal commands on any items on my Mac that have spaces in their pathnames? Because Finder allows spaces in file and directory names, I'm often creating such with spaces but then if I try to cd to one in the Terminal the space kills the command. How is this done?"

There are three ways that I know of to handle this. They are:
  1. Drag-and-drop the file or directory onto the terminal; this will preserve the spaces.

  2. Enclose the path name in single quotes, like this:
    cd '/Users/username/temp/directory with spaces'
  3. Quote the space character with a backslash, like this:
    cd /Users/username/temp/directory\ with\ spaces
Any of these will allow you to easily navigate files and directories with spaces in their names.
  Post a comment  •  Comments (4)  
  • Currently 2.33 / 5
  You rated: 5 / 5 (3 votes cast)
 
[45,295 views] Email Article To a Friend View Printable Version
UNIX MP3 encoder UNIX
Vasantha Crabb has compiled the LAME MP3 encoder for OS X. This is a command-line program which will (duh) encode an audio file into the MP3 format. Here's what Vasantha had to say about it:

"Although not fast, LAME is a high quality MP3 encoder, using the GPSYCHO psycho-acoustics/noise shaping model. The quality of the encoded files is much better than that of SoundJam and iTunes."

You can find LAME on Vasantha's download page, where you'll also find the latest version of the Links text browser, and EasyLookup, which does quick whois, finger, and DNS lookups.
  Post a comment  •  Comments (0)  
  • Currently 2.00 / 5
  You rated: 1 / 5 (4 votes cast)
 
[8,047 views] Email Article To a Friend View Printable Version
Installing OpenSSH 2.3 UNIX
In the hint on fixing the security hole in SSH, one of the possible solutions was to install OpenSSH 2.3. No detail was provided on exactly how to do this, however! I had thought this link was already posted on the site somewhere, but a quick search failed to find it ... so I'm posting it now (again?).

To install OpenSSH 2.3, head on over to stepwise.com, and follow the excellent page of instructions written by Scott Anguish which will walk you through the process.

I have not built OpenSSH 2.3 on my machine, so you're on your own to see if it actually works. I'm sure it does, but I haven't tested it myself yet.
  Post a comment  •  Comments (1)  
  • Currently 3.75 / 5
  You rated: 5 / 5 (4 votes cast)
 
[5,248 views] Email Article To a Friend View Printable Version
root's daily/weekly/monthly mail UNIX
If you leave your OSX box up and running 24/7 and have been burning some midnight oil, you might have noticed some system activity in the early hours. If you look in /etc/crontab, you'll see that the root user runs some nightly, weekly and monthly security and maintenance tasks. Whenever cron produces output, it gets emailed to the job owner, so in this case root will be sent email nightly, weekly and monthly.

Unless you're in the habit of logging in as root and reading the email there it's more useful to have all of root's email redirected to your own mailbox. As with most (all?) unix systems, you can do this by creating a .forward file for the root user. Read the rest of this article if you'd like instructions on how to create this file.
read more (184 words)   Post a comment  •  Comments (6)  
  • Currently 3.17 / 5
  You rated: 4 / 5 (6 votes cast)
 
[6,133 views] Email Article To a Friend View Printable Version
What host types for configure? UNIX
I'm trying to get jed running so I have to install slang first. I finally got onto ADC and get the dev kit. The configure script dies at host type. What is host type? darwin? ppc? rhapsody? How can I get a list of acceptable host types?

Bordering on a dumb question I know, just can't find answer for this.

Clay

[answered in the comment]
  Post a comment  •  Comments (1)  
  • Currently 3.00 / 5
  You rated: 2 / 5 (4 votes cast)
 
[3,945 views] Email Article To a Friend View Printable Version
Apache virtual host setup tips UNIX
This is a first ... asking for help on my own site! I'm trying to set up Apache to run virtual hosts, and I'm having a bit of trouble.

If you have experience in this area and can lend a hand, please read the rest of this article for the details on what I'm trying to accomplish.

[see the notes for some helpful tips]
read more (348 words)   Post a comment  •  Comments (10)  
  • Currently 2.20 / 5
  You rated: 3 / 5 (5 votes cast)
 
[13,931 views] Email Article To a Friend View Printable Version
How to automate a remote backup UNIX
This past weekend, I took advantage of OS X's UNIX core to automate the database backup for this site. Until recently, I backed up the data by connecting to the ISP, launching the mySQL database program, exporting the data, then using one of a number of transfer programs (Fetch, RBrowser, etc) to bring the file back to my home machine.

Although this worked, it was quite tedious, and I would often forget to do the backup. Then another geeklog-powered site had a major disaster, and lost all of their articles (macosxapps.com, if you'd like to stop by and help them rebuild, it'd be greatly appreciated!). This was the kick I needed to find a better way to do my backups.

Read the rest of this article if you'd like a little insight into how I used some basic UNIX programs to handle this repetitive mundane task. This is fairly basic stuff for UNIX wizards, and I'm sure I could be doing this in a more advanced way, but it does demonstrate how the UNIX core of OS X can be put to good use.
read more (605 words)   Post a comment  •  Comments (5)  
  • Currently 3.00 / 5
  You rated: 2 / 5 (4 votes cast)
 
[24,969 views] Email Article To a Friend View Printable Version
Removing Samba from the system UNIX
I installed Samba a while back to play with it, but I've since moved my OS X box to a non-Windows environment. I want to uninstall Samba just for general "system purity," but I can't find any uninstall directions. Any clues?

[Editor's note - See the comments for the answer]
  Post a comment  •  Comments (3)  
  • Currently 3.00 / 5
  You rated: 1 / 5 (4 votes cast)
 
[9,361 views] Email Article To a Friend View Printable Version
Printing from a terminal session (lpr) UNIX
A while ago someone asked about how to configure osx for printing from the command line.

If you have a postscript printer in your network, this is actually pretty simple. Create a printcap file (named "myprintcap" for example) with jEdit, or vi or emacs or any other text editor:
lp:\
:lp=:rm=<printer ip or name>:rp=lp:\
:sd=/var/spool/lpd/lp:ty=PostScript:
Save this file somehere in your directory. Note: there should be backslashes terminating the first two lines. They were consumed by the scripts processing this hint, I guess. [Editor's note: Backslashes get stripped out, unless you enter in HTML mode, and use the character code '&#092;' for a backslash ... I've added them to the above lines.

Next you load this printcap into netinfo (line 1 below) and create the spool directory (line 2). Open a terminal and connect as root ("su"), then type:
niload printcap / < path/to/myprintcap
mkdir /var/spool/lpd/lp
Now you can print ps files from the command line by typing:
lpr file.ps
I should note that this hint is originally from the TeXshop readme.

Have fun,
Sven
  Post a comment  •  Comments (2)  
  • Currently 2.20 / 5
  You rated: 4 / 5 (5 votes cast)
 
[21,861 views] Email Article To a Friend View Printable Version