Posts

Showing posts with the label linux

A Short Guide to AWK

AWK is built to process column-oriented text data, such as tables. In which a file is considered to consist of N records (rows) by M fields (columns) Basic # awk < file ‘{print $2}’ # awk ‘{print $2}’ file file = input file print $2 = 2nd field of the line, awk has whitespace as the default delimiter Delimiter # awk -F: ‘{print $2}’ file -F: = use ‘:’ as delimiter # awk -F ‘[:;]’ ‘{print $2}’ file -F ‘[:;]’ = use multiple delimiter, and parse using EITHER ‘:’ OR ‘;’ # awk -F ‘:;’ ‘{print $2}’ file   -F ‘:;’ = use multiple delimiter, and parse using ':;’ as THE delimiter # awk -F ‘:’+ ‘{print $2}’ file   -F ‘:’+ = use multiple delimiter, to match any number ':' Arithmetic # echo 5 4 | awk '{print $1 + $2}' output is '9', the result of ‘+’ (works as addition) # echo 5 4 | awk '{print $1 $2}' output is '54', to get string concatenation #  echo 5 4 | awk '{print $1, $2}' output is '5 4',...

How to: Create Passwordless SSH Remote Login

The intention is simple: just let me in without asking for password again and again! Follow the steps to achieve this: 1. Generate RSA key from host machine (skip this if you have already got one) ssh-keygen -t rsa -C <youremail@email.com> Accept the default location and DO NOT give a password to it. 2. Copy the RSA key generated to your remote machine cat ~/.ssh/id_rsa.pub | ssh root@<remotemachineipaddress> 'cat >> ~/.ssh/authorized_keys' So far, it is all done. 3. A step further It would be great if can we save the time on typing the hideous 'SSH' and 'blarblar@blar.blar.blar.blar' as well, wouldn't it? Set up an alias for it from your host machine then. alias apple='ssh root@<remotemachineipaddress>' Put the line into '~/.bashrc' so that it would persist. And there we go, apple is your new login!

How to: Setup Proxy for Linux

When working inside an enterprise network, there could be a necessity to setup the network proxy in order to connect to internet. While Linux proxy does not really share the same proxy settings as windows, the other approach has to be performed. The following does work for me according to a Linux guru and some quick search: 1. Install cntlm sudo apt-get install cntlm since the internet cannot be established, the better way is to download it from some machine which does have internet connection and install it remotely. 2. Configure cntlm sudo nano /etc/cntlm.conf drop in the valid proxy settings and login credentials for the network, including username, domain and password. 3. Setup network proxy Open System Settings > Network > Network Proxy Set all proxy settings to use 'localhost' with port number '3128' Alternatively, try adding the following lines to /etc/bash.bashrc or ~/.bashrc sudo nano <unc> export http_proxy=http://local...