-->
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, August 15, 2014

how to migrate your mongodb into a bigger volume

First stop your mongodb
sudo service mongod stop
Assuming that your existing mongo installation is on /var/lib/mongodb/
sudo mv /var/lib/mongodb/ /your/preferred/destination/for/mongo/
set the rights correctly
sudo chmod -R mongodb.mongodb /your/preferred/destination/for/mongo/
and update the mongodb configuration file

# dbpath=/var/lib/mongodb 
dbpath= /your/preferred/destination/for/mongo/

Thursday, March 27, 2014

Notes on the most beautiful shell of the world: fish!

  • How do I run a command every login? What's fish's equivalent to .bashrc?
    Edit the file ~/.config/fish/config.fish, creating it if it does not exist. (Note the leading period.)
  • How do I set my prompt?
    The prompt is the output of the function fish_prompt. Put it in ~/.config/fish/config.fish, or in ~/.config/fish/functions/fish_prompt.fish. For example:
      function fish_prompt
        set_color $fish_color_cwd
        echo -n (prompt_pwd)
        set_color normal
        echo -n ' > '
      end

Thursday, March 21, 2013

calculate load of individual machines on a cluster


Use :

$ uptime


Output:

20:57:50 up 196 days,  1:36,  4 users,  load average: 4.00, 4.00, 4.42


The load averages reported are system load averages for the last 1, 5 and 15 minutes respectively.

Note that a  load average of 1 means there's enough work being done by the system to keep 1 CPU busy 100% of the time. (So either 1 process taking 100% or 2 processes taking each 50% etc.) A load average of 2 would likewise be enough to consume 100% of 2 CPU's. Etc.

Combine it with pssh to simultaneously check the load on multiple machines :

$ pssh -h ~/bin/spiders.pssh -o ./cluster.log "uptime"

Monday, March 18, 2013

command line emails from ubuntu

frome the excellent post of  http://askubuntu.com/questions/12917/how-to-send-mail-from-the-command-line


  • Install ssmtp Install ssmtpsudo apt-get install ssmtp
  • Edit the ssmtp config file : gksu gedit /etc/ssmtp/ssmtp.conf
  • Enter this in the file:
    root=username@gmail.com
    mailhub=smtp.gmail.com:465
    rewriteDomain=gmail.com
    AuthUser=username
    AuthPass=password
    FromLineOverride=YES
    UseTLS=YES

    you can then use 
    mutt or mailx to send your emails from command line

Wednesday, March 13, 2013

script to rename directories / files with spaces

here's a small script that normalizes directory names by getting rid of empty spaces in the directory name. Worth is noticing that can be tweaked to remove other unwanted characters:


find  -type d | \ find all the directories 
 grep " "\ get only the ones with a whitespace
 | while read line; do\ 
 mv -i ${line} \
`echo  ${line} | sed 's@ @_@g' `\ replace the space 
; done 


in one line the commands for

normalizing directory names

find  -type d | grep " " | while read line; do  echo "[RUN]: Normalizing directory "${line};  mv -i ${line} `echo  ${line} | sed 's@ @_@g' `; done | m

normalizing filenames

find  *  | grep " " | while read line; do echo "[RUN]: Normalizing filename "${line}; mv -i ${line} `echo  ${line} | sed 's@ @_@g' `; done 

Sunday, March 10, 2013

sending mail with attachements


use mutt:

echo "This is an attached file" | mutt -s "[DEBUG]: New version of the document"  yourdestinationmail@gmail.com -a temp.doc

stop not so secure/useful services on ubuntu

services you want to stop on your ubuntu server for improving security:

sudo netstat -ntaupe | grep LIST
sudo service  statd stop
sudo service cupsd  stop
sudo service cups  stop
sudo service rpcbind  stop
sudo service portmap  stop

enable daemon.log in ubuntu