Category Archives: Operating System

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

Delete All Symlink in The Current Directory

find . -maxdepth 1 -type l -exec rm -f {} \;

Posted in Linux, Operating System | Leave a comment

Benchmark How Long a Program Runs In Linux Using Bash

The following bash code might come handy for those of you who want to benchmark how long does a program runs. In the following example the assumption is that you want to pass along two parameters for your program to … Continue reading

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

Auto Login Using SSH Public and Private Keys

Assume that your main server (the one you use the most) is ServerA. And from ServerA, you want to automatically login to ServerB. For illustration purpose, ServerB can be a repo server and you don’t want to keep being asked … Continue reading

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

Linux Soft Symlink Folder or Directory

$ ln -s /home/rpringad/somefolder /home/rpringad/newfolder #or if your current directory is already /home/rpringad: $ ln -s /home/rpringad/somefolder /home/rpringad/newfolder $ ln -s existingSourceFolder newLinkedFolder

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

How To Know Which Linux Distribution You Are Using?

There are three commands that you can use, pick one of them: 12345cat /etc/issue cat /proc/version dmesg | head -1

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

How to Set up an FTP Server in Ubuntu Linux

Login to your Linux shell menu as root 12[root@locahost]# apt-get install vsftpd [root@locahost]# vim /etc/vsftpd.conf At VIM, 1st comment out anonymous_enable by adding a # sign at the beginning of the line # anonymous_enable=YES 2nd remove comment at local enable … Continue reading

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