Both sides previous revisionPrevious revision | |
classes:psyc410_s15:unix [2014/12/26 19:48] – admin | classes:psyc410_s15:unix [2014/12/26 19:50] (current) – removed admin |
---|
====== Getting started with the Mac Terminal ====== | |
| |
The Mac operating system is a Unix-based on graphical user interface. You can therefore interact with your Mac computer using many (most) of the same commands used in Unix/Linux systems. Many of these commands achieve the same things that you can achieve using 'point and click' methods. For instance, if you wanted to create a new folder on your Mac desktop you could click on your desktop, select ''File'' > ''New Folder''. But you can also create a new folder using Unix commands in Mac's ''**Terminal.app**'' (which can be found in ''Applications/Utilities/Terminal''). This will open a "command line" interface (meaning that you interact with the computer by typing out commands rather than pointing and clicking with your mouse/trackpad). By typing the following commands (press enter/return after each line) you will change the directory of your command-line interface to your desktop and create a new folder entitled "mynewfolder" | |
<code bash> | |
cd ~/Desktop | |
mkdir mynewfolder | |
</code> | |
| |
<note important>EVERY Apple computer running OS X is built on the Unix platform and comes with the Terminal app pre-installed. If you have a Mac, you have Terminal! So you can get familiar with the Terminal on your own machine.</note> | |
| |
At this point you are undoubtedly thinking "It was way easier to just use the trackpad, so why would I ever want to use the command-line!?" However, the command-line gives you direct control over many aspects of your computer that would be hard (or impossible) to access via the graphical interface. More importantly for our purposes, we can write our commands into a text file and then tell the computer to read the commands from that file (this file is called a "bash script" because the particular Unix language that we'll be using is called "bash".) This is great because it means that every time we do whatever task we've "scripted", we can be certain that we're doing it //exactly// the same way we did it last time. Moreover, if we need to run the task 100 times (e.g. we want to create 100 new folders), we can just tell the computer to read the bash script 100 times. Imagine creating those same 100 new folders by pointing and clicking! | |
| |
The majority of what we do in this course will rely on controlling your computer using the command-line. You should therefore dedicate a sufficient amount of time to getting comfortable with basic Terminal/Unix commands and behaviors. There are tons of useful OS X Terminal and Unix tutorials online. I've selected a few below that you can use to get started. | |
| |
===== OS X Terminal Tutorials ===== | |
*[[http://www.davidbaumgold.com/tutorials/command-line/|Getting to know the command line]] | |
*[[http://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line|Introduction to the Mac OS X command line]] | |
*[[http://www.maclife.com/article/feature/25_terminal_tips_every_mac_user_should_know|25 Terminal Tips Every Mac User Should Know]] | |
| |
===== Unix Tutorials ===== | |
| |
*[[http://snap.nlc.dcccd.edu/learn/idaho/unixindex.html|UNIX Introduction]] | |
*[[http://www.ee.surrey.ac.uk/Teaching/Unix/|UNIX Tutorial]] | |
*[[http://unixhelp.ed.ac.uk/|UNIX Help]] | |
*[[http://www.linux.org/lessons/beginner/toc.html|Linux.org tutorial]] | |
*[[http://www.linux-tutorial.info/|Linux tutorial - includes glossary and forums]] | |
*[[http://articles.techrepublic.com.com/5100-10878_11-5827311.html|Top 10 bash shell tips]] | |
| |
===== BASH Tutorials ===== | |
bash is just one of many different Unix "shells" available. Shells are basically different languages for interacting with your computer. We will use bash because it is common, user-friendly, and the default shell on OS X machines. | |
*[[http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html|BASH Programming - Introduction HOW-TO]] | |
*[[http://tldp.org/LDP/abs/html/|Advanced Bash-Scripting Guide]] | |
| |
====== Most Frequently Used Linux Commands ====== | |
| |
To get detailed help of these command, including the options available and how to use them, use | |
| |
man command_name | |
| |
or | |
| |
help command_name | |
| |
| |
==== manipulating files/directories ==== | |
| |
*** [[http://www.linuxcommand.org/man_pages/cd1.html|cd]] ** - change the current directory | |
*** [[http://www.linuxcommand.org/man_pages/ls1.html|ls]] ** - list directory contents | |
*** [[http://www.linuxcommand.org/man_pages/mkdir1.html|mkdir]] ** - make directories | |
*** [[http://www.linuxcommand.org/man_pages/mv1.html|mv]] ** - move (rename) files/directories | |
*** [[http://www.linuxcommand.org/man_pages/rm1.html|rm]] ** - remove files/directories | |
*** [[http://www.linuxcommand.org/man_pages/cp1.html|cp]] ** - copy files/directories | |
*** [[http://www.linuxcommand.org/man_pages/touch1.html|touch]] ** - change file timestamps. | |
*** [[http://www.linuxcommand.org/man_pages/chmod1.html|chmod]] ** - change file access permissions | |
*** [[http://www.linuxcommand.org/man_pages/rsync1.html|rsync]] ** - faster, flexible replacement for rcp (remote file copy) | |
*** [[http://www.linuxcommand.org/man_pages/scp1.html|scp]] ** - secure copy (remote file copy program) | |
| |
==== working with text files ==== | |
| |
*** [[http://www.linuxcommand.org/man_pages/cat1.html|cat]] ** - concatenate files and print on the standard output | |
*** [[http://www.linuxcommand.org/man_pages/head1.html|head]] ** - output the first part of files | |
*** [[http://www.linuxcommand.org/man_pages/tail1.html|tail]] ** - output the last part of files | |
*** [[http://www.linuxcommand.org/man_pages/wc1.html|wc]] ** - print the number of newlines, words, and bytes in files | |
*** [[http://www.linuxcommand.org/man_pages/more1.html|more]] ** - a filter for paging through text one screenful at a time | |
*** [[http://www.linuxcommand.org/man_pages/less1.html|less]] ** - a program similar to more, but more powerful (and user friendly) | |
*** [[http://www.linuxcommand.org/man_pages/grep1.html|grep]] ** - print lines matching a pattern | |
*** [[http://www.linuxcommand.org/man_pages/diff1.html|diff]] ** - find differences between two files | |
*** [[http://www.linuxcommand.org/man_pages/gvim1.html|gvim]] (vi) ** - The GUI version of vim - a text editor that is upwards compatible to Vi. | |
*** [[http://www.linuxcommand.org/man_pages/sed1.html|sed]] ** - a stream editor used to perform basic text transformations | |
*** [[http://www.linuxcommand.org/man_pages/awk1.html|awk]] ** - pattern scanning and processing language | |
| |
==== working with processes ==== | |
| |
*** [[http://www.linuxcommand.org/man_pages/ps1.html|ps]] ** - report a snapshot of the current processes | |
*** [[http://www.linuxcommand.org/man_pages/top1.html|top]] ** - display Linux tasks | |
*** [[http://www.linuxcommand.org/man_pages/bg1.html|bg]] ** - resume the suspended job in the background, as if it had been started with & (useful after you suspend a command with Ctrl-z) | |
*** [[http://www.linuxcommand.org/man_pages/kill1.html|kill]] ** - terminate a process | |
*** [[http://www.linuxcommand.org/man_pages/exit1.html|exit]] ** - cause the shell to exit | |
| |
==== getting useful information ==== | |
| |
*** [[http://www.linuxcommand.org/man_pages/man1.html|man]] ** - format and display the manual pages | |
*** [[http://www.linuxcommand.org/man_pages/help1.html|help]] ** - display helpful information about builtin commands | |
*** [[http://www.linuxcommand.org/man_pages/date1.html|date]] ** - print or set the system date and time | |
*** [[http://www.linuxcommand.org/man_pages/locate1.html|locate]] ** - find files by name | |
*** [[http://www.linuxcommand.org/man_pages/find1.html|find]] ** - search for files in a directory hierarchy | |
*** [[http://www.linuxcommand.org/man_pages/who1.html|who]] ** - show who is logged on | |
*** [[http://www.linuxcommand.org/man_pages/pwd1.html|pwd]] ** - print name of current/working directory | |
*** [[http://www.linuxcommand.org/man_pages/du1.html|du]] ** - estimate file space usage | |
*** [[http://www.linuxcommand.org/man_pages/df1.html|df]] ** - report filesystem disk space usage | |
*** [[http://www.linuxcommand.org/man_pages/which1.html|which]] ** - shows the full path of (shell) commands | |
*** [[http://www.linuxcommand.org/man_pages/history1.html|history]] ** - display the command history list with line numbers | |
| |
==== others ==== | |
| |
*** [[http://www.linuxcommand.org/man_pages/echo1.html|echo]] ** - display a line of text | |
*** [[http://www.linuxcommand.org/man_pages/source1.html|source]] ** - read and execute commands from a file | |
*** [[http://www.linuxcommand.org/man_pages/alias1.html|alias]] ** - prints the list of aliases or define new aliases | |
*** [[http://www.linuxcommand.org/man_pages/gimp1.html|gimp]] ** - an image manipulation and paint program | |
*** [[http://www.linuxcommand.org/man_pages/ssh1.html|ssh]] ** - a program for logging into a remote machine and for executing commands on a remote machine | |
*** [[http://www.linuxcommand.org/man_pages/mount8.html|mount/umount]] ** - mount and unmount filesystems | |
*** [[http://www.linuxcommand.org/man_pages/passwd1.html|passwd]] ** - update a user's authentication tokens (password) | |
*** [[http://www.linuxcommand.org/man_pages/nohup1.html|nohup]] ** - run a command immune to hangups, with output to a non-tty | |
*** [[http://www.linuxcommand.org/man_pages/rdesktop1.html|rdesktop]] ** - Remote Desktop Protocol client (connects to windows computers) | |
*** [[http://www.linuxcommand.org/man_pages/export1.html|export]] ** - export supplied names (variables) to the environment of subsequently executed commands | |
*** [[http://www.linuxcommand.org/man_pages/crontab1.html|crontab]] ** - maintain crontab files for individual users (used to execute commands at scheduled time) | |
| |
| |
====== MATLAB ====== | |
[[http://www.mathworks.com/products/matlab/|MATLAB]] is a multi-platform programming language that is designed to excel at numerical computing, particularly numerical matrix manipulation (indeed, it's name comes from **mat**rix **lab**oratory). It is therefore the preferred language for many scientific, engineering, and economics applications. Many of the EEG and fMRI programs and applications that we will use throughout the semester are written in MATLAB. | |
| |
As with Unix/Bash/OSX Terminal, there are many MATLAB tutorials available online. [[http://www.mathworks.com/academia/student_center/tutorials/launchpad.html|Here is a useful list of many tutorial options]] | |
| |
<note important>MATLAB is not freely available. However, it is installed on all the computers (except #18) in SMA 206. If you're interested in purchasing it for your personal computer there are reasonably priced student licenses for under $100 (this is **not required** for the course).</note> | |
| |