Unix Basics: Presented By: Benjamin Lynch
Unix Basics: Presented By: Benjamin Lynch
www.msi.umn.edu
Unix Basics
Outline
www.msi.umn.edu
I. Warnings! II. Basic Concepts III. Basic Commands IV. The Fun Stuff
Warnings!
www.msi.umn.edu
If you delete a file, it is GONE! The file can only be retrieved from a backup. If you overwrite a file it has been changed forever. The original file can only be restored from a backup. Home directories are backed up nightly. The scratch spaces are NOT backed up!
Warnings!
scratch space
www.msi.umn.edu
Warnings!
service units
www.msi.umn.edu
Basic Concepts
core resources
www.msi.umn.edu
IBM Power4
312 Power4 processors 664 GB of memory 16 TB of storage
SGI Altix
438 Itanium2 processors 884 GB of memory 10 TB of storage
IBM BladeCenter
1140 AMD Opteron cores 2280 GB of memory
(Available August 2006)
Basic Concepts
laboratory resources
www.msi.umn.edu
Med. Chem./Supercomputing Inst. 1 CPU SGI Altix - 48 CPU Vis. Workstation Lab
3 SGI Octanes 3 SGI O2s 2 SunBlade 2000s
1 SGI Onyx4 - 16 CPU 9 SGI Octanes 1 Sun UltraSparcIII - 8 CPU 4 Linux Workstations 1 SunBlade 2000 20 TB of storage 64 x 80 stereo system
http://www.msi.umn.edu/vwl
http://www.msi.umn.edu/bscl
http://www.msi.umn.edu/sdvl
http://www.msi.umn.edu/cgl
Basic Concepts
laboratory resources
www.msi.umn.edu
Basic Sciences Computing Lab Proteomics Structural Biology Computational Genetics Lab Bioinformatics Genomics Med. Chem./MSI Visualization Workstation Lab Drug Design Molecular Modeling Scientific Development & Visualization Lab Computational Fluid Dynamics Scientific Computation Scientific Data Management Lab Data Mining Large Data Storage
Basic Concepts
changing passwords
www.msi.umn.edu
After your first login you should change your initial password to something that is easy for you to remember, but not easy for someone to guess. %> passwd (Institute machines)
You should NEVER give your password to anyone! If you forget your password, send a message to help@msi.umn.edu and your password will be reset.
Basic Concepts
changing passwords
www.msi.umn.edu
Initial Passwords
Your initial password should be the same for all machines within a given lab, regardless of operating system.
Windows
All of the Windows bases machines share the same password file across all labs. When you change your password on one machine it is changed for all machines regardless of the lab.
Basic Concepts
console
Console Login:
www.msi.umn.edu
Basic Concepts
remote login
www.msi.umn.edu
secure shell; a program for logging into a remote machine providing encrypted communications between machines login name sets environment variables for porting X-display similar to -X, required for some programs
options: -l -X -Y example:
type: ssh -l blynch balt.msi type: ssh bi2
open a secure connection for the user blynch on the machine balt.msi.umn.edu open a secure connection to bi2.msi.umn.edu with current username
Basic Concepts
forwarding email
www.msi.umn.edu
Why? So that you get all of your email sent to one account. Makes it easier for sys admins to communicate with you. How? 1) Create the file .forward in your home directory 2) On the first line: your.email@desired.location 3) Create this same file in all of your accounts that you want to forward.
Basic Concepts
command line help
www.msi.umn.edu
info command
When in doubt, check the man/info pages! Need extra details? Check the man/info pages!
Basic Concepts
file structure overview
/ bin@ user1/ file1 .cshrc mail/ source/ work/ user1/ proj1/ proj2/ input output directory ( / ) executable ( * ) link (@) dir1/ home/ user2/ lib@ scratch/ bin/
www.msi.umn.edu
file1/
file2/
Basic Concepts
metacharacters
www.msi.umn.edu
? * ~ ~name . ..
single character wild card wild card, any number of characters home directory of current user home directory of user name current directory parent directory (back one)
Basic Concepts
command anatomy
www.msi.umn.edu
ls -al /scratch
command name argument (quite often a filename or directory)
Note: UNIX commands, options, and arguments are all CasE seNsiTive!
Basic Commands
Command ls [options] dirname pwd mkdir dirname cd dirname mv [options] source destination cp [options] source destination rm [options] source ssh [options] hostname scp [options] user@host1:file user@host2:file Description
www.msi.umn.edu
list the contents of dirname display full pathname create the directory dirname change to the directory dirname move a file or directory copy a file or directory remove a file or directory remote login remote copy; file transfer
Listing Contents
ls [options] dirname options: -a -l examples:
type:
www.msi.umn.edu
list all files including hidden files [hidden files are preceded by a .; eg .cshrc] long listing showing ownership, permissions, and links
ls /home/user/temp view the contents of a directory with absolute pathname /home/user/temp ls ../../temp list the contents of a directory using a relative path.
type:
Make Directory
www.msi.umn.edu
create the directory work/ in the current working directory create the directory proj1/ in the work/ directory create the directory user2/ in the /wrk/ directory
Change Directory
www.msi.umn.edu
cd cd dirname examples:
type: cd ~tom type: cd /wrk/user2
Moving or Renaming
www.msi.umn.edu
confirm overwrites
moves file from user1s home directory to the current working directory and renames it output file
Copying
www.msi.umn.edu
confirm overwrites recursively copy a directory and its contents, copies symbolic links
Removing
www.msi.umn.edu
remove a file
remove without prompting confirm removal recursively remove a directory and its contents
Note: Be careful when removing files! Especially with wild cards (*,?)!
Remote Copy
www.msi.umn.edu
scp [options] host:file1 host:file2 secure copy; copy files between hosts on a network using the ssh protocol options: -r example:
type: scp blynch@altix:output/*.out . type: scp -r mail origin:mail_copy
Changing Permissions
chmod [options] who ops permission filename change file permissions use ls -l to view permissions
www.msi.umn.edu
who can be any combination of: u (user) o (other/world) g (group) a (all or ugo)
ops adds or takes away permission, and can be: + (add permission) (remove permission) permission can be any combination of: r (read) w (write) x (execute) X (check user first)
Command Repetition
history !string up/down arrows left/right arrows Control-E Control-A examples:
type:
www.msi.umn.edu
repeat command beginning with string scroll up and down through most recent commands; csh and tcsh use for editing current line end of line beginning of line
!ls
Command Completion
www.msi.umn.edu
TAB
finish the current command, filename, or directory if possible, or show the possible completers (works with csh and tcsh and bash shells)
Tarring
www.msi.umn.edu
collect or extract files or directories into or from an archive create a new archive extract files from archive store files in archive print function letter and name of files store to standard output
extract the files and or directories from the archive, file.tar Create a new tar file with all the contents of a directory named work and all its subdirectories
Compression
www.msi.umn.edu
compress file
compress file and rename it file.Z (the program automatically renames the file) uncompress file.Z and rename it file compress file and rename it file.gz (the program automatically renames the file) uncompress file.gz and rename it file
gunzip file.gz
Process Control
www.msi.umn.edu
cancel a foreground job stop (interrupt) a foreground job list of background jobs run stopped job in the background run stopped job in the foreground appended to the end of a command will place that job in the background
run WU-BLAST job in the background
Process Control
www.msi.umn.edu
display the status of the current processes and the process id-number all processes display processes owned by a particular user shows any jobs that are currently running in the background or suspended
Process Control
www.msi.umn.edu
kill 9 id-number
terminate a process owned by you; idnumber (process id) can be found with the ps command
or kill %job-number terminate a process owned by you; jobnumber can be found with the jobs command
Other Commands
www.msi.umn.edu
display total disk usage of file or directory in kilobytes display the current disk usage for all connected file systems view attributes of a file or directory list your disk quota
Viewers
www.msi.umn.edu
dumps the contents of files to the screen a pager, that lets you view one page at a time similar to more, but more
Editors
www.msi.umn.edu
Graphical: nedit filename xemacs filename Command-line: pico filename vi filename full-screen text editor available on most UNIX systems full-screen text editor available on virtually every UNIX system
command output redirection (create new, overwrites existing file) command output redirection (append) command input redirection (from file)
combine individual sequence files into one file cat seq1 seq2 > seq
command1 | command2 |
directs standard output of one command into standard input for the next command
examples:
type: ls -al | more type: qstat -a | grep user1
look at the ls output one page at a time check the queue on the origin for any processes being run by user1
find and print out lines containing the string in a file or multiple files
ignore case
how to: extract sequence information from protein structure files type:
.cshrc Some things to add to your .cshrc file: alias alias-string com-string examples:
type: alias la ls -a type: alias q qstat -u pfast
create a shortcut for ls -a check if you have any jobs running in the queue (origin) load or unload the environment settings for a particular software runs the gcgstartup script to set the necessary env. variables
Easier for people (including user support staff) to work with you Easier for your advisor Good for your own productivity Faster to restore deleted files if you know where they are
Questions?
www.msi.umn.edu