Pear module Installation Procedure for Linux
================================
Step 1:First check whether Pear package installed or not by command 'pear'.If exists it shows the list of packages(buld,list,install,update,info,...)
To check packages installed type command - pear list
Step 2:If not,get go-pear.php from http://pear.php.net/go-pear.
Step 3:Go to Command prompt & click command 'php go-pear.php'
To update your PEAR installation, request http://pear.php.net/go-pear in your browser and save the output to a local file go-pear.php.
You can then run this command to install or update - php go-pear.php.
Step 4:After giving command php go-pear.php,it will ask for the path where to install,give the required path (Ex:/usr/) & press Enter,the packages will get downloaded & finally if the installation is successfull ,it will ask for that you want to alter php.ini file - click on yes,that will include path in php.ini automatically.
Step 5:Install add-on packages i.e; Mail,Mail_mime,Net_SMTP by giving following commands
pear install Mail
pear install Mail_mime
pear install Net_SMTP & if it is succesfully installed ,you will get message channel installed successfully.
Step 6:Write a sample file as below given & save it in php folder as mailsmtp.php
$current_path=ini_get("include_path");
ini_set("include_path","$current_path:/usr/PEAR:/usr/share/mime");
include("Mail.php");
include("Mail/mime.php");
//echo $current_path;
//echo ini_get("include_path");
$message = new Mail_mime();
$text = file_get_contents("mail_text.txt");
$html = file_get_contents("mail_html.html");
$message->setTXTBody($text);
$message->setHTMLBody($html);
$body = $message->get();
$extraheaders = array("From"=>"raja_taraka@yahoo.co.in", "Subject"=>"My Subject 7");
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send("raja.marni@gmail.com", $headers, $body);
/* include('Mail.php');
$smtpinfo["host"] = "localhost";
$smtpinfo["port"] = 25;
$smtpinfo["auth"] = false;
$smtpinfo["username"] = "";
$smtpinfo["password"] = "";
$mail = Mail::factory("smtp",$smtpinfo);
$headers = array("From"=>"raja_taraka@yahoo.co.in", "Subject"=>"Test Mail");
$body = "This is a test using pear mail!";
$mail->send("raja.marni@gmail.com", $headers, $body); */
echo "finished.....Dude!";
?>
Step 7:
finally run on browser:192.168.0.9/php/mailsmtp.php.
Wednesday, February 10, 2010
Thursday, January 28, 2010
Find urSystem Information by sar command
System Activity Information: sar
To use sar, sadc (system activity data collector) needs to be running. Check its status or start it with rcsysstat {start|status}.
sar can generate extensive reports on almost all important system activities, among them CPU, memory, IRQ usage, IO, or networking. With its many options, it is too complex to explain further here. Refer to the man page for extensive documentation with examples.
Memory Usage: free
The utility free examines RAM usage. Details of both free and used memory and swap areas are shown:
poison:~ # free
total used free shared buffers cached
Mem: 450128 398428 51700 0 10280 141204
-/+ buffers/cache: 246944 203184
Swap: 514040 182656 331384
The options -b,-k,-m,-g show output in bytes, KB, MB, or GB, respectively
User Accessing Files: fuser
It can be useful to determine what processes or users are currently accessing certain files. Suppose, for example, you want to unmount a file system mounted at /mnt. umount returns “device is busy.” The command fuser can then be used to determine what processes are accessing the device:
poison:~ # fuser -v /home/nikesh/
USER PID ACCESS COMMAND
/home/nikesh/: nikesh 5476 ..c.. su
Kernel Ring Buffer: dmesg
poison:~ # dmesg | more
Linux version 2.6.18.2-34-default (geeko@buildhost) (gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)) #1 SMP Mon Nov 27
11:46:27 UTC 2006
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009f400 (usable)
BIOS-e820: 000000000009f400 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000001bef0000 (usable)
BIOS-e820: 000000001bef0000 - 000000001bef3000 (ACPI NVS)
BIOS-e820: 000000001bef3000 - 000000001bf00000 (ACPI data)
BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
0MB HIGHMEM available.
446MB LOWMEM available.
found SMP MP-table at 000f5e30
On node 0 totalpages: 114416
DMA zone: 4096 pages, LIFO batch:0
Normal zone: 110320 pages, LIFO batch:31
DMI 2.3 present
…………………
List of Open Files: lsof.
To view a list of all the files open for the process with process ID PID, use -p. For example, to view all the files used by the current shell, enter:
poison:~ # lsof -p $$
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
bash 4700 root cwd DIR 3,6 4096 1811521 /root
bash 4700 root rtd DIR 3,6 4096 2 /
bash 4700 root txt REG 3,6 557704 913931 /bin/bash
bash 4700 root mem REG 3,6 131115 2139537 /lib/ld-2.5.so
bash 4700 root mem REG 0,0 0 [heap] (stat: No such file or directory)
bash 4700 root mem REG 3,6 42546 2137956 /lib/libnss_files-2.5.so
bash 4700 root mem REG 3,6 238464 344723 /usr/lib/locale/en_US.utf8/LC_CTYPE
bash 4700 root mem REG 3,6 1494633 2140298 /lib/libc-2.5.so
bash 4700 root mem REG 3,6 16082 2140299 /lib/libdl-2.5.so
bash 4700 root mem REG 3,6 294652 2140313 /lib/libncurses.so.5.5
bash 4700 root mem REG 3,6 28088 2140319 /lib/libhistory.so.5.1
bash 4700 root mem REG 3,6 192840 2140316 /lib/libreadline.so.5.1
bash 4700 root mem REG 3,6 42325 2137960 /lib/libnss_nis-2.5.so
bash 4700 root mem REG 3,6 95913 2140304 /lib/libnsl-2.5.so
bash 4700 root mem REG 3,6 32135 2137952 /lib/libnss_compat-2.5.so
bash 4700 root mem REG 3,6 25460 329733 /usr/lib/gconv/gconv-modules.cache
bash 4700 root 0u CHR 136,4 6 /dev/pts/4
bash 4700 root 1u CHR 136,4 6 /dev/pts/4
bash 4700 root 2u CHR 136,4 6 /dev/pts/4
bash 4700 root 255u CHR 136,4 6 /dev/pts/4
Interprocess Communication: ipcs
The command ipcs produces a list of the IPC resources currently in use:
poison:~ # ipcs
—— Shared Memory Segments ——–
key shmid owner perms bytes nattch status
0×00000000 98304 root 600 33554432 7 dest
0×00000000 32769 root 666 66136 2 dest
0×00000000 524290 root 600 393216 2 dest
0×00000000 557059 root 600 393216 2 dest
0×00000000 589828 root 600 393216 2 dest
0×00000000 622597 root 600 393216 2 dest
0×00000000 786438 root 666 131040 1 dest
—— Semaphore Arrays ——–
key semid owner perms nsems
0×00000000 65536 wwwrun 600 1
0×00000000 98305 wwwrun 600 1
—— Message Queues ——–
key msqid owner perms used-bytes messages
Process Tree: pstree
The command pstree produces a list of processes in the form of a tree:
Processes: top
The command top, which stands for “table of processes,” displays a list of processes that is refreshed every two seconds. To terminate the program, press Q. The parameter -n 1 terminates the program after a single display of the process list. The following is an example output of the command top -n 1:
Who Is Doing What: w
With the command w, find out who is logged onto the system and what each user is doing. For example:
poison:~ # w
00:32:58 up 33 min, 8 users, load average: 1.71, 1.35, 0.82
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root :0 00:00 ?xdm? 2:06 0.21s /bin/sh /usr/bin/kde
root pts/0 00:00 32:03 0.00s 1.17s kded –new-startup
root pts/1 00:01 31:48 0.14s 0.13s wvdial
root pts/2 00:01 31:18 0.08s 0.04s tail -f access.log
root pts/3 00:01 20:04 2.55s 0.03s /bin/bash
root pts/4 00:01 1.00s 0.07s 0.00s w
root pts/5 00:01 8:36 0.08s 0.06s -bash
root pts/6 00:01 31:33 0.03s 0.03s /bin/bash
To use sar, sadc (system activity data collector) needs to be running. Check its status or start it with rcsysstat {start|status}.
sar can generate extensive reports on almost all important system activities, among them CPU, memory, IRQ usage, IO, or networking. With its many options, it is too complex to explain further here. Refer to the man page for extensive documentation with examples.
Memory Usage: free
The utility free examines RAM usage. Details of both free and used memory and swap areas are shown:
poison:~ # free
total used free shared buffers cached
Mem: 450128 398428 51700 0 10280 141204
-/+ buffers/cache: 246944 203184
Swap: 514040 182656 331384
The options -b,-k,-m,-g show output in bytes, KB, MB, or GB, respectively
User Accessing Files: fuser
It can be useful to determine what processes or users are currently accessing certain files. Suppose, for example, you want to unmount a file system mounted at /mnt. umount returns “device is busy.” The command fuser can then be used to determine what processes are accessing the device:
poison:~ # fuser -v /home/nikesh/
USER PID ACCESS COMMAND
/home/nikesh/: nikesh 5476 ..c.. su
Kernel Ring Buffer: dmesg
poison:~ # dmesg | more
Linux version 2.6.18.2-34-default (geeko@buildhost) (gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)) #1 SMP Mon Nov 27
11:46:27 UTC 2006
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009f400 (usable)
BIOS-e820: 000000000009f400 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000001bef0000 (usable)
BIOS-e820: 000000001bef0000 - 000000001bef3000 (ACPI NVS)
BIOS-e820: 000000001bef3000 - 000000001bf00000 (ACPI data)
BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
0MB HIGHMEM available.
446MB LOWMEM available.
found SMP MP-table at 000f5e30
On node 0 totalpages: 114416
DMA zone: 4096 pages, LIFO batch:0
Normal zone: 110320 pages, LIFO batch:31
DMI 2.3 present
…………………
List of Open Files: lsof.
To view a list of all the files open for the process with process ID PID, use -p. For example, to view all the files used by the current shell, enter:
poison:~ # lsof -p $$
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
bash 4700 root cwd DIR 3,6 4096 1811521 /root
bash 4700 root rtd DIR 3,6 4096 2 /
bash 4700 root txt REG 3,6 557704 913931 /bin/bash
bash 4700 root mem REG 3,6 131115 2139537 /lib/ld-2.5.so
bash 4700 root mem REG 0,0 0 [heap] (stat: No such file or directory)
bash 4700 root mem REG 3,6 42546 2137956 /lib/libnss_files-2.5.so
bash 4700 root mem REG 3,6 238464 344723 /usr/lib/locale/en_US.utf8/LC_CTYPE
bash 4700 root mem REG 3,6 1494633 2140298 /lib/libc-2.5.so
bash 4700 root mem REG 3,6 16082 2140299 /lib/libdl-2.5.so
bash 4700 root mem REG 3,6 294652 2140313 /lib/libncurses.so.5.5
bash 4700 root mem REG 3,6 28088 2140319 /lib/libhistory.so.5.1
bash 4700 root mem REG 3,6 192840 2140316 /lib/libreadline.so.5.1
bash 4700 root mem REG 3,6 42325 2137960 /lib/libnss_nis-2.5.so
bash 4700 root mem REG 3,6 95913 2140304 /lib/libnsl-2.5.so
bash 4700 root mem REG 3,6 32135 2137952 /lib/libnss_compat-2.5.so
bash 4700 root mem REG 3,6 25460 329733 /usr/lib/gconv/gconv-modules.cache
bash 4700 root 0u CHR 136,4 6 /dev/pts/4
bash 4700 root 1u CHR 136,4 6 /dev/pts/4
bash 4700 root 2u CHR 136,4 6 /dev/pts/4
bash 4700 root 255u CHR 136,4 6 /dev/pts/4
Interprocess Communication: ipcs
The command ipcs produces a list of the IPC resources currently in use:
poison:~ # ipcs
—— Shared Memory Segments ——–
key shmid owner perms bytes nattch status
0×00000000 98304 root 600 33554432 7 dest
0×00000000 32769 root 666 66136 2 dest
0×00000000 524290 root 600 393216 2 dest
0×00000000 557059 root 600 393216 2 dest
0×00000000 589828 root 600 393216 2 dest
0×00000000 622597 root 600 393216 2 dest
0×00000000 786438 root 666 131040 1 dest
—— Semaphore Arrays ——–
key semid owner perms nsems
0×00000000 65536 wwwrun 600 1
0×00000000 98305 wwwrun 600 1
—— Message Queues ——–
key msqid owner perms used-bytes messages
Process Tree: pstree
The command pstree produces a list of processes in the form of a tree:
Processes: top
The command top, which stands for “table of processes,” displays a list of processes that is refreshed every two seconds. To terminate the program, press Q. The parameter -n 1 terminates the program after a single display of the process list. The following is an example output of the command top -n 1:
Who Is Doing What: w
With the command w, find out who is logged onto the system and what each user is doing. For example:
poison:~ # w
00:32:58 up 33 min, 8 users, load average: 1.71, 1.35, 0.82
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root :0 00:00 ?xdm? 2:06 0.21s /bin/sh /usr/bin/kde
root pts/0 00:00 32:03 0.00s 1.17s kded –new-startup
root pts/1 00:01 31:48 0.14s 0.13s wvdial
root pts/2 00:01 31:18 0.08s 0.04s tail -f access.log
root pts/3 00:01 20:04 2.55s 0.03s /bin/bash
root pts/4 00:01 1.00s 0.07s 0.00s w
root pts/5 00:01 8:36 0.08s 0.06s -bash
root pts/6 00:01 31:33 0.03s 0.03s /bin/bash
Hardware Information in Linux by lshw command
lshw (HardWare LiSter) is a small tool for Linux to provide detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc.
It currently supports DMI (x86 only), OpenFirmware device tree (PowerPC only), PCI/AGP, ISA PnP (x86), CPUID (x86), IDE/ATA/ATAPI, PCMCIA (only tested on x86) and SCSI.
Installation:
OpenSuSe 11.1 user can use "1-click" installer to install lshw - here
Debian packages are available for many platforms.
Ubuntu packages are available.
sudo apt-get install lshw-gtk
Fedora now includes lshw and its GUI and can be installed using following command
$ sudo yum install lshw lshw-gui
Once you have lswh installed on the system the usage is straight forth.Then running the lshw-X brings up the list of hardware that you can browse through. It is similar to checking the hardware information from Windows’ control panel.
lshw command also provides output in multiple file formats. For example, you can get the output in HTML, XML, text and a few more. For instance, to get the output in HTML, you use the -html option as follows :
# lshw -html > hardware.html
It currently supports DMI (x86 only), OpenFirmware device tree (PowerPC only), PCI/AGP, ISA PnP (x86), CPUID (x86), IDE/ATA/ATAPI, PCMCIA (only tested on x86) and SCSI.
Installation:
OpenSuSe 11.1 user can use "1-click" installer to install lshw - here
Debian packages are available for many platforms.
Ubuntu packages are available.
sudo apt-get install lshw-gtk
Fedora now includes lshw and its GUI and can be installed using following command
$ sudo yum install lshw lshw-gui
Once you have lswh installed on the system the usage is straight forth.Then running the lshw-X brings up the list of hardware that you can browse through. It is similar to checking the hardware information from Windows’ control panel.
lshw command also provides output in multiple file formats. For example, you can get the output in HTML, XML, text and a few more. For instance, to get the output in HTML, you use the -html option as follows :
# lshw -html > hardware.html
Grendel - Web Application Security Testing Tool
Grendel-Scan is an open-source web application security testing tool. It has automated testing module for detecting common web application vulnerabilities, and features geared at aiding manual penetration tests. The only system requirement is Java 5; Windows, Linux and Macintosh builds are available.
Current stable version:
1.0 Platform File
Windows Grendel-Scan-v1.0-win32.zip
Linux Grendel-Scan-v1.0-linux.zip
http://www.grendel-scan.com/download.htm
Macintosh Grendel-Scan-v1.0-mac.zip
Source Grendel-Scan-v1.0-src.zip
JavaDocs Grendel-Scan-v1.0-javadoc.zip
Current stable version:
1.0 Platform File
Windows Grendel-Scan-v1.0-win32.zip
Linux Grendel-Scan-v1.0-linux.zip
http://www.grendel-scan.com/download.htm
Macintosh Grendel-Scan-v1.0-mac.zip
Source Grendel-Scan-v1.0-src.zip
JavaDocs Grendel-Scan-v1.0-javadoc.zip
File recovery tool for Ext2/Ext3 filesystems
File recovery tool for Ext2/Ext3 filesystems
giis (gET iT i sAY) is a file recovery tool for Ext2/Ext3 filesystems. Once installed, current files and newly created files can be recovered. It allows users to recover all deleted files, recover files owned by a specific user, dump data from old file locations, and recover files of a specific type, such as text or PNG. A forensic analyzer is also provided to assist users during recovery.
giis won FOSS India Award 2008 (aka LinuxAsia 2008)
Features
* Recover files Deleted Date on specific date or deleted before/after specific date or even within specific date range.
* Recover files with their original access permission types and file owner and group details.
* User friendly configuration file which supports adding new directories even after installation.
* Recover deleted files of all users.
* Recover deleted files of a specific user.
* Recovery of files based on the File type (gif,mp3,jpeg)
* Recovers deleted hidden files or system files.
* Recovers Dropped mysql tables.
* Forensic analyzer is provided to assist data dump from the harddisk.
* If original path of deleted file exists,Recovered files automatically restored back to their appropriate directories.
* Provides list of deleted files and it's restore path
* If contents are modified or overwritten , during recovery user has the option to compare to old file data with current disk data using giis dump option.
* Displays your current file system details.
* If file is modified ,it allows user to decide whether to retrieve latest version of deleted file or older version.
* Allows user to choose directories (other than /root and /home) that can be protected by giis.
* All newly created files and directory are added,as time limit specified in crontab.
Installation on OpenSuse 11.1
Download Latest Version - giis_4.4
Install giis binary just follow the steps:
1) Change giis directory
cd giis_XX (Replace XX with appropriate version number for example giis_4.4)
2) Run the shell script named 'install_giis.sh',
For interactive installation use: sh install_giis.sh 0
For non-interactive: sh install_giis.sh 1
And after successful installation here is the detail explanation on how to use giis - here
Saturday, January 23, 2010
Apache Virtual Hosting Configuration in RHEL 5
Apache Virtual Hosting Configuration
Host based virtual hosting:
system1: setup apache virtual host
Step 1:Install http packages
#yum install httpd
Step 2:Create html files
#vi /var/www/html/main.html
#mkdir /var/www/mail
#vi /var/www/mail/mail.html
Step 3:Add html page to http configuration file
#vi /etc/httpd/conf/httpd.conf
Line no: 390
Directory Index mail.html main.html index.html index.html.var
Line no: 998 or Last
NameVirtualHost 192.168.0.25:80
Servername www.vv.com.
DocumentRoot /var/www/html
Servername mail.vv.com.
DocumentRoot /var/www/mail
Step 4:restart the http service
#service httpd restart
sys1:
add dns entries in /etc/resolv.conf
#vim /etc/resolv.conf
search vv.com
nameserver 192.168.0.25
Step 5:open firefox and type the following url in address bar
http://www.vv.com
http://mail.vv.com
IP based virtual hosting:system1:
Step 1:create ethernet alias ip address is 10.0.0.10
#netconfig d eth0:1
#service network restart
add host the entries in dns
#cat>>/var/named/chroot/var/named/rhel5.com.db
vvlinux IN A 10.0.0.10
reload the dns entries
#rndc reload
Step 2:Install http packages
#yum install httpd
Step 3:Create html files
#mkdir /var/www/vvlinux
#vi /var/www/mail/vvlinux.html
Step 4:Add html page to http configuration file
#vi /etc/httpd/conf/httpd.conf
Line no: 390
Directory Index vvlinux.html mail.html main.html index.html
Line no: 998 or Last
NameVirtualHost 192.168.0.25:80
Servername www.vv.com.
DocumentRoot /var/www/html
Servername mail.vv.com.
DocumentRoot /var/www/mail
NameVirtualHost 10.0.0.10:80
Servername vvlinux..vv.com.
DocumentRoot /var/www/vvlinux
Step 5:restart the http service
#service httpd restart
sys1:
add dns entries in /etc/resolv.conff
#vi /etc/resolv.conf
Step 6:open firefox and type the following url in address bar
http://www.vv.com
http://mail.vv.com
http://vvlinux.vv.com
Finally apache virtual host configure successfully.
Apache(httpd) Server Configuration setup in RHEL 5
system1: httpd server configuration setup
Step 1:Configure dns
Step 2:Install http packages
#yum install httpd
Step 3:Create html file
Create html file
#vi /var/www/html/main.html
Step 4: Add html page to http configuration file
#vi /etc/httpd/conf/httpd.conf
Line no: 390
Directory Index main.html index.html index.html.var
Step 5:restart the http service
#chkconfig httpd on
#service httpd restart
sys1:
add dns entries in /etc/resolv.conf
#vi /etc/resolv.conf
search vv.com
nameserver 192.168.0.25
Step 6:open firefox and type the following url in address bar
http://system1.vv.com
Finally Apache server httpd server configure successfully
Step 1:Configure dns
Step 2:Install http packages
#yum install httpd
Step 3:Create html file
Create html file
#vi /var/www/html/main.html
Step 4: Add html page to http configuration file
#vi /etc/httpd/conf/httpd.conf
Line no: 390
Directory Index main.html index.html index.html.var
Step 5:restart the http service
#chkconfig httpd on
#service httpd restart
sys1:
add dns entries in /etc/resolv.conf
#vi /etc/resolv.conf
search vv.com
nameserver 192.168.0.25
Step 6:open firefox and type the following url in address bar
http://system1.vv.com
Finally Apache server httpd server configure successfully
Wednesday, January 6, 2010
Most Basic Questions & Commands
• What is Linux?
Linux is an Open Source, free Operating System created by Linus Torvalds.
• What is the linux kernel?
The Linux kernel is the core of the Linux operating system. To find out which version of the Linux kernel you are running, simply type uname -r in a terminal. For more information on the Linux kernel, please visit http://www.kernel.org. For information on how to install or compile the Linux Kernel, please see our Kernel Compile/Upgrade Guide.
• What distribution of Linux should I install?
One of the pleasures of running linux is choice. The choice of which Linux Distribution you wish to run is 100% up to you. You can browse our Distributions Page for comparisons of the various distributions out there. If you are totally new to linux we suggest you start off with either Red Hat Linux or Mandrake Linux as they are easier to install, configure and maintain.
• Who is the root user?
The root user is the master user or systems adminstrator of the machine. The root user has full access to all files and directories, which is why you will only want to use the root account to perform system maintainance or to install applications.
• How do I reboot my machine?
In order to reboot your machine, you must instruct the Linux kernel to stop all the processes (programs) it's currently running. Do not simply press the reboot button on the front of your computer case, as Linux must be properly shut down/restarted. To restart your machine, as root, run either of the following commands in a terminal:
reboot
• How do I shut down my machine?
In order to shut down your machine, you must instruct the Linux kernel to stop all the processes (programs) it's currently running. Do not simply press the power off button on the front of your computer case, as Linux must be properly shut down/restarted. To shut down your machine, as root, run either of the following commands in a terminal:
If you want to remove the Lilo or Grub boot loader from your system (if you are uninstalling linux etc) follow the procedures below:
For Windows 95/98 etc:
Use a dos boot disk and at the command prompt type:
For Windows XP:
Boot off the XP Installation CD and go into rescue mode. From there run the command:
While logged in as root, type adduser username at the shell prompt, replacing username with the name you want to use to log in. You can create as many users as you wish, one for each member of your family, for example.
• How do I delete a user?
While logged in as root, type userdel username at the shell prompt, replacing username with the user name you wish to delete.
• How do I change my login password?
To set the password for a specific user, type (while logged in as root) passwd username at the shell prompt, replacing username with the name of the person who's password you wish to change. By typing just passwd you'll be able to change the password of the user under who's name you're currently logged in as. Do not use passwords which are easy to guess, like your middle name or your pets name.
• How do I change directories?
cd - Used to change directories
Usage: cd [directory]
Example: cd /home/joey/html
Example: cd ../ (to move back one directory)
Example: cd (to return to your home directory)
For more information, in a terminal, type man cd
• How do I copy files?
cp - Used to copy files/directories from one location to another
Usage: cp file newlocation
Example: cp /home/joey/index.html /var/www/index.html
Example: cp /home/joey/* /var/www/ (this will copy everything in /home/joey to /var/www/)
For more information, in a terminal, type man cp
• How do I rename files?
mv - Used to move or rename files
Usage: mv file location (to move)
Usage: mv filename newfilename (to rename)
Example: mv index.html /var/www/index.html (to move)
Example: mv index.html index2.html (rename)
For more information, in a terminal, type man mv
• How do I move files?
mv - Used to move or rename files
Usage: mv file location (to move)
Usage: mv filename newfilename (to rename)
Example: mv index.html /var/www/index.html (to move)
Example: mv index.html index2.html (rename)
For more information, in a terminal, type man mv
• How do I edit files
The default editor that ships with almost every distribution of Linux is Vi. This editor is slightly advanced and confuses most newbies. We suggest starting off with Pico, a more simple editor. Pico is part of the Pine software package which can be downloaded at http://www.washington.edu/pine (It might already be installed on your system). To edit a file with pico, simply run:
pico filename
This will open up the file and allow to you edit it. At the bottom of the screen you will notice the various commands that you have access to with Pico. If you wish to save the file and exit, simply hold down the control key and hit the x key on your keyboard.
• How do I list directory contents?
Example: ls (To list the current directory)
Example: ls /home/joey (To list the contents of /home/joey)
Example: ls -a (To list hidden files)
Example: ls -l (To list file/directory permissions and file sizes)
Example: ls -al /home/joey (To list all files and permissions in /home/joey)
For more information, in a terminal, type man ls
• How do I delete files?
To delete a file you must first have write permission to it. For information about permissions, click here. Once you have write permission, in a terminal run:
When removing files, you may use an astrix (*) as a wildcard flag to remove certain files, for example if I wanted to remove all files that began with the letter j, I would run rm j*
If anyone tells you to run rm -rf / as root, DO NOT LISTEN TO THEM. Running this command will delete all the files/directories on your Linux system.
• How do I delete directories?
If you have ownership to the directory and the directory is empty, you can simply type rmdir directoryname to remove the directory. If the directory is not empty and you wish to simply delete it and all its contents, run
• How do I access my cdrom drive?
Linux requires you to mount your cdrom/floppy drives when you wish to use them. On most Linux distributions, the mount command will require root access. Depending on which Linux distribution you run, one of the following commands should mount your cdrom drive. As root, run:
Linux requires you to mount your cdrom/floppy drives when you wish to use them. On most Linux distributions, the mount command will require root access. Depending on which Linux distribution you run, one of the following commands should mount your floppy drive. As root, run:
One of the great features of Linux is that it is a multi-user system. With multi-users, it allows certain users to own files and directories so nobody else can access/modify them, for example your /home directory. To change the ownership of a file/directory, as root execute the following command in a terminal:
• How do I view/change permissions on files/directories?
There are 3 different attributes a file can have that make up the permissions for the file.
There is read access that allows users to read the file.
There is write access that allows users to modify the file.
There is executable access that allows users to execute the file.
From these three attributes, you now have three different levels of permissions, the first being for the owner of the file, the second being for the group the file belongs to and the third being all other users on the system.
To view the current permissions on files and directories run the following command:
ls -l and you should see something that looks like:
drwxrwxr-x 3 joey html 4096 Sep 12 2000 images/
-rw-rw-r-- 1 joey html 267 Aug 8 12:55 index.shtml
The above shows you that images is a directory (d) and that the owner and group (joey html) have read (r), write (w) and execute (x) permissions while other users on the system only have read (r) and execute (x) permissions.
For the index.shtml file, it shows joey and html as the owner and group and they both have read and write access to the file. It also shows that other users on the system only have read access. Note there is no executable permission since the file is not an executable.
To modify the permissions on a file, you either have to own it or be logged in as root. To modify the permissions, in a terminal type:
Some common numerical values are:
755 - Read, Write, Execute for owner, read, execute for group and other.
644 - Read, Write for owner, read for group and other.
666 - Read, Write for all.
700 - Read, Write, Execute for owner, nothing for group, other.
So if you wanted to make a file an executable for your user and other users on the system, you would run the following:
chmod 755 somefile
For more information, in a terminal, type man chmod
• How do I find files on my system?
There are two methods to search for files on your Linux machine, one method being the locate command and the other being the find command. If you wish to use the locate command, you must first update the locate database by running the following command in a terminal as root:
/usr/bin/find / -name filename Be sure to replace "filename" with the actual name of the file.
• How do I unzip a .tar.gz/.tgz file?
To extract .tar.gz or .tgz files, run the following command in a terminal:
• How do I unzip a .bz2 file?
To extract .bz2 files, run the following command in a terminal:
• How do I install a program?
There are many ways to install applications in Linux. If the file you wish to install is in .rpm format and you are running an RPM based distribution such as Red Hat, Mandrake or SuSE, run the following command as root in a shell prompt/terminal:
rpm -Uvh filename.rpm
If you are running Debian GNU/Linux and you wish to install a .deb file, you can do so by running the following command in a terminal as root:
dpkg -i filename.deb or apt-get install package (if you have APT already installed/configured).
If the file you with to install is in a .tar.gz, .tgz or .bz2 format, you will first have to decompress (unzip) the file. Once the file has been unziped, it should create a directory based on the filename. Simply change into that directory and open up the README or INSTALL file in a text editor and follow the installation instructions.
• How do I run a program?
To run a program, you must first make sure it has executable permissions set. For more information on permissions, see How do I view/change permissions on files/directories? above. Once the file has executable permissions, simply run the filename from a terminal. I will use the filename "irc" as an example
Example: /usr/bin/irc (from anywhere on the system)
Example: ./irc (from the /usr/bin directory)
Linux is an Open Source, free Operating System created by Linus Torvalds.
• What is the linux kernel?
The Linux kernel is the core of the Linux operating system. To find out which version of the Linux kernel you are running, simply type uname -r in a terminal. For more information on the Linux kernel, please visit http://www.kernel.org. For information on how to install or compile the Linux Kernel, please see our Kernel Compile/Upgrade Guide.
• What distribution of Linux should I install?
One of the pleasures of running linux is choice. The choice of which Linux Distribution you wish to run is 100% up to you. You can browse our Distributions Page for comparisons of the various distributions out there. If you are totally new to linux we suggest you start off with either Red Hat Linux or Mandrake Linux as they are easier to install, configure and maintain.
• Who is the root user?
The root user is the master user or systems adminstrator of the machine. The root user has full access to all files and directories, which is why you will only want to use the root account to perform system maintainance or to install applications.
• How do I reboot my machine?
In order to reboot your machine, you must instruct the Linux kernel to stop all the processes (programs) it's currently running. Do not simply press the reboot button on the front of your computer case, as Linux must be properly shut down/restarted. To restart your machine, as root, run either of the following commands in a terminal:
reboot
shutdown -r now
On most systems you can also press (all at once) the control, alt and delete keys. • How do I shut down my machine?
In order to shut down your machine, you must instruct the Linux kernel to stop all the processes (programs) it's currently running. Do not simply press the power off button on the front of your computer case, as Linux must be properly shut down/restarted. To shut down your machine, as root, run either of the following commands in a terminal:
halt
shutdown -h now
• How do I remove/uninstall Lilo/Grub?If you want to remove the Lilo or Grub boot loader from your system (if you are uninstalling linux etc) follow the procedures below:
For Windows 95/98 etc:
Use a dos boot disk and at the command prompt type:
fdisk /mbr
For Windows XP:
Boot off the XP Installation CD and go into rescue mode. From there run the command:
fixmbr
• How do I add a user?While logged in as root, type adduser username at the shell prompt, replacing username with the name you want to use to log in. You can create as many users as you wish, one for each member of your family, for example.
• How do I delete a user?
While logged in as root, type userdel username at the shell prompt, replacing username with the user name you wish to delete.
• How do I change my login password?
To set the password for a specific user, type (while logged in as root) passwd username at the shell prompt, replacing username with the name of the person who's password you wish to change. By typing just passwd you'll be able to change the password of the user under who's name you're currently logged in as. Do not use passwords which are easy to guess, like your middle name or your pets name.
• How do I change directories?
cd - Used to change directories
Usage: cd [directory]
Example: cd /home/joey/html
Example: cd ../ (to move back one directory)
Example: cd (to return to your home directory)
For more information, in a terminal, type man cd
• How do I copy files?
cp - Used to copy files/directories from one location to another
Usage: cp file newlocation
Example: cp /home/joey/index.html /var/www/index.html
Example: cp /home/joey/* /var/www/ (this will copy everything in /home/joey to /var/www/)
For more information, in a terminal, type man cp
• How do I rename files?
mv - Used to move or rename files
Usage: mv file location (to move)
Usage: mv filename newfilename (to rename)
Example: mv index.html /var/www/index.html (to move)
Example: mv index.html index2.html (rename)
For more information, in a terminal, type man mv
• How do I move files?
mv - Used to move or rename files
Usage: mv file location (to move)
Usage: mv filename newfilename (to rename)
Example: mv index.html /var/www/index.html (to move)
Example: mv index.html index2.html (rename)
For more information, in a terminal, type man mv
• How do I edit files
The default editor that ships with almost every distribution of Linux is Vi. This editor is slightly advanced and confuses most newbies. We suggest starting off with Pico, a more simple editor. Pico is part of the Pine software package which can be downloaded at http://www.washington.edu/pine (It might already be installed on your system). To edit a file with pico, simply run:
pico filename
This will open up the file and allow to you edit it. At the bottom of the screen you will notice the various commands that you have access to with Pico. If you wish to save the file and exit, simply hold down the control key and hit the x key on your keyboard.
• How do I list directory contents?
ls - To list the contents of a directory
Usage: ls [flags] directoryExample: ls (To list the current directory)
Example: ls /home/joey (To list the contents of /home/joey)
Example: ls -a (To list hidden files)
Example: ls -l (To list file/directory permissions and file sizes)
Example: ls -al /home/joey (To list all files and permissions in /home/joey)
For more information, in a terminal, type man ls
• How do I delete files?
To delete a file you must first have write permission to it. For information about permissions, click here. Once you have write permission, in a terminal run:
rm filename
There is no "Recycle Bin" in Linux so once you delete a file, it's gone for good. When removing files, you may use an astrix (*) as a wildcard flag to remove certain files, for example if I wanted to remove all files that began with the letter j, I would run rm j*
If anyone tells you to run rm -rf / as root, DO NOT LISTEN TO THEM. Running this command will delete all the files/directories on your Linux system.
• How do I delete directories?
If you have ownership to the directory and the directory is empty, you can simply type rmdir directoryname to remove the directory. If the directory is not empty and you wish to simply delete it and all its contents, run
rm -rf directoryname
Please be careful with the -rf flag, as it will remove everything in the specified directory including sub directories. With root access and the rm -rf command you can wipe out your entire system if you make an error. • How do I access my cdrom drive?
Linux requires you to mount your cdrom/floppy drives when you wish to use them. On most Linux distributions, the mount command will require root access. Depending on which Linux distribution you run, one of the following commands should mount your cdrom drive. As root, run:
mount /dev/cdrom /mnt/cdrom
mount /dev/cdrom /cdrom
• How do I access my floppy drive?Linux requires you to mount your cdrom/floppy drives when you wish to use them. On most Linux distributions, the mount command will require root access. Depending on which Linux distribution you run, one of the following commands should mount your floppy drive. As root, run:
mount /dev/fd0 /mnt/floppy
mount /dev/fd0 /floppy
• How do I view/change ownership on files/directories?One of the great features of Linux is that it is a multi-user system. With multi-users, it allows certain users to own files and directories so nobody else can access/modify them, for example your /home directory. To change the ownership of a file/directory, as root execute the following command in a terminal:
chown username. filename/directory
This will change the ownership and group ownership of the specified file or directory to the specified user. For more information, in a terminal, type man chown • How do I view/change permissions on files/directories?
There are 3 different attributes a file can have that make up the permissions for the file.
There is read access that allows users to read the file.
There is write access that allows users to modify the file.
There is executable access that allows users to execute the file.
From these three attributes, you now have three different levels of permissions, the first being for the owner of the file, the second being for the group the file belongs to and the third being all other users on the system.
To view the current permissions on files and directories run the following command:
ls -l and you should see something that looks like:
drwxrwxr-x 3 joey html 4096 Sep 12 2000 images/
-rw-rw-r-- 1 joey html 267 Aug 8 12:55 index.shtml
The above shows you that images is a directory (d) and that the owner and group (joey html) have read (r), write (w) and execute (x) permissions while other users on the system only have read (r) and execute (x) permissions.
For the index.shtml file, it shows joey and html as the owner and group and they both have read and write access to the file. It also shows that other users on the system only have read access. Note there is no executable permission since the file is not an executable.
To modify the permissions on a file, you either have to own it or be logged in as root. To modify the permissions, in a terminal type:
chmod xxx filename/directory
You will have to replace the xxx flags with the permissions you wish to change. You can either go by the numerical value or by the actuals.Some common numerical values are:
755 - Read, Write, Execute for owner, read, execute for group and other.
644 - Read, Write for owner, read for group and other.
666 - Read, Write for all.
700 - Read, Write, Execute for owner, nothing for group, other.
So if you wanted to make a file an executable for your user and other users on the system, you would run the following:
chmod 755 somefile
For more information, in a terminal, type man chmod
• How do I find files on my system?
There are two methods to search for files on your Linux machine, one method being the locate command and the other being the find command. If you wish to use the locate command, you must first update the locate database by running the following command in a terminal as root:
/usr/bin/updatedb
This will create an index of all the files and their locations on your hard drive. Once updatedb has completed running, you may now search your drive for a specific file by running the following command in a terminal:/usr/bin/locate filename
Another way to search your linux system is with the find command. To find a file on your sytem with the find command, in a terminal run the follwoing:/usr/bin/find / -name filename Be sure to replace "filename" with the actual name of the file.
• How do I unzip a .tar.gz/.tgz file?
To extract .tar.gz or .tgz files, run the following command in a terminal:
tar -zxvf file.tar.gz (or file.tgz)
This will normally create a new directory based on the filename. If you want to extract a filename called file.tar (without the .gz) simply run:tar -xvf file.tar
For more information, in a terminal, type man tar • How do I unzip a .bz2 file?
To extract .bz2 files, run the following command in a terminal:
bunzip2 -dv file.bz2
This will normally create a new directory based on the filename. For more information, in a terminal, type man buznip2 • How do I install a program?
There are many ways to install applications in Linux. If the file you wish to install is in .rpm format and you are running an RPM based distribution such as Red Hat, Mandrake or SuSE, run the following command as root in a shell prompt/terminal:
rpm -Uvh filename.rpm
If you are running Debian GNU/Linux and you wish to install a .deb file, you can do so by running the following command in a terminal as root:
dpkg -i filename.deb or apt-get install package (if you have APT already installed/configured).
If the file you with to install is in a .tar.gz, .tgz or .bz2 format, you will first have to decompress (unzip) the file. Once the file has been unziped, it should create a directory based on the filename. Simply change into that directory and open up the README or INSTALL file in a text editor and follow the installation instructions.
• How do I run a program?
To run a program, you must first make sure it has executable permissions set. For more information on permissions, see How do I view/change permissions on files/directories? above. Once the file has executable permissions, simply run the filename from a terminal. I will use the filename "irc" as an example
Example: /usr/bin/irc (from anywhere on the system)
Example: ./irc (from the /usr/bin directory)
Tuesday, January 5, 2010
Squid proxy in 5 minutes
Install
On a Red Hat® Enterprise Linux® or Fedora™ Core operating system, it is easy to check if Squid is installed using the rpm system. Type the command:
rpm -q squid
If Squid is already installed, you will get a response similar to:
squid-2.5.STABLE6-3.4E.12
If Squid isn’t installed, then you can use Yum to install it. Thanks to Yum the installation is quite easy.
Just type at a command line:
yum install squid
If you happen to have downloaded the rpm you can also type something like:
rpm -ivh squid-2.5.STABLE6-3.4E.12.i386.rpm
Configure
Squid’s main configuration file lives in /etc/squid/squid.conf. The 3,339 line configuration file is intimidating, but the good news is that it is very simple to setup a proxy server that forward http, https, and ftp requests to Squid on the default port of 3128 and caches the data.
Back up the configuration file
It is always good policy to backup a configuration file before you edit it. If you haven’t been burned yet, you haven’t edited enough configuration files. Make a backup from the command line or the gui and rename the original file something meaningful. I personally like to append a bck.datestamp. For example:
cp /etc/squid/squid.conf /etc/squid/squid.conf.bck.02052007
If it is the original configuration file you might choose to do:
cp /etc/squid/squid.conf /etc/squid/squid.conf.org.02052007
Edit the file
Open /etc/squid/squid.conf with your favorite text editor. I use vim, but nano is a good beginner’s command line text editor. If you do use nano, make sure you use the nano –nowrap option to turn off line wrapping when editing things like configuration files. A gui editor like Gedit will also work.
Five minute configuration
There are many fancy options for squid that we will not enable, specifically acls (access control lists) or authentication. We are going to set up a caching proxy server with no access control. This server would be suitable for a home network behind a firewall.
The default squid configuration is almost complete, but a few small changes should be made. You will need to either find and uncomment entries, or modify existing uncommented lines in the squid configuration file. Use your favorite text editor or a text find to quickly locate these lines:
visible_hostname machine-name
http_port 3128
cache_dir ufs /var/spool/squid 1000 16 256
cache_access_log /var/log/squid/access.log
In the acl section near the bottom add:
acl intranet 192.168.0.0/24
http_access allow intranet
Let me explain what each of these six lines means:
visible_hostname – Create this entry and set this to the hostname of the machine. To find the hostname, use the command hostname. Not entering a value may cause squid to fail as it may not be able to automatically determine the fully qualified hostname of your machine.
http_port 3128 – Uncomment this line but there is no need to edit it unless you want to change the default port for http connections.
cache_dir ufs /var/spool/squid 1000 15 256 – Uncomment this line. You may want to append a zero to the value 100 which will make the cache size 1000MB instead of 100MB. The last two values stand for the default folder depth the cache will create on the top and subdirectories respectively. They do not need modification.
cache_access_log – Uncomment this line. This is where all requests to the proxy server will get logged.
acl intranet 192.168.0.0/24 – This entry needs to be added. It should correspond to whatever your local network range is. For example, if your Fedora server is 192.168.2.5 then the entry should be acl intranet 192.168.2.0/24
http_access allow intranet – This allows the acl named intranet to use the proxy server. Make sure to put allow directives above the last ‘http_access deny all’ entry, as it will overide any allow directives below it.
Turning on squid
Enable the proper run levels:
chkconfig squid on
Start the service:
service squid start
Verify that squid isrunning:
service squid status
Note, if you have problems starting squid, open a separate shell and run:
tail -f /var/log/messages
Then start the squid service in your original window:
service squid start
The tail command should show an error for squid that can help you solve the problem. One common error is that the swap (cache) directory doesn’t exist. To solve this problem, run squid with the -z option to automatically create the directories:
/usr/sbin/squid -z
Make sure that squid has write permission to the swap directory or this command won’t work.
Configuring the clients
If you are using Firefox or Mozilla you will need to add the proxy server as follows:
Go to Preferences>Network>Settings
Add the name of your new proxy server and port 3128 to the http proxy field (under manual configuration).
Open a shell to your proxy server so you can observe the log file being written to. Use tail, as before:
tail -f /var/log/squid/access.log
Now surf the web through your proxy server. You should see entries flying by in real time as you surf different http addresses. Congratulations, you now have a caching proxy server setup!
On a Red Hat® Enterprise Linux® or Fedora™ Core operating system, it is easy to check if Squid is installed using the rpm system. Type the command:
rpm -q squid
If Squid is already installed, you will get a response similar to:
squid-2.5.STABLE6-3.4E.12
If Squid isn’t installed, then you can use Yum to install it. Thanks to Yum the installation is quite easy.
Just type at a command line:
yum install squid
If you happen to have downloaded the rpm you can also type something like:
rpm -ivh squid-2.5.STABLE6-3.4E.12.i386.rpm
Configure
Squid’s main configuration file lives in /etc/squid/squid.conf. The 3,339 line configuration file is intimidating, but the good news is that it is very simple to setup a proxy server that forward http, https, and ftp requests to Squid on the default port of 3128 and caches the data.
Back up the configuration file
It is always good policy to backup a configuration file before you edit it. If you haven’t been burned yet, you haven’t edited enough configuration files. Make a backup from the command line or the gui and rename the original file something meaningful. I personally like to append a bck.datestamp. For example:
cp /etc/squid/squid.conf /etc/squid/squid.conf.bck.02052007
If it is the original configuration file you might choose to do:
cp /etc/squid/squid.conf /etc/squid/squid.conf.org.02052007
Edit the file
Open /etc/squid/squid.conf with your favorite text editor. I use vim, but nano is a good beginner’s command line text editor. If you do use nano, make sure you use the nano –nowrap option to turn off line wrapping when editing things like configuration files. A gui editor like Gedit will also work.
Five minute configuration
There are many fancy options for squid that we will not enable, specifically acls (access control lists) or authentication. We are going to set up a caching proxy server with no access control. This server would be suitable for a home network behind a firewall.
The default squid configuration is almost complete, but a few small changes should be made. You will need to either find and uncomment entries, or modify existing uncommented lines in the squid configuration file. Use your favorite text editor or a text find to quickly locate these lines:
visible_hostname machine-name
http_port 3128
cache_dir ufs /var/spool/squid 1000 16 256
cache_access_log /var/log/squid/access.log
In the acl section near the bottom add:
acl intranet 192.168.0.0/24
http_access allow intranet
Let me explain what each of these six lines means:
visible_hostname – Create this entry and set this to the hostname of the machine. To find the hostname, use the command hostname. Not entering a value may cause squid to fail as it may not be able to automatically determine the fully qualified hostname of your machine.
http_port 3128 – Uncomment this line but there is no need to edit it unless you want to change the default port for http connections.
cache_dir ufs /var/spool/squid 1000 15 256 – Uncomment this line. You may want to append a zero to the value 100 which will make the cache size 1000MB instead of 100MB. The last two values stand for the default folder depth the cache will create on the top and subdirectories respectively. They do not need modification.
cache_access_log – Uncomment this line. This is where all requests to the proxy server will get logged.
acl intranet 192.168.0.0/24 – This entry needs to be added. It should correspond to whatever your local network range is. For example, if your Fedora server is 192.168.2.5 then the entry should be acl intranet 192.168.2.0/24
http_access allow intranet – This allows the acl named intranet to use the proxy server. Make sure to put allow directives above the last ‘http_access deny all’ entry, as it will overide any allow directives below it.
Turning on squid
Enable the proper run levels:
chkconfig squid on
Start the service:
service squid start
Verify that squid isrunning:
service squid status
Note, if you have problems starting squid, open a separate shell and run:
tail -f /var/log/messages
Then start the squid service in your original window:
service squid start
The tail command should show an error for squid that can help you solve the problem. One common error is that the swap (cache) directory doesn’t exist. To solve this problem, run squid with the -z option to automatically create the directories:
/usr/sbin/squid -z
Make sure that squid has write permission to the swap directory or this command won’t work.
Configuring the clients
If you are using Firefox or Mozilla you will need to add the proxy server as follows:
Go to Preferences>Network>Settings
Add the name of your new proxy server and port 3128 to the http proxy field (under manual configuration).
Open a shell to your proxy server so you can observe the log file being written to. Use tail, as before:
tail -f /var/log/squid/access.log
Now surf the web through your proxy server. You should see entries flying by in real time as you surf different http addresses. Congratulations, you now have a caching proxy server setup!
Subscribe to:
Posts (Atom)