os – functions for various operating system operations
os.path – functions for manipulating directory/folder path names
sys – functions for system-specific programs and services
time – functions for program timing and returning the current time/date in various formats
filecmp – functions for comparing files and directories
tempfile – functions for automatic creation and deletion of temporary files
glob – functions for matching wildcard-type file expressions (e.g., "*.txt")
shutil – functions for high-level file operations (e.g., copying, moving files)
struct – functions for storing numeric data as compact, binary strings
gzip, bz2, zipfile, tarfile – functions for writing to and reading from
various compressed file formats
pickle – functions for converting any Python object to a string that can be written to or subsequently read from a file
hashlib – functions for cryptography / encrypting strings
socket – functions for low-level networking
popen2 – functions for running other programs and capturing their output
urllib – functions for grabbing data from internet servers
ftplib, telnetlib – functions for interfacing with other computers through ftp
and telnet protocols
audioop, imageop – functions for manipulating raw audio and image data (e.g.,
cropping, resizing, etc.)
I am fascinated by a lot of stuff, such as foreign policies, social justice, education, technology and economics. Recently I found myself passionate about street photography.
Tuesday, March 5, 2013
Saturday, March 2, 2013
A few ways to check hacker attacks on Linux machines
Professional hackers probably will not leave obvious fingerprints. But there still benefits to check if your Linux server is under attack from malicious hackers. Here are a few ways to check.
1. /var/log/auth.log file. This log file logs all the log in information in and out of the system, including system processes, and users log in.
grep 'Failed password' /var/log/auth.log: this command checks if someone is trying to brute force a login via password enumeration;
grep 'Accepted password' /var/log/auth.log: this command checks if anyone managed to log into the system without your knowledge.
2. lastlog command. This command, extracts information from the auth.log file and display them to the terminal. It also shows system processes as well. So if you are only interested as human login, we can use the following command line to filter out system processes:
lastlog | sed '/Never/d' | less
1. /var/log/auth.log file. This log file logs all the log in information in and out of the system, including system processes, and users log in.
grep 'Failed password' /var/log/auth.log: this command checks if someone is trying to brute force a login via password enumeration;
grep 'Accepted password' /var/log/auth.log: this command checks if anyone managed to log into the system without your knowledge.
2. lastlog command. This command, extracts information from the auth.log file and display them to the terminal. It also shows system processes as well. So if you are only interested as human login, we can use the following command line to filter out system processes:
lastlog | sed '/Never/d' | less
Friday, March 1, 2013
Useful log files in Linux
=> /var/log/messages : General log messages
=> /var/log/boot : System boot log
=> /var/log/debug : Debugging log messages
=> /var/log/auth.log : User login and authentication logs
=> /var/log/daemon.log : Running services such as squid, ntpd and others log message to this file
=> /var/log/dmesg : Linux kernel ring buffer log
=> /var/log/dpkg.log : All binary package log includes package installation and other information
=> /var/log/faillog : User failed login log file
=> /var/log/kern.log : Kernel log file
=> /var/log/lpr.log : Printer log file
=> /var/log/mail.* : All mail server message log files
=> /var/log/mysql.* : MySQL server log file
=> /var/log/user.log : All userlevel logs
=> /var/log/xorg.0.log : X.org log file
=> /var/log/apache2/* : Apache web server log files directory
=> /var/log/lighttpd/* : Lighttpd web server log files directory
=> /var/log/fsck/* : fsck command log
=> /var/log/apport.log : Application crash report / log file
=> /var/log/boot : System boot log
=> /var/log/debug : Debugging log messages
=> /var/log/auth.log : User login and authentication logs
=> /var/log/daemon.log : Running services such as squid, ntpd and others log message to this file
=> /var/log/dmesg : Linux kernel ring buffer log
=> /var/log/dpkg.log : All binary package log includes package installation and other information
=> /var/log/faillog : User failed login log file
=> /var/log/kern.log : Kernel log file
=> /var/log/lpr.log : Printer log file
=> /var/log/mail.* : All mail server message log files
=> /var/log/mysql.* : MySQL server log file
=> /var/log/user.log : All userlevel logs
=> /var/log/xorg.0.log : X.org log file
=> /var/log/apache2/* : Apache web server log files directory
=> /var/log/lighttpd/* : Lighttpd web server log files directory
=> /var/log/fsck/* : fsck command log
=> /var/log/apport.log : Application crash report / log file
Recent Progress in Ion Optics Column Design
Recently, through mostly self-learning and vivid discussion with Dr. Ray Hill, I've made quite some progress in understanding the technique and work flow in designing an electrostatic-lens-based, ion optics column for charged particle apparatus.
First, I've managed to learn how to model an electrostatic lens, and to calculate its axial potential distribution with First Order Finite Element Method (FO-FEM). Knowing the potential, one can easily calculate the lens' paraxial optical properties, such as focal length, focus voltage, third-order spherical aberration and first order chromatic aberration.
A typical column design starts with designing the most critical elements in the column - the lenses. Two lenses are usually employed in an ion optics column. Lens design involves optimizing the geometry of the lens, such as bore sizes, electrode thickness and gap sizes between neighbouring electrodes to minimize spherical and chromatic aberration coefficients, within the physical boundaries set by practical limits, such as focus voltage, breakdown stability and etc. I've been able to model the objective lens and understand the effects of each geometrical factor on the optical properties of the lens.
After lenses are designed, they can be put together to form a column. In a column, one cares about one thing: for a given probe current, what is the minimum probe size that can be achieved. This calculation can be done using the so-called "d50" method, with which the probe size can be calculated from a series of parameters: beam energy, energy spread, spherical and chromatic aberration, probe current, source brightness and angular source intensity. I've developed several python-based programs to iteratively compute the Probe Size vs Probe Current curve of a given ion column.
First, I've managed to learn how to model an electrostatic lens, and to calculate its axial potential distribution with First Order Finite Element Method (FO-FEM). Knowing the potential, one can easily calculate the lens' paraxial optical properties, such as focal length, focus voltage, third-order spherical aberration and first order chromatic aberration.
A typical column design starts with designing the most critical elements in the column - the lenses. Two lenses are usually employed in an ion optics column. Lens design involves optimizing the geometry of the lens, such as bore sizes, electrode thickness and gap sizes between neighbouring electrodes to minimize spherical and chromatic aberration coefficients, within the physical boundaries set by practical limits, such as focus voltage, breakdown stability and etc. I've been able to model the objective lens and understand the effects of each geometrical factor on the optical properties of the lens.
After lenses are designed, they can be put together to form a column. In a column, one cares about one thing: for a given probe current, what is the minimum probe size that can be achieved. This calculation can be done using the so-called "d50" method, with which the probe size can be calculated from a series of parameters: beam energy, energy spread, spherical and chromatic aberration, probe current, source brightness and angular source intensity. I've developed several python-based programs to iteratively compute the Probe Size vs Probe Current curve of a given ion column.
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 restart the server: $sudo service ssh restart
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.
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.
/: 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.
Subscribe to:
Posts (Atom)