Bash While Loop Example

How do I use bash while loop to repeat certain task under Linux / UNIX operating system? How do I set infinite loops using while statement? The bash while loop is a control flow statement that allows code or commands to be executed repeatedly based on a given condition. For example, run echo command 5…

Close ssh and leave a job running

  Using the Job Control of bash to send the process into the background: ctrl+z to stop (pause) the program and get back to the shell bg to run it in the background disown -h so that the process isn’t killed when the terminal closes nJoy! 😉  

Reset Mysql password from bash prompt

You can recover MySQL database server password with following five easy steps. Step # 1: Stop the MySQL server process. Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password. Step # 3: Connect to mysql server as the root user. Step # 4:…

One Liner to test php sending mail from a bash script

To check if your php installation can successfully send emails from a bash script try this :  php -r ‘var_dump(mail(“david.saliba@testemail.com”, “test subject”, “test body”));’ Thanks Gareth ! nJoy 🙂 !

Test if memcache is installed in php from bash line

php -i | grep -i memcache Short and sweet sample output : memcache memcache support => enabled memcache.allow_failover => 1 => 1 memcache.chunk_size => 8192 => 8192 memcache.default_port => 11211 => 11211 memcache.default_timeout_ms => 1000 => 1000 memcache.hash_function => crc32 => crc32 memcache.hash_strategy => standard => standard memcache.max_failover_attempts => 20 => 20 memcached memcached support…

Using Expect to automate an scp filetransfer

Sometimes you know passwords but are not ion a position to use shared keys. Solution is using expect to pass the password from a script read or a comman line parameter. ** NOTE Passwords in command lines are a really bad idea since you can see them in the history / ps -ef so best…