Subscribe to our RSS news feed
AAPL 275.62 (0.56)

> Forum Guidelines

Welcome to the Genius Bar. Here's how this forum works:

1. Members are encouraged to make a guide that details something that they might have found troubling or challenging. Chances are, if you've seen the same question asked over and over again, you should write a guide for it.

2. This is not the forum for asking questions. If you have a question about a thread that's already here, feel free to ask it. Just don't start a thread for a specific question. Use the other forums here for that.

3. Posting links to off-site tutorials is not allowed.

4. That's it! Thanks for sharing your information with the rest of us. :)

To keep this forum clean this forum is moderated. You can post in existing topics but new ones will have to be approved before they show up. Quality guides promoting new methods and encouraging users to learn will be approved.


[INFO] Various Unix/Mac OS X terminal commands, And other info! :D
Group Icon
  • Group: Retired
  • Posts: 1,623
  • Joined: 13-February 06
  • From: Wandering the world over.
  • Member No.: 23,327
I figured I'd post some useful information, since I didn't see a similar topic anywhere using Search, so here it is.

***BEGIN TERMINAL INFO***
First off, Terminal is Mac OS X's version of Konsole from Linux, or Command Prompt from Windoze. It is located in /Applications/Utilities, down at the bottom. To open it, double click it.

When it opens and has a rectangular block sitting there, it is ready for your command(s).

Info about Root
On UNIX based systems such as Mac OS X or Linux, root is the main user for the computer, which has access to *everything*. In other words, this is the System Administrator account, which lets you do maintenance, etc.

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.

WARNING: TERMINAL WILL *NOT* PROMPT YOU FOR CONFIRMATION OF DELETIONS, RENAMES, ETC.
***NOTE: sudo CAN BE LINKED WITH ALL OF THESE COMMANDS, IF YOU DO NOT WISH TO LOGIN AS ROOT; THIS WILL LET YOU ACT AS THE SUPER USER FOR THE ONE COMMAND.***

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: 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. tongue.gif

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, hysterical.gif , 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

NOTE: This can also be done(to a lesser extent) through Disk Utility in /Applications/Utilities. Open Disk Utility and select your Mac Volume, then click Repair Disk Permissions.

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

NOTE: This will show you the files in the current directory you are in. You can also do ls <path> to see what's in a specific folder. Example: ls /applications
That will show you files in the Applications folder.

Text editing
If you want to edit various files in the Terminal:
nano <filename>
vi <filename>
emacs <filename>

Whichever you use is up to you. They all are text editors. NOTE: I have only used nano, so I can't really help people with vi or emacs.

You can also call TextEdit from the Terminal:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit

You can add the path of the file you want to edit to the end of the command line and it will open with TextEdit or just browse for it in TextEdit.

Add your own commands to Terminal!
If you want to add your own commands to terminal, follow these easy steps. In this example, we'll add a command called textedit, which will launch TextEdit with sudo priviliges, giving you a text editor with GUI capabilities that allows you to edit any file.
1. Open Terminal.
2. Type sudo -s, then enter your password.
3. nano /usr/sbin/textedit
4. paste this into the file: sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit
5. press CTRL+O, then enter to save.
6. Type textedit into terminal, and enjoy your new command!

***END TERMINAL INFO***

***BEGIN GENERAL MAC OS X INFO***

Run a Universal program in Rosetta
If you have a program that seems to be acting funny, and it's Universal, just right click(CTRL+Click for one button mice) the program, then choose Get Info, then when it pops up, look for a check box that says "Run in Rosetta". This will make the program run under Rosetta, Mac's PowerPC emulator, which allows for PowerPC apps to run, or Universal apps to run under PowerPC instructions.
N.B.: Not all programs have a "Run in Rosetta" option, so don't freak out if there's no option for it.

NOTE: ALL THE FOLLOWING CAN ALSO BE DONE ON HACKINTOSHES BY PRESSING F8 AT STARTUP WHERE IT WILL GIVE YOU A BOOT COMMANDLINE, WHERE YOU CAN INPUT YOUR OPTIONS THERE, SO THAT YOU CAN HAVE THOSE OPTIONS ON THAT BOOT ONLY.

Boot in verbatim mode to see errors/info about your mac
If you seem to be having weird errors with Mac and can't figure out why, try booting in verbatim mode, which tells you word for word what Mac is doing as it is starting up. In Terminal, navigate to /Library/Preferences/SystemConfiguration. Then sudo nano com.apple.boot.plist . Then below where it reads, "<key>Kernel Flags</key>", where it says <string></string>, add -v between the two string angle brackets so it looks like this:
<string> -v </string>

After this, press CTRL+O to save the file and reboot. To remove verbatim mode, simply follow the steps again and just remove -v from the string line.

Force a screen resolution on startup
If you want to force Mac OS X to start with a certain screen resolution: you have to add a new key and string line to your com.apple.boot.plist.
<key>Graphics Mode</key>
<string>1024x768x32@60</string>
Where 1024x768 is the resolution you want, x32 is the color depth you want, and if you have VESA 3.0 graphics, @60 the refresh rate you want.

Startup in Safe Mode
If you want to boot up in Safe Mode if something is giving you problems, simply add -x to the kernel flags:
<string> -x </string>
Just follow previous instructions.

NOTE: All of these are to be added on the same <string> </string> line!

----------------------------------------------------------------------------------------------------------------------------------------
More OS X Shell commands can be found at...

http://www.ss64.com/osx/index.html
----------------------------------------------------------------------------------------------------------------------------------------

***END GENERAL MAC OS X INFO***

That's it for now. If anyone thinks of anymore, or I think of anymore, I will add them to this guide. Enjoy!

Thanks to: Bofors, for the su info and the TextEdit from Terminal info, and Deetman for the Whereis and Locate commands.

June 20/'06 - Added in external link. Very good resource!
PM Profile Card
Go to the top of the page
+ Quote Post

Posts in this topic
- DaxTsurugi   [INFO] Various Unix/Mac OS X terminal commands   Apr 9 2006, 05:49 PM
- - bofors   QUOTE (DaxTsurugi @ Apr 9 2006, 01:52 PM)...   Apr 9 2006, 06:07 PM
|- - Hagar   QUOTE (bofors @ Apr 9 2006, 06:07 PM) Wha...   Apr 30 2006, 01:18 PM
- - DaxTsurugi   There is no difference, I'll add it to the gui...   Apr 9 2006, 06:09 PM
- - bofors   QUOTE (DaxTsurugi @ Apr 9 2006, 01:52 PM)...   Apr 9 2006, 10:58 PM
- - DaxTsurugi   Added to the guide. I added thanks to you at the ...   Apr 10 2006, 02:19 AM
- - DaxTsurugi   I didn't know that..thanks for telling us.   Apr 30 2006, 03:07 PM
- - time66   little ad. I had both: <string> -v </str...   May 1 2006, 09:03 PM
- - DaxTsurugi   You do all those commands on one line.   May 1 2006, 09:05 PM
- - sigxcpu   sudo asks for the USER password, if it has adminis...   May 1 2006, 09:14 PM
|- - Jdhore   QUOTE (sigxcpu @ May 1 2006, 09:11 PM) su...   Sep 16 2006, 04:08 PM
- - DaxTsurugi   Hagar said that in a previous post already, but th...   May 1 2006, 09:16 PM
- - Mashugly   Thanks for the info, DaxT! It's guides li...   May 3 2006, 09:19 AM
- - DaxTsurugi   Thanks. :)   May 3 2006, 11:00 AM
- - DaxTsurugi   Would anybody be willing to translate this info in...   May 18 2006, 09:15 AM
|- - hugo Guerreiro   QUOTE (DaxTsurugi @ May 18 2006, 10:15 AM...   Aug 27 2007, 07:11 PM
- - bilditup1   There's no way to move folders? Also, is there...   May 19 2006, 06:31 AM
- - DaxTsurugi   Added how to move a folder. As far as I can tell,...   May 19 2006, 07:02 AM
- - bilditup1   Aight thanks. I was wondering about moving folders...   May 19 2006, 08:42 PM
- - DaxTsurugi   Added how to change directories, change to differe...   May 25 2006, 10:57 AM
- - DaxTsurugi   Added how to find files and binary files.   Jun 16 2006, 06:07 AM
- - vassalle   QUOTE (bofors @ Apr 10 2006, 06:58 AM) I ...   Jun 17 2006, 06:48 PM
- - DaxTsurugi   Added how to make your own Terminal Commands.   Jun 19 2006, 03:53 AM
- - monkeysr   Replacing: <string>-v</string> with: ...   Jun 19 2006, 06:09 AM
- - DaxTsurugi   Then boot in -s to remove it . I also fixed it to...   Jun 19 2006, 06:41 AM
- - monkeysr   Thanks!   Jun 19 2006, 07:11 AM
|- - DaxTsurugi   QUOTE (monkeysr @ Jun 19 2006, 03:08 AM) ...   Jun 19 2006, 07:48 AM
- - youraa   hi i 've been trying to change my resolution a...   Jun 19 2006, 05:41 PM
- - youraa   QUOTE QUOTE hi i 've been trying to change my ...   Jun 19 2006, 10:15 PM
- - panos   Not a good ideal to set a root account. Always us...   Jun 20 2006, 07:15 PM
- - DaxTsurugi   I just list it for people who want it. I never sa...   Jun 20 2006, 09:29 PM
- - kuba   Find a file To find a file, use: locate <filena...   Jul 14 2006, 08:21 PM
- - willgonz   For an editor I like to use Pico. At the terminal...   Jul 17 2006, 08:18 PM
- - Crazor   There is an IMPORTANT difference between cp and di...   Aug 10 2006, 06:36 PM
- - Manaka   There are some other differences between the cp (a...   Sep 4 2006, 07:53 PM
- - vassalle   hey Dax, thanks for responding to my earlier comm...   Nov 4 2006, 04:08 PM
- - realfolkblues   THanks for this it helps alot!   Jan 3 2007, 03:21 AM
- - DaxTsurugi   I went ahead and made this a sticky so it's ea...   Feb 2 2007, 08:59 AM
- - myha   Hi, can someone please tell me how to use aliases...   Feb 4 2007, 05:44 PM
- - asap18   Usually you can just right click the file/folder a...   Feb 4 2007, 06:08 PM
- - myha   Hi, I ment aliases from console... for example: ...   Feb 7 2007, 08:14 AM
- - Markandeya   I've found this side,it may help to you as wel...   Feb 11 2007, 12:32 PM
- - nimb0z   whats the command to view the cd/dvd drive via ter...   Feb 13 2007, 07:27 AM
- - DaxTsurugi   It's cd /Volumes/Name_Of_Your_CD where Name_Of...   Feb 14 2007, 08:30 AM
- - soup4you2   This is not a terminal command but a little trick....   Feb 16 2007, 04:31 PM
- - peterblood   to make an alias, just type alias ll='ls -l...   Feb 22 2007, 02:54 AM
- - MONGO!   Found this browsing around for Terminal info. It...   Mar 19 2007, 03:17 AM
- - dan98203   Hi everyone, I would like to know if there is a wa...   Mar 20 2007, 11:41 AM
- - SunLizard   Greetings, I'm *trying* to get OSX86 (10.4.8 ...   Apr 11 2007, 01:20 PM
- - triofour   hy! i only can start with pressing x while s...   May 9 2007, 09:56 PM
- - technosaints   Will be usefull, if you can include few usefull ke...   May 21 2007, 01:03 AM
- - QuietRiot   Not exactly a command, but saves a lot of work and...   Sep 18 2007, 09:42 PM
|- - jmhuff   QUOTE (QuietRiot @ Sep 18 2007, 04:42 PM)...   Feb 25 2010, 01:48 PM
- - osx86_noob   Something good for use with Automator e.g. :-Run S...   Sep 20 2007, 06:55 PM
- - Rickyo   QUOTE (DaxTsurugi @ May 18 2006, 11:15 AM...   Oct 5 2007, 08:27 PM
- - socal swimmer   I feel super-dumb right now, but i cannot find com...   Oct 26 2007, 04:32 AM
- - udnan   Can you let us know the other kernel flags which c...   Dec 1 2007, 11:57 AM
- - i9300   DaxTsurugi I have something I did not see on your ...   Dec 27 2007, 07:28 PM
- - TheG33k   Here are my Terminal Tweaks: Make your "ls...   Jan 24 2008, 09:20 AM
- - inimicus   Eject! umount /Volumes/SomeVolume Mount...   Jan 25 2008, 09:13 AM
- - Juo   Great guide thanks a lot.   Jan 26 2008, 09:31 PM
- - Noom   A brilliant guide for command line. Thanks a lot ...   Feb 24 2008, 08:59 AM
- - JumpZero   Hello, the ls command list the content of a direc...   Mar 18 2008, 11:07 AM
- - tawakol   is there a command to run apps? like for instance...   Mar 23 2008, 08:48 PM
- - giggles778   i'm surprised i havent seen the wonderful usef...   Apr 6 2008, 10:48 PM
- - manan   Hey guys I edited my com.apple.boot.plist to add t...   Jun 1 2008, 06:48 PM
- - YzorYzor   Add a few more: To find our your details of your ...   Jun 4 2008, 05:07 PM
- - XweAponX   I just got a little Stupid thing that happens: QU...   Jun 14 2008, 05:36 AM
- - Grav3Mind   You should add the touch command its helpful :] l...   Aug 4 2008, 11:50 PM
- - conjure1   Are these Terminal commands different from those y...   Aug 12 2008, 07:42 AM
- - ZoroLives   I appreciate the time it took to write a guide, th...   Feb 16 2009, 01:57 PM
|- - simsim   You can copy and paste in terminal, use the same k...   Feb 18 2009, 07:25 PM
|- - ZoroLives   QUOTE (simsim @ Feb 18 2009, 12:25 PM) Yo...   Feb 23 2009, 01:16 PM
- - StarkIndustries   What about OS X commands when booting the INSTALL ...   Feb 10 2010, 06:35 PM
- - gdscei   **DUTCH VERSION OF THIS GUIDE (TRANSLATED BY ME ) ...   Feb 27 2010, 09:33 AM
- - Dancing Fool   If you are at the Hackintosh boot prompt, can you ...   Apr 15 2010, 08:31 PM
- - monogrim7   thx that is really helpfull   Apr 28 2010, 08:25 AM
- - harutik_11   I thin k lifehackers version is simpler   May 12 2010, 10:18 PM
- - jojeee   Thanks Alot, Saved For Later.... use....   May 24 2010, 03:35 PM
- - purity2010   thanks im sure these commands will come in usefull   Jun 10 2010, 01:19 PM
- - AMDFTW   very well compiled   Jun 13 2010, 08:48 PM

Reply to this topic Start new topic

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 3rd September 2010 - 08:58 AM