iHackintosh

Jailbreak your iPhone

Basic Terminal Commands for Mac OS X.

Advertisements

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 Terminal OS X 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.
OR:
“ 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:

rm <filename>

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:

locate <filename>
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:

mkdir <name_of_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:

mkdir /Applications/directory

  • 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>

Example

“ 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 “

Pin It

Advertisements

Tags: Commands, Mac OS X, OSX86, Terminal

Comments ( 4 )

Have Something To Say ?

  1. gilligan February 25, 2010 Reply

    RE: shilmud said:
    If I do : cat file1( Hello) File2(world)>> file3

    im a bit rusty

    but wouldnt you pipe ” | ” the output to file3 and then cat file3

  2. shilmud February 21, 2010 Reply

    If I do : cat file1( Hello) File2(world)>> file3

    I get:
    File3 as:

    Hello
    world

    I want to get :

    File3 as:
    Hello wold

    Please let me know how can I do that.

  3. Brian miller January 19, 2010 Reply

    I have a new business as a Mac tech and have just started to help clients with X-servers and just started using Terminal. I found your site very informative for myself. It has helped me immensely with my current server project. I am, however, curious about the comment by LaFarr Stuart as to the wisdom of “login as root user” as I am a beginner.
    I have to run a debugging command to fix a large ( 20 computers) tour company
    server. heavy stress if I screw up. There is no one else out here to to this kind of work. Any thoughts? voncoilenstout @ All Things Mac.

  4. LaFarr Stuart October 20, 2009 Reply

    I just looked at: http://www.ihackintosh.com/2009/05/basic-terminal-commands-for-mac-os-x/

    Effectively it tells people to use “sudo” to explore Terminal. It is my belief: A new user should not run as Administrator, and he should never use sudo until he has learned a lot about Unix. sudo is like taking the protective guards off dangerous machinery.

    Wild cards, piping, and command options are too much that has been given up for GUI; and can be learned without Administrator power.

Leave your comment here