More linux helpful commands
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
Leave a Reply