Do Some Basic UNIX

From Center for Cognitive Neuroscience
Jump to: navigation, search

Some basic unix commands

Want more? Try the excellent tutorials at, Mayo, or Idaho state and, of course, the bash manual

Command Meaning
man function show the manual page for a function
id list your personal user id, username, and the groups you belong to.
id username list username's id, username, and the groups they belong to.
top shows currently running processes - do not leave this running for more than 30sec (ctrl-c)
ps show the names of all running processes
mkdir dir_name create a sub-directory of the current directory
rmdir dir_name remove a directory. You must remove files in the directory first.
cp source dest copy a file or directory from source to dest
rm file_name remove a file (permanent!)
chmod xxx file_name change the file permissions:

Three numbers indicate the permissions for the owner, the group and the world.

1 - execute permission
2 - write permission
4 - read permission

You can add these permissions together, for example:

7 - read, write, execute
6 - read and write (not execute)
5 - read and execute (not write)

chmod 777 filename

  • Give all users read, write and execute

chmod 744 filename

  • owner read, write, execute
  • group members and all others read only

chmod 755 filename

  • owner read, write, execute
  • all other read and execute (but not write)

chmod 700 filename

  • owner read, write execute
  • others: no access

chmod -R will make these changes to all of the files in any sub-directories, as well. </td> </tr>

chgrp groupname filename</td> change the group that has access to the file. For example: chgrp bookheimergroup myWork </td>
ls</td> list contents of current directory</td>


ls -l</td> list the contents of the directory (long form, showing sizes)</td>


ls dir_name</td> list the contents of the named directory</td>


cd dir_name</td> change to the named directory</td>


pwd</td> show the name of the current directory</td>


.</td> the current directory</td>


..</td> the parent directory of this directory</td>


more file_name</td> print out the contents of the named (text) file</td>


df</td> show the free space on the present disk</td>


du</td> show the disk usage on the system</td>


*</td> unix wild card - matches all file names (except those beginning with '.')

e.g. rm * will remove all files from the current directory!

You will absolutely never type 'rm *'. Ever.

Always type something like "ls *" first to verify what such a wildcard will match

</td> </tr>

xemacs file_name

textedit file_name
nedit file_name

vi file_name</td>

These are all text editors that are found commonly on unix systems.

Most people seem to prefer xemacs, but each has its adherents.</td> </tr>

?</td> matches any single character</td> </tr>