Introduction to Mac OS X
The Mac OS X operating system both a graphical user interface and a command line interface. We will see how to use both to our advantage.
Using DOCK
The dock on Mac OS X is the Application bar which by default is situated at the bottom of your screen. It is similar to the Task Bar on Windows.
The dock is customizable (see Mac help for more info).
To launch applications in your Dock, click on their icon once. A black triangular shape appearing under the icon indicates that the application is currently open.
Adding a shortcut for an application
You can add easily an item to the Dock. For example we are going to use the software MacMolPlot along the sessions so let's add it into the Dock.
First you need to open a Finder window and click on the Application short cut on the left of the window, like it is shown below:
When you reach the icon of your application (in our example MacMolPlot) you simply click and keep the button pressed until you drag the icon into Dock where you simply drop it. Now you can see the icon of MacMolPlot in your dock so by clicking on it you can open the application.
Using FINDER
Finder on mac OS X is the same as the "Windows Explorer" on Windows. Finder gives you lots of options to locate, display and organize all your files and folders. The 3 buttons we circled on the picture allow you to modify the display as you like to visualize your folders.
From Finder you can open an application by double clicking on it. It works the same for the files. Each kind of files has an application assigned by default to open it, so when you double click on a file it will be open with that application.
You can also drag and drop the file on the icon of the application in Dock with which you want to open that file.
Using X11-terminal
On your mac you will find two kind of terminals. One installed by default which is called "Terminal" and one installed by the user called "X11". The X11
terminal is a X window. It allows the user to display graphical interface on Unix-like operating systems.
X11 terminal is in the Utilities directory under the Applications.
Launching X11
Usually when you install the developper's tools on your mac, X11 terminal is installed under the Utilities directories. As we plan to use X11 a lot, it would be useful to add it in the Dock. Then to launch the X11 terminal it will be easy to click on the icon in the Dock
After clicking on the icon, it will begin activate and a little black triangular shape will appear under the icon to mention that the application is opened. And then a X11 terminal will open..
The X11 terminal is used as a Unix terminal as all of the standart UNIX utilities and scripting languages are included in Mac OS X: editors like emacs, vi (you will see later), file management tools, shell scripts ...
Hints on Mac OS
Web Browser
The most popular browser for mac users is now Safari. we will be using this browser in this course.
If it is not in the Dock you can drag and drop the icon of Safari from the Applications folder.
Enable tabs on Safari
First go to Safari menu and select Preferences.
The Preferences window opened, you will click on the tabs icon on the top. Then activate the option called "Enable Tabbed Browsing".
Activate the tabbed browsing on Safari. Shortcuts with Safari:
• Open a new tab: command + t
• Open a link in a new tab and select it: command + click • Open a link in a new tab: command + shift + click
• Open a link in a new window and select it: command + option + click
• Open a link in a new window behind the current one: command + option + shift + click
• Access the search field: command + option + f
• Increase font of a webpage: command + Plus-sign
• Decrease font size of a web page: command + Minus-sign
Quit an application properly
When you want to quit an application you close the window by clicking on the red button. BUT the application is not quit, it is still opened. So to close the application you need to go to the menu of the application and select Quit, or simply use the short cut: command + q.
You can check if you let application opened by looking at the Dock. All applications open have a black triangular shape under the icon that
disappears when you quit the application. Checking this avoids to have too many applications opened.
Shortcuts on Mac OS:
keyboard commands
On Mac the keyboard is slightly different than on Windows machines. The most important difference is the Apple or command key. This key is used much like the Control key on a Windows machine. Also many shortcuts in programs on a Windows program will work with the Apple key on the Mac.
Text
• Copy: command + c • Paste: command + v • Cut: command + x • Undo: command + z
• Redo: command + y
• Select all: command + a
Window
• Close window:command + w
• Close all windows: Option + command + w
Menu Command
• Log out: shift + command + q
• Log out immediately: shift + option + command + q • Hide the active application: command + h
• Hide others application: option + command + h • New windows: command + n
• New folder in Finder: shift + command + n
• Open a new document: command + o
• Save a document: command + s
• Save as: shift + command + s • Print menu: command + p
• Move to Trash: command + delete
Other Commands
• Switch application: command + tab • Force quit: option + command + ESC
• Restart, Sleep, Shutdown dialog box: control + eject
• Sleep: option + command + eject(buton on the left-up corner) • Quit all applications and restart: control + command + eject Reference to learn more shortcuts on Mac:
http://support.apple.com/kb/HT1343
Introduction to Basic Unix commands
The Graphical User Interface (GUI) of Mac OS X provides a visual "user-friendly" layer that provides visual cues to help users use their computer with greater ease. The same operation can also be done typing in a command on the "command line". For example, dragging and dropping a file HelloBaby.txt into folder PinkyToes could be done on the command line using: mv
HelloBaby.txt PinkyToes
To use the command line on a Mac you need to open a terminal In unix, tasks often use the following syntax:
Syntax of a Unix Command
This example shows how to copy a directory called folder1, making a new directory called, folder2.
Useful tip! Wildcards can be used to add flexibility to your commands:
• The most common wildcards *
For example: ls *.inp returns the list of files with the extension ".inp" in the directory.
• Another common wildcard is: ?
For example: ls my??put.inp => return the list of files with 2 letters to replace the two ?.
Common Command lines
Information:
Any time you wish to find information about how to use a command properly, you can type:
• man the_command_of_interest
This will open the unix manual for the command, which you may scroll through using the arrow keys, or by pressing the letter "f" for "forward" or the letter "b" for "backward", and you can exit the manual by pressing the letter "q".
Try, for example, typing:
• man cd
In your command line window, to see information about the first command listed below.
Directory
• cd [directory] change directory
• mkdir directory_name make a directory
• rmdir delete an empty directory
• ls [options] directory or file list directory contents or file permission • pwd find out which directory you are in
File
• cp [options] file1 file2 copy file1 into file2 • cp [options] file1 file2 copy file1 into file2 • less [options] file page through a text file
o [shift] g => go the end of the file o [ctrl] d => go 10 lines down o [ctrl] b => go 10 lines back
• tail -f filename Show the line at the same time as they are written • tar [options] archive_name.tar files_name combined multiple files and
folders into a single file, but does not compress anything.
• gzip [options] file_name > ar archive_name compress files • gunzip [option] archive_name Extract the files from the archive • bzip2 [option] filenames create a compressed file.bz2
• bunzip2 [option] archive.bz2 Uncompress the compress file
Find
• find directory -name file Look for a file in a directory and his content • grep pattern file Look for a pattern in a file
Processes
• ps -al display the processes • jobs display the tasks
• ctrl z interrupt the current task • ctrl c Stop the current task
• kill -9 processus_number kill the processes
• bg job_number put a task in background
• fg job_number put the task in front
Right
• ls -l filename list file permissions
• chown [option] file modify the owner of a file/directory
Introduction to VI
There are many VI tutorials and cheat sheets on the web.
VI Tutorial : http://www.cs.colostate.edu/helpdocs/vi.html
List of VI Commands: http://www.unix-manuals.com/refs/vi-ref/vi-ref.htm
Why bother learning VI? It is installed by default on UNIX systems.
The key to learning VI is to keep in mind the 2 principal modes that are the text-insert mode used to add text to a file and the command-mode used to give commands. The ESC key has to be pressed to pass from one mode to another one.
To invoke VI: vi filename
If you did not already have the file, this command will create it.
VI modes
Editing mode
Edit mode allows you to move the cursor and edit the text buffer. It is the default mode when you open a file with vi.
Inserting mode
Insert mode "drops" the cursor at a specific point in the buffer, allowing you to insert text.
• i Insert before cursor.
• I Insert at start of current line. • a Append after cursor.
• A Append at end of current line. • o Open new line below.
• O Open new line above.
Command mode
Command mode moves the cursor to the command line, allowing you to invoke program commands such as write to file (:w) and quit (:q). You enter colon mode from edit mode by typing a colon followed by a command.
• :w newname Write buffer to file newname. • :r Read the current filename into the buffer. • :r oldname Read the file oldname into the buffer.
• :q! Quit vi without saving buffer.
• :wq Write buffer to current filename and quit vi.
• :e filename Close current buffer and edit (open) filename. • :e # Close current buffer and edit (open) previous file.
Cursor movement
In addition to the arrow keys, you can use these edit mode commands to move the cursor:
• h Left one character.
• j Down one line. • k Up one line.
• l Right one character.
• b Beginning of previous word.
• e End of next word.
• w Beginning of next word.
• { Backward one paragraph. • } Forward one paragraph.
• ^ Go to first character of current line. • $ Go to last character of current line. • CTRL/d Forward (down) one-half page.
• CTRL/u Backward (up) one-half page.
• CTRL/f Forward one page.CTRL/b Backward one page.
• G Go to the end of the file. • 1G Go to the first line of the file. • nG Go to line number n.
Searching in VI editor
• / The slash is the symbol to indicate you wish to search for whatever
follows (make note that this is case-sensitive)
• E.g.) /GAMESS will result in a search for the word GAMESS in your file,
Typing / again will result in proceeding again foreward in the file to find the next location of the word GAMESS.
• ? The question mark is also a search symbol, to search backwards from
your current position in the file.
• E.g.) ?ENERGY will search backwards for the word ENERGY previously written in the file.