Linux: disk usage command – du

du is a standard unix command to calculate disk space from Unix/Linux system.

To get the sum space of the directory,


To get sum space with human-readable,

du -sh

To get sub directories space

du -sh *

To get sub directories space with all hidden folder,

du -sk .[!.]* * | sort -n

Understand Linux runlevels

runlevels is the term that the mode of operation running in one of the computer operating system that running with Unix box.

With runlevels, it determine what should be running from the system boot or operation. runlevel is typically come with level 0-6 though it do have 0-9 or 0-10 and even S as a level.

Typical Linux runlevel come with code below,
0 – Halt
1 – Single-User mode
2 – Multi-User mode
3 – Multi-User mode with networking
4 – Not used/user definable
5 – Start from system normally with appropriate display manager
6 –  Reboot

Replace your text from a file

In Unix, basically you could easily replace all of the specific text to another text without using the editor.

By using replace command, you could replace your text within seconds.

The structure of the replace command will be as below.

replace old_text new_text — file


replace — /var/named/

with the command above, the IP of will change to for file /var/named/

How to access AwStats outside from cPanel

Many of the user will ask how could them access the AwStats outside cPanel since cPanel restricted them must log into the cPanel to get their information.

To get the AwStats for every of your webmaster to view and you do not need to let them access to the cPanel account, you may follow with the full step as below.

1. Assume that you are creating a subdomain name where I will use

1. Download the latest stable version of AwStats as URL below. (I’ll guide you for Unix tar.gz file)
2. Extract the tar file. (according to your downloaded version)
$ tar zxf awstats-6.95.tar.gz
3. Move the all folder from the extracted file wwwroot folder to subdomain folder.
4. Go to the cgi-bin folder, copy the file named awstats.model.conf to
5. Open and edit the file
– Edit the LogFile, change it to/usr/local/apache/domlogs/
– Edit the SiteDomain, change it to
– Edit the HostAliases, delete the REGEX[myserver\.com$] and change it ( and
– Edit the DirData, from . to /home/mickgenie/tmp/awstats/ where this MUST same like your cPanel setting.
6. You have done for all.

You may now access to your awstats as URL below.

Scheduled MySQL database backup

Assume that you are using crontab to schedule your task which you are using Unix system.

To schedule a database backup, it will be very easy as step below.

1. Log into your SSH.
2. Type “crontab -e” without quote.
3. Enter the command below.

0 0 * * * date=`date -I` ; mysqldump -a -u[user] -p[password]  [dbname] | gzip > /path/folder/[dbname]_$date.sql.gz

where you shall replace the user, password and dbname to your database information.

With the command as above it will actually backup your database by 12.00AM daily and place to the desired path and name with date.

How to use Linux Screen

Screen is one of the powerful command in Linux(Unix System) that allow user to run command in remote mode and this is to avoid connection timed out or etc issue causing the previous launched command stopped.

You may install screen by running yum or apt-get depending on your box, then you can start screen by typing screen at the command prompt.


Once screen session has started, you can use the following commands to mess around:

– Ctrl + A + ‘c’ = To open a New Windows
– Ctrl + A + ‘n’ = next window (if you have multiple windows running)
– Ctrl + A + ‘0…9’ = go to window number x where it should come with 0 to 9.
– Ctrl + A + ‘d’ = detach from a window. Say, if you want to close your session and return later.
– Ctrl + ‘d’ = detach and clear the screen session,

To re-attach to a screen, you may need to check the number of screen is running.

screen -ls

This will display the screens currently running, you could run the command as below to resume the screen session.
[code]$ screen -x pid.tty.user[/code]

How to remove file older than 3 days

You might ask how to remove file that existed for 3 days or more.

It is quite straight forward and easy from Unix(Linux) command if you using find.

You may refer to the sample script as below.
find . -type f -mtime +3 -exec rm -rf {} \;

As the command above, it will find the file type of file and file existed for 3 days, execute the command of rm (remove). To be clear you may refer to the detail as below.
type – file type, you may define f for file and d for directory
mtime – It could be define that the last modified date and +3 is 3 days
exec – execution of your Linux command
\; – indicate that your command end

Alternatively,  you may use atime which last active time to replace mtime. Have fun.

Run ASP.Net with cPanel

Nothing is impossible for Unix and many of the users do not know how to run ASP.Net framework from cPanel.

With this article, I will teach you how to enable ASP.Net Framework from cPanel, but before that, you must be the server owner/administrator for the server that tried to install this and have/have not setup the server.

To run ASP.Net(.aspx) from Apache, you may install third party component to support the ASP.Net. cPanel included a feature called EasyApache and EasyApache allow user to install third party component named mod_mono and mono project that make the possible for ASP.Net run in Apache.

For more information for the support component from the Microsoft .Net Framework, please refer to the mono default web page, Mono Project.

To run EasyApache, run the following script from root by using shell will do.
# /scripts/easyapache