Linux Commands

Warning message

JQuery Cycle must be installed in order to run the slideshow. Please go to Status Report for instructions.

In below example we will find total number of audio/video files and add their sizes to show total volume on disk.

find /folder/destination -type f -regex '.*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\|mp3\)' -exec du -ch {} + | grep total$
7.8G total

/folder/destination is destination of your folder inside which you want to calculate total size of audio/video files

To calculate total size any folder browse in that directory and run:

du sh

If apache server failed to restart like this :

sudo service httpd restart
Stopping httpd: [FAILED]
Starting httpd: [FAILED]

then you need to check error logs which might be under this directory if you are running CentOS:


inside this directory you will see error_log. Open this file and read last few entries with:

trail -100 error_log

and if you spot that last few entries are like this :

[Fri Apr 14 19:59:25 2017] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

Then probably you have mis-configured your ssl.conf file or its got corrupted. This file can be under directory:


now to fix this error you need to rename your existing ssl.conf file with mv command:

mv ssl.conf ssl.conf.old

and then create one new ssl.conf and put the defaults contents in it from this comment:
or download from attached post and rename from ssl.conf.txt to ssl.conf and save it on your server.

and press :wq to save and quit.

Now restart your apache server to see if problem is gone:

sudo service httpd restart

Stopping httpd: [ OK ]
Starting httpd: [ OK ]

By using the -r parameter we can run a script in-line.

php -r "require 'mylocation.php'; callmyfunc(143);"

where -r Run PHP without using script tags <?..?>

The above line will call callmyfunc() function with numeric argument 143 inside a mylocation.php file.
To run the above command you chould be in the directory where mylocation.php resides.

To count total number of directories within specific directory you have to go to one step back from the directory you want to count.
For example you have to count number of modules in modules folder on path /sites/all/modules. First navigate to folder /sites/all and then run the below command :

ls -l modules | grep -c ^d 

where "modules" is the name of the folder inside which you need to count directories.

Run following on Linux terminal :

ps -ef | grep apache

which will yield the result like

root  3753   1  0 Jul12 ?    00:00:19 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf

The last parameter above ( /etc/apache2/httpd.conf) will show the apache directory and the path of httpd.conf .

To download the file use :
scp username@serveraddress:file_location_from_copy file_location_to_copy
For example :

scp root@ ./downloads/

To upload the file use :
scp -P port_name file_location_to_be_copied_from username@serveraddress:file_location_to_replace_on_server
For example :

 scp -P 222 abc/abc.module UserX@

Note : Upload command will replace the file from its new content

1) For RedHat Linux (Fedora Core/Cent OS) use the following command:
# To Start MySql Server:

/etc/init.d/mysqld start
service mysqld start

# To Stop MySql Server:

/etc/init.d/mysqld stop
service mysqld stop

# To restart MySql Server :

 /etc/init.d/mysqld restart
service mysqld restart

2) For Debian / Ubuntu Linux use the following command:
# To Start MySql Server:

/etc/init.d/mysql start

# To Stop MySql Server:

/etc/init.d/mysql stop

# To Restart MySql Server :

/etc/init.d/mysql restart

To get all information about PHP :

 php -i 

To get only specific version of PHP

 php -v 

You can copy the directory to another directory :

1. Without copying that directory itself

cp -R one_directory/* another_directory

Here cp is copy command and R is used for recursive copying.

2. By copying the whole directory

cp -R one_directory another_directory

To remove all files and folders inside a folder you have to use :

rm -rf FolderName


Subscribe to RSS - Linux Commands