* Continuously check Apache error log file: $ tail -f /var/log/httpd/error_log * View first 15 lines from MySQL log: $ head -15 /var/log/mysqld.log * vi keyboard shortcuts => jump to end of line $ => start of line 0 => Delete rest of line D => Repeat the last command given: . (dot) => add [...]
Read the rest of this entry »Archive for the 'Linux' Category
Feb 05
May 12
Feb 24
Backup MySQL Database to a file
Backing up your database is a very important system administration task, and should generally be run from a cron job at scheduled intervals. We will use the mysqldump utility included with mysql to dump the contents of the database to a text file that can be easily re-imported. Syntax: mysqldump -h localhost -u root -pmypassword [...]
Read the rest of this entry »Feb 24
Feb 17
Backup your bootsector
Messing with bootloaders, dual-booting and various other scary processes can leave you with a messed up bootsector. Why not create a backup of it while you can: dd if=/dev/hda of=bootsector.img bs=512 count=1 Obviously you should change the device to reflect your boot drive (it may be sda for SCSI). Also, be very careful not to [...]
Read the rest of this entry »Feb 17
Transferring files without ftp or scp
Need to transfer a directory to another server but do not have FTP or SCP access? Well this little trick will help out using the netcat utility. On the destination server run: nc -l -p 1234 | uncompress -c | tar xvfp – And on the sending server run: tar cfp – /some/dir | compress [...]
Read the rest of this entry »Feb 17
Faster Hard drives
You may know that the hdparm tool can be used to speed test your disk and change a few settings. It can also be used to optimise drive performance, and turn on some features that may not be enabled by default. Before we start though, be warned that changing drive options can cause data corruption, [...]
Read the rest of this entry »Feb 17
Save battery power
You are probably familiar with using hdparm for tuning a hard drive, but it can also save battery life on your laptop, or make life quieter for you by spinning down drives. hdparm -y /dev/hdb hdparm -Y /dev/hdb hdparm -S 36 /dev/hdb In order, these commands will: cause the drive to switch to Standby mode, [...]
Read the rest of this entry »Feb 17
Finding the biggest files
A common problem with computers is when you have a number of large files (such as audio/video clips) that you may want to get rid of. You can find the biggest files in the current directory with: ls -lSrh The “r” causes the large files to be listed at the end and the “h” gives [...]
Read the rest of this entry »Feb 17
Replacing same text in multiple files
If you have text you want to replace in multiple locations, there are several ways to do this. To replace the text Windows with Linux in all files in current directory called test[something] you can run this: perl -i -pe ‘s/Windows/Linux/;’ test* To replace the text Windows with Linux in all text files in current [...]
Read the rest of this entry »