There will be a lot of times that you may need to search, find and locate a folder, file or a text line inside your hosting account. Linux offers a couple of very easy ways to search in your file system using SSH. In this article, we will show you the most common and easy ways to find what you are looking for the easy, fast and secure way.
What is SSH?
SSH is a network protocol that allows encrypted data transmission. It is developed to run commands on a remote machine (server) and to transfer files from one machine to another. It also allows easy management of the server you are connected to. SSH provides a high level of authentication and security during communication between servers over an insecure connection. There are multiple SSH commands that are easy to use and can help you search for, find and locate files and folders on Linux hosting servers. WebHostFace offers SSH as part of our award-winning SSH shared Web Hosting.
How to search for and locate files in LINUX using SSH commands
Let’s start by the most common SSH search for a file by its name:
find . -name MyCoolPhoto.jpg
Of course, if you are not sure about the file extension, you can locate files using SSH commands by their name only:
find . -name “MyCoolPhoto”
If you are looking to find a certain directory, you can use the following command:
find / -type d -name MyDirectory (where “/” is the starting point in our case the whole file system)
If you would like to filter for files that were modified in the four days:
find . mtime -4
Detailed explanation of how the above mentioned SSH commands work
find – this is a build-in Linux library that allows you to find files and folders through SSH
. (the dot or the first argument) – with this you specify your search start point in SSH commands. The dot in the specific example above represents the current directory of the user.
name – this argument specifies that you are making a SSH search for a file by its name
-type d – the argument type can take two values d (for directory) and f (for file)
mtime – with this argument you can easily locate files and folders in Linux that have been modified in the last X days. In the example above 4 is the number of days.
To search in SSH for a word or a sentence in a file you can use the grep command:
grep “username” wp-config.php
this command will output the username keyword in the wp-config.php file, but if you are not sure in which file this is located, you can use:
grep -r – H “username” *
This will look for the username in all files and give out the output in a recursive and human-readable format which the -r and -H options stands for.
Play around and use a Linux Dedicated Servers or Linux SSD VPS to master your SSH skills or any other TOP SSH Commands you wish. Get a new cheap cPanel hosting account now with a great discount price – 40% OFF the regular price!