Find a string in any file in a directory

grep -ri “searchstring”

Find a file

find <path> -name *FileName*

Case Insensitive Search
find /path/to/search -iname '*.txt'
 RegEx File Name (either pipe to grep or use regex from find .)
 find | grep "*.txt"
find . -regex 'f[[:test:]]\.txt'
Or another way to find Recursively
tree -f | grep filename

Find where a command is located and the history of commands

which file , which which
history --> will show you all recent commands

Find some text in a file – e.g find ‘error’ in apache access_log

sudo cat /var/log/httpd/access_log |  grep error

sudo cat /var/log/httpd/error_log |  grep error

Reset the hostname on a linux host

sudo hostnamectl set-hostname mywebsite.com

Check OS version

lsb_release -a

On rhel - cat /etc/redhat-release

Check whether firewall port is open

grep -w '443/tcp' /etc/services

Check what my proxy server is

env | grep proxy

echo $http_proxy

 

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.