Tuesday, July 14, 2015

My useful linux commands notes

show open files and programs holding it 
#lsof +L1

Repeatedly run a command and see output 

watch -n 1 date +%r


Create a password that works for Debian and Ubuntu  (can be used in Puppet manifests ) 


 mkpasswd -m sha-512


Create database (MySql) 

CREATE DATABASE databasename;

Create user for a database 

mysql> grant all privileges on databasename.* to 'user'@'host' \
identified by 'password';

if you want to access this database with that user over the network (tcp connection) replace the 'host' with the one you need or change to '%' to allow access from any host (a security threat) .

Delete database 

DROP DATABASE databasename;


Convert flac to mp3 - right in the flac files folder

(install flac and lame)
apt-get install flac lame

for f in *.flac; do flac -cd "$f" | lame -b 320 - "${f%.*}".mp3; done

Mount Windows shares 


mount -t cifs //FILE-SERVER-IP-ADDRESS/public /local/mountpoint -o user=nobody

Compress and Decompress Folder ( for backup or whatever ) - use p to preserve permissions


COMPRESS 
tar -zcvf outputfile.tar.gz /home/jerry/prog

DECOMPRESS 
tar -zxvf outputfile.tar.gz

Copy files over ssh using *.pem file authentication 

scp -i  mykey.pem somefile.txt root@ec2-123-123-123-123.compute-1.amazonaws.com:/tmp

Copy files to S3 bucket 

apt-get install s3cmd
( configure s3cmd to authenticate with your credentials, make sure you have the required permission for the bucket) 

s3cmd put file.tar.gz s3://bucketname/


VI(M) tips


make a .vimrc file in the user directory and in /etc/skel , type syntax on in it in order to always have syntax highlighting enabled.

:%s/foo/bar/g
Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.
:s/foo/bar/g
Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
:%s/foo/bar/gc
Change each 'foo' to 'bar', but ask for confirmation first.
:%s/\/bar/gc
Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation.
:%s/foo/bar/gci
Change each 'foo' (case insensitive) to 'bar'; ask for confirmation.
This may be wanted after using :set noignorecase to make searches case sensitive (the default).







Monday, March 16, 2015

MySQL database and user creation reminder

MySQL database and user creation reminder 



CREATE DATABASE DATABASENAME;

GRANT ALL PRIVIEGES ON DATABASENAME.* TO "USER"@"HOST" IDENTIFIED BY "PASSWORD";

FLUSH PRIVILEGES;

Enable Permalink/Clean URLs (hebrew) in WordPress

Wordpress notes: 

Enable "clean URLs" :


For hebrew ,
1-  change apache default encoding to utf-8
2- enable mod_rewrite :

To enable it the rewrite module, run "apache2 enable module rewrite":
sudo a2enmod rewrite
You need to restart the webserver to apply the changes:
sudo service apache2 restart
If you plan on using mod_rewrite in .htaccess files, you also need to enable the use of .htaccessfiles by changing AllowOverride None to AllowOverride FileInfo. For the default website, edit /etc/apache2/sites-available/default:
    
            Options Indexes FollowSymLinks MultiViews
            # changed from None to FileInfo
            AllowOverride FileInfo
            Order allow,deny
            allow from all
    
After such a change, you need to restart Apache again.
3. Change Settings->Permalink settings in WP 





    Wednesday, February 25, 2015

    Is the low oil price pointing to an upcoming war to be lead by the next (Republican) President?

    OPINION: Hussein Obama's two terms presidency looks just like another proof of American voters being ignored by the (power) minority pulling the strings backstage.


    They run the show since ever,  and it becomes more and more apparent to the naked eye.
    I believe that this power minority doesn't care about the presidential candidate's political side as long as his goals or ideology serves their agenda. That's how they decide to affect the Electoral College in order to choose their man.
    So at the time they elected Bush, of course, a Republican,  to conquer Iraq and control the energy market.  So he did his part, and they thought they've succeeded to enroll Iraq in this plot. After that, a Democrat, Bill Clinton was put to power in order to continue the military punch with contracts, peace processes and 'economy' driven acts. It still didn't work out so... again use of force by Bush Jr. 2003 with 9/11 in the reasons arsenal. Maybe there's a truth behind the ME hatred for America's intervention in their own business, after all.

    Now, again Obama, drawing back the army from the ME and making deals with the devil. Deals that are not in the favor of his alleged voters but the interest of few people behind the wheel.
    They make money on the way to their target by selling everything the well paying Army needs by owning the weapons and supplies companies. And they make even more money if they can play with the energy price. I'm not sure what's best for them, low or high, looks like they prefer the higher. All interventions by the US caused the oil price to jump at least for a long while.

    They demolish buildings and burn the evidence, manipulate insurance companies, Wall Street during expected radical attacks. They own the media and cut out footage that raise questions. Everything is Kosher.

    Does a low oil price points to an upcoming war? Is a low oil price a reason for aggression by the oil countries?  The lower revenues might fuel terrorism cause no Arab country can declare war on America, which in turn requires another military intervention ?!
    Obama was instructed to calm down the public doing nothing. Meanwhile, make some money. So he did in a lucrative way, pulling back the Army and turning against EU. The US seized and amended accounts and banks for compliance reasons and by controlling the money moving mechanisms.
    Bush Jr. was the one sitting shocked in the kinder garden chair holding the book upside down when 9/11 attacks occurred, not Bill Clinton who few years before created the background for it.
    Obama will be gone soon, for his bosses he has done his job. But the loose hands in the ME  probably just cooked the next attack on America. The proportion might be linear or exponential, but the scale will be in its league and probably make 9/11 look a pale small incident GD forbid.
     It doesn't have to be an explosion; it can manifest in a spiritual way, like Koran mandatory teaching in schools, Arab mass emigration, just an example.

    We forgot, being overwhelmed by the reality, but the 24 TV series  was a detailed premonition.

    The next president will be a Republican. He will forcedly swallow what Obama passively prepared ... and if televised for some reason, he will have the same lost look on his face, in total disbelief of what just happened.
    America and the string pullers got a real problem trying to repeat the Japanese (society reset) model, although it worked only once by using the Judgment Day weapon. The Japanese, stubborn as they had been, didn't rely on God's "will" as the Arab's.
    An Atheist/Christian society has all the means and technology to hurt anyone badly. However,  it lacks the patience, the inner strength and motivation to win the mighty long war against monotheistic ideology, as twisted as it might be in Islam's case.
    As long as sugar is the main ingredient in America's food, the masses will continue to watch American Idol and do 9 to 5 until the next bump.
    I hope this opinion didn't trigger too many threat flags on NSA's content analysis systems.