Category Archives: Linux

You got to love Linux. Not only that it is free, but it is also very strong, stable, and widely used.

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

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

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

Find and Replace File Content using Linux Command Line

1find . -name "*.pgsql" -print | xargs sed -i ‘s/STRINGTOREPLACE/REPLACERSTRING/g’

Posted in Linux, Operating System | Leave a comment

How To List All Users or Groups in Linux

To list all users in Linux: 1cat /etc/passwd See only the first word before double colon (:) for exampple, user “root” will look like: root:x:0:0:root:/root:/bin/bash And to list all groups do the following 1cat /etc/group

Posted in Linux, Operating System | Leave a comment

Preventing Another Instance of A Program Running in Linux

The code below is my solution for preventing a program from running more than once at the same time in Linux. The scenario: Consider if you have a cron job (jobA.sh) set to run at 6PM, 7PM, and 8PM. While … Continue reading

Posted in Linux, Operating System | Leave a comment

MySQL Backup and Restore – Using Command Line

Here is how you backup database using command line. The first line is to backup and the second line is to restore. These commands work on both Windows and Linux. In Windows you might want to setup mysql bin directory … Continue reading

Posted in Database, Linux, MySQL | Leave a comment