Category Archives: tricks

mount remote file systems over ssh (sshfs)

Mount remote file systems over ssh with three steps:

1. install sshfs

witr@witr-pc:~$ sudo apt-get install sshfs

2. create directory where you willi mount your remote file sustem

witr@witr-pc:~$ sudo mkdir /mnt/witrRemote

3. finally, mount the remote file system

witr@witr-pc:~$ sudo sshfs witr@serv.witr.net:myRemoteFolder/ /mnt/witrRemote/

Assumes myRemoteFolder is on witr serve home directory. See warning bellow.
————–
warn : ~ is expanded by the shell. Paths are relative on sshfs. that means : “sshfs witr@serv.witr.net:~/myRemoteFolder …” will fail with No such file or directory error.

guess ssh key passphrase

You have probably forgotten your ssh key passphrase. But you have a hunch what it might be. The simple way to check it, is to use ssh-keygen with -y argument which read private key file and print public key :

witr@witr-pc:~$ ssh-keygen -y
Enter file in which the key is (/home/witr/.ssh/id_rsa): /tmp/my_private_ssh_key
Enter passphrase:

If you input the correct passphrase, it will show you the associated public key. Otherwise, it will display

load failed

recover lost centos 5&6 root password

1. Reboot
2. Press any key after reboot when boot countdown, to go to GRUB menu
3. From that menu, select the appropriate kernel version and press the ‘e’ key
4. Then select the kernel /vmlinuz-… line and press the ‘e’ key
5. At the end of displayed line type space and then type 1 (you can type ‘s’ or ‘single’ rather than ‘1’). Press Enter to save changes
6. You should already be on the kernel /vmlinuz… line. Press the ‘b’ key to boot to these temporary options to allow you to recover your root password
7. When prompted type ‘passwd’ and press enter. You will be prompted to type new password twice
8. After typing new password and confirming it, type ‘reboot’ command.

Got from here

disk analyzer : how to ignore mounts

under ubuntu the default disk analyser (baobab) don’t offer ignore directories option.
In the case of we would like analyse the root folder / and ignore mounts in /media for example the easy way is to :
– create new temporary folder,
– mount the root filesystem on it,
– analyse the temporary folder
– unmount and delete it

So, first proceed like following

> sudo mkdir tmpAnalysis
> sudo mount /dev/sda1 tmpAnalysis
> baobab tmpAnalysis

Analysis is ready to explore.
Then

> sudo umount tmpAnalysis
> sudo rm -rf tmpAnalysis

WordPress changes don’t take effect immediately

Changes made on php files or appearance customization don’t take effect immediately, if the wordpress cache plugin is not disabled.

Edit wp-config.php and disable cache :

Cache plugins are very helpfull. Keep cache DISABLED until you are finished any customization work.

Interactive Ruby : simplify your computing

Interactive Ruby helps you to make complex computations without having to write a whole program.
Under linux type irb.

Ex1. calculate (10-7+500)*(4 power 3 )-square root of(900)

irb(main):001:0> (10-7+500)*(4**3)-Math.sqrt(900)
=> 32162.0

Ex2. get exact date at 14 days before now (in seconds 14x24x60x60 before now)

irb(main):002:0> Time.new – (14*24*60*60)
=> Thu Nov 21 15:52:53 +0100 2013