Tuesday, February 26, 2013

Setting up a Linux server at home

A little project that I took on today is to establish my newly built Linux box into a network server, which I can remotely login via SSH Secure Shell.

Here are the steps that I took to set the home VAIO machine as a Linux server for SSH access:

1. First I installed OpenSSH server on the home Linux box:
    "sudo apt-get install openssh-server"

2. After successful installation, the server should starts automatically. Then I tested the SSH on the server end:
    "ssh localhost"
    It should prompt me to enter a password for authentication.

3. Now the server is up and running. But in order to access this server from a remote computer (outside your home LAN), we need a static domain name for it. Usually under DHCP, the ip address of the home Linux box is changed from time to time. We can use dynamic DNS service to link the actual ip address to a given domain name. To do that, I logged on to www.no-ip.org, signed up for an account, and added xpennyhuang.no-ip.org as the domain name for the home Linux box. Then I downloaded and installed a client onto the Linux box, to update the dynamic ip address to the domain name (the name of the client package is called no-ip2, which requires a build from source).

4. One last step we needed to do to enable the SSH access is to correctly set the "Port Forwarding" for the SSH service. The idea is, my Linux box is connected to the internet with via a router. From the point of view of external hosts on the internet, my Linux box ip address is invisible to them. Therefore, in order to allow external hosts (a remote computer) to access my Linux box for certain services(eg. SSH here), we need to set up "Port Forwarding". This is done on the Verizon router page/Firewall Setting/Port Forwarding.

5. Finally, with everything setup as mentioned above, we can test the access from a remote PC. I tested with a Windows PC running SSH Secure Shell.

6. To start, stop or restart the SSH server, the following commands can be used.

-To start the server: $sudo service ssh start
-To stop the server: $ sudo service ssh stop
-To restart the server: $sudo service ssh restart

Monday, February 25, 2013

Linux system administative commands

Here are a few useful commands for system administration in Linux:

last : to show you the people who have logged into the computer today and the terminals they are/were using.

df -h: to show the utilization of the hard-drive capacity.

du -h: to show the size of a file, or a directory (including all sub-directories).

free:  to show how much RAM memory you have free on your system.

top: to show all active processes that are running in the system, and the resource they are hogging (cpu, memory)

ps: to show a list of processes running on the system. 

Sunday, February 24, 2013

Linux File System

Linux has its own rules in where to put things. Here is a list of the basic file system.

/: root, it is the origin of whole file system.

/bin: most of the basic programs related to day-to-day operation, such as 'cd', 'rm', or 'ls', are stored here.

/sbin: this folder also hosts executable programs, not intended for users, but meant to be run by the system.

/etc: this folder stores all the system configuration files.

/lib: this folder stores share library files which can be called upon by other programs, usually dynamically.

/boot: the kernal of the Linux OS is located in this directory.

/var: files with variable sizes, such as database, emails, log files and etc.

/tmp: temporary files that are created during programs' runtime are usually located here.

/dev: all devices, including hard-drives, monitors, CD-ROM, flash drives and etc., are mapped as files, and stored in the /dev folder.

/home: personal files for each users are stored in their respective directories under /home.

/usr: programs installed by users are installed here.

Embarking on Linux Journey...again.

Been a fan of UNIX/Linux for years since graduate school. My first encounter of Linux was the cluster that Bin and I built back in 2004-5 for numerical analysis and electron microscopy simulation. Later I awarded myself an Apple Powerbook that runs on MacOS X, which is also a flavour of UNIX. However, my UNIX/Linux journey came to a halt since late 2007, when I started working for first job, which did not require much programming skills. It only starts to come back recently as my current job involves some finite element method simulation of electro-optical systems.

A lucky coincidence is that, my wife's company gave her a new PC for her job, thus retiring her old Sony VAIO laptop. The VAIO has been gathering dust for months, and with a clunky 5-year-old Windows Vista running painstakingly slow. A random point in last couple evenings, I saw the word Ubuntu flying by. Immediately, I made the decision of turning my wife's retired VAIO, into a Linux machine, purely for relearning Linux, programming and numerical analysis. After about half an hour of installation, the VAIO laptop now boots with Ubuntu 12.10. A clean and stable system, and I don't have to worry about installing anti-virus software.

 The first few packages that I installed following the OS are:
-Vim, my favorite text editor
-Python, a great high-level scripting language that I recently started learning -Numpy, a numerical analysis module for Python
-Scipy, a scientific analysis module for Python
 -Matplotlib, a scientific plotting module for Python

I expect to use Python-Numpy-Scipy-Matplotlib to do a lot of things that other people do with Matlab on Windows PC. I am also glad to find that one can also install Microchip's MPLAB IDE and XC18 compilers on Linux (for PIC micro-controller programming). I will wait a little bit, but probably won't be long.