Find and Delete log files on a linux system. Think before you act.
1 |
find / -name '*bash_history*' -name '*.bash_logout' -name '*log*' -name '*ksh_history*' -name '*bash_logout*' -name '*utmp*' -name '*wtmp*' -name '*adm*' |
Find and Delete log files on a linux system. Think before you act.
1 |
find / -name '*bash_history*' -name '*.bash_logout' -name '*log*' -name '*ksh_history*' -name '*bash_logout*' -name '*utmp*' -name '*wtmp*' -name '*adm*' |
Mount disk and install grub boot loader
1 2 |
mount /dev/sdX /mnt grub-install --boot-directory=/mnt/boot /dev/sdX |
Delete all lines of a file containing a regex pattern using sed. For example you can delete all commented lines of a default configuration file. Take a look on my basic regex cheat sheet
1 |
sed -i '/regexPattern/d' path/to/file1.log |
Replace a string with a new one in all files using sed and xargs
1 2 3 |
oldstring="some_string_to_search" newstring="new_string_to_replace" grep -rl $oldstring /path/dir/ | xargs sed -i s@$oldstring@$newstring@g |
Comment specific line using sed command can be used to configuration files …
1 |
sed -i '123 s/^/#/' filename |
Should be used for really huge database imports like tens of GB … Note: remember to navigate to the directory where your .sql file lives so you can use source on it later …
1 2 |
cd path/to/dir/ mysql -u root -p |
Note: if you’re not sure what these options do, please, do some research first.
1 2 3 4 5 6 7 8 9 |
set global net_buffer_length=1000000; --Set network buffer length to a large byte number set global max_allowed_packet=1000000000; --Set maximum allowed packet size to a large byte number SET foreign_key_checks = 0; --Disable foreign key checking to avoid delays,errors and unwanted behaviour source file.sql --Import your sql dump file SET foreign_key_checks = 1; --Remember to enable foreign key checks when procedure is complete! |
Copy multiple files via ssh and preserve permissions and ownership. Creating a tarball on the fly and pipe its output through ssh afterwards extracting the files from the tarball will let us speedup the uploading times because the stream of data is continuous through the network and therefore will be done in one single connection. […]
Discover world writable files (aka with permission 777) will help you sometimes find out which files you missed to secure from your user’s eyes.
1 |
find / -perm -2 ! -type l -ls |
If you don’t understand Linux file permission bits you should read this
IPduh IPduh is a set of Internet Forencics and Troubleshooting Tools made to work Together. IPduh may be used as an Internet Forensics Search Engine or a General Purpose Search Engine. Smart Humans and Aliens researching the internetz on Earth Love IPduh. Download test files from thinkbroadband.com thinkbroadband.com Download at full speed 10, 20, […]
1 |
<strong><span style="font-size: x-large;">Description</span></strong> |
1 2 3 |
BFD is a modular shell script for parsing application logs and checking for authentication failures. It does this using a rules system where application specific options are stored including regular expressions for each unique auth format. The regular expressions are parsed against logs using the ‘sed’ tool (stream editor) which allows for excellent performance in all environments. In addition to the benefits of parsing logs in a single stream with sed, BFD also uses a log tracking system so logs are only parsed from the point which they were last read. This greatly assists in extending the performance of BFD even further as we are not constantly reading the same log data. The log tracking system is compatible with syslog/logrotate style log rotations which allows it to detect when rotations have happened and grab log tails from both the new log file and the rotated log file. <span style="font-size: x-large;">Installing on <strong>Ubuntu</strong>/<strong>Debian</strong></span> |
1 2 3 |
sudo apt-get install libxml2 libxml2-dev libxml2-utils sudo apt-get install libaprutil1 libaprutil1-dev sudo apt-get install libapache-mod-security |
regards, @specktator