Astronomy computer Linux Note


有时候你想在一个目录的所有子目录下批量建立文件夹,并且批量的运行这些子目录内新建立好的文件夹内的 IDL 程序,以下是一种可能的解决途径,如果你有更好的方法,欢迎告诉我

Here are the things I want to do:

  1.  I have a data folder containing many sources, like Arp220, NGC981, etc.. Each of them possesses a folder under the whole data folder (./source/Arp220, ./source/NGC891, …). I want to create a subfolder named “plot” under each sources folder, e.g., ./source/Arp220/plot.
  2. And then I want to copy the IDL routine to each “plot” folder I just created and run all the PRO routines at one time.

Here is a bash script being able to do such things:

for i in $(ls -d */); do mkdir -p $i/'plot'; done
for i in $(ls -d */); do cp ./ $i/'plot'/; done
for i in $(ls -d */); do cd $PWD/$i/'plot';idl -e ".r ./"; cd ../.. ; done

The first line means creating a “plot” folder under all the subfolders under you present folder. And the next line is to copy the IDL routine ( to each “plot” folder you created. The last line runs all the IDL routines.


find ./* -type f|grep X|while read file; do rm "$file"; done

比如你要删除“./you suck/arXiv.pdf“这种文件。上面那句话中 -type f|grep X|while read file 是为了保证有空格的目录也可以被写入到一个变量里面


find ./* -type f -name "*X*" -exec rm {} \;
Astronomy computer Internet Linux Note

Obfuscated ssh Client under Linux

SSH is a powerful tool not only for astronomers. We often use it to download observation data from the observatory’s server or run some complicated programs on remote (overseas) servers. But for the reason as we all know, the SSH tunnels are always being obstructed. So we need some technique to get over such obstruction. Therefore, the obfuscated SSH turns out to be a sufficient method.

I will describe how to use obfuscated SSH_TUNNEL under Linux as below:
(Original Code: Here)


cd ./brl-obfuscated*
./configure  --prefix=/usr/local/newssh --sysconfdir=/etc/newssh
make install

Then you need to configure the ssh server following the guide here.

Then use this to run the ssh client:

/usr/local/newssh/bin/ssh -N -v -Z ObfuscateKeyWord -p ***** username@hostname -D

There are 4 parameters you need to specify: “ObfuscateKeyWord” is the obfuscated keyword you set in the configuration file (sshd_config) of the server, “*****” is the ssh server port number, “username” and “hostname” are as the name described.

Astronomy Linux Note

Forwarding port behide a router

Yesterday I was trying to configure my computer behind a router to enable it for the SSH connection from outside the router. After some google-ing, I found many ways all involving changing the iptables rules, but all turned out to be failures. Finally, under the help of Daizhong, I found the working way to configure my computer in order to solve the problem.

Before beginning all the operation below, you need to setup the router to fix your IP address and set the forwarding port through the ADMIN page (normally is of your router(two steps, first is fixing your IP address and then set the port forwarding).

The following steps are:
Firstly, you need to edit the SSHD configuration file

vi /etc/ssh/sshd_config

to enable the port forwarding you set on the ADMIN page of your router.
Then, you need to edit file

vi /etc/services

to set the value of ssh port to the number you gave before.
After that, you should set the firewall either using terminal or UI tools to allow the port for ssh. The terminal way is by adding the following line into the file /etc/sys config/iptables:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport XXXX -j ACCEPT

put your port number to the position of “XXXX”.
In the end, you should set the port allowed under SELinux using:

 sudo semanage port -a -t ssh_port_t -p tcp XXXX

In the end, you can restart the sshd and iptables for a test, by using:

service sshd restart
service iptables restart
ssh username@ip -p XXXX


Note all the commands above need superuser account.

Astronomy Linux Note

pgplot quick install guide

Here you can follow the steps to install pgplot on you linux OS.
First, you need to be sure you have X11 lib development packages installed, and then just follow the steps copied as below:

cd /usr/local/src
tar -zxvf pgplot5.2.tar.gz
cd pgplot
mkdir /usr/local/pgplot
cd !$
cp /usr/local/src/pgplot/drivers.list .

then use vim to edit drivers.list in the directory, choose the PSDRIV 1,2,3,4 for EPS figures and XWDRIV 1,2 for X-window output. And then

/usr/local/src/pgplot/makemake /usr/local/src/pgplot linux g77_gcc
ln -s /usr/bin/g77-3.3 /usr/bin/g77 
#(if you have g77 you can skip this, 
#or if you have g77-**, please use g77-** instead of g77-3.3)
make cpg

And then replace the first line of /usr/local/src/pgplot/makehtml with #!/usr/bin/perl, run

make pgplot.html
make clean
cd /usr/local/lib
ln -s /usr/local/pgplot/libpgplot.a libpgplot.a
ln -s /usr/local/pgplot/libcpgplot.a libcpgplot.a
cp /usr/local/pgplot/ .
/sbin/ldconfig -v
ln -s /usr/local/pgplot/cpgplot.h /usr/local/include/cpgplot.h

Then, setup the environment variables. If you want to use bash, just edit /etc/bash.basrc file, adding

into it. If you want to use tcsh/csh, you need to edit /etc/csh.cshrc file by adding

setenv PGPLOT_DIR /usr/local/pgplot/ setenv PGPLOT_DEV /xwin

into it. Then re-login your bash/csh/tcsh and go to the /usr/local/pgplot directory and run demo to check whether you successfully installed pgplot as

cd /usr/local/pgplot

All the steps are taken form: with some little variation by myself. And this is a part of LensTools intallation, and the most difficult part of it.