ls -a
// lists all
ls -l
// lists all files including hidden files like .htaccess
ls -l | more
// shows in paged format with pipe
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 <>
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
top
// shows the memory, cpu load and other processes running
free
// shows the memory usage of linux
df -h
// shows the disk usage and outputs the disk usage left
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
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!
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
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.
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.
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.
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
rake [task] RAILS_ENV=production
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.
I have been writing a rails application on top of a large existing Oracle database where each table has 5+ triggers that each call several stored procedures and each of those PL/SQL stored procedures is hundreds of lines long. Often a simple update statement fails with an ORA-xxxx exception coming from deep in the PL/SQL code and it can be tough to figure out what's gone wrong.
The usual way Oracle database folks figure out what's going on is to put print statements in their code. In oracle this looks like
dbms_output.put_line('hi i hit this line of pl/sql');set serveroutput on;This is great if you divide the application between Rails
CREATE OR REPLACE FUNCTIONNow we can run the following in TOAD
MORE_THAN_FIVE_CHARACTERS_LONG (some_text VARCHAR2) RETURN INTEGER
AS
longer_than_five INTEGER;
BEGIN
dbms_output.put_line('before the if -' || some_text || '-');
IF length(some_text) > 5 THEN
dbms_output.put_line('it is longer than 5');
longer_than_five := 1;
ELSE
dbms_output.put_line('it is 5 or shorter');
longer_than_five := 0;
END IF;
dbms_output.put_line('about to return: ' || longer_than_five);
RETURN longer_than_five;
END;
set serveroutput on;And we get this output
select MORE_THAN_FIVE_CHARACTERS_LONG('a long string') from dual;
select MORE_THAN_FIVE_CHARACTERS_LONG('short') from dual;
MORE_THAN_FIVE_CHARACTERS_LONG('ALONGSTRING')
---------------------------------------------
1
1 rows selected
before the if -a long string-
it is longer than 5
about to return: 1
MORE_THAN_FIVE_CHARACTERS_LONG('SHORT')
---------------------------------------
0
1 rows selected
before the if -short-
it is 5 or shorter
about to return: 0
module ActiveRecord
module ConnectionAdapters
class OracleEnhancedAdapter < AbstractAdapter
DBMS_OUTPUT_BUFFER_SIZE = 10000 #can be 1-1000000
DBMS_LINE_MAX_SIZE = 1000
def enable_dbms_output
@enable_dbms_output = true
execute "BEGIN dbms_output.enable(#{DBMS_OUTPUT_BUFFER_SIZE}); END;"
end
def disable_dbms_output
@enable_dbms_output = false
execute "BEGIN dbms_output.disable(); END;"
end
def dbms_output_enabled?
@enable_dbms_output
end
protected
def log(sql, name)
super(sql, name)
ensure
log_all_dbms_output if dbms_output_enabled?
end
private
def log_next_line_of_dbms_output
dbms_output_text, status = @connection.exec "BEGIN dbms_output.get_line(:return, :status); END;", ' '*DBMS_LINE_MAX_SIZE, 1
got_text = (status == 0)
@logger.debug "DBMS_OUTPUT: #{dbms_output_text}" if got_text
got_text
end
def log_all_dbms_output
while log_next_line_of_dbms_output do
end
end
end
end
end
>> ActiveRecord::Base.connection.enable_dbms_outputAnd what's in log/development.log
=> []
>> ActiveRecord::Base.connection.select_all("select MORE_THAN_FIVE_CHARACTERS_LONG('a long string') from dual")
=> [{"more_than_five_characters_long('alongstring')"=>1}]
SQL (27.0ms) BEGIN dbms_output.enable(10000); END;
SQL (25.9ms) select MORE_THAN_FIVE_CHARACTERS_LONG('a long string') from dual
DBMS_OUTPUT: before the if -a long string-
DBMS_OUTPUT: it is longer than 5
DBMS_OUTPUT: about to return: 1
I have been writing a rails application on top of a large existing Oracle database where each table has 5+ triggers that each call several stored procedures and each of those PL/SQL stored procedures is hundreds of lines long. Often a simple update statement fails with an ORA-xxxx exception coming from deep in the PL/SQL code and it can be tough to figure out what's gone wrong.
The usual way Oracle database folks figure out what's going on is to put print statements in their code. In oracle this looks like
dbms_output.put_line('hi i hit this line of pl/sql');set serveroutput on;This is great if you divide the application between Rails
CREATE OR REPLACE FUNCTIONNow we can run the following in TOAD
MORE_THAN_FIVE_CHARACTERS_LONG (some_text VARCHAR2) RETURN INTEGER
AS
longer_than_five INTEGER;
BEGIN
dbms_output.put_line('before the if -' || some_text || '-');
IF length(some_text) > 5 THEN
dbms_output.put_line('it is longer than 5');
longer_than_five := 1;
ELSE
dbms_output.put_line('it is 5 or shorter');
longer_than_five := 0;
END IF;
dbms_output.put_line('about to return: ' || longer_than_five);
RETURN longer_than_five;
END;
set serveroutput on;And we get this output
select MORE_THAN_FIVE_CHARACTERS_LONG('a long string') from dual;
select MORE_THAN_FIVE_CHARACTERS_LONG('short') from dual;
MORE_THAN_FIVE_CHARACTERS_LONG('ALONGSTRING')
---------------------------------------------
1
1 rows selected
before the if -a long string-
it is longer than 5
about to return: 1
MORE_THAN_FIVE_CHARACTERS_LONG('SHORT')
---------------------------------------
0
1 rows selected
before the if -short-
it is 5 or shorter
about to return: 0
module ActiveRecord
module ConnectionAdapters
class OracleEnhancedAdapter < AbstractAdapter
DBMS_OUTPUT_BUFFER_SIZE = 10000 #can be 1-1000000
DBMS_LINE_MAX_SIZE = 1000
def enable_dbms_output
@enable_dbms_output = true
execute "BEGIN dbms_output.enable(#{DBMS_OUTPUT_BUFFER_SIZE}); END;"
end
def disable_dbms_output
@enable_dbms_output = false
execute "BEGIN dbms_output.disable(); END;"
end
def dbms_output_enabled?
@enable_dbms_output
end
protected
def log(sql, name)
super(sql, name)
ensure
log_all_dbms_output if dbms_output_enabled?
end
private
def log_next_line_of_dbms_output
dbms_output_text, status = @connection.exec "BEGIN dbms_output.get_line(:return, :status); END;", ' '*DBMS_LINE_MAX_SIZE, 1
got_text = (status == 0)
@logger.debug "DBMS_OUTPUT: #{dbms_output_text}" if got_text
got_text
end
def log_all_dbms_output
while log_next_line_of_dbms_output do
end
end
end
end
end
>> ActiveRecord::Base.connection.enable_dbms_outputAnd what's in log/development.log
=> []
>> ActiveRecord::Base.connection.select_all("select MORE_THAN_FIVE_CHARACTERS_LONG('a long string') from dual")
=> [{"more_than_five_characters_long('alongstring')"=>1}]
SQL (27.0ms) BEGIN dbms_output.enable(10000); END;
SQL (25.9ms) select MORE_THAN_FIVE_CHARACTERS_LONG('a long string') from dual
DBMS_OUTPUT: before the if -a long string-
DBMS_OUTPUT: it is longer than 5
DBMS_OUTPUT: about to return: 1

Being an enthusiastic car lover, I always dreamt of driving around the city without shelling out much on the fuel. Well here comes a car from the General Motors that not only breaks the 100 mark barrier in fuel economy rating but does so by a large margin. The Chevrolet Volt, a plug-in hybrid car is estimated to get a whopping 230 miles per gallon. It basically consists of an electric engine with Lithium batteries & a internal combustion engine. You can charge its batteries by plugging in to your household electricity when you're home. It operates as an electric car until its batteries start to get low, and then it starts running a small gas motor to power a generator and knowing that Google helped develop this technology makes it even more interesting.
A dream car to own right? Not exactly, as it carries a not too attractive sticker price of ~ $40,000 largely due to high manufacturing costs. Its battery itself costing $8000.
Expected to roll out in 2011, it seems to have got competition even before hitting the roads. Nissan recently announced the 2010 Nissan LEAF dubbed as the possible "Volt killer" claiming 367 mpg - wow!. As a consumer, its great to see competition growing towards greener technology & helping the environment.
So would you go for it? Well analysts say that you'd have to drive at least 200,000 miles—or 158,000 miles before you start saving money. Huh! probably you would be having a different car by then. Or if you dont wont to spend so much of moolah on this new super machine just wait for the technology to improve over the years which could eventually bring its price down.
Everyone collects dev tools, utilities and most folks have a list of a few that they feel are indispensable. Here's mine (of course all these on my home PC).