• 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

This Article Has Been Shared 293 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic 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

  • Cloud Computing Benchmark

    Cloud Computing Benchmark Standard is needed to quantify and standardize the performance from various Cloud Computing service providers.

  • Juju Package Manager for Cloud Computing

    Juju is a Package Manager, service orchestration management tool developed by Canonical for development of Cloud Computing of your own. It is Open Source.

  • Platform as a Service : Careful About Disaster Recovery as User

    Platform as a Service is mostly free for the small scale App, CMS Hosting. New users must be careful about Cloud Computing Disaster Recovery as users of PaaS.

  • Changing Scenario in US Based Cloud Computing : The Business Aspects

    Changing Scenario in US Based Cloud Computing Will Render the Telecommunication companies to could become the wholesale suppliers of cloud services in future.

  • Price War in the cloud : The Actual War is Rackspace Versus Amazon

    Price War in the cloud is in practical World is Rackspace Versus Amazon as infrastructure provider or rather Open Source versus closed source. Let us look deep.

Additionally, 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

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

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 (20K Followers)
  • Twitter (4.9k Followers)
  • Facebook (5.8k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.2k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is a Loosely Coupled System? January 17, 2021
  • How To Repack Installed Software on Debian/Ubuntu January 16, 2021
  • Components of Agile Software Development January 15, 2021
  • What is Conway’s Law? January 14, 2021
  • Effects of Digitization on Companies : Part XIII January 13, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "How To Find File On SSH : Examples With Log Files With Conditions," in The Customize Windows, July 27, 2017, January 17, 2021, https://thecustomizewindows.com/2017/07/find-file-ssh-examples-log-files-conditions/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

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

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