• We have a 5 STAR service and only happy clients ! 5 Star Rating
  • sales@plothost.com

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

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

C:\Users\Web>curl plothost.com/kb
<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://plothost.com/kb/">here</a>.</p>


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

C:\Users\Web>curl http://plothost.com/test_file -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 http://plothost.com/test_file -o test_file.test
PS C:\Users\Web>

Related articles:
Download files in Linux


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 – https://yourdomain.com/phpinfo.php

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 https://github.com/plothost/php-list-values

phpinfo() help

How to list all logged-in users

To see the connected users on your server, you can use the shell commands: w, who or users. You can use the three commands without any parameters. For more options run the commands with the –help argument.

In the examples below, you can see there are three logged in users – you can see their IPs, logged-in time etc.

The w shell command:

root@s04 [~]# w
 01:42:08 up 22 days, 23:37,  3 users,  load average: 0.43, 0.58, 0.66
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0     01:40    1:12   0.04s  0.04s -bash
tony     pts/1     01:41    8.00s  0.03s  0.03s -bash
adam     pts/2     01:48    0.00s  0.03s  0.00s w

As you can see, the header os the result will show the current time of the server, the uptime, how many users are connected and the server load for the last 1, 5 and 15 minutes.

The next lines will show for each user – the login name, tty name, the Ip of their host, login time, idle time, JCPU, PCPU, and the current command line.

The who shell command:

root@s04 [~]# who
root     pts/0        Jan 19 01:40 (
tony     pts/1        Jan 19 01:41 (
adam     pts/2        Jan 19 01:48 (

The who command is very similar to w.

The users shell command:

root@s04 [~]# users
root tony adam

This command will only list the usernames.

w man page
who man page

Updating/Patching your Linux Server

As a web hosting server admin, you want to keep your machine up-to-date. In RedHat/CentOS, you will use the yum tool to keep your packages updated.

What is yum?
yum is the primary tool for getting, installing, deleting, querying, and managing Red Hat Enterprise Linux RPM software packages from official Red Hat software repositories, as well as other third-party repositories. yum is used in Red Hat Enterprise Linux versions 5 and later. Versions of Red Hat Enterprise Linux 4 and earlier used up2date.


To update your operating system packages:

1. Log in to SSH and switch to the root user

2. Clear the cached packages

yum clean all

On a cPanel server, the output will look like:

root@web [~]# yum clean all
Loaded plugins: fastestmirror, tsflags, universal-hooks
Cleaning repos: EA4 cpanel-addons-production-feed cpanel-plugins MariaDB103 base epel extras psrepo updates
Cleaning up list of fastest mirrors
Other repos take up 6.5 M of disk space (use --verbose for details)
root@web [~]#

3. Run the yum update command to update the packages

On one of our web hosting servers, the output is:

root@web [~]# yum update
Loaded plugins: fastestmirror, tsflags, universal-hooks
Determining fastest mirrors
epel/x86_64/metalink                                                                                                                             |  17 kB  00:00:00
 * EA4:
 * cpanel-addons-production-feed:
 * cpanel-plugins:
 * base: mirrors.unifiedlayer.com
 * epel: fedora-epel.mirror.lstn.net
 * extras: mirror.dc2.hackingand.coffee
 * updates: mirror.netdepot.com
EA4                                                                                                                                              | 2.9 kB  00:00:00
cpanel-addons-production-feed                                                                                                                    | 2.9 kB  00:00:00
cpanel-plugins                                                                                                                                   | 2.9 kB  00:00:00
MariaDB103                                                                                                                                       | 2.9 kB  00:00:00
base                                                                                                                                             | 3.6 kB  00:00:00
epel                                                                                                                                             | 5.3 kB  00:00:00
extras                                                                                                                                           | 2.9 kB  00:00:00
psrepo                                                                                                                                           | 2.9 kB  00:00:00
updates                                                                                                                                          | 2.9 kB  00:00:00
vz-base                                                                                                                                          |  951 B  00:00:00
vz-updates                                                                                                                                       |  951 B  00:00:00
(1/12): cpanel-addons-production-feed/x86_64/primary_db                                                                                          |  18 kB  00:00:00
(2/12): cpanel-plugins/x86_64/primary_db                                                                                                         |  30 kB  00:00:00
(3/12): MariaDB103/primary_db                                                                                                                    |  53 kB  00:00:00
(4/12): epel/x86_64/group_gz                                                                                                                     |  90 kB  00:00:00
(5/12): base/7/x86_64/group_gz                                                                                                                   | 165 kB  00:00:00
(6/12): EA4/7/x86_64/primary_db                                                                                                                  | 1.0 MB  00:00:00
(7/12): extras/7/x86_64/primary_db                                                                                                               | 153 kB  00:00:00
(8/12): psrepo/7/primary_db                                                                                                                      |  74 kB  00:00:00
(9/12): epel/x86_64/updateinfo                                                                                                                   | 1.0 MB  00:00:00
(10/12): base/7/x86_64/primary_db                                                                                                                | 6.0 MB  00:00:01
(11/12): updates/7/x86_64/primary_db                                                                                                             | 5.9 MB  00:00:01
(12/12): epel/x86_64/primary_db                                                                                                                  | 6.9 MB  00:00:01
(1/2): vz-base/primary                                                                                                                           |  723 B  00:00:00
(2/2): vz-updates/primary                                                                                                                        | 1.0 kB  00:00:00
vz-base                                                                                                                                                             1/1
vz-updates                                                                                                                                                          4/4
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be updated
---> Package epel-release.noarch 0:7-12 will be an update
---> Package kmod-libs.x86_64 0:20-23.el7 will be updated
---> Package kmod-libs.x86_64 0:20-25.el7 will be an update
---> Package yara.x86_64 0:3.8.1-1.el7 will be updated
---> Package yara.x86_64 0:3.11.0-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

 Package                                    Arch                                 Version                                       Repository                          Size
 epel-release                               noarch                               7-12                                          epel                                15 k
 kmod-libs                                  x86_64                               20-25.el7                                     base                                51 k
 yara                                       x86_64                               3.11.0-1.el7                                  epel                               213 k

Transaction Summary
Upgrade  3 Packages

Total download size: 278 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/3): epel-release-7-12.noarch.rpm                                                                                                              |  15 kB  00:00:00
(2/3): kmod-libs-20-25.el7.x86_64.rpm                                                                                                            |  51 kB  00:00:00
(3/3): yara-3.11.0-1.el7.x86_64.rpm                                                                                                              | 213 kB  00:00:00
Total                                                                                                                                   656 kB/s | 278 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : epel-release-7-12.noarch                                                                                                                             1/6
  Updating   : kmod-libs-20-25.el7.x86_64                                                                                                                           2/6
  Updating   : yara-3.11.0-1.el7.x86_64                                                                                                                             3/6
  Cleanup    : epel-release-7-11.noarch                                                                                                                             4/6
  Cleanup    : kmod-libs-20-23.el7.x86_64                                                                                                                           5/6
  Cleanup    : yara-3.8.1-1.el7.x86_64                                                                                                                              6/6
  Verifying  : yara-3.11.0-1.el7.x86_64                                                                                                                             1/6
  Verifying  : kmod-libs-20-25.el7.x86_64                                                                                                                           2/6
  Verifying  : epel-release-7-12.noarch                                                                                                                             3/6
  Verifying  : kmod-libs-20-23.el7.x86_64                                                                                                                           4/6
  Verifying  : yara-3.8.1-1.el7.x86_64                                                                                                                              5/6
  Verifying  : epel-release-7-11.noarch                                                                                                                             6/6

  epel-release.noarch 0:7-12                             kmod-libs.x86_64 0:20-25.el7                             yara.x86_64 0:3.11.0-1.el7

root@web [~]#

Working with yum cache
yum command cheat sheet

Page 4 of 60
1 2 3 4 5 6 60
back to top