Basic Terminal Commands for Mac OS X.
Terminal is a terminal emulator included in Apple’s Mac OS X operating system. Terminal is designed for you to typing in specific commands that you would not be able to do otherwise. This is great for customizing your Mac and unveiling hidden features.It originated in Mac OS X’s predecessors, NEXTSTEP and OPENSTEP, and allows the user to interact with the computer through a command line interface. You can find the Terminal in the Utilities folder within the Applications folder. Open the Terminal program, which you’ll find in the Applications_Utilities folder. Once launched, Terminal opens a single window displaying a greeting and a second line of text that comprises the prompt. With that window active, anything you type will enter just before the rectangular cursor that follows the prompt. After you type a command, simply press Return or Enter to run it. Here we listed some vey basic commands you must know. These commands are very useful for your daily Mac Adventure.
- Login as Root
“ sudo –s ”
After typing that, it will prompt you for your user password, assuming you’re on an administrator account. Once you are accepted, you can do the rest of these commands.
“ su “, which asks for the root password. If you don’t have the root user enabled, follow the directions below. NOTE: Enabling the root user can be dangerous.
Again, after typing that, it will ask for the root password.
- Change root password
If you don’t like your root password, use:
“ sudo passwd root “
Then type in your old root password, then give it a new password. If you had no root password before, it will simply ask you to enter a new password.
- Change directories
To move around in the various directories, use cd. Example:
“ cd /applications “
That will move you into the applications folder.
Typing cd with no argument will return you to the directory you were in before.
To change to a directory with spaces in the name, surround the directory name in quotes Example:
“ cd /Applications/”XChat Aqua”
That will move you into a folder called XChat Aqua in the applications folder.
- Move to other volumes/disks/partitions
To move to different volumes/disks/partitions, use cd again Example:
“ cd /volumes/Mac “
That will move you into the root (/) directory of the volume named Mac.
You can also change to a volume with spaces, much like the last hint Example:
“cd /volumes/”Mac OS X”
- Remove a file from your Mac
This will remove a file from the same directory you are in:
Example: “ rm something.txt “
You can specify a path to a file to delete, if it is in a different folder.
rm /path/to/something Example:
“ rm /Applications/Candybar.app “
This will remove the application Candybar from your applications folder:
This will remove a directory/folder on your Mac:
rm -d <folder>
Example: ” rm -d delete_me “
(Say you had a folder called delete_me in /, your start disk’s main folder)
Note: You can specify a path for this too, like the previous rm commands.
- Copy a file
To copy a file, use:
cp <filename> <name_of_copy>
Example: “ cp something.txt somethingelse.txt “
This will make a duplicate of something.txt and name it somethingelse.txt
- Move a file
To move a file, use:
mv <filename> <destination>
Example: “ mv something.txt /Applications “
This will move something.txt to the Applications folder.
- Find a file
To find a file, use:
Example: “ locate Callisto.kext “
This will look for anything related to Callisto.kext on your system.
- Find a binary file
To find a binary file, like rm, use:
whereis <binary file>
Example: “ whereis rm “
This will look for the rm command.
- Create a folder
If you want to make a folder:
Example: “ mkdir directory “
Will make a folder called directory in the current folder you are in.
- Move a folder
If you want to move a folder:
mv folder_name path Example:
“ mv folder /applications “
Will move a folder called “folder” to applications.
NOTE: You can also specify a path if you want to put the folder somewhere specific. Example:
- Repair Permissions of a folder
If you’ve been naughty and messed with the System/Library/Extensions folder at all, you can repair the owner and permissions of the folder by doing:
chmod -R 755 <path>
chown root:wheel <path>
“ chmod -R 755 /System/Library/Extensions “
” chown -R root:wheel /System/Library/Extensions “
- Repair permissions in Terminal without DiskUtility
To repair permissions on your whole system without the need of disk utility, do:
“ diskutil repairPermissions / “
- List Files in a directory
If you want to view files in a folder, do:
“ ls “