Jump to content

[INFO] Various Unix/Mac OS X terminal commands


  • Please log in to reply
82 replies to this topic

#61
Noom

Noom

    InsanelyMac Protégé

  • Members
  • Pip
  • 39 posts
  • Gender:Male
  • Location:Boulder, CO, USA.
A brilliant guide for command line. Thanks a lot Dex. :)

#62
JumpZero

JumpZero

    InsanelyMac Protégé

  • Members
  • Pip
  • 26 posts
Hello,

the ls command list the content of a directory but I always prefer ls -la
the l option outputs in a list with more info for each files (dates, permissions, etc.. )
the a opion outputs also the hiden files (on Unices the hiden files start with a . )

more option with the ls manual page:
man ls

Because I prefer ls -la and it's boring to type it everytime I created an alias:
alias 'la=ls -la'
And I added this line to the bashrc file (it's like an autoexec.bat on Dos, it's run each time a shell is started)
On Mac OsX there is a bashrc that is system wide (for all users)
bashrc is located in /etc/

So any user just have to type la in any terminal...

--
Jmp0

#63
tawakol

tawakol

    InsanelyMac Protégé

  • Members
  • Pip
  • 15 posts
is there a command to run apps?

like for instance system prefs?

cause at my school i can run most blocked apps thru right click --> show package contents -->contents -->mac os -->"program's name" (it has a terminal icon)

but when i do that with system prefs nothing is active.. all the buttons are greyed out.

#64
giggles778

giggles778

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
i'm surprised i havent seen the wonderful useful command line text search tool GREP

$ ls -al | grep string

the string is anything you're looking for ... or

if your looking for something in your logs that you need

& cat /var/log/system.log | grep whatever
& cat /var/log/secure.log | grep failure .... this one shows you only the lines that have the word failure in them ...

that's really all i can think of right now :)

#65
manan

manan

    InsanelyMac Protégé

  • Members
  • PipPip
  • 81 posts
Hey guys I edited my com.apple.boot.plist to add the resolution, I did it correctly but now OS X reboots the moment it shows the boot screen, even in verbose mode it simply restarts.

#66
YzorYzor

YzorYzor

    InsanelyMac Protégé

  • Members
  • Pip
  • 46 posts
Add a few more:

To find our your details of your System like kernel version, CPU architecture etc: uname
hostinfoMach kernel version:	 Darwin Kernel Version 9.3.0: Fri May 23 00:49:16 PDT 2008; root:xnu-1228.5.18~1/RELEASE_I386Kernel configured for up to 2 processors.2 processors are physically available.2 processors are logically available.Processor type: i486 (Intel 80486)Processors active: 0 1Primary memory available: 3.00 gigabytesDefault processor set: 69 tasks, 234 threads, 2 processorsLoad average: 0.01, Mach factor: 1.98

Also uname
uname -a
Darwin HOSTNAME.local 9.3.0 Darwin Kernel Version 9.3.0: Fri May 23 00:49:16 PDT 2008; root:xnu-1228.5.18~1/RELEASE_I386 i386


#67
XweAponX

XweAponX

    InsanelyMac Protégé

  • Members
  • Pip
  • 47 posts
I just got a little Stupid thing that happens:

Repair Permissions of a folder
If you've been naughty and messed with the System/Library/Extensions folder at all, :P , 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.


When I DO dis little thing it says this little thing uh, ah, "Operation Not Permitted"

-Wt_?? That aint a question though.

#68
Grav3Mind

Grav3Mind

    Super l33t T3H HaX0r ARE YOU? WELL..I can..umm..HaX your Tires?

  • Members
  • PipPipPipPipPip
  • 324 posts
  • Gender:Male
You should add the touch command its helpful :]

like "touch /system/library/extensions/"

:]

#69
conjure1

conjure1

    InsanelyMac Protégé

  • Members
  • Pip
  • 49 posts
Are these Terminal commands different from those you can use in -s? I'm very new at this, so appreciate the help. Thanx

#70
ZoroLives

ZoroLives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 219 posts
  • Gender:Male
  • Location:Albuquerque NM
I appreciate the time it took to write a guide, thanks. What I Want to know is, can I cut and paste terminal commands? As I research all the changes that others are suggesting for setting up my new system (still shipping), I see I have a few lines of things to write into the terminal. And I know that typing and spaces do matter. I was wondering if I could be setting up (saving) a text file in BBEdit now with the set up lines of code for when I get my system in the mail?

It would add to my confidence level if I could cut and paste long or multiple lines of command lines in the terminal. Possible?

Thanks

#71
simsim

simsim

    InsanelyMac Protégé

  • Members
  • Pip
  • 31 posts
You can copy and paste in terminal, use the same key combination as in other applications. command-c , command-v

One thing I find practical in terminal is "open ." It opens the current directory as a finder window. It's good if you want to drag and drop files into the terminal window (lazy way to get paths right) or open directories in finder that are hidden normally.
Also, "man man" gives you the manual for the manual :-)

#72
ZoroLives

ZoroLives

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 219 posts
  • Gender:Male
  • Location:Albuquerque NM

You can copy and paste in terminal, use the same key combination as in other applications. command-c , command-v

One thing I find practical in terminal is "open ." It opens the current directory as a finder window. It's good if you want to drag and drop files into the terminal window (lazy way to get paths right) or open directories in finder that are hidden normally.
Also, "man man" gives you the manual for the manual :-)

Thanks. I have messed around with the terminal enough not to be really "afraid" of it, but only just. I have done some MDLS lookups with my Mail and MailSmith indexes and moved that data to my database language. I have looked at Man pages here and there, mostly as an outsider. The only real taste I get on a regular basis of UNIXy flavored Mac is the occasional boot I do into single user mode to run Applejack.

Which reminds me, any idea if Applejack would break my hack? Or, if Applejack would properly repair permissions? I read in another thread where repairing permissions had to be done in a specific way with the hack process and standard permission repair programs would not work for this purpose. I do have the recommended program downloaded and in my kit, ready to go. But would Applejack do this as well?

Thanks

#73
StarkIndustries

StarkIndustries

    InsanelyMac Protégé

  • Members
  • Pip
  • 26 posts
What about OS X commands when booting the INSTALL DVD and running terminal. I know its shell or bash commands, but it seems that lot of commands are disabled. "rm" is disabled because im trying to remove dsmos.kext and it wont let me. Is there a way around rmdir if there are files in the dir. Again it wont let me.

#74
jmhuff

jmhuff

    InsanelyMac Protégé

  • Members
  • Pip
  • 8 posts

Not exactly a command, but saves a lot of work and helps on the guessing is the TAB-completion.


Tab ROCKS!!!
If you hit tab and it doesn't fully complete the string it can mean that there are multiple options, hit tab twice to show the options available.

#75
gdscei

gdscei

    InsanelyMac Protégé

  • Members
  • PipPip
  • 78 posts
**DUTCH VERSION OF THIS GUIDE (TRANSLATED BY ME :() IT IS NOT YET TRANSLATED FULLY BUT I'LL EDIT THIS POST SEVERAL TIMES TO MAKE COMPLETE TRANSLATION.** // **NEDERLANDSE VERSIE VAN DEZE HANDLEIDING (VERTAALT DOOR MIJ ;)) HIJ IS NOG NIET COMPLEET VERTAALD, MAAR IK ZAL DEZE POST EEN AANTAL KEER BEWERKEN OM ER EEN VOLLEDIGE VERTALING VAN TE MAKEN.**

***BEGIN TERMINAL INFO***
Als eerste, Terminal is Mac OS X's versie van Konsole in Linux of Opdrachtprompt in Windows. Je kan het vinden in /Programma's/Hulpprogramma's, beneden. Om het te openen, dubbel-klik er op.

Als het is geopend, en je ziet een rechthoekig blokje in het venster, dan is het klaar om jouw commando's in te voeren.

Info over Root
Op UNIX-achtige systemen, zoals Mac OS X en Linux, root is de hoofdgebruiker van de computer, wat toegang heeft tot *alles*. In andere woorden, dit is het Systeem Administrator account, wat je onderhoud laat doen, etc.

Login als Root
sudo -s

Als je dit intypt, dan zal het vragen om jouw gebruikerswachtwoord, denkend dat jouw gebruikersaccount een Administrator account is. Na dit, kan je commando's invoeren die het nodig vinden om root te zijn.

OF:
su, wat voor de root wachtwoord vraagt. Als je dit nog niet hebt, volg dan de instructies hieronder. WAARSCHUWING: het aanzetten van de root-modus kan gevaarlijk zijn!

Opnieuw, nadat je dat hebt ingevoerd, zal het vragen om het root wachtwoord.

Verander root wachtwoord
Als je het wachtwoord van root niet leuk vind, gebruik:
sudo passwd root
Daarna, typ in je oude root wachtwoord en daarna het nieuwe root wachtwoord, naar jouw keuze. Als je eerder nog geen root wachtwoord had, dan zal het alleen vragen om een nieuw root wachtwoord.

WAARSCHUWING: TERMINAL VRAAGT NIET OF JE HET ZEKER WEET ALS JE DINGEN GAAT VERWIJDEREN, HERNOEMEN, ETC. EN KAN GEVAARLIJK ZIJN.
***NOTITIE: sudo CAN GELINKT WORDEN MET ALLE VOLGENDE COMMANDO'S, ALS JE HET ZONDER sudo DOET, DAN ZAL HET JE NIET AANWIJZEN ALS IEMAND DIE ROOT IS, MAAR EEN SUPERGEBRUIKER.***

Verander mappen

Om rond te bewegen doro verschillende mappen, gebruik cd.
Voorbeeld: cd /programma's
Dat zal je verplaatsen naar de Programma's map.
Intypen van cd zonder argument leidt dat het je zal doorsturen naar de laatst in wezende map.

Om naar een map te veranderen die spaties bevat, stop aanhalingstekens rond deze map.
Voorbeeld: cd /Applications/"XChat Aqua"
Dat zal je verplaatsen naar de XChat Aqua map in de Programma's map.

Verplaats naar andere volumes/disks/partities

Om je naar andere volumes/disks/partities te verplaatsen, gebruik cd opnieuw.
Voorbeeld: cd /volumes/Mac
Dat zal je verplaatsen naar de root map (/) van het volume Mac.

Je kan ook naar volumes plaatsen die spaties bevatten, net zoals de laatste hint.
Voorbeeld: cd /volumes/"Mac OS X"

Verwijder een bestand van jouw Mac

Dit zal een bestand verwijderen die in dezelfde map is waar jij bent:
rm <bestandsnaam>
Voorbeeld: rm iets.txt

Je kan ook een pad naar iets typen, zodat je ook bestanden in andere mappen kan verwijderen:
rm /pad/naar/iets
Voorbeeld: rm /Programma's/Candybar.app
Dit zal een applicatie genaamd Candybar verwijderen uit je Programma's map.

Dit zal een hele map verwijderen uit je Mac:
rm -d <map>
Voorbeeld: rm -d verwijder_mij
(Zeg maar dat je een map hebt genaamd verwijder_mij in de root van je Mac (/))

Notitie: hier kan je ook weer een heel pad naar typen, net zoals eerder.

Kopieer een bestand

Om een bestand te kopieeren:
cp <bestandsnaam> <naam_van_kopie>
Example: cp iets.txt ietsanders.txt
Dit zal iets.txt dupliceren en veranderen in ietsanders.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. :P

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>

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!
[/quote]

#76
Dancing Fool

Dancing Fool

    InsanelyMac Protégé

  • Members
  • Pip
  • 9 posts
  • Gender:Male
  • Location:Dallas
If you are at the Hackintosh boot prompt, can you open Terminal before the boot process is completed? If so what is the command to type at the boot prompt?

#77
Timdphotos

Timdphotos

    InsanelyMac bookPro

  • Members
  • PipPipPipPip
  • 233 posts
  • Gender:Male
thx that is really helpfull

#78
harutik_11

harutik_11

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts
I thin k lifehackers version is simpler

#79
jojeee

jojeee

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
Thanks Alot, Saved For Later.... use....

#80
purity2010

purity2010

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts
thanks im sure these commands will come in usefull





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy