Friday, September 30, 2011

Restart(close and open) a new console window and continue running these commands on Rails

Setelah semalaman berkutat dengan instalasi yang error Ruby di OpenSuse 11.3 akhirnya kutemukan obatnya...

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

restart console

Insert the following code to the last line of your .bashrc file then save your changes
$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm”
Restart(close and open) a new console window and continue running these commands
  • rvm install 1.8.7
  • rvm install 1.9.2
  • rvm —default 1.9.2
  • rvm use 1.9.2
  • ruby -v
  • gem update —system
  • gem install rails
  • rvm rubygems current
  • Finally

  • fatur@internal:~> rails new ~/test/code
          create
          create  README
          create  Rakefile
          create  config.ru
          create  .gitignore
          create  Gemfile
          create  app
          create  app/assets/images/rails.png
          create  app/assets/javascripts/application.js
          create  app/assets/stylesheets/application.css
          create  app/controllers/application_controller.rb
          create  app/helpers/application_helper.rb
          create  app/mailers
          create  app/models
          create  app/views/layouts/application.html.erb
          create  app/mailers/.gitkeep
          create  app/models/.gitkeep
          create  config
          create  config/routes.rb
          create  config/application.rb
          create  config/environment.rb
          create  config/environments
          create  config/environments/development.rb
          create  config/environments/production.rb
          create  config/environments/test.rb
          create  config/initializers
          create  config/initializers/backtrace_silencers.rb
          create  config/initializers/inflections.rb
          create  config/initializers/mime_types.rb
          create  config/initializers/secret_token.rb
          create  config/initializers/session_store.rb
          create  config/initializers/wrap_parameters.rb
          create  config/locales
          create  config/locales/en.yml
          create  config/boot.rb
          create  config/database.yml
          create  db
          create  db/seeds.rb
          create  doc
          create  doc/README_FOR_APP
          create  lib
          create  lib/tasks
          create  lib/tasks/.gitkeep
          create  lib/assets
          create  lib/assets/.gitkeep
          create  log
          create  log/.gitkeep
          create  public
          create  public/404.html
          create  public/422.html
          create  public/500.html
          create  public/favicon.ico
          create  public/index.html
          create  public/robots.txt
          create  script
          create  script/rails
          create  test/fixtures
          create  test/fixtures/.gitkeep
          create  test/functional
          create  test/functional/.gitkeep
          create  test/integration
          create  test/integration/.gitkeep
          create  test/unit
          create  test/unit/.gitkeep
          create  test/performance/browsing_test.rb
          create  test/test_helper.rb
          create  tmp/cache
          create  tmp/cache/assets
          create  vendor/assets/stylesheets
          create  vendor/assets/stylesheets/.gitkeep
          create  vendor/plugins
          create  vendor/plugins/.gitkeep
             run  bundle install
    /home/fatur/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.0.20/lib/bundler/index.rb:110: [BUG] Segmentation fault
    ruby 1.8.7 (2010-01-10 patchlevel 249) [i586-linux]

    Fetching source index for http://rubygems.org/
    fatur@internal:~>

Tuesday, May 24, 2011

count all files in one folder

Sometimes we want to know how many files in folder using GNU/Linux command, here the code:



$ls -1 targetdir | wc -l 
454
Enjoy.....

Tuesday, April 26, 2011

iptables

Untuk melihat DNAT yang dibelakukan di iptables:

internal:/home/fatur # iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 265K packets, 29M bytes)
 pkts bytes target     prot opt in     out     source               destination
96559 4999K DNAT       tcp  --  eth0   any     anywhere             anywhere            tcp dpt:http to:192.168.1.1:3128
    0     0 REDIRECT   tcp  --  eth0   any     anywhere             anywhere            tcp dpt:http redir ports 3128

Chain OUTPUT (policy ACCEPT 358K packets, 26M bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 523K packets, 45M bytes)
 pkts bytes target     prot opt in     out     source               destination

Untuk melihat list di chain INPUT:

internal:/home/fatur # iptables -L INPUT
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
PORT12_IN  tcp  --  anywhere             anywhere            tcp dpt:imap
PORT11_IN  tcp  --  anywhere             anywhere            tcp dpt:domain
PORT10_IN  tcp  --  anywhere             anywhere            tcp dpt:ndl-aas
PORT09_IN  tcp  --  anywhere             anywhere            tcp dpt:hylafax
PORT08_IN  tcp  --  anywhere             anywhere            tcp dpt:mysql
PORT07_IN  tcp  --  anywhere             anywhere            tcp dpt:netbios-ssn
PORT06_IN  tcp  --  anywhere             anywhere            tcp dpt:pop3
PORT05_IN  tcp  --  anywhere             anywhere            tcp dpt:telnet
PORT04_IN  tcp  --  anywhere             anywhere            tcp dpt:ssh
PORT03_IN  tcp  --  anywhere             anywhere            tcp dpt:http
PORT02_IN  tcp  --  anywhere             anywhere            tcp dpt:ftp
PORT01_IN  tcp  --  anywhere             anywhere            tcp dpt:smtp

untuk melihat chain INPUT beserta port yang dipakai:

internal:/home/fatur # iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
PORT12_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:143
PORT11_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:53
PORT10_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3128
PORT09_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:4559
PORT08_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3306
PORT07_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:139
PORT06_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:110
PORT05_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:23
PORT04_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22
PORT03_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80
PORT02_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:21
PORT01_IN  tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:25



Untuk melihat chain INPUT secara lebih detail:
internal:/home/fatur # iptables -vnL INPUT
Chain INPUT (policy ACCEPT 10M packets, 7783M bytes)
 pkts bytes target     prot opt in     out     source               destination
    1    44 PORT12_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:143
  758 42290 PORT11_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:53
3338K  420M PORT10_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3128
    0     0 PORT09_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:4559
    2    84 PORT08_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3306
61676   42M PORT07_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:139
    1    44 PORT06_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:110
    1    44 PORT05_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:23
73196 4317K PORT04_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:22
16237 3426K PORT03_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:80
    1    44 PORT02_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:21
    2    84 PORT01_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:25

Untuk melihat chain INPUT secara detail beserta line numbernya, line number disini bisa digunakan untuk mendeleted rule-rule yang ingin dibuang.

internal:/home/fatur # iptables -vnL INPUT --line-numbers
Chain INPUT (policy ACCEPT 10M packets, 7790M bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        1    44 PORT12_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:143
2      758 42290 PORT11_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:53
3    3341K  421M PORT10_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3128
4        0     0 PORT09_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:4559
5        2    84 PORT08_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3306
6    61676   42M PORT07_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:139
7        1    44 PORT06_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:110
8        1    44 PORT05_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:23
9    73206 4318K PORT04_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:22
10   16252 3427K PORT03_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:80
11       1    44 PORT02_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:21
12       2    84 PORT01_IN  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:25


Untuk melakukan delete rules no 11 pada chain INPUT:


internal:/home/fatur # iptables -D INPUT 11   

Untuk melakukan insert rule, setelah hal ini diproses maka rules yang di insertkan akan berapa pada posisi pertama.
 
internal:/home/fatur #iptables -I INPUT -p tcp -s 212.100.apa.saja --dport 22 -j logaccept

Untuk melakukan replace pada chain yang sudah dibuat:

internal:/home/fatur #iptables -R INPUT 1 -p tcp -s 100.100.200.100 --dport 22 -j ACCEPT



Untuk melakukan drop dengan spesifikasi IP tertentu:


internal:/home/fatur #iptables -I FORWARD -d 123.123.123.123 -j DROP
 
hal ini bisa diberlakukan juga pada chain yang lain, misalnya:
 
internal:/home/fatur #iptables -I OUTPUT -d 123.123.123.123 -j DROP
 
Untuk melakukan drop packet dengan subnet tertentu :
iptables -I FORWARD -s 192.168.2.0/255.255.255.0 -j DROP
 
Drop alamat website tertentu
internal:/home/fatur #iptables -A OUTPUT -p tcp -d whateversite.com  -j DROP 


Salam
Fatur

Thursday, April 7, 2011

Linux Rename Multiple Files At a Shell Prompt

rename file

from:
3207020003001_0%.pdf
3207020005010_0%.pdf
3207020007002_0%.pdf
3207060003014_0%.pdf
3207080007004_0%.pdf

to

3207020003001_0.pdf
3207020005010_0.pdf
3207020007002_0.pdf
3207060003014_0.pdf
3207080007004_0.pdf

command:  for i in *.pdf; do mv $i `echo $i |cut -c1-15,17-20` ; done


3207080007001_50%.pdf
3207080007003_50%.pdf
3207080007005_50%.pdf
3207080007002_50%.pdf


to


3207080007001_50.pdf  
3207080007003_50.pdf  
3207080007005_50.pdf
3207080007002_50.pdf



commad: for i in *.pdf; do mv $i `echo $i |cut -c1-16,18-21` ; done


3207080007001_100%.pdf
3207080007004_100%.pdf
3207080007002_100%.pdf
3207080007005_100%.pdf

to

3207080007001_100.pdf  
3207080007004_100.pdf  
3207080007002_100.pdf  
3207080007005_100.pdf


for i in *.pdf; do mv $i `echo $i |cut -c1-17,19-22` ; done


ref: http://www.cyberciti.biz/tips/renaming-multiple-files-at-a-shell-prompt.html

Monday, March 14, 2011

Crontab Sarg

I am using GNU/Linux OpenSUSE 11.3 as server operating system for this tutorial.  Make easy to read your squid access report, install the sarg application follow this link. With sarg you can monitor the user activities that using squid as the cache server. To make the sarg report automatically using cron please follow this instruction. If u have problem yo can comment in this page or yoy can mail me faturr [at] gmail.com. Thank you for reading.

$ sudo vi /etc/sysconfig/sarg
RUN_SARGREPORT=yes


$ sudo crontab -e
#sarg
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
00 08-18/1 * * * sarg-reports today
00 00 * * * sarg-reports daily
00 01 * * 1 sarg-reports weekly
30 02 1 * * sarg-reports monthly

The preview edit is look like like this image.



The sarg report is look like this.

Problem with installation and configuration? We can help you or your company. Call +62 888 198 0879 or +62 821 337 600 29.

Monday, March 7, 2011

Linux command


Perintah du (disk usage) digunakan untuk meengetahui besaran dari file yang akan ditampilkan dalam layar monitor, untuk mengetahui detail yang bisa dihsilkan oleh perintah du bisa menggunakan 'man du' (tanpa tanda kutip)
$man du 

NAME
       du - estimate file space usage


SYNOPSIS
       du [OPTION]... [FILE]...
       du [OPTION]... --files0-from=F


DESCRIPTION
       Summarize disk usage of each FILE, recursively for directories.

Sample of du command: 


fatur@123$ du -ah --time *
19M 2011-03-07 10:27 20110307/To_20110304/aa.mdb
1.6M 2011-03-07 11:07 20110307/To_20110304/nn.rar
404K 2011-03-07 11:04 20110307/To_20110304/4.rar
1.2M 2011-03-07 10:27 20110307/To_20110304/gg.rar

Thursday, January 20, 2011

Saidar untuk memonitor GNU/Linux Ubuntu melalui console/ terminal

Saidar adalah aplikasi untuk menampilkan statistik dari sebuah sistem operasi. Statistik termasuk adalah penggunaan CPU, proses, load, memori, swap, jaringan I / O dan disk I / O dari sistem operasi dari sebuah komputer.

Saidar memanfaatkan pustaka libstatgrab. Libstatgrab adalah pustaka yang menyediakan akses lintas platform untuk membaca statistik dari sistem yang sedang berjalan. Pustaka ini ditulis dalam bahasa C dan menyajikan pilihan interface yang berguna yang dapat digunakan untuk mengakses statistik dari sebuah sistem operasi yang sedang berjalan. Daftar statistik yang saat ini bisa di dukung adalah penggunaan CPU, penggunaan memori, penggunaan media penyimpanan, jumlah proses, lalu lintas jaringan, disk I / O, dan banyak lagi.

Beberapa operating sistem yang disupport adalah Solaris 2.x, Linux 2.2/2.4/2.6, 4.x/5.x FreeBSD, NetBSD 1.6.x, OpenBSD 3.x, Dragonfly BSD 1.0, HP-UX, dan Cygwin.

Proses instalasinya sangat mudah jika anda memakai  GNU/Linux Ubuntu 9.10, tentunya dengan akses internet yang sudah terhubung.

$sudo apt-get install saidar

Dibawah ini adalah hasil capture dari system GNU/Linux Ubuntu 9.10 yang sedang berjalan.