From customizing settings to managing files
Beginner and intermediate computer users alike are often intimidated by using command line. Taking the time to learn how to use command line on your Mac can optimize your computing experience.
Everything from customizing your settings to managing your files can be achieved in only a few keystrokes. Best of all, you can take advantage of the Unix-based platform behind the flashy OS X graphical interface.
So, what is command line and how do we enter commands on Mac OS X? It all starts with the Terminal. Your Terminal is a screen that allows you to enter command line and access the Unix underbelly of your Mac.
To find your Terminal feature, go to the Finder > Applications > Utilities folders. Double click on the icon that looks like a black screen and is labeled “Terminal”.
From here, the Terminal screen will appear with a cursor and the date that you last accessed the Terminal. Now you’re ready to enter commands.
Several tutorials could be written on basic command line logic. What follows are some interesting commands that will introduce you to the idea of using the Terminal. This is in no way a substitute for learning how to fully navigate your system.
It should also be noted that it is possible to erase crucial files or systems by using your Terminal. By accessing the Terminal, you are bypassing many of the safeguards put in place by the OS X design team. Most commands, however, aren’t likely to damage your machine. Just be wary of using the “remove” command (rm) without fully understanding what it is you’re removing.
So, without further ado, here are four of the most interesting/useful commands for beginning OS X users:
1. Change Directory/List Information/Help
It’s crucial that you understand how to navigate your system using command line. The change directory command (cd), and the list information command (ls) are a great place to start this process.
First, you must realize that your system is laid out like a tree. Files exist within directories. Your Downloads folder, for example, will contain all the files you’ve recently downloaded. There’s a method to the madness.
To find files using command line, first determine where you are on the tree. The easiest way to do this is to look at the text following the colon and preceding the cursor in the Terminal. If it says, “Pictures johndoe$” it means you’re currently in the Pictures folder on John Doe’s user login.
Here’s where we can start entering commands:
Entering the following text will give you your exact location within the tree:
Then hit the “Enter” key. Your location in the tree will appear in the Terminal window.
If we want to find out what files exist within the Pictures folder under John Doe’s login, we would enter the following text:
Voila! A list appears of all the files and directories within the Pictures folder.
So, what if you wanted to move up the tree into another folder on the larger system or to delve deeper into one of the individual files in the Pictures folder?
Enter the following:
(The two dots indicate moving up the tree.)
cd [File Name]
Example: cd Pictures/
Hint: if you’re unfamiliar with the syntax required to open a file —i.e. those seemingly random dashes and spaces— start to type the name of the file you want to enter, then press the Tab key. The file name will be automatically populated using the correct syntax. Typing “cd Pi” and hitting the Tab key will produce cd Pictures/.
Once again, type enter “ls” to list the available files. If you want to check the permission on the files at any given level of the tree type the following:
If you continue to go up the tree, you reach the root directory. The existence of the root directory proves that your operating system is sitting on a Unix platform.
A list of the basic Unix commands can be obtained by entering “help”.
2. Eject Disk
Now that you have a basic idea of how to navigate your computer using the Terminal, we can safely move on to some cut-and-paste commands that could come in handy.
Macs are amazing machines, but they often suffer from jammed disks. If you’ve exhausted all your options for removing a disk from the disk drive, open your Terminal and cut/past this command:
drutil tray eject
Hit “Enter” and watch your disk drive problems disappear!
3. Show Hidden Files
All Macs have hidden files. These files are primarily hidden to prevent the user from accidentally erasing crucial systems. Certain problems with the Mail application, among others, can only be solved if you have access to the hidden files.
To view all hidden files on you machine, enter the following two lines one after the other:
defaults write com.apple.finder AppleShowAllFiles TRUE
Finder will restart and you’ll be able to view all the hidden files by searching Finder.
4. Star Wars Episode IV
This might not be the most utilitarian terminal command, but it certainly is entertaining! By using the telnet command, your computer will be allowed to access a complete rendition of Star Wars Episode IV created by a remote user. Enter the following text:
It’s interesting to note that advanced computer users utilize telnet to get around certain types of blocking software at their place of business or school. Even if you don’t want to use this command for nefarious purposes, understanding its full potential can allow you to ensure that your own security software is doing its job.