Categories
Server

Find String in Files in Linux

To find some string within files in Linux, you can use this command

grep -rnw '/your/path/' -e "find this string"

-r means recursive
-n means line number
-w means match the whole word 🙂

Categories
JavaScript Programming

How to Install PhantomJS in cPanel / WHM Server

Here is what i did to install PhantomJS in cPanel / WHM 🙂

Categories
Server

How to Append Date and Time to Log File in Linux

If we want to get detailed log report, we can store multiple log files with date and time information on the file name 🙂

We can do this command in Linux :

your_command_here > /path_1/path_2/your_log_$(date +"%Y-%m-%d_%H-%M-%S").txt
Categories
Server

How to Delete Files in Directory in Linux

If you want to delete files within a directory in Linux, you can use this simple command

rm -f /your/directory/*

If you want to delete files and directories recursively within a directory in Linux, you can use this command instead 🙂

rm -rf /your/directory/*
Categories
Server

Empty a File Using Linux Command

Today i received an e-mail notification from cpanel that a partition in my server is almost full.
First i checked largest directories / files using this command :

du -h --max-depth=1 /some/path

Then i noticed that they were some log files which took space in my partition 🙂