Thursday, January 15, 2009

Starting the mysql command

To get started creating databases and tables, you can use the mysql command. From any Terminal window, open the mysql database on your computer by typing the following:
# mysql −u root −p mysql
Enter password: *********

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with −A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39 to server version: 3.23.36
Type 'help;' or '\h' for help. Type '\c' to clear the buffer
mysql>
Type in the root user's MySQL password as prompted. The mysql> prompt appears, ready to accept commands for working with the mysql default database on the localhost. If you are connecting to the MySQL server from another host computer, add a −h hostname to the command line (where hostname is the name or IP address of the computer on which the MySQL server is running). Remember, you can also login as any valid mysql login you created, regardless of which Linux login account you are currently logged in under. As the mysql text notes above, be sure to end each command that you type with a semi−colon (;) or a \g. If you type a command and it appears to be waiting for more input, it's probably because you forgot to put a semi−colon at the end.

MySQL Server

For Red Hat Linux, the MySQL server is off by default. To turn it on, however, is fairly simple. The /etc/init.d/mysqld start−up script is delivered with the mysql−server package. To start the server, you can either run the mysqld start−up script manually or set it to start each time your system boots. To start the MySQL server manually, type the following from a Terminal window as root user:
# /etc/init.d/mysqld start
To set the MySQL server to start automatically each time your computer reboots, type the following as root user:
# chkconfig mysqld on
This sets mysqld to start during most multi−user run states (levels 3, 4, and 5). To check that the service is turned on for those levels, type chkconfig −−list mysqld from a Terminal window.

Wednesday, January 14, 2009

Starting the Samba service

To start the Samba SMB and NMB daemons, you can run the /etc/init.d/smb start−up script by typing the following as the root user:
# /etc/init.d/smb start
This runs the Samba service during the current session. To set up Samba to start automatically when your Linux system starts, type the following:
# chkconfig smb on
This turns on the Samba service to start automatically in run levels 3, 4, or 5. At this point, you can open the Network Neighborhood icon from the Windows desktop on the local LAN for a user you have just set up. An icon representing the Linux Samba server you just configured should appear in the Network Neighborhood window. When you open the server icon, you should see an icon representing the user’s home directory (/home/user) and one icon for each shared printer available from the Linux Samba server.

Adding Samba users

Doing user−style Samba security means assigning a Linux user account to each person using the Linux file systems and printers from his or her Windows workstation. (You could assign users to a guest account instead, but in this example, all users have their own accounts.) Then you need to add SMB passwords for each user. For example, here is how you would add a user whose Windows 98 workstation login is chuckp:
1.Type the following as root user from a Terminal window to add a Linux user account:
# useradd −m chuckp
2.Add a Linux password for the new user as follows:
# passwd chuckp
Changing password for user chuckp
New UNIX password: ********
Retype new UNIX password: ********
3.Repeat the previous steps to add user accounts for all users from Windows workstations on your LAN that you want to give access to your Linux system to.
4.Type the following command to create the Samba password file (smbpasswd):
# cat /etc/passwd /usr/bin/mksmbpasswd.sh>/etc/samba/smbpasswd
5.Add an SMB password for the user as follows:
# smbpasswd chuckp
New SMB password: **********
Retype new SMB password: **********
Repeat this step for each user. Later, each user can log in to Linux and rerun the passwd and smbpasswd commands to set private passwords.

Configuring Samba server

The procedure in this section steps you through an example of a Red Hat Linux system configured as a Samba server. In this example, the Linux Samba server uses “user” security to share home directories and printers with users from Windows workstations on the local LAN. The procedure consists of three basic steps:
1.Editing the smb.conf file.
2.Adding Samba users.
3.Starting the Samba service.

Editing the smb.conf file
Using either SWAT or a regular text editor (as root user), create an /etc/samba/smb.conf file. Here is an example of an smb.conf file (with comment lines removed) that can be used to share printers and directories with several Windows systems on a single LAN:
[global]
workgroup = ESTREET
netbios name = MAPLE
server string = Samba Server on Maple
hosts allow = 192.168.0.
printcap name = /etc/printcap
load printers = yes
printing = lprng
log file = /var/log/samba/%m.log
max log size = 0
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
dns proxy = no
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
printable = yes
In the [global] section, the workgroup is set to ESTREET, the server is identified as the Samba Server on Maple, and only computers that are on the local network (192.168.0.) are allowed access to the Samba service.