Hack the Day

Productivity, life and computer tips. Tricks for a better day.

  • Blog
  • About
  • Contact me!
« Heat survival tips you can learn from Animal Planet How I aced most exams (in spite of skipping most classes) »

Beginner’s guide to Apple Terminal, part 2

June 12th, 2007 |

Apple Terminal
In the previous article in the series you learned what Terminal.app is, what it does, how to start it and a couple of basic tasks to do with it(move around folders - the cd command, look what’s inside folders - the ls command, opening up files - the open command and how to remove files - the rm command). Today you’ll learn how to remove entire folders, how to copy files or folders, how to move them somewhere else, how to create aliases to files or folders and even a bit more.

How to delete an entire folder
You already know how to remove a file. Just type rm followed by the name of the file and you’re set. To remove an entire folder, you’d have to type rm -rf followed by the name of the folder. What this actually does is to remove all the contents of the folder and eventually the folder as well. You should use this carefully, ’cause unlike removing a folder from the Finder, this command doesn’t move anything into Trash. You can’t recover things deleted using rm. The good part, though, is that, whenever you are stuck with some file or folder that simply won’t let itself be erased in the classic ways, you can try removing it from the Terminal command line.

How to rename a file/folder in Apple Terminal
The command to rename a file or folder starts to show its strength. All you have to do is type “mv” followed by the name of the file/folder to rename and the new name you want to call it.
mycomputer:~ Alex$ mv Research/ Research1
Typing this (using the shortcut with the “Tab” key mentioned last time) is actually faster for experienced users than opening up Finder, browsing around to find the folder/file in question, Ctrl+Clicking it, selecting Rename and eventually typing the new name.

How to copy a file/folder from Apple Terminal
You already guess the answer to this one, as it combines what you learned in the previous tips: the command for it is “cp” (as in CoPy), it takes two parameters at the minimum - the name of the file to be copied, and the name of the new file. However, if you want to copy a folder, you’ll have to add the extra parameter “-rf” right after the “cp” command.

The IP address
I promised last time that I would teach you how to check out your IP address. That’s the address your computer has on the internet/local network, and sometimes you need to know it. One way to do it would be to open up System Preferences, then Network, then Configure, then TCP/IP. One other way would be to open up the System Profile utility (available in Applications/Utilities or by clicking on the apple icon in the top menu bar, chosing “About this Mac” and “More Info..”) and look into the Network menu for the IPv4 Addresses values.
The Terminal way to do this is much simpler: just type ifconfig in the command line. You’ll be presented with a long list with information on all the network devices present in your computer. The one of interest for now is en1 (might be different in your case), namely the one with information on the inet address. The value of inet is the IP address of your computer.

Aliases
Aliases are shortcuts to existing files or folders on your system. You can create them by right-clicking(Ctrl+Click) in the Finder on an existing file/folder, selecting the option “Make Alias”. This creates a shortcut that you can rename or move around without messing with the original.
Creating aliases in Terminal is extremely easy - just type in ln -s followed by the name of the file/folder you want to create the shortcut to, and by the name you want to give to the shortcut.

mycomputer:~ Alex$ ln -s Research/ Researchalias

What about stubborn commands?
Let’s say you just want to remove or rename a system file or folder. If you don’t know what you’re doing, you probably shouldn’t. Still, you might at times need to do some stuff that your system won’t let you(it would say “Permission denied”). The solution is the sudo command - you prefix the command you want to run by the sudo word. When you press enter, you’ll be asked to type the Administrator password. On most computers this password is absent, so pressing the Enter key is enough. Sudo is a powerful command that shouldn’t be taken lightly, or you risk messing up your system.

I think you already feel the scary power hidden beneath the Terminal application. Off course, we’ve only scratched the surface of a vast subject. Trying to initiate you further might be a bit out of our goal. That’s why I’m going to stop here and point you to a couple of resources around the web:

  • Linux - learning the shell
  • Ten OS X Command Line Utilities you might not know about
  • Command-line lifesavers
  • Linux command line tips
  • Force empty the Trash

Next week, we’ll show you how to do the same things from within Quicksilver - a bit less powerful than Terminal, but with a much more beautiful user interface.

Related posts:
  • 3 tips you probably didn’t know on your Mac Book
  • Forget the Apple Terminal, now you have Quicksilver
  • Beginner’s guide to Apple Terminal, part 1
  • Usability on the Mac - tricks for Mobility Impaired Programmers
  • 7 geek tricks for a fresh OSX Tiger install
  • 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...

    Posted in linux, osx, tips | RSS 2.0 comments feed | Go ahead and comment; Trackback.

    One Response to “Beginner’s guide to Apple Terminal, part 2”

    1. Gravatar Forget the Apple Terminal, now you have Quicksilver - Hack the Day:
      July 26th, 2007 at 9:42 am

      [...] I promised I’d show you how to do your basic computer stuff from within Quicksilver? Well, it took me a [...]

    Leave a Reply

    •   Subscribe in one click and stay notified!

    • I use Dreamhost!

      use Dreamhost promo code discount BRIEPROMOCODE for 70$ off your bill

      Dreamhost huge discount
    • UserOnline

      • 3 Users Online
    • Recent Comments

      • tiger on Mac tips - Turn off your Mac’s startup sound
      • Bryan on Happiness is like a pair of sunglasses
      • Alex Mielus on Happiness is like a pair of sunglasses
      • fcb on The 5 best spots in your favorite city
      • King K on Mac tips - Turn off your Mac’s startup sound
    • Recent Posts

      • Happiness is like a pair of sunglasses
      • Create any kind of charts easily with Google Visualization API
      • DIY a Firefox Search Engine - Twitter People
      • Zen of debugging - remember the Seiza
      • HackTheDay - top 100 productivity blogs
      • Top 10 Firefox search engines
      • Usability on the Mac - tricks for Mobility Impaired Programmers
      • My question for 2008
      • 7 geek tricks for a fresh OSX Tiger install
      • How I applied the 4-hour workweek principles for the last 2 months. Part 1.
      • How to read 728 new feed articles in less than one second
      • Make up your mind. Faster!
      • Mobile Geeks use Mobile GMaps - now better than ever, despite threats from Google
      • Forget the Apple Terminal, now you have Quicksilver
      • More practical tips for surviving extremely hot days
    • Categories

      • beautiful life
      • brain
      • d-i-y
      • firefox
      • gtd
      • hack the day
      • inspirational
      • life hacks
      • links
      • linux
      • mac
      • osx
      • productivity
      • psychology
      • software
      • tips
      • win
    • Tags

      apple browsing charts debugging firefox google happiness launchers meditation mycroft online osx quicksilver search engine Seiza software spreadsheet step by step terminal thoughts tips tutorial Twitter Zen
    • Archives

      • July 2008
      • May 2008
      • April 2008
      • March 2008
      • January 2008
      • November 2007
      • October 2007
      • September 2007
      • August 2007
      • July 2007
      • June 2007
      • May 2007
    • Add to Technorati Favorites

    Entries (RSS) and Comments (RSS).
    Copyright ©  2008 Hack the Day Powered by WordPress. Theme AlexCrunchLite by Alex Brie . net.