Basic UNIX Commands for Musicians
The table below presents a summary of frequently used UNIX commands.
f (f1, f2,. . . ) refers to any allowable UNIX filename plus extension, which may not have any blank spaces included (use an underscore to separate words, such as "my_file.snd"). It may also include the path (such as /usr/local/csound) necessary to specify that file. UNIX filenames are case-sensitive. "Csound" specifies a different file than "csound." You may specify almost any extension to keep your file organized by purpose or type. For example, the file gener ating this page has an .html extension for my convenience in grouping all of my Web documents. To see them all at once, I could specify ls *.html, which as you will see below, will list all files with the .html extension
d refers to a directory plus as much of the pathname for a directory as is necessary from the current working directory (such as /usr/hass/music, or just /music/csound if you are currently located in hass).
Either f or d in brackets ([ ]) indicates an option to specify a file or directory not in the the current working directory, or omit the argument to use the current working directory. For example, ls wi ll list files in the current working directory, while ls /usr/bin will list files in /usr/bin without changing the current working directory. Be sure to leave a space between the UNIX command and an argument!
Command (Flags) Arg(s) Definition
man term Provides help for UNIX terms (usually more than you want) in a standard format, usually without a usage example that would be really helpful. Type man man to learn how to use man (really).
cd d Change directory (cd /usr/local will make /usr/local your current working directory)

. Current Working Directory

.. Parent Directory (cd .. will take you up one level)

~ Your home directory (cd ~ will take you to your home directory)

/ Root directory (cd / will take you to the top of the file structure)
pwd
List current working directory
ls [d] [f...]
List files in directory (no argument means current working directory). -C flag organizes longer lists into neat columns.  
ls -l [d] [f...] Long (detailed) list of files
ls -a [d] [f...] List all files, including hidden (dot) files not usually seen
ls -s [d] [f...] List files in order of increasing size. Very handy for musicians looking for those large digital audio files!

mkdir

[d]

Make new subdirectory in current working directory
rm f Permanently remove file (careful, if your administrator did not alias rm as rm -i, you won't be asked to confirm). Will not remove directories.
rm -r f The mother of all rm commands. Will remove all files and subdirectories from the current working directory. Use with extreme caution!
rmdir
(or rd)
d Remove directory -- must be emptied of files (use rm) and subdirectories first. Cannot remove current working directory (cd .. first)
*
"Wildcard" character meaning all alphanumeric characters-- can be used for filename or extension or both (rm *.snd will delete all files in the current directory with the "snd" extension. To empty an entire di rectory of files, use rm *.* (very carefully)
cp f1 f2 Copy contents of file1 into file2.
mv f1 [f2...] d Move file(s) f to directory d.
mv f1 f2 Rename file f1as f2
lpr f Send file f to laserprinter. Use lpr -P printer f if your administrator has not specified printer in your environment.
cat f List contents of file f. Use "cat f | more" or just "more f" to list long files one screen at a time.
cat f1 f2 > f3 Concatenates (combines in order) contents of f1 and f2 into file f3
ln sourcefile [newfile] Creates a new link appearing as newfileto an ordinary (source) file (or directory). ln /usr/hass/mydata.txt mydata.txt will create a link to /usr/hass/mydata.txt in the current working directory. If you omit the newfile name, the original filename is used. ln -s creates a'sybolic' link which can be access over different volumes.
ps
List current processes and thier process id #'s-- important for kill command below.
kill process id # Stop current processes -- use if process hangs or you decided not to phase vocode two hours of music after all. Kill -9 process id # does a more complete job.
pico f Brings up file f in Pico text editor window. If you are using this chart, it is unlikely you will want to know about emacs or vi, two less user-friendly UNIX text editors at this point.

chmod

various

Sets file permissions for user, group and everyone. Use 'man chmod' to see all the various arguments for read, write and execute for each class.
chown
user f
Changes owner of file to user. See man chown for changing group.
ssh
computer
name
A program for logging into a remote machine securely and for
executing commands on a remote machine (example: ssh steel.ucs.indiana.edu).
telnet node Connect to other computer to check email, etc. If you are in a UNIX shell, type VT100 for term type, if asked.
rlogin node Remotely connect to another computer.
alias term1 term2 Establishes new name for existing command, for example "alias ls ls -la" will automatically add the -la flags whenever you type "ls". To have a permanent list of aliases in effect, you may add them to the .cshrc file of your account (or .bashrc if using bash). back up your '.' files before messing with them! A good start is to alias rm as rm -r (alias rm 'rm -r') Use single quotes for commands with flags.
| (pipe)
Allows user to send the results of one command directly into another, thereby saving a step. For example, ls -l | lpr will send the results of a long list directly to the printer. Without the pipe, you would need to redirect the output of ls to a file (ls -l > file) and then print the file (lpr file). See FTP section below for a one-step command for expanding and decompressing a file (zcat filename.tar.Z | tar -xvf -) using a pipe.
touch f Sets the modification and access times of files to the current time of day. If the file doesn't exist, it is created withdefault permissions. Useful for creating dummy files or faking out scratch disks which delete unused files.
FTP Commands
It is often necessary to transfer files to and from your current computer--convenience programs are usually available. If not, ftp (File Transfer Protocol) or sftp (secure ftp) is a utility for such a task. To get a file from another host, it is easiest if you first create and then move to the directory you wish the files to reside in. Errors often occur if your current working directory is not yours (i.e. you have no permission to write to it), so make sure you are in a directory for which you have "write" priveledges. FTP uses a simplifi ed version of UNIX commands, so once you log into a remote machine, you can navigate to the files you want using cd (and pwd to check your location) and ls to list the files. Many applications and files are public domain, so you may want to try the "pub" directory of an FTP site first. For such public domain transfers, you should log in under the username "anonymous" and use your Internet user name (ex. hassj@indiana.edu) for the password. You may want to practice first, so try to get som ething from ftp.indiana.edu (note that some sites use "ftp" as part of their nodename, but you would still have to connect by typing ftp ftp.indiana.edu. Also, remember to set the file transfer type (ascii or binary) before using the get or mget commands . Once connected, you can usually type "help" at anytime for a longer list of commands.

Many files you download will be in an archived format (indicated by a tar extension) creating several files when expanded, and may also be compressed (indicated by a Z extension. These are usually labeled filename.tar.Z. To expand t hese files into a useable format, use the following sequence of steps. Create a new directory and place the compressed file in it (using mv). Make that directory your working directory (using cd). Then type the following command:
zca t filename.tar.Z | tar -xvf -
substituting the name of your compressed file for filename. This will expand the file. Some applications arrive with a README file with further instructions for use of the software. A README file will als o usually contain information about how to compile a program if it doesn't arrive as an executable binary.

ftp sitename Open ftp session to site sitename
ascii sitename Set transfer type to ascii text (normally the default, but not good for binary files, such as digital audio, etc.).
binary sitename Set transfer type to binary (good for compiled programs, digital audio files, etc.). Use binary transfers if you are not sure what the filetype is.
get f Transfer file f to your current local directory.
mget f1 f2 ... Transfer multiple files to your current local directory.
put f Transfer file f from your local directory (or specify path) to the remote computer.
mput f1 f2 ... Transfer multiple files from your local directory (or specified path) to the remote computer.
bye
Close ftp session. Very much appreciated by busy host sites. Immediately frees space for another connection.

This document prepared by:
Prof. Jeffrey Hass Indiana University School of Music
Center for Electronic and Computer Music.
Last updated August 29, 2005

Email any comments, suggestions, requests for new documents, or corrections to cecm@indiana.edu