This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to Zip the files from given start date to end date | |
### find all files that were modified less than 29 days ago and more than 21 days ago. | |
# find . -type f -mtime -29 -mtime +21 | zip -@ my.zip | |
# tar cvf - `find . -type f -mtime -29 -mtime +21` | gzip -c 1>061110_061201.tgz | |
# find largest files | |
# du -m /some/path | sort -nr | head -n 20 | |
# find / -type f -size +20M -exec ls -lh {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Latest_files(options, roots): | |
"""" A generator to enumerate the contents of directories recursively. """ | |
for root in roots: | |
for dirpath, dirnames, filenames in os.walk(root): | |
name = os.path.split(dirpath)[1] | |
if any(fnmatch.fnmatch(name, w) for w in options.exc_dirs): | |
del dirnames[:] # Don't recurse here | |
continue | |
for fn in filenames: | |
if any(fnmatch.fnmatch(fn, w) for w in options.exc_files): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install latest setuptools and pip | |
# get the setup script for Setuptools: | |
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | |
# Then install it for Python 2.7 and/or Python 3.3: | |
python2.7 ez_setup.py | |
python3.3 ez_setup.py | |
# Install pip using the newly installed setuptools: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# restart netsniff-ng | |
#sudo nsm --sensor --restart --only-pcap | |
# status of all nsm process | |
# sudo service nsm status | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file creation and modification times | |
import os.path, time | |
print "last modified: %s" % time.ctime(os.path.getmtime(file_name)) | |
print "created: %s" % time.ctime(os.path.getctime(file_name)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Edit .bashrc in your home directory and add the following line: | |
export PATH=/usr/local/bin:/opt/bro/bin:$PATH | |
#To source your .bashrc, simply type | |
$ source .bashrc | |
in the home directory. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
raise Exception('blabla') | |
except Exception: | |
logging.info('blabla', exc_info=True) | |
import sys | |
import traceback | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you setup Kibana 3 with ElasticSearch 1.4, it throws "Connection Failed" error . The way to fix is: | |
http.cors.allow-origin: "/.*/" | |
#http.cors.allow-origin: "*" | |
http.cors.enabled: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
z= "{} is here".format("joshi") | |
print(" To escape {} bracket, add double brackets like this - {{0}} ".format("empty")) | |
Very good examples available here - https://mkaz.com/2012/10/10/python-string-format/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#start bro at boot - /etc/rc.local | |
/usr/local/bro/bin/broctl start | |
exit 0 | |
#Housecleaning items every five minutes via broctl cron - /etc/crontab | |
0-59/5 * * * * root /usr/local/bro/bin/broctl cron |
OlderNewer