Harry Seldon's blog

Fractals, Chaos, and Control Systems on Rails

Read

Some useful commands in Linux administration when making a website.

Posted by Harry Seldon on September 27, 2008

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 demo/ -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 (svn meaning):

    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 

Create a branch:

    git branch mybranch 

Configure the user settings:

    git config –global user.name "toto" 
    git config –global user.email "toto@example.com"  

Posted in | 2 comments | Tags , , , , , | atom

Delicious

Trackbacks

Use the following link to trackback from your own site:
http://harryseldon.thinkosphere.com/trackbacks?article_id=17

Comments

Leave a response

  1. Amr Ellafi on January 22, 2009 at 11:46 am

    add file permissions to the website files :

    chown -hR www-data WebSiteDirectory

  2. Larry on January 23, 2009 at 01:31 pm

    I don’t normally like to link off to my own site in comments, however I have some really good linux cheat sheets on my blog that I wrote recently. Check them out and link to them if you like.

Leave a comment

Markdown enabled




Search

Sponsor