Monthly Archives: January 2020

Execute Perl/PHP scripts from the command line

Executing PHP/Perl scripts from the command line is a very easy task. Executing scripts from the command line can be very useful when troubleshooting cron jobs.

For PHP, just use the php command:

root@web [/backup]# php /home/manus/public_html/phpscript.php
I am a PHP script ... :)
root@web [/backup]#

For Perl, we will use the perl command:

root@web [/backup]# perl /home/manus/public_html/
I'm a PERL script.
root@web [/backup]#

For specific command options run php -h and perl -h.

As you see, when using the commands without any options, the output will be printed on the terminal.

Share this post:

Download files from the command line in Linux

There are man times when you will have to download files from the command line. In most distributions, you have two tools – wget and curl.


This a very powerful command to simply download a file. Just use wget URL to download the file to the current location:

root@web [/]# wget
--2020-01-19 06:11:50--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 94371840 (90M)
Saving to: 'test'

100%[==============================================================================================================================>] 94,371,840  11.2MB/s   in 8.3s

2020-01-19 06:11:58 (10.9 MB/s) - 'test' saved [94371840/94371840]

root@web [/]#

To use a custom filename, the command is wget URL -O filename.


With the curl command, you can get the file content or download a file. To get file content, use curl URL:

root@web [~]# curl

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<TITLE>Test file</TITLE>

<BODY bgcolor="#EFEFEF">
Testing ...
root@web [~]#

To download a file, curl URL -o filename

root@web [/]# curl -o test_file
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 90.0M  100 90.0M    0     0  10.5M      0  0:00:08  0:00:08 --:--:-- 11.1M
root@web [/]#

wget man page
curl man page

Share this post:

How to show line numbers in vi/vim?

For displaying line numbers in vi/vim we will need to set the number flag.

Necessary steps to display the line numbers in vi/vim:

1. Edit your file with vi <filename>

2. Press the : (colon sign). The sign will appear the bottom-left of your screen

3. Enter the command for setting the number flag

set number

4. Now you will see the line numbers for your file.

Line numbers in vi/vim

To hide line numbers, press : (colon) and enter:

set nonumber

Notice that the vi/vim will not save your option to display the line numbers.

To automatically display line numbers:

1. Navigate to your home directory.

2. Create a file named .exrc

3. Edit the file and add the line:

set number

From now on, the vi/vim editor will display line numbers by default.

How to install vim
How to install nano
Show line numbers in nano

Share this post:

Download files from the command line in Windows

Probably you will not need too often to download files from the command line/PowerShell, but in case you need, we will show here how you can archive this task.

In Linux, we have two commands to download files – wget and curl. Windows OS has the curl command. The curl command came to Windows in 2008.

To get the file content from the command line/PowerShell use curl URL

<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="">here</a>.</p>


To save the file on the local disk use curl URL -o local_filename

C:\Users\Web>curl -o test_file.test
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2054k  100 2054k    0     0   342k      0  0:00:06  0:00:06 --:--:--  420k


The -o option will output the content to a file instead of the terminal.

-o, –output Write to file instead of stdout

curl –help

To see all curl options, use curl –help.

If you are using Windows PowerShell, you can also use the Invoke-WebRequest command.

The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of links, images, and other significant HTML elements.

Invoke-WebRequest Doc

PS C:\Users\Web> Invoke-WebRequest -o test_file.test
PS C:\Users\Web>

Related articles:
Download files in Linux


Share this post:

How to create phpinfo pages

Do you want to know PHP/Apache information? The easiest way is to use the phpinfo() function.

1. Log in to your control panel (cPanel, DirectAdmin, CWP etc)

2. Go to the File Manager and create a new file – phpinfo.php – in your public directory (where your site’s files are)

3. Edit this file and put the text:


4. Access the newly created file –

phpinfo() output

If you are an admin you can easily create such a file for the specific user:
1. navigate to the specific directory:

cd /home/username/public_html/

2. create a phpinfo file, edit it with the vi/nano editor and add the above PHP code:

touch phpinfo.php
nano phpinfo.php

3. modify phpinfo.php file permissions:

chmod 644 phpinfo.php
chown <username>:<username> phpinfo.php

4. access the file phpinfo.php in your web browser or send the link to the client.

Notice that on some servers the phpinfo() function is disabled. In this case, you may need to use other functions like ini_get(). A simple PHP file to get the most common PHP values is here

phpinfo() help

Share this post:
Page 1 of 4
1 2 3 4