Evelyn's LINA Basic Guide To LINUX Commands
Evelyn's LINA Basic Guide To LINUX Commands
*Please note that some of these commands are specific to the programs and environment I have set-
up on my machine and will not work for you unless you have your machine set-up similarly.
Use the command locate program_name to determine whether or not you have a specific program
on your machine.
Many commands have extra options you can add. For instance, using the ls command above
with the extra options:
ls -latr
will list the contents of the directory in reverse order (oprion r) of the time last modified
(option t) with additional informatiom about the file sizes and permissions.
To copy files between computers use scp (ftp is no longer allowed for security reasons), which
is almost the same as cp except that you need to include the user and machine name as well:
scp filename [email protected]:/misc/folder/foo
Where filename is what you are copying and the rest is where you are copying to. The scp
program must exist on both machines for this to work. If you need to install it on your
Windows machine at home, WinSCP can be found on the web for free at
http://winscp.sourceforge.net/eng/download.php.
If you want to copy something to our group's laptop, you have to scp from rather than to it:
scp [email protected]:/misc/folder/foo .
which will copy a file called foo in /misc/folder directory of your machine into whatever
directory you are in on the laptop.
If you need to login to your computer from home, or you want to login to another machine
from your own, you will have to use ssh. On our lab's machines this will already be installed.
To install it on your windows machine at home go to:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and get the PuTTY
executable you need. For more information you can read about ssh at the MSI web page:
http://www.msi.umn.edu/user_support/ssh/
To use ssh:
ssh -l mayaan sp.msi.umn.edu
Where 'mayaan' is your user name and sp.msi.umn.edu is the name of the machine you are
ssh-ing to. (You can also use an IP address instead.) You only need to add your user name if it
is different on the machine you are logging on to. Otherwise just use:
ssh sp.msi.umn.edu
If you want to be able to use molden or open emacs buffers in a new window then you will also
need to use the options:
ssh -X -Y sp.msi.umn.edu
to enable X11 forwarding. (Usually you will want to do this.)
When you ssh to a particular machine for the first time, it will ask you if you want to add
them to your list of known hosts. Later, if the name of a machine you have ssh-ed to or from
in the past is changed, it will create conflicts with the ssh security keys your machine has
saved. If you get this warning, go into the .ssh/known_hosts file within your home directory
and delete the old offending key. It will look something like this:
pinot-noir 1024 35 1291129784473943918414976868999086549
86410415517156181529778994379806391528830362867173995734
66658080759778377074425427610673221589448680346317493289
5288707144936026451479604363236711070229633796081649813
Most of the files you create in LINUX will be made with a file editor such as emacs, xemacs or
vi. Usually emacs and vi will already be installed on your machine. To open a new file with
emacs type:
emacs filename
If you want to keep using the command line in your terminal while the editor is open you can
type:
Ctrl-z
bg
which places your currently opened file in the 'background'. Or open the editor instead with:
emacs filename &
If you want to bring the editor into the foreground again type:
fg
As long as the editor (or any program for that matter) is in the foreground, you can close it by
typing:
Ctrl-c
(This isn't the best way to close most programs. It usually comes in most handy when you
accidentally open something and want to quit out of it immediately.)
Whenever you want to learn more about how a specific command works, you can type:
man command or command --help
and a help page will pull up that explains the command details to you.
Some common programs we use in the lab that you may want to familiarize yourself with are:
molden (for viewing Gaussian .out files or creating .xyz or z-matrix files)
vmd (for viewing CHARMM pdb and dcd files)
xmgrace or tecplot (for making data graphs)
cvs (for storing and accessing files)
latex or pdflatex (for creating/compiling LaTeX documents)
gnumeric (for creating spreadsheets)
xpdf or acroread (for viewing pdf files)
gimp (for editing image files)
tkYorkLib.pl (for looking up journal references)
ooffice (stands for OpenOffice and is a complete set of word processing, spread sheet, and
presentation software similar to what you may be used to from Windows)
Additional information about using and obtaining most of these programs can be found on
the Software link of our York Group Intranet.
To search within all the files of a directory branch for a word or phrase type:
find . -type f -print -exec grep -i 'searchword' {} \;
You can also use:
grep -i 'searchword' */*.src90 | grep INE
where "*/*" will search both the current and next lower directories, and "| grep INE" will
filter out all the lines found with 'searchword' which don't also contain "INE".
To find any file that has been on your computer for more then a day type:
locate filename
In addition to editors like emacs, you can also edit files directly from the terminal using sed,
the built-in stream editor. You can use it to make substitutions or deletions in a file with
commands such as:
sed 's/oldword/newword/g' filename
which substitutes "newword" for "oldword". The "g" makes the substitution global (all
instances on that line). Without the g, it will only change the first match on that line.
Other sed commands:
sed 's/word/d' filename
This deletes the whole line, not just the word. To delete just the word:
sed 's/word//' filename
The examples given will print out the changes to the terminal. If you want to print the
changes to a file instead type:
sed 's/oldword/newword/' filename > newfilename where > directs the output into a file
called newfilename
To link more than one command together use &&. For example:
sed 's/oldword/newword/' filename > newfilename && emacs newfilename
If you want to look at the contents of a tar file before you untar it use:
tar -t filename.tar
If you then decide there is only a small part of the total tar file you actually need to extract,
type:
tar -zxvf tarfile filepath
If you have a large number of files you wish to transfer you can make it simpler by tarring
them first:
tar -cvf file.tar directory_to_tar
(Make sure you don't reverse the order of "file.tar" and "directory_to_tar"). Then to zip it
type:
gzip -cv file.tar
Or better yet, do it all at once with:
tar -zcvf
On our SGIs, this must be done with the command:
tar -tvf file.tar directoryname instead.
Here's a neat trick for transferring a tar file to another machine that will tar "on the fly"
rather then requiring you to create a tar file on your own machine first. (Which can be useful
if you don't have much space left.) To do this simultaneous tar, zip, and transfer type:
tar --rsh-command=`which shh` -zcvf -- --host_computer:filename.tar -- --
directory_to_tar
Note that "which ssh" needs back-ticks rather than apostrophies.
After you uncompress a program tar file you will usually still have to install the program
yourself. The usual directory to install programs in is /usr/local/. (You will need root
permissions.) Look for a README file in the file's source code to get further instructions.
An easier method of installing programs though is to get a rpm package rather then a tar file
for a program whenever possible. Rpm packages do all the work of untarring and installing
for you. A good source for these files can be found at:
http://linux.s390.org/download/rpm2html/index.html or
ftp://ftp.software.umn.edu/pub/linux/redhat/redhat-9-en/os/i386/RedHat/RPMS
(Note that this particular link is for people using Redhat 9 but if you go up a few directories
you can get to the directory specific to the LINUX version your using).
An even easier way to install things is to use a program that grabs and installs all the rpms
you need for you. One such program (which you may already have installed) is called yum and
you can get it from: http://linux.duke.edu/projects/yum/download.ptml. Once yum is installed
you can install new packages by either:
yum install packagename
for a specific package or
yum upgrade
to get everything newly available for your LINUX version.
To see where the executable for a program you want to run is type:
which executablename
If you want to be able to run a program from anywhere in your directory tree it needs to be
"in your path", meaning in the list of places it will look for it. (You can see what is currently
in your path by typing the env command mentioned above). The directory "~/bin" is always
in your path and is a good place for personal programs/files. To run a program file though
you will also need to have executable permission for that file.
If you want to use a file/program that is in a different directory but you don't want to actually
move or copy the file/program over, you can instead make a link to it. There are two types of
links, hard and soft. To make a soft link:
ln -s filepathtoexecutable placetomakelinkto
for example:
ln -s ~/CVS/DataBase/Semiempirical-SRP/Utilities/EXE/GenRefGeomData .
where the "." stands for the directory you are in.
A soft link is usually preferable to a hard link, as a hard link will delete the actual file if you
delete the link.
This is often used to set up a link to an executable from your "~/bin" directory because it
allows you to run the executable from anywhere in your directory tree.
If you want to make up your own command name to stand for something else, you can make
an alias. Make a file in your ~/bin directory named what you want your command to be.
Then, inside of the file put the commands that you want it to execute when you type your
command. For example, you can make a file called "sl", inside of which is the command ls.
(That way, every time you accidentally type sl instead of ls, it will still execute ls.) Make sure
you give the file executable permission or you won't be able to run it.
Checking Processes
To find your IP address:
/sbin/ifconfig
and look for inet addr:
To see how much disk space is being used by a directory tree branch:
du -sh directoryname
To see the space used per directory in a branch:
du | sort -nr | more
To see total space used for each disk partition:
df -h
If something running on your machine is taking up too much of your processor, you can
change its priority by 'renice'-ing it. To renice something, first run top:
top
then type r at the cursor prompt. It will ask you which PID you would like to renice (the PID
found in the left most column). Finally it will ask you what renice value you would like to set
the process to. Entering a positive value (something like 20) will lower your job's priority
while a negative one will raise it.
If the process you want to change belongs to another user, you will have to be root to be
allowed to change it.
To see the parent to child branching for all processes running type,
ps afx
This will tell you, for instance, which programs are running out of each terminal and will give
you the PID for each process too.
Supercomputers
There are a number of supercomputers available for use at MSI to help you run jobs more
quickly using multiple processors. To find a full list of your machine options go to:
http://www.msi.umn.edu/user_support/
You can also use the Linux cluster we have available in our own lab. To find out more about
what computers are available on this go to:
http://theory.chem.umn.edu/Group/Private/compinfo.html
To change your password type passwd and follow prompts. (This works on our Linux
machines too).
To temporarily (1 day) stop our Linux cluster jobs from running on your machine:
nodemodify.pl pause computername
or to remove your computer from the Linux cluster:
nodedown
and to re-add it again:
nodeup
Note than when you are off the cluster other people can't run their jobs in cluster queue on
your machine but you can't run your on theirs either.
In order to use many of the programs available on the MSI machines you will have to load a
module first. Going to http://www.msi.umn.edu/user_support/software/all.html and finding
your desired program will usually tell you how to do this.
To make computer usage equally distributed between all users, the supercomputers use a
queuing system. You have to submit large jobs to the queue in order to have them run (rather
than run them interactivly like you can on your own machine). To put something into the
queue system you need to make a submission script file. The format of these files is a different
depending on which supercomputer you running are on. For instance, on the netfinity, a
multiple processor submission script file looks something like this:
#PBS -l nodes=4:ppn=2,mem=1000mb,walltime=96:00:00
#PBS -m e
cd ~/charmm/projects/
mpirun -np 8 ~/charmm/projects/charmmpar < ribo379_ionequil.inp >
ribo379_ionequil.out
On the sp:
#!/bin/csh
#@ error = err.err
#@ job_type = parallel
#@ wall_clock_limit =3:00:00
#@ network.MPI = css0,shared,US
#@ node = 4
#@ tasks_per_node = 2
#@ node_usage = shared
#@resources = ConsumableMemory(500)
#@ queue
If you are running Gaussian jobs, however, you can have the submission script created for
you. First load the Gaussian module:
module load g03
then create the submission script and submit it to the queue simultaneously with:
qg03 -p 2 -t 96:00:00 -m 512mb jobname.inp
where "-p 2" is the number of processors you want, "-t 96:00:00" is the amount of time you
want (each system has an upper limit on this) and "-m 512mb" is the amount of memory you
need. Make sure you set this to match up with what you put in your Gaussian input file.
You can find out more about the queuing systems by going to
http://www.msi.umn.edu/user_support/ and selecting the link for the system you are using.
To check the status of a job that has been submitted on the netfinity:
showq or qstat | grep username or
qstat -f jobid if you need more information.
On the sp: showq or llq | grep username
showq can also be used to see how many processors are available.
Once a job has been submitted you can find out how soon it will run by:
showstart jobid
To delete a job after it has been queued, first use qstat or llq to find the job id. It will be
something like this: "17147.ofs". Then:
On the sp: llcancel jobid
On the netfinity: qdel jobid
InsightII is only available on the bscl supercomputer machines and you may need to email
them to get an account set up. To use InsightII remotely:
source /usr/local/biosym/cshrc
InsightII -axxess
(It may give you some error messages but it should still work.)
To make molden stop beeping!:
xset -b
(Sorry I can't help you with InsightII).
To use babel on the supercomputers you will need to be in bash shell first (just type bash at
the command prompt to get this). Then:
export BABEL_DIR=`pwd`
Miscellaneous
If your computer freezes, it is best to not just shut it off. First try going to another computer,
shh to your machine and become root. Then use the top (see info on using top above) to kill
the job that is causing the problem.
You can also try:
Ctrl-F4
to open another session on your own computer amd run top from there. Then to get back to
your session:
Ctrl-F7
If you have a floppy disk you want to look at the files on type:
mount /dev/floppy
or if it is Windows formatted:
mount -t vfat /dev/fd0 /mnt/floppy
You will have do be root to do this or have permissions for this device. When you are done,
unmount the disk with:
unmount /dev/fd0
To read a cd:
mount /dev/cdrom
cd /mnt/cdrom
Some of the newer LINUX versions will mount things like disks, cds and flash drives
automatically.
To play a cd:
xplaycd &
To compile a program you've written in fortran with a Makefile, checkout the directory:
~/CVS/Software/Configure
and copy the file prog.mk to the directory your program is in. Edit the file to be specific for
your program. Then type:
configure
(which should be in your path) to create your Makefile. Now to compile your code type:
make
If you do not have a Makefile you can compile with:
f95 filename
It is often useful to create shell scripts for carrying out tasks. For instance, if you want to
change the names of many files at once, instead of changing each one separately, you can do
this by typing the following set of commands:
for i in `ls *.dat`
do
mv $i `echo $i|sed 's/dat/txt/'`
done
This will substitute "tex" for "dat" in each filename that ends in "*.dat".
Or, if you wanted to run a number of jobs in succession, you can create your own submission
script. First open a file named what you want your script to be called. Then type:
#! /bin/sh
To turn off beeping, go into Current Profile under the Edit menu of one of your terminals and
de-select terminal bell. You will have to re-login for this to become permanent.
To get rid of a CVS sticky tag on a file (usually created when checking out an older version of
a file), first make a backup file, then:
cvs update -A
To get a previous cvs version of a file, first:
cvs log filename
to list all previous versions, then: cvs update -r version filename
To change to font settings of your emacs editor, left mouse click inside the emacs buffer while
holding the shift key or go into xfontsel.