Author: Jason Mazzota

How to Use the Linux Find and Locate Commands on a Linux Cloud Server

Verified and Tested 2/22/16


The Linux find command allows you to find files or directories using fields such as age, group, name, last modified, size, type, and many others. This is very useful when you’re working on a Linux system which you are not familiar with. We will go over the basic and most commonly used flags you’ll run into in our Find section.

The Linux locate command comes paired with its partner updatedb. The locate command allows you to locate files that contain your searching criteria and displays them out for you. The updatedb partner it has is what keeps the locate command up to date on the files in your system. It can essentially be seen as a directory list and your locate command helps you sort through for locations/files that have what your searching for in the path or name.


A Linux server with find and locate installed. Try our Linux Cloud Hosting if you don’t have one – we even offer HIPAA-compliant cloud hosting and cloud storage. The find command typically comes installed on Linux operating systems by default. If it does not, you can use your operating system’s package manager(yum, apt-get, pkg_add) to install it. Depending on your operating system, locate may be installed as well. If it is not, you can install it via your operating system’s package manager and installing its containing package. This package is typically called “mlocate.”


Let’s Find something!

If at any time you are confused by find and it’s command or you wish to know even more about it, you can bring up its manual with the below command. The manual contains all information regarding using the find command in great detail.

# man find

When using find, you would follow the syntax below.

find [options] [path] [expression]

options: This is optional. You can leave this out most of the time. You can read the manual page for all the options the find command has.

path: This is the directory you want to search.

expression: This is where you place your search criteria for what you want to find whether by name, or size etc.


With the below we will be going over multiple ways on using find.

Let’s find any files named index.html without knowing the directories the files may be in.

#find / -name 'index.html'


/ : This is the “/” directory which causes you to search the entire “slash” directory.

-name : This is the flag telling “find” to search for a pattern, in this case, the name pattern which compares the names of files with your expression.

‘index.html’ : This is the expression you’re searching for.


Now we’ll find a file call index.html in a specified directory.

#find /var/www/html -name 'index.html'


This will cause find to search only the /var/www/html directory for any files named ‘index.html’.


In this example, we’ll have “find” find a file call index.html in a specific directory ignoring the casing of the name.

#find /var/www/html -iname 'index.html'


-iname : This is the flag telling “find” to search for an expression, while ignoring the case of the text.


Now we’ll search and “find” a directory’s name while ignoring the case of the directory.

#find / -type d -iname 'www'


-type d : This tells find to look only for directories, not files. If you change the “d” to “f” you will get the opposite and find files instead.


And now we’ll find every file on the system that ends in .php.

# find / -type f -iname "*.php"


*.php : The * in the expression stands for a wildcard. A wildcard will grab any file it finds as long as it ends with what follows it. In this case it is “.php”


We will continue with an example of finding a file ending with .cgi that has 755 permissions and we’ll ignore the case.

# find / -type f -iname "*.cgi" -perm 755


-perm 755 : The flag ‘-perm’ searches permissions in the directory specified. In our case it searches for files with ‘755’ permissions.


Now we’ll get time specific. We’ll search for files which have been modified between now and 10 days ago.

# find / -type f -mtime -10

(we don't have any)

-mtime -10 : Find any file that’s been modified between now and 10 days ago in the specified directory. As you can see the from 10 days ago til now is signified by the “-” in front of the 10. If you wanted to find anything older than 10 days, you can change the “-” to a “+”. This will have the search only list files that were changed 10 days ago and onward. If you wanted to find a file changed in the last 24 hours, you can actually use “-mtime 0” as it has not been a full 24 hours.


We can find files by size.

# find / -type f -size +50M -size -100M


-size +50M -size -100M : With “-size” you tell find to search by size. In our case +50M which would be files more than 50 megabytes in size. We limit the search with a -100M which means the maximum file size can only be 100 megabytes. You can specify other file sizes such as bytes(c), kilobytes(k), and gigabytes(G). Case does count in this situation as not using the correct notation can lead you searching for the wrong information.


And finally, find can not only be used to search for files or directories, but you can also execute and run commands for each item found. Please note that executing a command while using find can lead to dangerous results if you do not know exactly what you are doing.


# find / -type f -size +50M -size -100M -exec du -lsh {} \;

70M     /usr/sbin/mysqld-debug
84M     /usr/sbin/mysqld
62M     /usr/lib/jvm/java-1.8.0-openjdk-
95M     /usr/lib/locale/locale-archive
65M     /var/log/messages
54M     /var/lib/rpm/Packages

-exec : This flag tells find that for each item found, run the following command

du -lsh : This command prints in a more readily human readable format that size of a file.

{} : This serves as a placeholder. Each time an item is found, the item is placed in place of these brackets and executes the command preceding these brackets. So in the example find will execute a “du -lsh” on it item found.

\; : This finishes the “-exec” statement. You must end every find command containing “-exec” with a ‘\;’ or it will fail.


And that’s the basics of using the Linux command “find”. There are many more flags to explore such as “printf” for output formatting, “max/min depth” which limit how deep find will dive into a directory, and “newer” which compares if a file was modified more recently than another file. Keep using find and soon you’ll be able to “find” anything.


Let’s Locate some files!

Locate in a few ways is like “find” discussed above in that it is another method of searching your operating system to find a file. One of the key differences with locate is that it will discern between a directory or file. It will always look for both. Locate comes paired with it’s partner command “updatedb” which, as it looks like, updates the DB or database of files it has that locate can parse through. Locate will not provide you with full, accurate results unless you run it’s partner, “updatedb” first.

When using locate, you’d want to follow the syntax below.


[OPTION] : Would be any and all options that locate can use. For a full list of the options, you can see the manual page (#man locate).

PATTERN : This is what you would be searching for.


So getting started, lets first run updatedb.


Updatedb will not give any output but will simply drop the shell to the next line once it has completed. Now lets try to locate any .repo file.

# locate *.repo


*.repo : This again is a wildcard search which allows us to find any and all files that end in .repo


You can use locate to find directories as well. In this case, we only want to look for the www directory, so we restrain the search to looking only for “www”.

# locate -b www


-b : This option tells locate only to pull files/directories that contain or end with www and nothing else. The opposite of this is -w which is what locate does by default and will find absolutely anything with your pattern in it.


We can also tell locate to search for a file or directory and ignore any casing.

# locate -bi noindex.html


-bi : The -b option is explained above but this time we tacked on -i as well. -i is what allows you to ignore casing in your search.


Now lets say you want to limit your locate results to only a few. We’ll use the *.repo search early and search for only three results.

# locate -il 3 *.repo


-il 3 : The new tack on this time is -l #. -l tells locate to limit the search to the number of results you put after it. If you use -l, remember to always use it last on your options list if you are combining options or to separate it (in this case -i -l 3) otherwise you will get an error.


Unfortunately locate does not have a built-in ability to execute commands per result found like find does. But like “find” and most any commands in Linux, you can pipe the results to narrow out your results. “find” allows you to do a lot of limiting with the options it provides but locate doesn’t have that innate ability. So to limit our results we’ll “pipe” them to “grep” which is a command that prints lines only for the results containing the pattern given to it.

# locate -i index.html | grep www


| : This is the pipe command

grep www : This limits out the results to only list the results that have a www in them whether in the name or part of the directory.

And those are the basics of the locate command. While it doesn’t have the flexibility that the find command may have, it is another searching tool and doesn’t require you to know much about Linux to use it. There are options to provide more results like -L which will follow symbolic links, -e which only lists files that exist at the time locate is run, and -c which provides a count for how many results are found, and more. The very best thing to remember about using locate is to always make sure that you do an updated before running locate to get accurate, up-to-date results.

How to Install and Configure Fail2ban on CentOS

Verified and Tested 4/28/16


Fail2ban is a great, wonderful service that is primarily used to stop brute forcers from accessing your system. It’s simple to install and configure and works great at deterring your basic attackers away.

This article is specifically for installation on Centos. To install  and use Fail2Ban in Ubuntu and Debian, check out our how-to on that here.

Installing and configuring Fail2Ban on CentOS

We will be performing steps below as the root user. You will just need to sudo if you are using another user. For all editing of configuration files, we will be using vi. However, you can use whichever editor you are comfortable with. This installation is performed on a clean CentOS 6.5 64bit cloud server.

Read More

How to Enable MySQLi in cPanel/WHM with EasyApache 3

Jason Mazzota January 25, 2016 by under VPS Hosting 0 Comments
Verified and Tested 1/11/16


In this tutorial we will walk you through enabling MySQLi in cPanel/WHM by using EasyApache. MySQLi is an extension used for PHP coding so PHP can interface directly to MySQL.


A server with cPanel/WHM installed and using EasyApache 3.  If you do not have a server and need one, Atlantic.Net offers reliable VPS hosting options.

Note: EasyApache 4 is still listed as a Technology Preview. Because of this, not all features or security updates are available should you replace the EasyApache 3. It is not recommended that you enable EasyApache 4 at this time.

Enabling MySQLi in cPanel/WHM with EasyApache 3

Installing the MySQLi extension is a simple process in cPanel/WHM. The first thing you will want to do is log into WHM and in WHM’s search bar, enter “EasyApache.” From here you will need to select EasyApache 3. If you do not have the latest cPanel/WHM update, your option may just say “EasyApache.”

Read More

How to Limit Your Root User Access in Debian and Ubuntu

Jason Mazzota January 7, 2016 by under VPS Hosting 0 Comments
Verified and Tested 1/7/16


What we’ll be doing in this tutorial is making it so that you can no longer SSH using your root user. In this article, we are using Ubuntu 14.04 64bit in our Cloud. However,  this also works on any modern version of Ubuntu or Debian. We will be making a new user on the server to use as our new SSH user and we will be setting the user up to be a sudo access user. In other words, the new user will be able to access commands as if it were the root user!


A server with root access on Debian or Ubuntu. Need a Debian or Ubuntu server? Try one of our VPS hosting solutions.

Limiting Your Root User Access in Debian and Ubuntu

First, we will want to SSH into our server as the root user using your preferred SSH client. Now what we will want to do is run the below command to make a new user and their home directory.

adduser newuser --home /home/newuser

You will want to change “newuser” to be the new user that you wish to create. After running this, you will be prompted to create a password for the user. After creating the password, you will be prompted to add details to this new user. These details are for you and you may fill them out if you’d like. If not, simply press enter through each step and finish by verifying your new user information and entering ‘y’ for yes and pressing enter.

Remember to always use strong passwords!

Sample adduser

Sample adduser

Now, we will want to edit our sudoers file so that our new user can run commands like the root user.


note*In Debian, you do not need to configure your visudo. In fact, all you need to do is run:

adduser newuser sudo

Where newuser is your username. If you are running Debian, you may skip to the testing the new user section below.

In your sudoers file, you will need to locate the area that has the below information. This is where we will be adding our new user’s rights. Right under the root entry, you will want to make the entry:

newuser ALL=(ALL:ALL) ALL

The newuser entry is your new user. It should look similar to the below picture.

Sample sudoers

Sample sudoers

If you don’t know how to edit in vi, you will want to (on your keyboard) hit the Insert button. Then go to the location to add the new user information and type it out. When you are done hit the ESC key on your keyboard and then do “:wq!” to save your changes.

Now the next thing to do is to test the new user! The best way to do this is to either log out or create a new SSH session using that new username and password to log in. Once you log in successfully, we can test your sudo access by going into the SSHD configuration file as the new user. This is because we still have one more change to do to prevent root log in. You can use your favorite editor for this part, we are using vi.

Note: To use other commands on the server “as root” you will need to preface it with sudo

sudo vi /etc/ssh/sshd_config

This command will open the SSHD configuration file like you are the root user. You will want to locate the “PermiteRootLogin” option indicated by the green indicator in this picture and change the “yes” to a “no”

locate the “PermiteRootLogin” option indicated by the green indicator in this picture and change the “yes” to a “no”

Once done, save and exit the file. Then run:

sudo service ssh restart

You will now be unable to SSH to your server as the root user.

Thank you for following along this how-to, we hope you enjoyed it.  Please check back here for new updates or check out our related articles below.

How to Install CodoForum software on Ubuntu with Nginx

Jason Mazzota December 23, 2015 by under VPS Hosting 0 Comments
Verified and Tested 12/23/15


This walkthrough will take you through a base installation of CodoForum on an Ubuntu server that has Nginx as the web application and MySQL and PHP installed. At this time, the current download of CodoForum is .


An Ubuntu server with LEMP (Nginx, PHP, and MySQL ) installed. Use our Ubuntu LEMP guide, if needed. We also offer Nginx with Ubuntu as part of our One-Click Applications on our Cloud Service under the application name LEMP Cloud Hosting.  If you do not have a server already, you may try one of our fast SDD VPS Servers.

Read More

How to Install Webmin on CentOS 6.7

Jason Mazzota December 9, 2015 by under VPS Hosting 0 Comments
Verified and Tested 12/8/15


In this tutorial, we will be instructing you on how to install Webmin, a web-based interface for system administration, on a server running a base CentOS 6.7 server. With Webmin you can setup specified user accounts, web sites through Apache, your DNS locally, and more. Webmin removes the need to manually edit configuration files and lets you manage the system from a GUI (Graphical User Interface.)


For our tutorial, you will only need to have a server running CentOS 6.7 and access to the Internet. If you do not have a CentOS server, Atlantic.Net offers fast SSD virtual private servers, up in 30 seconds.

Read More

How to Install Discourse Forum on Ubuntu 14.04

Jason Mazzota November 4, 2015 by under VPS Hosting 0 Comments
Verified and Tested 10/28/15


This walkthrough is written to walk you through the base install of Discourse on an Ubuntu 14.04 LTS Server. Discourse is an Internet forum software application, that is fun and easy to use. To keep the installation process as simple and straightforward as we can, we will be using Git and the application Docker. The installation process will automatically install and configure base access for Nginx (Web Application) and PostgreSQL (Databases).

One of the best features of Discourse is that it is 100% open-source. Not only does the community help develop the forum software but it has a built-in API and is completely mobile friendly with plug-ins for CDN (Content Distribution Networks) and it has SEO built-in for your URLs. You can also, of course, customize the look and how Discourse functions for your needs.


You will need a server running Ubuntu 14.04 LTS without a web service application installed. If you do not have a server, try Atlantic.Net’s cost-effective virtual private servers.

Minimum recommended system memory is 1GB of RAM.

Installing Discourse Forum

As the first step of install Discourse, you will want to install their Docker/Git application. You will want to connect to your server via SSH or VNC and run:

wget -qO- | sh

Once done, you will need to make a Discourse folder, and Git clone the Discourse Docker into the new directory:

mkdir /var/discourse
git clone /var/discourse

Following that, copy the standalone.yml from the samples directory to a container called app.yml. This will be our container we run Discourse in:

cp /var/discourse/samples/standalone.yml /var/discourse/containers/app.yml

Once copied, we will want to edit the app.yml with our settings, specifically administrative email. If you do not do this and do this with invalid information, Discourse will not build, and there is a possibility with incorrect information that you will be unable to create users. The spots to look for are in the picture below encased in red.

nano /var/discourse/containers/app.yml
app.yml email config

app.yml email config

For the developer email address, make sure to use the email address that will belong to the administrator account. You can use more than one email for this, just make sure to separate them by a comma.

-The Discourse hostname will need to be the hostname for the server or for the forum itself. It is the hostname you want to type in the address bar in order to get to the forum.

SMTP_ADDRESS - the SMTP address Discourse will be using to send emails (required).

If this server requires additional information (such as a username and password) in order to relay/send mail, you will need to uncomment the lines after (remove the #) and edit:

SMTP Port - The port that SMTP responds to on your email server.
SMTP Username - The username for the email account that will be sending the emails.
SMTP Password - The password for said account.
SMTP Start TLS - If TLS has to be enabled, set this to true, otherwise set this to false.

*Note* One major point outside of email is the basic configuration. If you have a 1 GB server (it is not recommended that you have anything lower than this) you will want to change the UNICORN_WORKERS field to be a value of 2 and db_shared_buffers to be 128MB.

app.yml mem and unicorn config

app.yml mem and unicorn config

Once this is done you can save and exit the file.

Now we simply run:

/var/discourse/launcher bootstrap app

This will cause Discourse to start building. This process can take some time. Once it’s finished building the below command to start Discourse. You may be prompted with a”Your system may not work properly” warning if you are performing this install on Atlantic.Net’s Cloud service. If there is an error, the build process will stop and tell you to scroll up to see the error. The most likely cause is that either the system hostname or email settings are not configured correctly; take a look at your /var/discourse/containers/app.yml file again to verify your settings.

/var/discourse/launcher start app

If this command runs with no errors, you now have Discourse running! Simply go to your configured hostname and you should see Discourse running. You may be prompted with a”Your system may not work properly” warning if you are performing this install on our Cloud service. If there is an error it will state so and refer you to scroll up to see it. You may simply hit Enter to continue.

Once Discourse is running, you will need to make your Administrator user. You will want to register a new user that will have the Developer email address. This will automatically make that user an Administrator.

Sign-up location

Sign-up location

If you cannot create the user (email doesn’t reach you) you can run the following to create the admin user. You may be prompted with a”Your system may not work properly” warning if you are performing this install on our Cloud service. If there is an error it will state so and refer you to scroll up to see it. You may simply hit Enter to continue.

/var/discourse/launcher enter app
rake admin:create
exit (once all done with the creation)
manually create admin

manually create admin


The create command will prompt for an email address. Once you put in the developer email address, it will prompt a user with that email already exists and if you want to reset the password. You can say ‘y’ if you want to or ‘n’ if you do not. After this, it will ask if you want to make the user an Admin. To this, you will hit ‘y’. You may now log in with the user you just previously tried to create. You will want to fix the email issue otherwise you will need to run this and go through these options for every user you plan to have.

That’s it. You can now log in as an admin and do anything on the admin side you want. Your forum is now running! Check back later for any additional articles about Discourse configuration.

How to Use Rsync to Copy/Sync Files Between Servers

Jason Mazzota October 2, 2015 by under VPS Hosting 0 Comments
Verified and Tested 10/02/2015


Rsync is a great way to synchronize files between servers or to simply move files between servers without the need of FTP. It connects two servers via the SSH protocol, allowing for the transfer of data between them. The rsync daemon, covered later in this article, uses its own protocol and runs on a specified port. Below we’ll go over the basics; copying between servers, copying to/from rsync daemons, and keeping files in sync with each other on different servers.


– 2 Linux servers that both have rsync installed.
– The server doing the initiating of the transfer needs to be able to access the receiving server’s SSH port (or rsync port, if connecting to an rsync daemon).
– The user needs to have permissions to use rsync (the examples below will be run as the root user).

Read More

How to Set Up an Rsync Daemon on Your Linux Server

Jason Mazzota September 28, 2015 by under VPS Hosting 0 Comments
Rsync Illustration by Walker Cahall

Rsync Illustration by Walker Cahall 

Verified and Tested 09/28/2015


This tutorial will take you through setting up an rsync daemon on your Linux server. You might want an rsync daemon if you have files that you want available so anyone (or just yourself) can download existing files or upload new files. This guide will review both running rsync as its own daemon and running it via xinetd.


– A Linux server with rsync installed – if you do not have a server already, why not spin up a robust and reliable VPS Server in under 30 seconds.
– (Optional) Xinetd installed.
– Appropriate permissions to read and/or write on the rsync daemon (this tutorial will show commands run as the root user).

Read More

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4


London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom