Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Monday, March 31, 2008

How To Install VMware Server On OpenSUSE 10.3

How To Install VMware Server On OpenSUSE 10.3

Today, I will explain to you how to install VMWare Server on openSUSE 10.3. What this will do for you is be able to run Windows inside your Linux computer. If you have that Windows app that just doesn't run under Wine, then this is the setup for you.

Read more...

Setting Up LVM On Top Of Software RAID Subsystem - RHEL & Fedora

Setting Up LVM On Top Of Software RAID Subsystem - RHEL & Fedora

Here is a quick look how to build an LVM on top of RAID 1 array, so that we combine the power of these two. This kind of setup is extremely useful in situations where we want a file server to store large amounts of data which provides a centralized backup, storage space for downloadable files via ftp/http, and that may grow enormously in the coming years after the initial setup.

Read more...

How To Set Up Internet Access Control And Internet Filtering With SafeSquid Proxy Server

SafeSquid - Content Filtering Internet Proxy, has many content filtering features that can be used to decide who is allowed what, when and how much on the net. In this tutorial I will describe how to create user profiles, and give them access to specific websites only, while blocking access to all other websites.

Read more...

Tuesday, December 25, 2007

Crontab details

Here is the format of a line in crontab.
#minute, hour, day of month, month, day of week, command
* * * * * command

Entries in a crontab Command Line

Field

Value

minute

0–59

hour

Based on a 24-hour clock; for example, 23 = 11 P.M.

day of month

1–31

month

1–12, or jan, feb, mar, etc.

day of week

0–7; where 0 and 7 are both Sunday; or sun, mon, tue, etc.

command

The command you want to run

If you see an asterisk in any column, cron runs that command for all possible values of that column. For example, an * in the minute field means that the command is run every minute during the specified hour(s). Consider another example, as shown here:

1  5  3  4  *  ls

This line runs the ls command every April 3 at 5:01 A.M. The asterisk in the day of week column simply means that it does not matter what day of the week it is; crontab still runs the ls command at the specified time.

The crontab file is flexible. For example, a 7–10 entry in the hour field would run the specified command at 7:00 A.M., 8:00 A.M., 9:00 A.M., and 10:00 A.M. A list of entries in the minute field such as: 0,5,10,15,20,25,30,35,40,45,50,55 would run the specified command every five minutes. The cron daemon also recognizes abbreviations for months and the day of the week.

The actual command is the sixth field. You can set up new lines with a percent (%) symbol. This is useful for formatting standard input. The example of a cron file follows formats input for an e-mail message:

# crontab -l
# Sample crontab file
#
# Force /bin/sh to be my shell for all of my scripts.
SHELL=/bin/sh
# Run 15 minutes past Midnight every Saturday
15 0 * * sat $HOME/scripts/scary.script
# Do routine cleanup on the first of every Month at 4:30 AM
30 4 1 * * /usr/scripts/removecores >> /tmp/core.tmp 2>>&1
# Mail a message at 10:45 AM every Friday
45 10 * * fri mail -s "Project Update employees%Can I have a status
update on your project?%%Your Boss.%
# Every other hour check for alert messages
0 */2 * * * /usr/scripts/check.alerts

For more examples, review some of the scripts in the /etc/cron.daily directory.

Wednesday, November 21, 2007

Mysqldump certain tables

To take the Mysql dump of certain tables use the following command

mysqldump --user=username --password= password -B Database --tables Table1 Table2 Table3 Table4 > backup.sql

Sunday, October 21, 2007

How do I protect a directory in Apache on linux

There are many ways you can password protect directories under Apache web server. This is important to keep your file privates from both unauthorized users and search engines (when you do not want to get your data indexed). Here you will see the basics of password protecting a directory on your server. You can use any one of the following method:
  1. Putting authentication directives in a section, in your main server configuration httpd.conf file, is the preferred way to implement this kind of authentication.
  2. If you do not have access to Apache httpd.conf file (for example shared hosting) then with the help of file called .htaccess you can create password protect directories. .htaccess file provide a way to make configuration changes on a per-directory basis.
In order to create apache password protected directories you need:
  • Password file
  • And Directory name which you would like to password protect (/var/www/docs)

Step # 1: Make sure Apache is configured to use .htaccess file

You need to have AllowOverride AuthConfig directive in httpd.conf file in order for these directives to have any effect. Look for DocumentRoot Directory entry. In this example, our DocumentRoot directory is set to /var/www. Therefore, my entry in httpd.conf looks like as follows:

Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
Allow from all
Save the file and restart Apache
If you are using Red Hat /Fedora Linux:
# service httpd restart
If you are using Debian Linux:
# /etc/init.d/apache-perl restart

Step # 2: Create a password file with htpasswd

htpasswd command is used to create and update the flat-files (text file) used to store usernames and password for basic authentication of Apache users. General syntax:
htpasswd -c password-file username
Where,
  • -c : Create the password-file. If password-file already exists, it is rewritten and truncated.
  • username : The username to create or update in password-file. If username does not exist in this file, an entry is added. If it does exist, the password is changed.
Create directory outside apache document root, so that only Apache can access password file. The password-file should be placed somewhere not accessible from the web. This is so that people cannot download the password file:
# mkdir -p /home/secure/
Add new user called vivek
# htpasswd -c /home/secure/apasswords vivek
Make sure /home/secure/apasswords file is readable by Apache web server. If Apache cannot read your password file, it will not authenticate you. You need to setup a correct permission using chown command. Usually apache use www-data user. Use the following command to find out Apache username. If you are using Debian Linux use pache2.conf, type the following command:
# grep -e '^User' /etc/apache2/apache2.conf
Output:
www-data
Now allow apache user www-data to read our password file:
# chown www-data:www-data /home/secure/apasswords
# chmod 0660 /home/secure/apasswords

If you are using RedHat and Fedora core, type the following commands :
# grep -e '^User' /etc/httpd/conf/httpd.conf
Output:
apache
Now allow apache user apache to read our password file:
# chown apache:apache /home/secure/apasswords
# chmod 0660 /home/secure/apasswords

Now our user vivek is added but you need to configure the Apache web server to request a password and tell the server which users are allowed access. Let us assume you have directory called /var/www/docs and you would like to protect it with a password.
Create a directory /var/www/docs if it does not exist:
# mkdir -p /var/www/docs
Create .htaccess file using text editor:
# cd /var/www/docs
# vi .htaccess

Add following text:
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /home/secure/apasswords
Require user vivek
Save file and exit to shell prompt.

Step # 3: Test your configuration

Fire your browser type url http://yourdomain.com/docs/ or http://localhost/docs/ or http://ip-address/docs
When prompted for username and password please supply username vivek and password. You can add following lines to any file entry in httpd.conf file:
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /home/secure/apasswords
Require user vivek
To change or setup new user use htpasswd command again.

Troubleshooting

If password is not accepted or if you want to troubleshoot authentication related problems, open and see apache access.log/error.log files:
Fedora Core/CentOS/RHEL Linux log file location:
# tail -f /var/log/httpd/access_log
# tail -f /var/log/httpd/error_log

Debian Linux Apache 2 log file location:
# tailf -f /var/log/apache2/access.log
# tailf -f /var/log/apache2/error.log

Thursday, October 18, 2007

Managing Software with yum

Use the yum utility to modify the software on your system in four ways:

  • To install new software from package repositories

  • To install new software from an individual package file

  • To update existing software on your system

  • To remove unwanted software from your system

Read more..............

Virtualization in Fedora 7

Fedora 7 includes support for both the KVM and the Xen virtualization platforms. For more information on different virtualization platforms, see http://virt.kernelnewbies.org/TechComparison.

More information on Xen itself can be found at http://wiki.xensource.com/xenwiki/ and the Fedora Xen page. More information on KVM can be found at http://kvm.qumranet.com/kvmwiki.

Fedora is following the 3.0.x Xen line. Xen 3.0.0 was released in December of 2005 and is incompatible with guests using the previous Xen 2.0.x releases.

Read more.......................



Wednesday, September 26, 2007

Lintrack As A LAN Gateway And An OpenVPN Bridge

This tutorial will guide you through installation and configuration of Lintrack, a GNU/Linux distribution specialized in networking tasks. We will give two LANs access to the internet along with DHCP and DNS cache servers, and then we will connect our networks using OpenVPN in bridging mode. You should be running all these in well under an hour, thanks to the unified configuration interface of Lintrack.

Read More.........

Wednesday, September 5, 2007

I forgot the MySQL root password, how do I reset it?

The Mysql root password can be set using the following procedure:

1.
Stop the MySQL service:

# service mysqld stop

Example output:

#service mysqld stop
Stopping MySQL: [OK]

2.
Start MySQLwith:

# /usr/bin/safe_mysqld --skip-grant-tables &

On Red Hat Enterprise Linux 4, safe_mysqld has been changed to mysqld_safe.

Note: safe_mysqld is a shell script which invokes mysqld, but additionally traps any forceful
terminations of the MySQL server and avoids any database corruption.

3.
Change the password of the root user:

# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='root'
mysql> FLUSH PRIVILEGES;
mysql> exit;


4.
You could perform Step 1 here and avoid using step 4, but in some cases, the startup script may not
behave as expected since mysqld was started directly, i.e. not using the init script.

# mysqladmin shutdown

5.
Start the MySQL service:

# service mysqld start

Example output:

# service mysqld start
Starting MySQL: [ OK ]

Wednesday, August 29, 2007

Exclude directories in tar

TAR:

tar -cvf httpdocs_06_20_2006.tar.gz
/home/user/domain.com/site
--exclude "/home/user/domain.com/site/excluded-dir1"
--exclude "/home/user/domain.com/site/excluded-dir2"

GNU TAR:

tar -cvf httpdocs_06_20_2006.tar.gz
--exclude "/home/user/domain.com/site/excluded-dir1"
--exclude "/home/user/domain.com/site/excluded-dir2"
/home/user/domain.com/site

Tuesday, August 21, 2007

Setting Up A PXE Install Server For Multiple Linux Distributions With Ubuntu Edgy Eft

This tutorial shows how to set up a PXE (short for preboot execution environment) install server with Ubuntu 6.10 (Edgy Eft). A PXE install server allows your client computers to boot and install a Linux distribution over the network, without the need of burning Linux iso images onto a CD/DVD, boot floppy images, etc. This is handy if your client computers don't have CD or floppy drives, or if you want to set up multiple computers at the same time (e.g. in a large enterprise), or simply because you want to save the money for the CDs/DVDs. In this article I show how to configure a PXE server that allows you to boot multiple distributions: Ubuntu Edgy/Dapper, Debian Etch/Sarge, Fedora Core 6, CentOS 4.4, OpenSuSE 10.2, and Mandriva 2007. Read more.....

Linux Quota Tutorial

1. Edit file /etc/fstab to add qualifier "usrquota" (for user) or/and "grpquota" (for groups) to the partition in which you want to add quota support. For example here I've added both types to my / (root) partition. Make sure there are NO SPACES after "defaults" and up to your qualifiers that you add.

LABEL=/ / ext3 defaults,usrquota,grpquota 1 1


2. Create files aquota.user (and aquota.group if you want to add group quota support) on the root of the partition that you added quota support to. Following the above example:

touch /aquota.user

Then change the permissions on these files as such

chmod 600 /aquota.user

3. Run quotacheck

quotacheck -va

Note: If you are trying to enable quota on the / partition you might get an error such as
"quotacheck: Can't find filesystem to check or filesystem not mounted with quota option."
In that case run "quotacheck -vam" and then "quotacheck -vgam" (for groups)
If you still get the error then reboot the system.
Make sure that if you are using the -m flag that no other process will be writing to that partition. If you are unsure you are recommended that you start the system in single user mode.
You may get this warning:
quotacheck: WARNING - Quotafile //aquota.user was probably truncated. Can't save quota settings...
This is nothing to worry about.



4. Turn quota on

quotaon -av

5. Now you are ready to edit quotas. Edit a user quota with the command "edquota -u user" and edit a group's quota with the command "edquota -g group". Both of these commands will run vi by default and give you the ability to edit the quota for the user/group. For example

[root@localhost root]# edquota -u testuser
Disk quotas for user testuser (uid 504):
Filesystem blocks soft hard inodes soft hard
/dev/hda3 40 0 0 11 0 0

The above shows the testuser using 40 blocks (1 block = 1 KB) and no soft or hard quotas on block usage, using 11 inodes and no soft or hard quotas on inodes.

After editing the file to give the user 5 MB soft limit and 6 MB hard limit the file would look something like this



Disk quotas for user testuser (uid 504):
Filesystem blocks soft hard inodes soft hard
/dev/hda3 40 5120 6144 11 0 0

Soft limit indicates the maximum amount of disk usage a quota user has on a partition. When combined with "grace period" it acts as the border line, which a quota user is issued warnings about his impending quota violation when passed. Hard limit works only when "grace period" is set. It specifies the absolute limit on the disk usage, which a quota user can't go beyond his "hard limit".

You can edit the grace period with the command "edquota -t" to edit grace period.

Misc:
To show your quota : "quota"
To show a users quota : "quota -u user"
To show all users quota usage : "repquota -a"

Monday, August 13, 2007

Linux MRTG Configuration HOW-TO

MRTG is wonderful tool. You can use it to monitor traffic on your router or leased server located at remote IDC. Since it is written in Perl and some code in C language, it is portable and high performance tool.

for more info read here...........


Tuesday, August 7, 2007

Setting up an OpenVPN server in Fedora 7

Setting up an OpenVPN server

  1. yum install openvpn.$HOSTTYPE

  2. Copy /usr/share/openvpn/easy-rsa/ somewhere (like root's home directory with cp -ai /usr/share/openvpn/easy-rsa ~).

  3. cd ~/easy-rsa

  4. Edit vars appropriately.

  5. . vars

  6. ./clean-all

  7. Before continuing, make sure the system time is correct. Preferably, set up NTP.

  8. ./build-ca

  9. ./build-inter $( hostname | cut -d. -f1 )

  10. ./build-dh

  11. mkdir /etc/openvpn/keys

  12. cp -ai keys/$( hostname | cut -d. -f1 ).{crt,key} keys/ca.crt keys/dh1024.pem /etc/openvpn/keys/

  13. cp -ai /usr/share/doc/openvpn-*/sample-config-files/roadwarrior-server.conf /etc/openvpn/server.conf

  14. Edit /etc/openvpn/server.conf appropriately.

  15. chkconfig --level 2345 openvpn on

  16. service openvpn start

  17. Verify that firewall rules allow traffic in from tun+, out from the LAN to tun+, and in from the outside on UDP port 1194. The following should work:

     iptables -A INPUT -i eth1 -p udp --dport 1194 -j ACCEPT
    iptables -A INPUT -i tun+ -j ACCEPT
    iptables -A FORWARD -i tun+ -j ACCEPT
    iptables -A FORWARD -i eth0 -o tun+ -j ACCEPT
    iptables -A FORWARD -i eth1 -o tun+ -m state --state ESTABLISHED,RELATED -j ACCEPT

    Or for genfw (my firewall-generation script, not currently available in Fedora), this in /etc/sysconfig/genfw/rules:

     append INPUT -i eth1 -p udp --dport 1194 -j ACCEPT
    append INPUT -i tun+ -j ACCEPT
    append FORWARD -i tun+ -j ACCEPT
    append FORWARD -i eth0 -o tun+ -j ACCEPT
    append FORWARD -i eth1 -o tun+ -j established

Setting up a Windows OpenVPN client

On the server:

  1. cd easy-rsa

  2. . vars

  3. ./build-key username

On the client:

  1. Install the OpenVPN GUI or the stand-alone OpenVPN client.

  2. Copy username.crt, username.key, and ca.crt to C:\Program Files\OpenVPN\config\ on the client.

  3. Drop roadwarrior-client.conf into C:\Program Files\OpenVPN\config\ as whatever.ovpn and edit appropriately.

  4. Either use the GUI to start the connection, start the OpenVPN service manually, or set the OpenVPN service to start automatically.
Ideally the client should do some verification on the server key with tls-remote in the whatever.ovpn configuration file.

Loads of linux links for video

http://loll.sourceforge.net/linux/links/Audio-Video/Video/index.html

Tutorial: Video, DVD players, TV and Multimedia

This covers Linux video players, DVD players, TV, HDTV and Hauppauge WinTV PCI card use. Included in this tutorial are links to software, video formats and information pertaining to video multimedia on Linux. This page also includes a tutorial on the use of the Hauppauge WinTV PCI card, linux video conferencing, surveillance, capture and TV broadcast display under Linux.

http://www.yolinux.com/TUTORIALS/LinuxTutorialVideo.html


Note: Taken from www.yolinux.com

Tuesday, July 31, 2007

Mounting USB storage drives in Linux

Plug in Memory Stick into available USB port and then..
# dmesg | less

(The device is picked up as a USB 1.1 and allocated an address.
Also says what HCD it is using.)

usb 1-1: new full speed USB device using uhci_hcd and address 2

(SCSI emulation automatically kicks in)
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2

(Now the device information including model number is retrieved)
usb-storage: waiting for device to settle before scanning
Vendor: JetFlash Model: TS512MJF2A Rev: 1.00
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sda: 1003600 512-byte hdwr sectors (514 MB)

(The write-protect sense is EXPERIMENTAL code in the later kernels)
sda: Write Protect is off
sda: Mode Sense: 0b 00 00 08
sda: assuming drive cache: write through
SCSI device sda: 1003600 512-byte hdwr sectors (514 MB)
/dev/scsi/host0/bus0/target0/lun0: p1
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0, type 0
usb-storage: device scan complete
(At this point, the device is generally accessible by mounting /dev/sda1)

(When the device is disconnected, the system acknowledges the same)
usb 1-1: USB disconnect, address 2

To see the partition table type fdisk -l /dev/sda

To Mount the partition type

# mount /dev/sda1 /mnt/usb
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda8 9.4G 7.5G 1.9G 80% /
/dev/hda9 11G 8.1G 2.4G 78% /usr
none 189M 0 189M 0% /dev/shm
/dev/sda1 490M 34M 457M 7% /mnt/usb