Computational Chemistry Using Linux
Computational Chemistry Using Linux
February 6, 2017
Contents
1 Basic Commands 2
2 Changes 2
3 Services 3
3.1 sysvinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.2 systemd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4 Network 4
4.1 NIS Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.2 NFS Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.3 VPN Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
5 Packages 5
5.1 Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5.2 Computational Chemistry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
6 Security 7
6.1 NO iptables for the future?. FirewallD a new XML based firewall . . . . . . . . . . . . . . . . . . . 7
6.2 TCPWrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
6.3 iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
6.4 ssh port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.5 SElinux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.6 Close Unsecure Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
7 Software Details 8
7.1 MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
7.2 postgreSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
7.2.1 User Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
7.2.2 Querying a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7.3 Django . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
7.4 R packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
7.5 Rapache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
7.6 gitweb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.7 Wordpress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.8 Wine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.9 Apache Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.10 Latex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.11 Gnome 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.12 VNC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1
8 Linux Tricks 15
9 Fedora Tricks 15
10 Links 15
11 Complaints 15
12 Missing in Linux 16
1 Basic Commands
This document is a constantly changing and expanding guide to linux mainly for computational chemists but also
for scientists in general, and perhaps for those interested in keeping up with the latest developments in the Fedora
Linux distribution (current version 25).
Linux is an operating system which shares a very similar philosophy to that of UNIX [1]. There are many linux
distributions (distros) and a place to check-out new ones and the status of the standard ones like Fedora, Ubuntu,
SuSe, Slackware, Debian, etc, is distrowatch.com [2].
Nowadays the terminal program is hidden more and more from the user, so this is the first effort that the new
user has to make in linux. Once a terminal is running the user can start playing around with many commands.
Perhaps the most valuable information that can be given to the new user at this point is on the existence of the
command man. The man command shows you information on any linux/unix command, for example:
bash> man ls
Will show you information related to the list (ls) command. The ls command does just that, it lists the files in
the folder you are positioned at. To know where you are located at, you can use the command pwd (print working
directory), and to move away from there the command cd (change directory), for example:
bash> pwd
/home/username
bash> cd Desktop
bash> ls
Trash
2 Changes
Fedora 22 came with the great surprise that the yum package manager is being deprecated. The reasons for this
are yet unknown to me, perhaps there is good reason as there was also good reason for systemd from Lennart
Poettering, but, for now, just headache. The new package manager is called dnf.
2
bash> dnf update
bash> dnf upgrade
bash> dnf install emacs
3 Services
Starting with Fedora 15 a switch was made from the sysvinit system and service manager to systemd, so the
services management administration has changed accordingly but for now one can still use sysvinit. One can
find the scripts which start services at: /etc/init.d.
You can call them directly like so:
3.1 sysvinit
Or you can call them using services:
You can also control which services get started or not at boot time depending on the runlevel that your system is
going into with:
You can also check the list of what services get turned on depending on runlevel with:
sudo chkconfig
3.2 systemd
The new way to control services in systemd is done using the command systemctl, so, for example to query the
status and restart the httpd service you have to use the commands:
Fedora 24 by default does not start the ssh daemon, so youll have to enable it for every time the system
boots-up, and youll also have to start sshd.
Fedoras description of the systemd system and service manager, systemd is at:
http://fedoraproject.org/wiki/Systemd
3
4 Network
4.1 NIS Client
In Fedora you have to :
include your nis server in /etc/sysconfig/network
NISDOMAIN=nisserver.ki.se
Then modify /etc/sysconfig/authconfig
USENIS=yes
To configure a NIS client you will have to modify the files:
yp.conf nsswitch.conf
According to how your administrator has setup your internal NIS.
Sometimes your NIS may hang, supposedly you can change a little bit how things are organized in nss-
witch.conf to make things move a little bit faster.
https://bugzilla.redhat.com/show_bug.cgi?id=183188
Make sure to look at /etc/auto.master to see if its going to the export that has been setup at the NFS server side.
You will also need to have a soft link calling the NFS exported partitions. e.g.
ln -s /net/myosin/u1 myosin/
One can have various problems with the NFS connection to audit them you can use:
df -F nfs
showmount -e shamu
showmount -e cod
nfsstat -c
rpcinfo -u shamu nfs
automount -t 3600
http://docstore.mik.ua/orelly/networking_2ndEd/nfs/ch09_02.htm
4
Gateway: vpn.rutgers.edu
Group name: rutgers-ipsec
Group password: rutgers
User name: myusername
Domain: rci.rutgers.edu
5 Packages
One important reason for linux distributions becoming more appealing to general (windows and mac) users since,
say, ten years ago, is the genesis/development of package managers. The main package managers are apt-get
(Debian-based or FreeBSD), and yum (RedHat based distributions - soon to be replaced by dnf but retains
compatibility with yum).
The following is a list of frequently used yum functions:
Care should be taken on these automatic updates if there are special hardware configurations, say, a special
graphics card, or a non-supported wireless device.
On installing a new Fedora I usually need the following packages.
5.1 Python
jython: Java like Python
pyopengl: OpenGL for python
5
5.2 Computational Chemistry
As a computational chemist you want to hit your molecular problem with as many tools as you can. In an ideal
world perhaps all of the following programs would be available in a correctly set-up machine. Some of the
following packages can be installed directly via yum (dnf), but many cannot. Some might even be windoze. Some
are free, some are expensive.
FREE
================================================================================
Viewers
--------------------------------------------------------------------------------
avogadro: a molecular viewer with openbabel integration
chimera: molecular visualization from Thomas Ferrin
ifort: intel fortran
jmol: java like rasmol/pymol
king: molecular visualization from Richardsons lab
molden: for viewing quantum chemistry results
molekel: for viewing quantum chemistry results
prekin: generate files for king from pdb also from Richardsons
pymol: can be installed with yum, but not latest version.
vmd: molecular visualization from Schulten lab.
PAY
================================================================================
Viewers
--------------------------------------------------------------------------------
chemdraw: best chemical cartoons
hyperchem: molecular visualization some calculation -- windoze -- expensive
maestro: from the schrodinger bundle 3D and 2D view and draw
poseview: protein-ligand complexes in 2D
6
6 Security
6.1 NO iptables for the future?. FirewallD a new XML based firewall
So, starting with fedora 18, theyve decided to switch to another type of securing ports and services in Fedora.
The new thing is called firewalld and, although quite ignorant about it for the time being, it smells like this is upper
red-hat, NSA influenced.
Google fedora firewalld for info.
Reading more into this there seems to be a general opinion that the main difference between iptables and firewalld
is on how the configuration of rules is taken care of. In firewalld XML configuration takes over.
To stop firewalld if needed use systemd:
6.2 TCPWrappers
To completely close all your connections the first line of defense against intruders is TCPWrappers. You just
have to make sure that the file /etc/hosts.deny has just one line, that is: ALL:ALL Which will stop all ip addresses
from being able to connect to your computer. The next level of security is to open only those ports and protocols
which you want to keep open to the outside world given a set of allowed ip addresses. You do this by modifying
hosts.allow, for example:
ALL:127.0.0.1
sshd: .rutgers.edu
sshd: .ccb.rutgers.edu
sshd: 172.16.65.0/255.255.255.0
sshd: 172.16.23.0/255.255.255.0
6.3 iptables
To DROP all connections coming from a specific IP address.
Sometimes specific ports need to be opened, for example if one runs a Schrodinger license server one needs
to open the ports 27008 and 53000. This can be done using the iptables command:
And then:
or go to /etc/sysconfig and edit the iptables file adding the next two lines:
-A INPUT -s 192.168.0.0/16 -i eth1 -p tcp -m tcp dport 27008 -m state state NEW -j ACCEPT
-A INPUT -s 192.168.0.0/16 -i eth1 -p tcp -m tcp dport 53000 -m state state NEW -j ACCEPT
Notice that 192.168.0.0 means the range 192.168.* is open, the /16 means use all allowed addresses in 192.168.X.X,
if one wanted just 192.168.0.X, then /24 at the end would be needed.
After the change one must restart the firewall:
7
6.4 ssh port
One way to drastically reduce the amount of attacks your server might be having is to change the address of
the ssh port to a high number of your preference, for example, change it to port 3146. You just have to modify
/etc/ssh/sshd_config.
6.5 SElinux
If you are using NFS as a client its better to disable selinux. You will have to modify /etc/sysconfig/selinux to read
disabled.
But, to disable it also at the kernel level you will have to go to your grub configuration file, that is, /boot/-
grub2/grub.cfg and append selinux=0 to it.
Yet another nasty of selinux is its intrusiveness even at the filesystem level. Selinux does this by labeling the
whole filesytem. The way to clean up the mess is with:
7 Software Details
For some packages like R, of django, there are some additional packages on top of them that I have to install
every time I get a new machine. I will just list them here.
7.1 MySQL
Two additional programs which make managing MySQL easier are MySQL workbench and phpMyAdmin. It is
recommended to install both in your development machine.
After installing MySQL one has to create users and their corresponding passwords, but even before one has
to check that mysql is running, and that it will be run at boot time.
mysql -u root
mysqladmin -u root password secret_password
8
7.2 postgreSQL
Connecting to a database
You can also explicitly specify if you want to enter a password -W or not -w
$ psql -w postgres
$ psql -W postgres
Password:
Once youre inside psql you can control the database. Heres a couple of handy commands
At this point you can just type SQL statements and theyll be executed on the database youre currently
connected to.
Once your application goes into production, or basically anywhere outside of your dev machine, youre going to
want to create some users and restrict access.
We have two options for creating users, either from the shell via createuser or via SQL CREATE ROLE
$ createuser john
postgres=# CREATE ROLE john;
One thing to note here is that by default users created with CREATE ROLE cant log in. To allow login you need
to provide the LOGIN attribute
You can also add the LOGIN attribute with ALTER ROLE
You can also specify multiple attributes when using CREATE ROLE or ALTER ROLE, but bare in mind that ALTER
ROLE doesnt change the permissions the role already has which you dont specify.
9
postgres=# CREATE ROLE deploy SUPERUSER LOGIN;
CREATE ROLE
postgres=# ALTER ROLE deploy NOSUPERUSER CREATEDB; # the LOGIN privilege is not touched here
ALTER ROLE
postgres=# \du deploy
List of roles
Role name | Attributes | Member of
-----------+------------+-----------
deploy | Create DB | {}
Theres an alternative to CREATE ROLE john WITH LOGIN, and thats CREATE USER which automatically cre-
ates the LOGIN permission. It is important to understand that users and roles are the same thing. In fact theres
no such thing as a user in PostgreSQL, only a role with LOGIN permission
You can also create groups via CREATE GROUP (which is now aliased to CREATE ROLE), and then grant or
revoke access to other roles.
To retrieve data from a table, the table is queried. An SQL SELECT statement is used to do this. The statement
is divided into a select list (the part that lists the columns to be returned), a table list (the part that lists the
tables from which to retrieve the data), and an optional qualification (the part that specifies any restrictions). For
example, to retrieve all the rows of table weather, type:
10
SELECT * FROM weather;
Here * is a shorthand for all columns. [1] So the same result would be had with:
You can write expressions, not just simple column references, in the select list. For example, you can do:
Notice how the AS clause is used to relabel the output column. (The AS clause is optional.)
A query can be qualified by adding a WHERE clause that specifies which rows are wanted. The WHERE clause
contains a Boolean (truth value) expression, and only rows for which the Boolean expression is true are returned.
The usual Boolean operators (AND, OR, and NOT) are allowed in the qualification. For example, the following
retrieves the weather of San Francisco on rainy days:
Result:
You can request that the results of a query be returned in sorted order:
In this example, the sort order isnt fully specified, and so you might get the San Francisco rows in either
order. But youd always get the results shown above if you do:
11
You can request that duplicate rows be removed from the result of a query:
SELECT DISTINCT city
FROM weather;
city
---------------
Hayward
San Francisco
(2 rows)
Here again, the result row ordering might vary. You can ensure consistent results by using DISTINCT and
ORDER BY together: [2]
SELECT DISTINCT city
FROM weather
ORDER BY city;
7.3 Django
As Django is becoming one of the favorite web-frameworks for web developers now its easy to install using yum,
and so are some of its extensions. In my work Ive needed pagination and table sorting, which now are standard
in Fedora 16. To install just issue:
sudo yum install Django django-pagination django-sorting mod_wsgi
7.4 R packages
R packages can easily be installed either from their source, or if they are hosted in one of the cran repositories.
For programs which are not included in the repositories such as bio3d (an interface program to molecular
dynamics results) one can do the following after downloading the source in tar.gz format:
R CMD INSTALL bio3d_*.tar.gz
R
>install.packages("clue")
7.5 Rapache
First have to make sure that apache is running and that will run on startup.
sudo chkconfig --level 345 httpd on
sudo systemctl enable httpd.service
sudo service httpd start
sudo systemctl start httpd.service
Also have to install the httpd development package to be able to install rapache.
sudo yum install httpd-devel
12
7.6 gitweb
To install git and gitweb in fedora is pretty simple:
Now you have to modify the /etc/gitweb.conf and /etc/httpd/conf.d/git.conf. For gitweb.conf this is what I have:
$projectroot = /var/www/html/;
$site_name = "RNA-BPSDB";
$my_uri = "/";
$home_link = /;
@stylesheets = ("/git/static/gitweb.css");
$favicon = "/git/static/git-favicon.png";
$logo = "/git/static/git-logo.png";
Now you have to go to your site and make it into a git repository. You will also have to move the default gitweb.cgi
to your folder.
cd /var/www/html
git init
git add .
git commit -a
cp -r /var/www/git/ /var/www/html/git/
Finally you have to modify your gitweb.cgi, which must be in the git folder you just copied in the previous step.
You just have to find the our $projectroot variable, and modify it to the path of your git folder. In this perl script you
can also modify the header and the footer for your gitweb repository.
7.7 Wordpress
Installing wordpress was amazingly easy. I just followed the steps at http://www.if-not-true-then-false.
com/2010/install-wordpress-on-fedora-centos-red-hat-rhel and was done in a few minutes. Perhaps
the only additional information relevant here is that I am using the virtual server configuration by creating .conf
files in the /etc/httpd/conf.d folder.
7.8 Wine
Installing wine in Fedora 14 is a piece of cake, yum works right out of the box.
Nonetheless the configuration is another story. And what might happen to your X11 after running wine, will, most
likely, make you go into single user mode and back to X-mode to fix it. Worst case scenario youll have to reboot.
The interest of installing wine is that of being able to use acrobat professional to anotate pdf documents, that is,
articles.
13
7.9 Apache Configuration
It is convenient to set up apache as a virtual web server, that way you can have various sites in one server. To
do this you have to mimick the httpd.conf file (which is the main apache configuration file) with a mysite.conf file
which resides in /etc/httpd/conf.d. You can have as many mysite.conf files as you like. Some security settings
which are recommended are to deny folder indexing by changing your httpd.conf to:
<Directory "/yourvirtualsitesfolder/">
# Options Indexes FollowSymLinks
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Where Indexes has been erased from options. There are various needs that will start adding up in your
mysite.conf, for example telling it where the cgi-folder is at and to avoid giving freebies of info about your system
by turning off server signature.
7.10 Latex
There are a good amount of latex editors for Linux today. Fortunately many of them can be installed automatically
using yum in Fedora.
To install them use:
sudo yum install texmaker
sudo yum install gummi
sudo yum install texmacs
sudo yum install kile
sudo yum install geany
I mainly use emacs to write my latex documents, but sometimes you can learn new tricks with these editors.
In texmacs is nice to see that you can call various packages for your format, for example the Springer-Verlag
format for books, nice!.
If you want to use the Nucleic Acids Research latex format for publishing youll need to install additional
packages:
It seems like as of fedora 17, texlive was stuck in the 2009 version. You will have to install from scratch the
2012 version which comes with a manager called tlmgr. For some packets, like slashbox, tlmgr cant help you at
all. Youll have to download from the repositories and install to you path. In my case:
An additional package used at the website www.writelatex.com is colorlistoftodos. It allows you to comment some com-
and highlight a document by using backslash todo. ment using
some other comment but inline and not on the side colorlistofto-
dos package
7.11 Gnome 3
To configure gnome 3 system setting you will need to run the configure tool as root, so youll have to invoke it via
command line.
sudo yum gnome-control-center
14
7.12 VNC
One of the default vnc-clients in fedora is tigervnc, but its not very customizable. Another one is remmina, which
is not installed by default.
8 Linux Tricks
Some general linux tricks here.
9 Fedora Tricks
When you install Fedora or any other distro you just have to deal with whatever type of artwork they give you for
the splash screens on starting the gnome-desktop-manager (gdm). So, the trick to change this is to modify the
xml file at:
emacs /usr/share/backgrounds/laughlin/default/laughlin.xml
10 Links
This is just a collection of googled links.
A description of problems and fixes from a user whos just gotten Fedora 15 into his/her laptop.
http://www.cs.bham.ac.uk/~axs/laptop/
11 Complaints
Going from Fedora 14 to Fedora 15 and 16 has been a road full, very full, of thorns. The first problem was on
having Gnome 3 in Fedora 15 and also the switch to systemd, which makes you change all of what youre used
to, I mean, it changes everything!, its almost as a complete change in fundamentals, no more init levels, for
example. Many things are broken in Fedora 15 and 16 by default, here is a list:
If you install qt3 the links will be broken. The necessary binaries are at /usr/lib64/qt-3.3/bin
You can start having issued with the gnome-keyring bs. To disable just go to .gnome2/keyrings and erase
everything there. When you relaunch chrome, which will ask for the keyring, make sure to enter an empty
password.
15
12 Missing in Linux
One of the things missing in Linux is an easy to use pdf editor, for example something which works like preview in
Mac OSX, or like Adobe Acrobat. The task needed is very easy, or at least seamingly easy, that is, to be able to
underline, highlight, and make margin notes on pdf articles which can be modified later on by just opening the pdf
document. Such task can be acomplished easily with the mentioned softwares which are not available in Linux.
So far Ive triend the following in Linux but all fall short.
xournal #
makes unmodifiable permanent changes in pdf
okular #
same as xournal. Have to save in their format
ooffice #
bad rendering and translates it into its own format
gimp #
opens one page at a time
inkscape #
same as gimp
flpsed #
only good for writing text over
scribus #
imports pdf and shows only parts of the document
pdftk #
same story, does not natively change the pdf
pdfedit #
first have to export QTDIR=/usr/lib64/qt-3.3 to be able to
compile it in Fedora 16. And it doesnt allow you to
underline or annotate in a letter by letter fashion. It
will select the full paragraph.
pdfstudio # need to pay to get rid of watermark, same as xournal.-
This paragraphs is just to test justification and line wrapping in gedit which I would like to work like in emacs
http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
First steps
3 Remove selinux and clean selinux tags
3 Add user to sudoers
3 dnf install emacs
3 update linux
3 add repos
3 Copy .bashrc and .inputrc files
16
3 erase useless folders
3 install guest additions
Install scientific packages
3 dnf install pymol avogadro
3 rdkit
3 R, rstudio, latex
References
[1] Wikipedia Linux. http://en.wikipedia.org/wiki/Linux (2015).
17