Posts tagged command
Linux Anti Virus for Websites
Jan 30th
Just because you run linux does not mean you completely forgo anti virus. Your website can be broadcasting Windows viruses or malware. Clamav, run from the command line, will scan your web directories recursively to identify various concerns. Install Clamav:
Then you can run Clam manually or you can install a cron job for it to be run automatically. Running Clam as root allows you to scan the higher level directories. The following command will scan the entire computer and remove viruses and malware:
sudo clamscan -r / --remove
Set this as a cronjob to run in the middle of the night; add it to the root crontab list:
0 2 * * * clamscan -r / --remove
Related articles by Zemanta
- Scan your Linux machine for viruses with ClamTk (ghacks.net)
Mysql Database Replication
Dec 20th

Howtoforge.com does it well, but it took me some time, and in particular I feel one command was left out. Start by removing the bind address in /etc/mysql/my.cnf:
#skip-networking
#bind-address = 127.0.0.1
Then add the following to /etc/mysql/my.cnf. Particularly to the mysqld section!!:
log-bin = /var/log/mysql/mysql-bin.log
binlog-do-db=exampledb
server-id=1
Exampledb is the database that you intend to replicate. Server-id should be 1 being that we are dealing with the master server. Make sure that you have the log directory /var/log/mysql. On the server login as root:
mysql -u root -p
Enter the password you configure when you setup mysql. If you don’t know the password you can reset it by skipping the grant tables:
sudo /etc/init.d/mysql stop
mysql --skip-grant-tables
Then login as root:
mysql -u root
Then change the root password:
UPDATE user SET password=PASSWORD('newpassword') WHERE user='root';
Then restart mysql:
sudo /etc/init.d/mysql restart
Then login as root:
mysql -u root -p
The latter, resetting the root password, was a slight digression that may be helpful. Now add a new user with replication privileges:
GRANT REPLICATION SLAVE ON *.* TO 'replicate'@'%' IDENTIFIED BY 'replicate';
The previous command will create a user replicate with password replicate. Your slave server will connect to the master as user replicate.
Then flush privileges:
FLUSH PRIVILEGES;
USE exampledb;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
UNLOCK TABLES;
quit;
Show master status displays information about the log file mysql generates. It will give you the log position which is necessary to synchronize the slave.
Now onto the salve. Login to the slave mysql server:
mysql -u root -p
Create a database of the same name that is on the master:
CREATE DATABASE exampledb;
quit;
Edit the slave’s /etc/mysql/my.cnf file, add:
server-id=2
master-host=192.168.0.100
master-user=replicate
master-password=replicate
master-connect-retry=60
replicate-do-db=exampledb
Set the master host ip address to that of the master; kinda logical, don’t ya think… Log back into mysql on the slave:
Login to mysql:
mysql -u root -p
Issue the following:
STOP SLAVE;
RESET SLAVE;
LOAD DATA FROM MASTER;
The following will set the slave accordingly:
CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='replicate', MASTER_PASSWORD='replicate', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;
Make sure the master log file is what is printer on the slave when you issue master status. The same goes for the position of the log!!!!! If you don’t have that screen up anymore issue on the master mysql server:
SHOW MASTER STATUS;
Then on the slave issue:
START SLAVE;
Quit mysql and your good to go…. Give me an email and I’ll help you out…
Grep Without a Pipe
Dec 6th
Grep is used commonly to filter the printout of ls and ps commands. It will only print the search criteria that is the parameter of the grep command. For example:
ps aux | grep apache2
The previous command will determine if apache2 has a running process. You can also use the grep command without the pipe. This will search a folder, which you can do recursively with -r, and look for a particular string in the files. You can sift through the contents of the entire /etc directory for a particular string. How powerful!
sudo grep -r static /etc/*
The above command will most likely pull up /etc/network/interfaces, particularly if your network adapter is setup as static.
LTSP-Build-Client Arch option not in Help
Jan 12th
To find the options for a command you type: command --help It spits out a bunch of options that you can use to tweak the parameters of a command. On the --help for the ltsp-build-client script is the --dist option, which I thought can be used to install a different distribution that the one you are current using on the host. For instance:
sudo lts-build-client --dist lenny
There is another option, and it is not specified in the --help. The --arch option allows the specification of different architecture than your host. For instance:
sudo ltsp-build-client --arch -i386
If you are using a 64 bit host, you can install an i386 client file system with this.
Sudo Apt-Get Update
Nov 26th
The sudo command is a program that is not included in the Debian project, although it is a standard, and well integrated component of upstream distributions such as Ubuntu. The sudo command allows a user to access root functionality, without having to “su” or login to the root account directly. On Debian systems the /etc/sudoers file must be configured in order to authorized sudo functionality, whereas on Ubuntu distributions the sudoers file automatically accommodates system users.
The Apt-Get command is part of the aptitude application, and is designed for package management, and software updating. The application supports dependency resolution, and is analogous in functionality to the yum package management system.
Passing the update argument to the Apt-Get command results in a system update process. This process will contact the configured repositories and compare them to existing files on the local system. If an update is possible, the “sudo apt-get upgrade” command will process the respective program upgrade.
You can enter these commands directly into a terminal. For more information about the terminal, its location, and some examples visit:
http://www.bgevolution.com/blog/index.php/terminal-location-debianubuntu-a-beginners-tutorial/
All that the previous link will show is the terminal location. Click the applications menu, and in the accessories tab is the terminal. You can also hit alt-f2 to get a applications windows; enter “gnome-terminal” to open a terminal. If you want to change the entire terminal, and not open a terminal emulator press cntrl-alt f1. This will change your entire desktop terminal to a command prompt. Press cntrl-alt f7 to get back to your default shell and desktop.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=3b7db24c-8fa8-459a-b574-e3af55df9979)