Category Archives: Operating System

Bash Scripting Basics (Variable Assignment, If, Loop)

12345678910111213141516171819202122232425262728293031#!/bin/bash ################################################## # Benchmark the processing time when wkhtmltopdf # converts an html file to a pdf file ################################################## if [[ $1 = "" || $2 = "" || $3 = "" ]]; then         echo "Usage: … Continue reading

Posted in Bash, Linux | Leave a comment

Compress and Extract Files in Linux

Extract: .tar.bz2 To extract a tar (Tape ARchiver) file, type the following in the shell prompt: 1tar xvjf yourFileName.tar.bz2 Which will untar it to the current directory. Depending on the file structure that being compressed, it might create sub-directories. Parameters: … Continue reading

Posted in Bash, Linux | Tagged | Leave a comment

Remote copy using scp

Do you ever need to copy one file from one server to another? If you have ssh access to the remote server then you can do an scp command like so: 1$ scp remoteUsername@remoteServername:remoteFile localFile

Posted in Linux, Operating System | Tagged | Leave a comment

Delete files older than X number of days in Linux

Say you backup your database daily and you need to delete the old backup files. You can issue the command bellow which will erase any files within the specified directory that are older than 7 days. 1$ find /your/target/directory* -mtime … Continue reading

Posted in Bash, Linux, Operating System | Leave a comment

Calling a mysql query from linux or dos command line

There are times when you want to call a mysql command from the bash or dos script then call this script in a scheduler (cron job). The example below will show you how to do so. 1mysql -uYOURUSERNAME -pYOURPASSWORD -DYOURDATABASE … Continue reading

Posted in Database, Linux, MySQL | Leave a comment

Remove all svn directory

Subversion (SVN) sometimes clutter our source directory by creating .svn folder in each folder or sub folder that we version control. The easiest way to erase them is by using a bash command: 1find . -name ".svn" -type d -exec … Continue reading

Posted in Linux, Version Control | Leave a comment

Adding New VirtualHost in Apache2

On linux Ubuntu 1. If your apache has /etc/apache2/sites-available directory then just create a new file “dev.newwebsite.com.conf” with the following content: 12345678910111213<VirtualHost *:80>     ServerName dev.newwebsite.com     DocumentRoot "/var/www/www.newwebsite.com"     # Error handlers     ErrorDocument 500 … Continue reading

Posted in Operating System, php, Ubuntu | Leave a comment

SVN Tricks in Linux

To show colorized svn diff 1sudo aptitude install colordiff Then on your home directory there is a hidden file called .bashrc. Edit it. 1vim ~/.bashrc Append the following code at the end of the file 1234svndiff() {   svn diff … Continue reading

Posted in Linux, Operating System, Version Control | Leave a comment

Robocopy – Automate Your Windows Copy

I backup my files regularly using the windows scheduler. For example several folders from my windows preferences folder in drive C (C:\Users\dellxps\AppData\Roaming) to another drive, to D:\Users\Ronald\AppData\Roaming. There is a built in smart copier in windows that is not known … Continue reading

Posted in DOS, Operating System | Leave a comment

Displaying Linux Distro Version and Showing 32Bit or 64Bit OS

Checking whether you have 32bit linux or 64bit linux. From the code below we can see that it is a 64 bit linux. 12[user1@ubuntu 17:14:37 ~/dev]$ uname -mrs Linux 3.2.0-30-generic x86_64 Checking which distro you’re using: 123456[user1@ubuntu 17:14:48 ~/dev]$ lsb_release … Continue reading

Posted in Linux, Operating System | Leave a comment