Archive for the 'tips' Category Page 5 of 24



FAQ: How to disable/remap a keyboard key in Linux?

Q: How can I disable one or several keys of my laptop keyboard in Linux? When I press DELETE key it gets stuck and deletes everything :)

A: No problem! You can use the following command to remap or disable any key of your keyboard:

xmodmap -e 'keycode <value>=<action>'

For example, run the following to disable your DELETE key: xmodmap -e 'keycode 107='. BTW you can get keycode that corresponds to certain keyboard button by using simple command xev

xev

The full list of available keycodes and actions assigned to them on UK keyboard is below…
Continue reading…

Another 10 good Unix habits to pickup

Well, IBM publishes a new article about useful Unix command line habits as a follow-up to Michael Stutz’s article. I promise that after reading this article you will say something like “A-ha, I didn’t know you could do that!” :) Here is the part of that staff:

The !$ command returns the last argument used with a command. But what happens if you have a command that used arguments and you want to reuse just one of them? The !:1 operator returns the argument used in a command. The example in Listing 3 shows how you can use this operator in combination with the !$ operator. In the first command, a file is renamed to a more meaningful name, but to preserve use of the original file name, a symbolic link is created. The file kxp12.c is renamed in a more readable manner, then the link command is used to create a symbolic link back to the original file name, in case it’s still used elsewhere. The !$ operator returns the file_system_access.c argument, and the !:1 operator returns the kxp12.c argument, which is the first argument of the previous command.

Listing 3
$ mv kxp12.c file_system_access.c
$ ln –s !$ !:1

Read more here

unix front

Ubuntu: Install Gnome

Why one should want to install Gnome in Ubuntu as it comes with this distribution by default? The answer is rather short: it works for Ubuntu server initially installed without X window manager. Here you go:

sudo aptitude install ubuntu-desktop gdm

When done you can run gnome desktop manager (gdm) and type your username and password to access Gnome Desktop and start using GUI applications:

sudo /etc/init.d/gdm start

If you still have troubles with starting gnome once installed necessary apt packages, most the probably the problme is in improper video driver selected by default. Try the command below or use google or ubuntu forums to find more information about “xorg.conf”:

sudo dpkg-reconfigure xserver-xorg

OpenLDAP + Samba Domain Controller on Debian or Ubuntu

samba logoHistorically domain controllers (DCs) were Windows servers responding to security authentication requests (logging in, etc.) within the Windows Server domain. Today Samba project goes beyond emulating Windows shares and can be used as Primary Domain Controller in Windows network.

To help people who are under installing/configuring Samba as a DC in their network I published here several links which helped me with this task. First of all, be ready for long time configuring as compared with Windows Active Directory configuration it takes much more time to do the same task with Samba… But practically vendor independent solutions usually worth time spent on compiling, installing, configuration and maintenance.

Why Debian/Ubuntu? Looking through Google’s findings regarding DC set up on these distributions, I noticed some kind of lack of the quality resources lying at the top.

1. The first place one should visit in order to start with above mentioned task is Samba official documentation. Probably not everything that is covered by it would be used, but this is the only place you can find some special aspects of installation and configuration their software.

2. Ricky Jone’s article on howtoforge.com is an excellent guide on how to get the task done on Ubuntu 7.10.

3. Excellent article “SAMBA (Domaincontroller) Server For Small Workgroups With Ubuntu 6.10” written by Till Brehm is applicable also for later Ubuntu versions.

4. Steve Lacey wrote interesting and informative article about Samba on Debian as primary DC on his blog.

5. A certain mawi wrote very informative manual:

Read this document on Scribd: Samba And Ldap On Debian

Quick copy/paste MySQL Replication Manual

This quick manual tells how to set up database replication in MySQL. Basically it was written for 5.* MySQL versions but is also applicable for 3.23/4.0 ones (btw they are still in use, believe me).

As you might already know, replication allows you to create a copy of certain MySQL database from a master server on another server (slave). What is the most important, all updates made to that database on master server will be replicated to the database on the slave server immediately, so that both databases are synchronized almost in real time mode (if you need completely real-time synchronization/mirroring, the only solution is to deploy MySQL cluster).

One of the main issues is that replication features coming out-of-the-box with Open Source MySQL software don’t provide full back/forward compatibility. This means that you can easily replicate data from master and slave of the same MySQL versions only e.g. 5.0. But if you like to replicate database from 5.0 master to 4.0 slave (or from 3.23 master to 5.0 slave), it is not possible in most cases.

From the beginning we have two Linux boxes with MySQL installed (5.0.27 version in my example), server has database reptest we need to replicate to slave.

A. Configure Master:

Configure MySQL to accept incoming connections from another hosts in the network. In order to do it, comment the following lines in /etc/my.cnf (exact location depends on Linux distribution you use) as follows:

#skip-networking
#bind-address=127.0.0.1

and restart MySQL by “/etc/init.d/mysql restart” or “mysqladmin reload” command. Make sure that slave can access master’s MySQL via network (e.g. execute on slave “telnet <server_ip> 3306“).

The next step is to configure master to log all database changes into binary log that will be used by slave for replicating, add the following lines to /etc/my.cnf in [mysqld] section:

log_bin = mysql-bin
binlog-do-db=reptest
server-id=1

Then restart MySQL and log on to its shell with root rights:

/etc/init.d/mysql restart
mysql -u root -p
Enter password:

Type in MySQL shell the following commands:

GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'slave_password';
FLUSH PRIVILEGES;

Note: If you use 4.0 MySQL or older, you need to replace REPLICATION SLAVE in above line to FILE, so the lines will look like:

GRANT FILE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'slave_password';
FLUSH PRIVILEGES;

The next commands are:

USE reptest;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;

The last command should provide the following output we will use later on slave server:

mysql> SHOW MASTER STATUS;
+---------------+----------+-----------------+------------------+
| File          | Position | Binlog_do_db    | Binlog_ignore_db |
+---------------+----------+-----------------+------------------+
| mysql-bin.001 |   73     | reptest         |                  |
+---------------+----------+-----------------+------------------+
1 row in set (0.00 sec)

Now quit from MySQL shell as we need to prepare current dump of reptest database: quit.

Now, run from shell “mysqldump -u root -p --opt reptest > reptest.sql” and transfer reptest.sql file to slave server.

2. Configure Slave:

Create reptest database:

mysqladmin create reptest

and apply previously created/transfered dump to it via command:

mysql -u root -p reptest < /path/to/reptest.sql

Now edit /etc/my.cnf on slave and add the following lines to [mysqld] section:

server-id=2
master-host=192.168.0.1
master-user=slave_user
master-password=slave_password
master-connect-retry=60
replicate-do-db=reptest

where 192.168.0.1 is IP address of the server and server-id is unique ID assigned to slave Linux box.

Now restart MySQL with /etc/init.d/mysql restart and log on MySQL shell:

mysql -u root -p reptest
Enter password:

The next step is to apply changes saved in binary log on server:

SLAVE STOP;
CHANGE MASTER TO MASTER_HOST='192.168.0.1', MASTER_USER='slave_user', MASTER_PASSWORD='slave_password', MASTER_LOG_FILE='mysql-bin.001', MASTER_LOG_POS=73;
SLAVE START;

Now whenever reptest is updated on the master, all changes will be replicated to reptest on the slave.

Here are useful links you can use to get more information about MySQL replication and how to configure it:

http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html
http://www.howtoforge.com/mysql_database_replication
http://www.onlamp.com/pub/a/onlamp/2005/06/16/MySQLian.html

If you’re planning to replicate on a remotely hosted machine, here are some of the best MySQL hosting plans.




Pages: Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Next
Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
TuxArena: The arena of Tux | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››