Tag Archives: shell

pdsh – parallell distributed shell

pdsh

This a software to run commands on a set of servers.

For example ‘pdsh -a uname -av’ will give you “uname -av” of all machines.

http://techsnail.com/howtos-tutorials/installing-pdsh-on-hpc-cluster/

It can be installed from rpmforge.0

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh rpm-release*
yum install pdsh

after that you can immediately run “pdsh -w oss1,client1 uname -av” to run a command on a remote node.

It’s possible to set up so that it executes on a pre-defined list. Check out /etc/machines.

Extremely useful if you want to save some time :)

Installing Squid 3.2 on CentOS 5.3

Giving this one a shot :) I will be compiling it myself as well.

Squid for those who do not know is a proxy server.
Proxys can be used for many things, but one great thing if you have a thinner connection to the Internet, you can use this to speed things up a bit. What it does is when you surf the web, the things you download are actually first downloaded to the proxy, and then your browser downloads it automagically from the proxy. If you afterwards browse to the same page the proxy should provide you with a cached copy and not re-download the whole page again.

Downloading/compiling

It’s a good idea to not run any service as root.

  1. Download it from http://www.squid-cache.org/ there are many options to chose from. Stable, unstable, 3.2, 3.1 etc. I just took a recent developer build from the 3.2 chain – squid-3.2.0.6.
  2. Untar this somewhere, doesn’t matter where. Move directory and:

To get the program to install itself in a location where you have access, you need to specify that while running the configure check.

You do this with:

./configure –prefix=/home/user/bin/squid-install

or wherever you want to put it. I just put it directly in /home/user/squid-inst.

If that completes without errors next step is to: make; make install. This will compile and then install it in the directory you specified above. After that completes sucessfully you can delete/hide the directory. I hide it just in case I want to change something in the configure or whatever.

Then it’s time to configure!

Now proxy servers you need to put some kind of authentication on. Unless you want a hoard of unwanted visitors.

There are a gazillion of different settings in the squid.conf.documented.

Configuration is done via ~/squid-inst/etc/squid.conf

cache_dir ufs /usr/local/squid/cache 100 16 256
The value 100 denotes 100MB cache size. This can be adjusted to the required size.
http_port 3128
This is the port you will be connecting to. Make sure you do not set one that other services on the machine uses. Might be a good idea to use a non-standard as well, to prevent some from “stumbling” onto it and trying to brute-force it.

Starting squid

  1. create cache directories with ~/squid-inst/sbin/squid -z
  2. run it in debug ~/squid-inst/sbin/squid -NCd1

If everything is working fine, then your console displays: “Ready to serve requests”.

You can now surf to your http://host:port

However, you cannot use it as a cache yet.

You need to set up the http_access part. The ACL – access list.

This can be complicated.

See here for some examples of that: http://wiki.squid-cache.org/SquidFaq/SquidAcl

However, all you “need” is as below. First, find out your IP-address. Let’s say it’s 12.24.48.96 for the fun of it. You can see what it is by surfing to www.ripe.net

add this somewhere on top near the other “acl” entries:

acl me src 12.24.48.0/24

Then a bit further down

http_access allow me

Now if you want to you can be more tight with the security, and you probably should.
The setting above means that everybody on that subnet can use your proxy server.
For example you might want to change it to only your IP – if you have a static one.

acl me src 12.24.48.96/32

If you change something in the configuration, you can do this to stop squid:

~/squid-inst/sbin/squid -k kill

~/squid-inst/sbin/squid &

is used to start it in a daemon mode (keeps running after you log off your shell).

There are other ways to set up password checks (used to be with .htpasswd) but I have no need for this today. I’ll have a look into it some other day :)
Also this proxy is transparent – meaning if you connect somewhere, people can see that you are indeed connecting through a proxy.

But first you need to set your browser to use the proxy, you do this under network settings.

Happy proxying!

The bash shell – Linux terminal keyboard shortcuts

Hey!

Recently found out that there are some quite awesome shortcuts available that I’ve missed – extremely useful if you use the bash shell in *Nix.

To see which one you are using you can type ‘chsh’ in a terminal – this will tell you if you are using /bin/bash.

Go try them out! This can speed up your work in the terminal incredibly.

** Updated 2011-04-05 – there are many moooore!
See this little link: http://www.faqs.org/docs/bashman/bashref_93.html#SEC100

You can see the bindings by typing “bind -P”

The easier shortcuts:

Ctrl + A Go to the beginning of the line you are currently typing on. Extremely useful in those scenarios when left/right arrow keys do not work. Same as HOME button.
Ctrl + E Go to the end of the line you are currently typing on. Same as END button.
Ctrl + L Clears the Screen, same as the clear command.
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Backspace.
Ctrl + R Let’s you search through previously used commands. Hit again to roll through the hits in the history. Searches through .bash_history in the user’s home directory.
Arrowkeys Up/Down Same as CTRL + P and CTRL + N. This will browse through the history. Hit enter to execute the command.
Ctrl + C Kill whatever you are running.
Ctrl + D Exit the current shell – logout.
Ctrl + Z Puts whatever you are running into a suspended background process. You can then use the terminal for something else.
Type ‘fg’ in the terminal to restore the process.
Ctrl + W Delete the word before the cursor.
Ctrl + K Clear the line after the cursor.
Ctrl + T Swap the last two characters before the cursor.
Esc + T Swap the last two words before the cursor.
Alt + F Move cursor forward one word on the current line.
Alt + B Move cursor backward one word on the current line.
Tab Auto-complete files and folder names.
Shift + Page Up / Down Scrolls through terminal buffer.

 

The shortcuts that are a little trickier:

Ctrl + X * In a directory you have two files: awesomeapp1.deb and notawesomebutneededapp4.deb. You want to install both. In debian the program you call is “dpkg -i filename.deb”. If you don’t want to write out all the names, you can type this: dpkg -i *.deb CTRL+x * (first ctrl+x and then press the * on your numpad or * on your normal, like shift+’) and then it will resolve the names so that your command will be “dkpg -i awesomeapp1.deb notawesomebutneededapp4.deb”
Ctrl + X Ctrl + V Prints something like this: GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Macros CTRL +X ( to start, CTRL +X ) to save. For example: first hit CTRL+x SHIFT+8 (this is on my keyboard layout) – then put in your commands. Everything you type after this is saved in a macro. Then CTRL+X SHIFT+9 to save. Then hit CTRL+x e to run the macro.

Have fun!