• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How To Find File On SSH : Examples With Log Files With Conditions

By Abhishek Ghosh July 27, 2017 8:29 pm Updated on July 27, 2017

How To Find File On SSH : Examples With Log Files With Conditions

Advertisement

Basically this guide is intended to be a quick reference to the relatively new users who are not easy with using find, locate, du combined with sed, awk, head, tail, unix pipes to find and locate files with some conditions. We can use other GNU tools. We can really extract huge information from log files like we have shown on our guides to check Fail2Ban log (we have a bash script for Fail2Ban log checking derived from it), Apache2 log checking etc. Here is a guide with examples on how to find file on SSH as not always checking log is the thing we need to search.

 

How To Find File On SSH : Examples With locate

 

locate is possibly most easy to use tool readily available on Ubuntu. The package is not locate but mlocate on other Linux distro like CentOS :

Vim
1
2
3
yum install mlocate
## deb linux
apt install locate

That locate is originally developed by Miloslav Trmac of Redhat. Here is manual page of locate :

Advertisement

---

Vim
1
https://www.linux.org/docs/man1/locate.html

locate can not search realtime, but the user needs to run :

Vim
1
sudo updatedb

to make sure that newest files are in the database. We can run command like to find the file readme :

Vim
1
locate readme

To get the number of files named readme, we can run :

Vim
1
locate -c readme

So, if we need to search the Apache log related all files, we can run :

Vim
1
locate apache | grep log

 

How To Find File On SSH : Examples With find

 

We use find to locate a specific file by name or extension. The basic syntax is find . The following example searches for *.log files in the /var/log and all sub-directories :

Vim
1
find /var/log/ -name "*.log"

The utility find is powerful if you know how to use it, you can do many works. We can change permissions with find as example ( -type d is directory, -type f is files ) :

Vim
1
find /var/log/ -type d -exec chmod +x {} \;

We can make a list of the :

Vim
1
find /var/log/ -type f \( -iname '*.log' \) > loglist.txt

You cat later to check that file :

Vim
1
cat loglist.txt

That function actually locate tool serves – locate has a database. We can find empty file :

Vim
1
find /var/log/ -type f -empty

We can find conf file which is modified within last 3 days :

Vim
1
find /var/log/ -name "*conf" -mtime 3

We can find file which has content 403 inside it :

Vim
1
find /var/log/ -type f -exec grep "403" '{}' \; -print

We can more filter the above command more to catch the definite bad tries :

Vim
1
find /var/log/ -type f -exec grep "403" '{}' \; -print | grep preauth

We can find files which are greater than 10MB in size at /var/log/ :

Vim
1
find /var/log/ -size +10M

To make the above command better, we can list with sizes :

Vim
1
find /var/log/ -type f -size +10M -exec ls -lh {} \; | awk '{ print $NF ": " $5 }'

The following command finds the top 50 largest files which are sized over 10M, sort by the biggest first :

Vim
1
find / -xdev -type f -size +10M -exec du -sh {} ';' | sort -rh | head -n50

How To Find File On SSH

 

How To Find File On SSH : Examples With ls

 

ls can find files by name! Run this :

Vim
1
ls /var/log | grep sql

ls can find files by size too! Run this :

Vim
1
ls /var/log -1Rs | sed -e "s/^ *//" | grep "^[0-9]" | sort -nr | head -n20

UNIX, Linux systems are matter of how you can use the tools.

 

How To Find File On SSH : Examples With du

 

​du itself searches for size. Simply list by size :

Vim
1
du -ax /var/log | sort -rn | head -20

We can find 10 largest files in /var/log directory with their sizes in GB, MB :

Vim
1
du -ahx /var/log | sort -rh | head -20

Tagged With where to find running file when i ssh , how to find out name of ssh file , how to find files on ssh , how to check ok file in ssh , how can you look at a file with ssh? , finding documents ssh , find ssh files on windows , find ssh file window , find s sh folder windows , where to find ssh folder windows
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How To Find File On SSH : Examples With Log Files With Conditions

  • Join/Merge Multiple Log Files For Big Data Analysis

    Here Are The Ways To Join/Merge Multiple Log Files For Big Data Analysis, Store Them To OpenStack Based Cloud Storage And Delete Old Files.

  • Command Prompt Commands : Alphabetical list of all commands in Windows 7

    Command Prompt Commands in Windows 7 provides the user access to 180+ command line commands. Here is a list of 200 Command Prompt Commands in Windows 7.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • unix Commands to Check Server Logs For Security

    Here is a Basic Guide For the Beginners to Self Manage Cloud Server Instances. Master these unix Commands to Check Server Logs For Security.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy