If you are facing an error on ubuntu while connecting oracle even though you have installed ruby-oci8 and activerecord-oracle_enhanced_adapter you need install following library.
Problem:
ERROR: ActiveRecord oracle_enhanced adapter could not load ruby-oci8 library. Please install ruby-oci8 gem.
Solution:
sudo apt-get install libaio1
I hope this should work for you.
If you are facing below issue while installing mysql gem on ubuntu then you need to install 'libmysqlclient-dev' library.
manohar@manohar-Inspiron-1525:~$ gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/home/manohar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/manohar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
Use below command to resolve above issue-
manohar@manohar-Inspiron-1525:~$ sudo apt-get install libmysqlclient-dev
Ruby on Rails is growing in enterprises in India, but they are still lagging with popular development platforms like Mac or linux. As it's difficult for them to afford Mac and they cannot use Linux based Operating Systems (OS) on host machines due to security constraints or to use some windows based apps. So I decided to use Virtual Machine on my Windows based Host System.
Here is configuration of my host system:
Processor: Intel Core 2 Duo CPU, RAM: 2GB, Operating System: Windows 7 Enterprise
Now To use Ubuntu (Linux based OS) with above configuration, follow below steps-
1. Download and Install VMWare Player which is free for personal non-commercial use. VMware Player is only distributable with written permission from VMware. So don't share the exe/setup, download it separately.
2. Download ISO of Ubuntu.
3. Create a New Virtual Machine for Ubuntu using VMware Player. Just follow 'Next' Its simple. It takes default 512 MB of RAM but I did allocate 896 MB of RAM as I had 2 GB of RAM. (It might install required files.)
Now you have Ubuntu ready on your windows based system. To install Ruby and Rails using RVM please follow below steps-
1. To install RVM you need git. Run below command to install git-
ubuntu@ubuntu:~$ sudo apt-get install git
And then follow installation steps for RVM here.
OR
Run below command in terminal-
ubuntu@ubuntu:~$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
And then follow steps mentioned in output of above command to update .bashrc.
2. After installing RVM successfully follow below steps to install ruby and rails. Steps mentioned below are used to avoid the issue mentioned
here.
ubuntu@ubuntu:~$ rvm pkg install zlib
ubuntu@ubuntu:~$ rvm pkg install openssl
ubuntu@ubuntu:~$ rvm install 1.8.7 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr
3. Create new gemset using rvm.
ubuntu@ubuntu:~$ rvm gemset create rails_3
4. Check available version of ruby and gemset.
ubuntu@ubuntu:~$ rvm list
ubuntu@ubuntu:~$ rvm gemset list
5. Set default versions of Ruby and Rails using rvm. I am using ruby-1.8.7-p352@rails_3 as I have installed ruby 1.8.7 and created gemset named as rails_3.
ubuntu@ubuntu:~$ rvm use --default ruby-1.8.7-p352@rails_3
6. Now you can install rails.
ubuntu@ubuntu:~$ gem install rails
You are ready with ruby and rails, Now you need database. You can simply install mysql or postgresql using apt-get install command or from ubuntu software center.
I wanted to use Oracle but I didn't install it on my ubuntu system (virtual machine) as it's running less than 1 GB RAM which is kind of minimum requirement for oracle database. And I have already installed Oracle XE on my host system so I am going to use it using Host IP address in my database.yml of rails app.
To use oracle I need to install ruby-oci8 and activerecord-oracle_enhanced-adapter gems.
1. Follow steps
here to install ruby-oci8 using InstantClient.
2. If you are facing any issues to install gem ruby-oci8, you have to set path for LD_LIBRARY_PATH in your .bashrc. Eg: export LD_LIBRARY_PATH="/opt/oracle/instantclient_11_2"
Apart from these you have to install few required libraries and application like tortoisesvn, NetBeans(IDE) etc. Currently I am using Ubuntu just by using 896MB of RAM and it works fine.
Few things to remember while using this combination-
1. Increase RAM size allocated from 512MB, if you are going to use NetBeans as it takes bit lot memory.
2. Increase number of Processors to 2 if you have core 2 Duo, Default its set to only 1. It really helps.
3. From Virtual Machine Settings -> Hardware -> CD/DVD Device, dis-select 'Connect at power on' check box as you may not have CD-ROM available.
4. CTRL+G is used to enter into Virtual Machine and CTRL+ALT get out of it.
CTRL+ALT+DELETE call is taken by both Virtual Machine and host system. So make sure you will be using host system if you want to lock it.
5. Add terminal in SYSTEM->PREFERENCES->KEYBORAD SHORTCUTS.
You can use- Name: CTRL+ALT_DELETE and Command: gnome-editor
6. If you want to have shared folder between host system and virtual system, refer the article
here to update Virtual Machine Tools first and then you can simply add folders from Virtual Machine Settings -> Options -> Shared Folders. You will get them in /mnt/hgfs
Note: I was using a network where I was able to download all required software.
If you have installed rvm and then ruby and now facing below issue while installing rails-
manohar@manohar-Inspiron-1525:~$ gem install rails
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
Below steps should fix your problem as it worked for me.
$ rvm pkg install zlib
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-zlib-dir=$rvm_path/usr
HEROKU:
If you need to use you might face below problem after installing heroku gem and running heroku commands:
no such file to load -- net/https.
Try running apt-get install libopenssl-ruby (LoadError)
Below steps will work:
$ rvm remove 1.9.2
$ rvm pkg install openssl
$ rvm install 1.9.2 -C --with-openssl-dir=$rvm_path/usr
And to resolve both zlib and libopenssl problem use below steps:
$ rvm remove 1.9.2
$ rvm pkg install zlib
$ rvm pkg install openssl
$ rvm install 1.9.2 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr
- Separate out the things that change from those that stay the same.
- Program to an interface, not an implementation.
- Prefer composition over inheritance.
- Delegate, delegate, delegate.
Yehuda Katz is a member of the
SproutCore,
Ruby on Rails and
jQuery Core Teams; during the daytime, he works as an architect at Strobe. Yehuda is the co-author of the best-selling "jQuery in Action", the upcoming "Rails 3 in Action", and is a contributor to "Ruby in Practice". He spends most of his time hacking on open source - his main projects, along with others, like Thor, Handlebars and Janus - or traveling the world doing evangelism work. He blogs at
yehudakatz.com and can be found on Twitter as
@wycats.And I am huge fan of his open source contributions, they could be from server side or client side or any other library and I had wish to have a snap with this great contributor which I completed in
RubyConf India 2011.
While running "sunspot:solr:run" on Windows ["sunspot:solr:run" works with windows otherwise use "sunspot:solr:start"] if you are receiving error like -
Exception in thread "main" java.lang.NoClassDefFoundError:
'-Djava/util/logging/config/file=C:/DOCUME~1/pli/LOCALS~1/Temp/
logging/properties20100617-11284-furc4v-0'
Caused by: java.lang.ClassNotFoundException:
'-Djava.util.logging.config.file=C:.DOCUME~1.pli.LOCALS~1.Temp.
logging.properties20100617-11284-furc4v-0'
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class:
'-Djava.util.logging.config.file=C:/DOCUME~1/pli/LOCALS~1/Temp/
logging.properties20100617-11284-furc4v-0'.
Program will exit.
Please change line no. 74 in server.rb from lib of sunspot gem,
"exec(Escape.shell_command(command))"
with "exec(Escape.shell_command(command).gsub("'",'"'))"For details refer source.
By the end of this post you will be able to integrate your Web Hosted Application with QuickBooks Online Edition. You will understand below points.
Objectives:
1. Establish a communications channel with QuickBooks
2. Build a set of request messages
3. Send the request messages set to QuickBooks
4. Check the status codes & data in the response message set received from QuickBooks
5. Close the communications channel with QuickBooks
The Basic Communication Model is shown in Fig. 1
Fig. 1
Terminologies from Fig. 1
• Developer Application => Rails App
• Request => Https request generated using QBXML
• Response => Response over https in QBXML format.
• Company Owner’s Authorization => Authorization process for security purpose explained in detail in part-1. i.e. Establish a communications channel with QuickBooks
• Request Processor => Its nothing but a QBXML parser which process request from developer application and response from QuickBooks and sent in QBXML format to Developer application.
• QuickBooks => QuickBooks Account.
Now step by step:
1. Establish a communications channel with QuickBooksSteps to establish connection between developer application and QuickBooks.
1. Obtain a test QBOE (QuickBooks Online Edition) account from IDN for testing during development. These are available to paid memberships and participants in the NFR program.
Purchase an account from QuickBooks
As the quickbooks doesn’t support Multitenant platform, so the process is defined in step-7 for connecting specific account with specific company if you have multitenant rails application.
2. Register your application with IDN (Register your app at
appreg.intuit.com)
It’s an IDN Gateway Application Registration which is required to generate an Unique ID which is later used in https requests. You need to register valid https url of rails application with IDN.
URL: https://app_url
APPLICATION ID: Unique App Id generated- You will have some unique id generated eg: 169442259
Please make sure you have valid https ceritificate for the same url. Otherwise redirect it using proxies.
It also asks for some basic URLs which QuickBooks uses for further reference.
Subscribe URL: https://app_url/quickbooks/subscribe
Usually connection ticket is returned in this action when connection to QuickBooks account is created for first time with Rails App.
Change URL: https://app_url/quickbooks/change
Cancel URL: https://app_url/quickbooks/cancel
Login URL: https://app_url/login
3. Obtain a server certificate from a supported root certificate authority. This will be your https certificate.
4. Obtain a client certificate by generating a certificate signing request (CSR) and use the
appreg.intuit.com site to get it signed by Intuit.
a) Obtain a client certificate by generating a certificate signing request (CSR):
i. Generate a new key:
ii. $ openssl genrsa -out idn.key 1024
iii. Generate CSR:
iv. $ openssl req -new -key idn.key -out idn-foo.csr
v. IMPORTANT: Common Name (Your Name) needs to be EXACTLY
vi. your.url(THIS MUST BE AN IP ADDRESS OF YOUR HOSTED APP SERVER):your.application.name
b) Get CSR signed at
appreg.intuit.com Go to site, copy and paste CSR text and sign that bad boy!
c) Create PEM
The signing process will return a certificate. Copy the certificate to a text file and name it qboe-cert.pem. Now open the key you used to generate the CSR and paste that into the same text file above the certificate.
5. Understand and follow the QBOE security requirements for hosted web applications.
Your hosted web application (Developer Application) needs a server certificate in order to receive callbacks from QBOE. Your hosted web application also needs a client certificate signed by Intuit in order to POST QBOE requests to QBOE. (You need register your application with IDN before you can generate your certificate signing request.)
6 .In your code, using SSL, implement the presentation of the client certificate to be used when posting to QBOE.
The Intuit-signed client certificate must be presented to QBOE at every POST to QBOE sites. You have to use SSL at your web server in conjunction with the client certificate. The client certificate is presented using “pem” feature of httparty gem.
require 'httparty'
class Qboe
include HTTParty
base_uri 'https://webapps.quickbooks.com/j/AppGateway'
format :xml
headers 'Content-Type' => 'application/x-qbxml'
pem File.read("#{RAILS_ROOT}/qboe-cert.pem")
end
7. In your code, prompt your customer to grant a connection ticket authorizing your application to access the QBOE Company. Respond by sending the customer to the QBOE login page to get a connection ticket. QBOE POSTs the connection ticket back to the application subscription URL you specified when you registered your application. Handle this POST at that URL and store the connection ticket securely.
Sending the User to QBOE to Create a Connection Ticket
In your main form displayed in the user’s web browser, provide a means for the customer to start the authorization process, for example, a Subscribe button. Whatever the means, respond to the customer’s action by sending the customer to the QBOE login page at the following URL:
for production QBOE:
https://login.quickbooks.com/j/qbn/sdkapp/confirm?appid=&serviceid=2004&appdata=
Appdata = > company id (It is not required or mandatory but preferred to use if you have multitenant application.)
After your application gets the POST from QBOE, you need to extract the connection ticket
from the POST in subscribe action.
8. In your code, implement session ticket handling code. That is, prior to sending QBOE requests for a particular customer, get a session ticket by sending a SignonMsgsRq containing a SignonAppCertRq with that customer’s connection ticket. You’ll POST this to the QBOE data exchange URL to get the session ticket in the Signon AppCertRs response.
Eg: session.erb <?xml version="1.0"?>
<?qbxml version="6.0"?>
<QBXML>
<SignonMsgsRq>
<SignonAppCertRq>
<ClientDateTime><%=today%></ClientDateTime>
<ApplicationLogin><%=APPLICATION_LOGIN%></ApplicationLogin>
<ConnectionTicket><%=CONNECTION_TICKET%></ConnectionTicket>
<Language>English</Language>
<AppID><%=APPLICATION_ID%></AppID>
<AppVer>1</AppVer>
</SignonAppCertRq>
</SignonMsgsRq>
</QBXML>
APPLICATION_LOGIN = 'app_url'
CONNECTION_TICKET = 'TGT-68-wltE9aMgPpzDAC46PJwZvQ'
APPLICATION_ID = '169442259'
def self.get_session_ticket
today = Time.now.strftime("%Y-%m-%d")
xml_to_send = ERB.new(get_file_as_string("lib/quickbooks/session.erb")).result(binding)
result = post('/', :body => xml_to_send )
result["QBXML"]["SignonMsgsRs"]["SignonAppCertRs"]["SessionTicket"]
end
Response text:
{ "QBXML"=> { "SignonMsgsRs"=> { "SignonAppCertRs"=> {"ServerDateTime"=>"2010-03-17T05:29:26", "SessionTicket"=>"V1-211-BN1A_Bt_lRGjZQRgHeVIFQ:169714916", "statusSeverity"=>"INFO", "statusCode"=>"0" } } } }
2. Build a set of request messages
Below example explains a request created to create an invoice in QuickBooks.
<?xml version="1.0"?>
<?qbxml version="6.0"?>
<QBXML>
<SignonMsgsRq>
<SignonTicketRq>
<ClientDateTime><%= today %></ClientDateTime>
<SessionTicket><%= session %></SessionTicket>
<Language>English</Language>
<AppID><%= APPLICATION_ID %></AppID>
<AppVer>1</AppVer>
</SignonTicketRq>
</SignonMsgsRq>
<QBXMLMsgsRq onError="continueOnError">
<InvoiceAddRq>
<InvoiceAdd defMacro="TxnID:1234"><!-- required -->
<CustomerRef> <!-- required -->
<ListID>4</ListID>
</CustomerRef>
<TxnDate>2010-10-10</TxnDate>
<!-- BEGIN OR -->
<InvoiceLineAdd > <!-- optional -->
<ItemRef> <!-- optional -->
<FullName >Hours</FullName> <!-- optional -->
</ItemRef>
<Desc >Its added from rails app.</Desc> <!-- optional -->
<Quantity >2</Quantity> <!-- optional -->
<!-- BEGIN OR -->
<Rate >111</Rate> <!-- optional -->
<Amount >101.00</Amount> <!-- optional -->
<ServiceDate>2010-10-10</ServiceDate>
</InvoiceLineAdd>
<!-- OR -->
<!-- END OR -->
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>
Following Fields of Rails App are mapped with QuickBooks Invoice using QBXML.
Rails App (Eg. Time/Expense Field Names) QuickBooks Invoice Field Names
Contact/Matter Contact (Full Name) => Client Name/Bill To
Time Entry Date/Expense Entry => Date Service Date
Activity Type/Expense Type => Product/Service
Description => Description
Duration (Hrs) => Qty
Rate/hr ($) => Rate
Final Bill Amount => Amount
Actual Mapping in QBXML for expense entry in invoice is explained below.
QBXML:
<InvoiceAddRq>
<InvoiceAdd defMacro="TxnID:1234">
<CustomerRef>
<ListID>4</ListID>
</CustomerRef>
<TxnDate>2010-10-10</TxnDate>
<InvoiceLineAdd >
<ItemRef>
<FullName >Fax</FullName>
</ItemRef>
<Desc >Fax to eric</Desc>
<Amount >101.00</Amount>
<ServiceDate>2010-10-10</ServiceDate>
</InvoiceLineAdd>
</InvoiceAddRq>
Eg: To add a client name in QuickBooks invoice we need to send ListID in QBXML request. ListID is acquired by executing a query to QuickBooks, Contact Full Name is the parameter passed to query.
3. Send the request messages set to QuickBooks
It’s done using “post” method from http arty gem.
4. Check the status codes & data in the response message set received from QuickBooks
Usually below set of parameters values exists in every request and response which we need to consider for every request and specifically for responses.
Attributes in Request and Response Messages
5. Close the communications channel with QuickBooks
Basically it not compulsory or needed while accessing QuickBooks Online Edition from Web Hosted application.
Tools & Software: Development Environment
QuickBooks SDK 8.0
QBXML Version 6.0
Ruby 1.8.6
Rails 2.3.5
Net Beans IDE 6.7
Gems: Http arty 0.5.2
References
1. Intuit QuickBooks SDK Technical Overview
2. Intuit QuickBooks SDK Programmer’s Guide
3. Onscreen Reference(OSR)
4. Web site for the Intuit Developer Network (IDN): http://developer.intuit.com
5. Blog: http://jnylund.typepad.com/joels_blog/2010/02/quickbooks-online-integration-from-ruby-on-rails-the-easy-way.html
6. Blog: http://www.depixelate.com/2007/05/03/rails-and-quickbooks-online-integration-part-1/
7. http://www.servicesidekick.com/ (Quickbooks Integration)
Points to remember while adding bundler to Rails < 3.x.x applications- When I had modified an application based rails 2.3.4 for bundler, it has taken my time to make it work as i forgot below points.
1. Please check if someone had made any changes inside plugins/gems which you have mentioned in gem file now.
2. Please note of gems if you are mentioning them :groups as they are not available to other groups. eg. Gems mentioned in :groups => :test are not available to :group => :development. Eg: if you run rake tasks which uses gem libraries in development and gems are mentioned in :tests group, it will give you errors for required gems.
3. Also make sure about gems and plugins versions which are being used in app and you mentioned Gemfile.
I hope it might save your time.
These are links/resources i referred for respective software installations.
memcached for Windows
How to install PhyMyAdmin on Centos 5.3
Installing RMagick on Linux, *BSD, or Cygwin systems
Ruby
Ruby-Language
Ruby Documentation
Ruby Support
Magazines:
The Rubyist
Rails Magazine
Code and Style:
Code and Style
Projects:
RubyGems
Rake
News:
Ruby Flow
Ruby Inside
Rails Inside
Videos:
Rails Casts
Ruby Libraries
Blogs:
Dave Thomas
Chad Fowler
Jim Weirich
Jamis Buck
Nathaniel Talbott
http://blog.grayproductions.net/
http://tim.theenchanter.com/
http://www.randquist.us/blog/
http://yehudakatz.com/
http://atmos.org/
http://squeejee.com/blog
http://blog.herdingtigers.com/
http://www.copiousfreetime.org/
http://blog.josephwilk.net/
http://evan.tiggerpalace.com/
http://satishtalim.com/
http://martinfowler.com/
http://www.chadfowler.com/
http://tomcopeland.blogs.com/
http://richkilmer.blogs.com/
James Golick
http://www.skorks.com/
http://blogs.thoughtworks.com/
http://testing.thoughtworks.com/
http://agileassessments.thoughtworks.com/
If you are getting an error like -
ERROR: could not find gem GEM_NAME locally or in a repository
then probably you might have missed the gem source if the name of gem is correct.
You can add a gem source link using command-
gem sources -a source_link
To view existing gem sources-
gem sources
Few gems sources-
http://gems.rubyforge.org/
http://gems.github.com
How to install memcached on CentOS
This is a step by step guide to installing memcached from source on CentOS. The version of CentOS that I am using is CentOS release 5.2 (Final); to find what version you are using:
cat /etc/redhat-release
First, install the dependency libevent:
cd /usr/local/src
curl -O http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz
tar xzvf libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
./configure --prefix=/usr/local
make
make install
Next, install memcached:
cd /usr/local/src
curl -O http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar xzvf memcached-1.2.6.tar.gz
cd memcached-1.2.6
LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local
make
make install
Verify that memcached starts:
memcached -u root -d
If there were no errors, make sure it is running:
ps aux | grep memcached
And finally, to stop memcached:
pkill memcached
These instructions prevent the following errors:
memcached: error while loading shared libraries: libevent-1.4.so.2:
cannot open shared object file: No such file or directory
configure: error: libevent is required
If it's already installed, specify its path using --with-libevent=/dir/
1. List command
ls -a
// lists all
ls -l
// lists all files including hidden files like .htaccess
ls -l | more
// shows in paged format with pipe
2. Untarring the uploaded tar.gz files
This command is the most important command and often regularly used to uncompress files..
tar -xzf filename.tar.g
How to dump/Import tar.gz (zipped) file into MySQL database
SSH command to restore/import gzipped large databases to mysql on the fly with just one single command. This is so useful as large databases can only be imported to mysql this way! Remember to upload the database dump before you issue this command
gunzip <>
3. Installing packages
Installing softwares in linux the most basic and you will need to know this command very well .
yum install
// for centos and redhat
apt-get install
// for debian/ubuntu
4. To look for memory usage
top
// shows the memory, cpu load and other processes running
free
// shows the memory usage of linux
5. To see the disk usage.
df -h
// shows the disk usage and outputs the disk usage left
6. To view running processes
ps aux
// shows the running processes and its ID. You can use this ID to kill the process later.
ps aux | grep "process_name" [eg. ruby script/server]
//To see specific process
kill -9 pid
// to kill the process
7. Deleting all files within a folder
This perhaps is one of the most sought after command to delete all subfiles and subfolders in linux with just one command in a fly.
rm -Rf /my/path
// this deletes all files. so be careful!
8. Edit a file in easy way!
I love nano command. Its just so easy to edit a file with menu options and save changes. You can easily search for specific text inside the file with the nano editor.
nano /file/path
// text editor to edit files
9. Changing Permissions and Ownership
whats there in linux without permissions and ownership
chmod -R 755 /folder/path
// this recursively changes all files and folders of the path.
chown pbu /file/name
//changes the ownership of filename
chgrp mygrp /file/name
//changes the group to new one
If you dont know how to interpret the 755 or number like permissions here is an easy way to remember
Ex: 755 means rwxr-xr-x
7 -> rwx (for owner)
5 -> r-x (non writable for group)
5 -> r-x (non writable for world)
First we consider '7' in 755 as it is made up of 3 bit binary. To construct 7 we need to construct 111(which is 4+2+1 in decimal).
5 -> 101 ( which is 4+0+1)
5 -> 101 (which is 4+0+1)
Remember 755 is the decimal of the binary and it is always made up of 4+2+1.
10. To find out what ports are open
Finding which ports are open and closed are so important in terms of security point of your server. You might want to close unwanted services using different ports.
netstat -nap --tcp
// lists connections and what ports are open.
OR
nmap fuser localhost
// easy command
Install firewall to block unwanted ports running on your PC or in server.
FAQs
How do i change root password?
Just login as root or su root and type passwd, you will be asked for new password.
> passwd
// Be CAREFUL! If you forget your new password, you will lock yourself
I am installing a firewall in my linux server? How do i know which ports to block and to open?
When installing firewall be sure to block all unwanted open ports. A comprehensive collection of ports and services run at that port can be found here
Here is the short of ports which needs to be kept open for listening.
Common ports
21 => FTP
22 => SSH
25 => SMTP Mail Transfer
43 => WHOIS service
53 => name server (DNS)
80 => HTTP (Web server)
110 => POP protocol (for email)
143 => IMAP Protocol (for email)
443 => SSL for HTTP
Cpanel => 2077,2078,2082,2083,2086,2087,2089,2095,2096,3306, 6666.
Plesk => 8443
Webmin => 10000
If you have root permissions, you can login to your server control panel like this...
https://ipaddress:2087/
// for cpanel
https://ipaddress:8443/
// for plesk
Hope my ports compilation should be helpful for beginners who use linux.
How to Investigate a port in Windows XP
If you find anything suspicious going on in your computer, you can investigate a port in your PC with windows xp task manager program. Many worms, viruses and trojans mailiciously download harmful scripts to your computer using different ports that you may not know. The best way to protect your PC from such worms and trojans is by using a firewall. You can use
comodo firewall which can be downloaded free of charge.
To investigate a port and see what programs are using, can be done easily in 2 steps
1. Go to Start > Run > command
2. At the command prompt type
netstat -noa
3. Look for connections with LISTENING and ESTABLISHED. Note that port numbers will be identified in the form of
127.0.0.1:1092 (IP address followed by colon is the port number). In this case 1092 is the port.4. Note the PID (process id) for that port and this process id corresponds to program using it.
5. Next we will find out that PID with windows task manager program.
6. Go to ALT+CTRL+DEL then press
task manager button. You will see the processes listed and the memory.
Note: By default with task manager it will not show the PID of the processes. You have to enable it from the options menu.
Should you find the running process to be suspicious just end the process.
Tip: Use a firewall like
ZoneAlarm or
Comodo Firewall (both are free) to block suspicious programs running on your PC.
How to Investigate a Port in Linux
It is very easy to investigate a port and kill that process in your linux server or box.
- First find the ports that are active and listening to.
- Note the port and the process ID (PID)
- Find which processes is running based on that PID
- If you find anything suspicious, kill that process.
netstat -nap
// lists both TCP and UDP connections (listening and established)

ps
// this command tells which program is running this process id
pidof
// alternate commandIf you find this running program or process suspicious like trojan or worm, kill the process
I got this over http://www.mysql-apache-php.com/investigate-port.htm I kept it over my blog to share as well for my knowledge management.
Basic search tips
More search tips
It's for you only if are new to RoR, as you may get confused, Bcoz they all come in different shapes and sizes.
For mongrel/Else
mongrel_rails start -e production/ ruby script/server -e production
For rake command:
rake [task] RAILS_ENV=production
For ruby console:
ruby script/console production
* Ruby on Rails includes features that help in increasing developer productivity. Some of the main features include the following:
* MVC/AGILE architecture: Ruby on Rails is based on the MVC (Model View Controller) architecture that enables the data to be separated from presentation. It's an agile web development framework.
* Database Access Library: Ruby on Rails includes a database access library - Active Record - that simplifies data handling in databases. Active Record automatically maps tables to classes and rows to objects.
* Libraries for common tasks: Ruby on Rails includes a host of libraries that simplify the coding of common programming tasks such as form validations, sessions management, etc.
* AJAX Library: An extensive library of AJAX functions is provided in the Rails framework. Ruby code can be used to generate AJAX code. The associated java scripting required for AJX gets generated automatically.
* Convention over configuration: Ruby on Rails does not have any XML configuration files. It includes simple programming conventions that can be used to specify the configuration parameters.
* Customized URL: Custom or Search Engine Friendly URLs can be developed using the Ruby on Rails framework.
* Debugging: Detailed error logs are provided, making it easier to debug applications.
* Components: Components can be used to store reusable code. Components can be included to modularize templates.
* DRY: Don't Repeat Yourself. You will get it when you actually write the rails code.