Sunday, December 21, 2008

Power Tip #8: Another Powerful List of Unix Commands

It's been too long, hasn't it? Oh well, no use begging for forgiveness.

Today's post is an extension (and possibly completion) of my series of posts on navigating throughout the wonderful world of terminal. So sit back, relax, and enjoy yet another wonderful post courtesy of yours truly.

The first command I'll tell you about is the "mv" command, which in addition to moving files, can also be used to rename them. When using it to move files, the syntax (way you right it out correctly) looks like this:
mv ~/Desktop/"Flipp'inSweetDocument.txt" ~/Documents/Text/"Flipp'inSweetDocument.txt"
First we typed "mv," followed by the original location of the file, and then the location we wanted it moved to. I used quotes because "mv" doesn't like my flipp'in sweet apostrophe. The other usage can be used in combination with this; all that's required is to change the name of the document in the first location to another, as seen below:
cd ~/Documents/Text
mv "Flipp'inSweetDocument.txt" "TotallyRadFile.txt"
And there you go, nice and simple.

The next command I'll get into is the command for making folders, "mkdir." To use it, type the following:
mkdir ~/Desktop/GnarlyDocumentReceptacle
You can also make folders without specify their location (path). Without telling "mkdir" where to put the new folder, it'll assume you want it in your current directory.

And now, the commands you've all been waiting for, the "sudo" and "su" commands. Here's a hint; they give you unlimited power. HAHAHA!!! "Sudo" can be used as a prefix to any other command. For instance:
sudo mkdir /System/TotallyRad
"Sudo" will ask you for your admin password, and after you've given it, you'll be free to do anything and everything on your system. But "su" (short for super-user) is even better. Whereas with "sudo" you must append it every time you issue a command, "su" only needs to be issued once (don't worry, it's not permanent; it goes away after closing your Terminal window).
To use "su" just type it by it's lonesome in the command line. However, in order to enable it, you must first enable the root user. In finder, go to /Applications/Utilities and open "Directory Utility." Next, authenticate by clicking the lock, and go to Edit>Enable Root User. Then make the password something cool.
A clear distinction between "sudo" and "su" is that while "sudo" asks for your admin password, "su" is asking for the password you entered for the root account in "Directory Utility."

Pheew! Well, hopefully I'll get a few more posts up during vacation.