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

Type Faster in Terminal UNIX
Terminal is a great app to get around your filesystem but it gets to be a pain in the hands to type those long pathnames. Here's some quick tips on typing paths or filenames in terminal.

1. If you want to get to your home directory quickly, just type ~ and hit return. You will be at the root level of you're home directory. Note if you are su'd as root you'll go to root home dir.

2. When type paths or file names, start typing the path and hit tab. Your Terminal (shell) will complete the word for you. If nothing appears to happen, hit tab again and shell will give you all the words in that path that have the partial of what you typed.Start typing again till you are past the uniqueness of the word and hit tab to finish typing the word for you. A little practice and you can navigate the CLI faster than point and clicking.

See the rest of this article for some additional examples and comments.
read more (159 words)   Post a comment  •  Comments (5)  
  • Currently 3.00 / 5
  You rated: 2 / 5 (3 votes cast)
 
[5,283 views]  View Printable Version
Start file sharing from the terminal UNIX
This may be useful for some people. To start file sharing from the terminal do the following:
cd /usr/sbin
./AppleFileServer
  Post a comment  •  Comments (2)  
  • Currently 3.67 / 5
  You rated: 4 / 5 (3 votes cast)
 
[8,480 views]  View Printable Version
FTP access and non-standard shells UNIX
OS X uses the tcsh shell for the terminal. There are a number of others you can install, including bash, which is probably the most popular. If you've installed one of these alternate shells, however, you may find that your FTP access has been disabled.

There's a file called shells that lives in /etc, and it contains a list of paths to known shells. The FTP server uses this file to limit the types of shells remote users will be allowed to connect with. The problem is that if you install a shell, it may or may not go where the shells file says it will go. For example, shells lists 'bash' as installed at /bin/bash, but it would more than likely be installed in /usr/local/bin/bash). If you try to connect and have a non-authorized shell, you'll see a message that says User username access denied.

The fix is simple - edit the /etc/shells file and make sure that the proper path to your alternate shell saved in the file. This tip was seen today on the X4U mailing list...
  Post a comment  •  Comments (3)  
  • Currently 5.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,961 views]  View Printable Version
One-line batch file renamer UNIX
This one was posted to the X4U mailing list by Dierdre M., and I think it's an incredibly useful tip, so I'm posting it here!

If you want to batch rename a bunch of files (say "foo*.jpg" to "bar*.jpg"), you might think you could just do "mv foo*.jpg bar*.jpg" in the Terminal. However, this doesn't work right since the shell expands each argument before the execution occurs. However, there's a cool way to accomplish the same result with a (more complex) command line argument.

Open a terminal, and "cd" your way to the directory of interest (or just drag the folder you want to work with onto the terminal icon in the dock; it will open in that directory). Once there, we'll run a 'test' before actually change any names. This first version of the command is "proof of concept"; it will output what will happen, without actually doing it. So to rename all those "foo*.jpg" files into "bar*.jpg" files, type:
ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2'
This should output a series of "mv" (the unix "move" command, which is used to rename files) lines, each one showing the old and new name for each file affected. If it all looks right, then just pipe the output to the shell to execute:
ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh
That should do the trick. Dierdre points out that this is an especially nice way to do it, since you get to see what will happen before you commit to it! I happen to agree with that logic completely!

To use this on your own files, you'll need to replace the references to filenames and items to be replaced in both the "ls" and "sed" portions of the script.
  Post a comment  •  Comments (21)  
  • Currently 4.38 / 5
  You rated: 5 / 5 (13 votes cast)
 
[98,733 views]  View Printable Version
Clear the terminal screen from the keyboard UNIX
Here is another shortcut (undocumented I believe) I found accidentally for use in a terminal window. Hitting Option-A will clear the screen as would the command 'clear'.

[Editor: You can also use Control-L, which is more standard]
  Post a comment  •  Comments (5)  
  • Currently 1.67 / 5
  You rated: 1 / 5 (3 votes cast)
 
[55,140 views]  View Printable Version
Counting files in a directory from the terminal UNIX
Sometimes, it's the little things. I was trying to replicate an error someone was experiencing involving a large number of files in a directory. So I made my large directory, opened a terminal, then did an "ls" on the directory. Everything scrolled by, and then I noticed that there's no total file or total size information. Size information is easy to get (type "du directory_name"), but how do you know how many files are in a directory in the terminal?

Given my basic UNIX skills, I headed to the "man" pages for "ls", but found nothing useful there. Same thing with "man du". I finally had to use a lifeline and phoned a friend ;-). The answer definitely speaks to the sometimes non-intuitive nature of UNIX, but also shows how you can pretty much make it do what you want by combining commands.

To count the number of files in a directory, enter:
cd directory_to_count
ls | wc -l
That's the "ls" directory listing command, the vertical bar (which 'pipes' the output of "ls" to the next command), and then the "wc" word count command with the "l" (lower-case L) option to count the number of lines instead of characters. The output of this command is the number of files in the directory. Subdirectories count as one entry; the files in the subdirectory are not counted.

Of course the GUI is much easier, but if you're connecting remotely via SSH, you won't have that option available!
  Post a comment  •  Comments (4)  
  • Currently 5.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[37,615 views]  View Printable Version
Quick ASCII character table view UNIX
I've seen a few applications on VersionTracker to display the ASCII character set.

If you don't need a fancy GUI, open a terminal and type man ascii instead.
  Post a comment  •  Comments (2)  
  • Currently 3.25 / 5
  You rated: 2 / 5 (4 votes cast)
 
[8,380 views]  View Printable Version
SETI script and the Console app UNIX
I run the SETI@home command line program on both cpus in my OSX box. After doing this for many months I finally got sick of seeing their terminal icons in the dock, so decided to run SETI in the background and not tie up a terminal (or two) to monitor SETI output.

Read the rest of this article for an excellent tutorial on how to set up Seti to run without requiring a terminal window...
read more (169 words)   Post a comment  •  Comments (3)  
  • Currently 2.33 / 5
  You rated: 1 / 5 (3 votes cast)
 
[3,883 views]  View Printable Version
Directory list shortcuts UNIX
in the terminal, the command "ls" lists the directory contents of the directory you're in.
"ls -l" lists the directory contents in "long" format, allowing you to see each file's/directory's privileges.
"ls -la" lists the COMPLETE directory contents in "long" format, including all . files.

Shortcuts:
simply typing "l" is equivalent to "ls -l"
simply typing "ll" is equivalent to "ls -la"

[Editor: And typing "alias" will show you some other pre-defined shortcuts!]

hope this helps!

jmil
  Post a comment  •  Comments (2)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,647 views]  View Printable Version
Mac OS X Terminal Basics FAQ UNIX
I originally wrote this FAQ because I moderate the OS X General Discussion forum at MacNN, and there have been a ton of newbie UNIX questions recently. I figured I'd compile a FAQ: essentially UNIX for the Mac User -- An Introduction that would explain some fundamental concepts and would get a Mac user a little more confident about the big black deep that lurks underneath Aqua.

Trust me. I know how some people feel about this frightening new UNIX core -- I've seen it time and time again. This FAQ may get you on your way to using UNIX more, maybe, but above all I really hope it dispels some fears by spreading information about some basic topics. The known is always less feared than the unknown.

The FAQ is located here.

Enjoy!

-gzl.
  Post a comment  •  Comments (6)  
  • Currently 2.00 / 5
  You rated: 1 / 5 (3 votes cast)
 
[9,498 views]  View Printable Version