Harry Seldon's blog

Psychohistory on Rails

Some useful commands in Linux administration when making a website.

Posted by Harry Seldon Sat, 27 Sep 2008 21:57:00 GMT

This is a cheatsheet of useful commands in Linux administration when making a website in Rails. I am using these commands over and over again so I thought it might help someone.

Linux 
—–
Detailed list of files 
    ls -l 
List the running processes 
    ps -e  
Create a directory 
    mkdir demo 
Kill the use of a specific port (I use it when Aptana/RadRails crashes and do not close the port) 
    fuser -k 3005/tcp  
Delete a directory and subdirectories, without confirmation, verbose mode. (BE CAUTIOUS !) 
    rm 20080120165422/ -r -f -v  
Add a cron jon 
    crontab cron_job.txt 
List cron jobs  
    crontab -l 
Create cron job 
    crontab -e 
Mount a local virtual directory for an actual remote directory 
    sshfs ‘-oworkaround-rename’ username@ssh.domain.com: /home/username/remote/ 
 
MySQL 
—–
Connect to mysql local server: 
    mysql -u username -p 
Connect to mysql remote server: 
    mysql -u username -h mysql.domain.com -p 

Create databases (Rails style) 
    CREATE DATABASE demo_development; 
    CREATE DATABASE demo_test; 
    CREATE DATABASE demo_production; 

Rails 
—–
Create a rails app 
    rails demo  
Install a plugin 
    script/plugin install git://github.com/pullmonkey/open_flash_chart.git 
Install a plugin, force reinstall 
    script/plugin install git://github.com/pullmonkey/open_flash_chart.git –force 
Launch server on a specified port 
    script/server -p 3005  
Open a console where you can send ruby commands to your app (Extremely useful!) in dev mode
    script/console development
Open a console where you can send ruby commands to your app (Extremely useful!) in prod mode (BE CAUTIOUS !)
    script/console production
Migrate the database 
    rake db:migrate 
Migrate the database to a given version  
    rake db:migrate VERSION-22 
Migrate the production database 
    rake db:migrate RAILS_ENV-production 
Install gem  
    gem install RedCloth 
Install a given version of Rails 
    gem install -v-2.0.2 rails  

Git  

Checkout a repo 
    git clone git://github.com/pullmonkey/open_flash_chart.git   
Get the differences 
    git diff 
Fetch from and merge with another repository or a local branch 
    git pull 
Checkout  
    git checkout 
Configure the user settings 
    git config –global user.name "toto" 
    git config –global user.email "toto@example.com" 

H

Posted in | no comments | Tags , , , , , | atom

Trackbacks

Use the following link to trackback from your own site:
http://harryseldon.thinkosphere.com/trackbacks?article_id=linux-admin-cmd&day=27&month=09&year=2008

Comments

Leave a response

Leave a comment