What are Port Numbers



Port Numbers - Linux
 
PORTS NUMBERS : Just as the physical address (MAC address) and the logical address (IP address) helps to route the traffic to a particular machine on a network, it is the port that identifies which service on the machine this traffic is destined to.

List of ports : /etc/services

A port on a specific computer is called a socket. It can be open, closed, listening or have a connection established.

###Important PORT NUMBERS to remember:

20 - FTP - data transfer
21 - FTP - control (command)
22 - SSH
23 - Telnet
25 - SMTP
37 - Time
43 - WHOIS
42 - WINS
53 - DNS
67 - BOOTp
68 - DHCP
69 - TFTP
79 - FINGER
80 - HTTP (WWW)
88 - Kerberose
101 - HOSTNAME
110 - POP3
111 - rpcbind
119 - NNTP
123 - NTP (Time)
137 - NetBios (nmbd)
139 - NetBios ( Samba)
143 - IMAP/Dovecot
161 - SNMP
180 - RIS
220 - IMAP3
389 - LDAP
443 - HTTPs
500 - Internet Key Exchange (IKE), IPSec
520 - RIP
546 - DHCPV6 client
547 - DHCPV6 server
554 - rtsp(Real Time Stream Protocol, Audio/Video)
631 - Printing (ipp)
744 - Flexlm
901 - SWAT
953 - rndc
993 - IMAPSecure
995 - POPs
999 - POP over SSL/TLS
2049 - NFS
2082 - CPANEL
2083 - CPANEL Secure SSL/TLS
2086 - CPANEL WHM
2087 - CPANEL WHM Secure/SSL
2095 - CPANEL Webmail
2096 - CPANEL Webmail Secure/SSL
2222 - Direct Admin Control Panel
2401 - CVSP server
3268 - AD Global Catalog
3269 - AD Global Catalog over SSL
3306 - MySQL Server
3389 - Terminal services (rdp-remote desktop protocol)
4643 - Virtusso Power Panel
(6000 - X11
6063)
8443 - Pleask Control Panel
9999 - Urchin
10000- Webmin Control Panel
21018- Skype


Read More Add your Comment 0 comments


Disk Quotas in linux



Disk Quotas

Disk space can be restricted by implementing disk quotas which alert a system administrator before a user consumes too much disk space or a partition becomes full. Disk quotas can be configured for individual users as well as user groups. This makes it possible to manage the space allocated for user-specific files (such as email) separately from the space allocated to the projects a user works on (assuming the projects are given their own groups).

In addition, quotas can be set not just to control the number of disk blocks consumed but to control the number of inodes (data structures that contain information about files in UNIX file systems). Because inodes are used to contain file-related information, this allows control over the number of files that can be created.

* Features of quotas
1). Limits disk usage (blocks or inodes)
2). Tied to file systems (et on a per file system basis)
3). can be configured for users and groups

* Steps to enable quota support :-
1) Enable quota support per file system in : /etc/fstab
a) defaults,usrquota,grpquota
Example:
#vi /etc/fstab
/dev/Volgroup00/logVol02/home ext3 defaults,usrquota,grpquota 1 2

2) Remount the file system(s)
a) mount -o remount /
b) use 'mount' to confirm that 'usrquota, grpquota' support are enabled
Example:
#mount -o remount /home

3) Create quota database files and generate disk usage table
a) quotacheck -mcug / (where c-create, u-user, g- group)
This creates /aquota.user and aquota.group
b) quotacheck -mavu

4) Assign quota policies: a) edquota username (set blocks/inodes, soft_limits, hard_limits)
Example:
edquota student1 (sets quotas for user student1)
b) edquota -g devl
(for group quota, check using #quota -g devl)

5) Check quotas
#quota username
Example:
#quota student1

6) Report on usage
#repquota -a

==> The blocks are measured in 1K increments, eg 20000 blocks is roughly 20 MB.

* To change the grace period of quota
#edquota -t

* Managing quotas
If quotas are implemented, they need some maintenance-mostly in the form of watching to see if the quotas are exceeded and making sure the quotas are accurate.

a) Enabling and disabling quotas

i) To turn all user and group quotas off
#quotaoff -vuag
If neither the -u and -g options are specified, only the user quotas are disabled. If only -g is specified, only group quotas are disabled. The -v switches causes verbose status informtion to display as the command executes.

ii) To enable quotas again:
#quotaon -vaug
To enable quotas for a specific file system, such as /home, use the following
#quotaon -vug /home
If neither the -u or -g options are specified, only the user quotas are enabled. If only -g is specified, only group quotas are enabled.

b) Reporting on Disk Quotas
#repquota -a

c) Keeping Quotas accurate Whenever a file system is not unmounted clearly (due to a system crash, for eg), it is necessary to run quotacheck. Running the following command periodically keeps the quotas more accurate.
#quotacheck -avug
The easiest way to run it periodically is to use cron.


**********************************


Read More Add your Comment 0 comments


How to install YUM server



YUM - Yellowdog Updater, Modified


The Yellowdog Updater, Modified (YUM) is an open-source command-line package-management utility for RPM-compatible Linux operating systems and has been released under the GNU General Public License.

Copy/Backup the RHEL5 DVD on the local hdd.

Mount DVD drive:
#mount /dev/cdrom /media

Now copy all the files from the DVD disk to the local Hard disk drive
#mkdir /var/ftp/pub/rhel5
#cp -avf /dev/media/* /var/ftp/pub/rhel5

To configure YUM server, following rpm's and services are required:


1.vsftpd->vsftpd-2.0.5.10.el5.i386.rpm
a). Run vsftpd rpm
#rpm -ivh vsftpd-*.rpm
b). iptables -I INPUT -p tcp --dport 20 -j ACCEPT
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
iptables -I INPUT -p udp --dport 21 -j ACCEPT
iptables -I INPUT -p udp --dport 20 -j ACCEPT
c). For SELinux
setsebool allow_ftpd_full_access on
d). open the file :- vim
#vim /etc/sysconfig/iptables-config and modify below mention line
IPTABLES_MODULES="ip_conntrack_netbios_ns ip_conntrack_ftp"
Now your ftp server is ready to take the responsibilty of yum server.

2.createrepo -> createrepo-0.4.11-3.el5.noarch.rpm
#cd /var/ftp/pub/rhel5/Server
#rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm
#cd..
#createrepo -vg /var/ftp/pub/rhel5/Server/repodata/comps-rhel5-server-core.xml Server

*****ON CLIENT MACHINE*****

#vim /etc/yum.repos.d/rhel-debuginfo.repo
[reposfile]
name= Updates
baseurl=ftp://ipaddress/pub
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY

Eg: #vim /etc/yum.repos.d/client.repo
{*you can use the following lines if configuring on a local PC*}
[server]
name=YUM configuration for the client PC
baseurl=ftp://127.0.0.1/pub/rhel5/Server
gpgcheck=0
====>>>>press esc key and type ->:wq - to save the file and exit from vim


Read More Add your Comment 0 comments


How to break root password



How to break root password !!!

Method 1:
 
One of the advantages of single-user mode is that you do not need a boot CD-ROM; however, it does not give you the option to mount the file systems as read-only or not mount them at all. 
 
If your system boots, but does not allow you to log in when it has completed booting, try single-user mode. 
 
In single-user mode, your computer boots to runlevel 1. Your local file systems are mounted, but your network is not activated. You have a usable system maintenance shell. Unlike rescue mode, single-user mode automatically tries to mount your file system. Do not use single-user mode if your file system cannot be mounted successfully. You cannot use single-user mode if the runlevel 1 configuration on your system is corrupted.
1) When you reach the grub screen press 'e' on linux.
2) Go to line which contains the word 'kernel' press 'e'
3) go to the end of that line and write 'linux single' or '1'
4) then press 'esc' twice and press 'b' to reboot the system
5) now wait for the prompt and then type 'passwd root'
6) enter new passwd

Method 2:
 
In emergency mode, you are booted into the most minimal environment possible. The root file system is mounted read-only and almost nothing is set up. The main advantage of emergency mode over single-user mode is that the init files are not loaded. If init is corrupted or not working, you can still mount file systems to recover data that could be lost during a re-installation.

1) Boot the computer with linux installation CD
2) Enter the linux rescue mode by entering the following command in boot screen
boot:linux rescue
3) When the sh prompt is reached, enter the following commands to change root password:
 
#chroot /mnt/sysimage
 
#passwd
 
The above step will prompt you to enter your new password


Read More Add your Comment 0 comments


How to install Webmin




WEBMIN

Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.

Install Webmin (Successfully tested/configured on Ubuntu server 10.04)

#sudo aptitude safe-upgrade

#sudo aptitude update

#sudo aptitude install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl apt-show-versions
 
#sudo mkdir downloads
 
#cd downloads
 
#sudo wget http://downloads.sourceforge.net/project/webadmin/webmin/1.510/webmin_1.510-2_all.deb?use_mirror=cdnetworks-us-1
 
or
 
#sudo wget http://downloads.sourceforge.net/project/webadmin/webmin/1.510
/webmin_1.510-2_all.deb?use_mirror=kent
 
#sudo dpkg -i webmin_1.510-2_all.deb
 
Incase the installation is not successful, try the following command
 
#sudo aptitude -f install

=>>You can access the Ubuntu machine from a Windows machine via a web browser by typing the address
https://yourip:10000
or
https://core:10000 , here core is the name of my Ubuntu server.


Read More Add your Comment 0 comments


Apt-Get command line tool



Apt-Get command line tool
(Ubuntu's Advanced Packaging Tool) !!!

The apt-get command is a powerful command-line tool used to work with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.

*Install package
#sudo apt-get install packagename

*Remove Package
#sudo apt-get remove packagename

*Install Multiple Packages
#sudo apt-get install packagename1 packagename2 packagename3

*Update the Package Index
#sudo apt-get update

The APT package index is essentially a database of available packages from the repositories defined in the /etc/apt/sources.list file.

*Upgrade the system
#sudo apt-get upgrade

*Read Debian APT User Manual
#sudo apt-get help

Tags: apt get apt-get advanced packaging tool install remove upgrade update help ubuntu linux unix package-management


Read More Add your Comment 0 comments


How to install a DNS Server



How to install a DNS Server

File Configuration bind9 on Ubuntu 10.04 :

/etc/bind

/etc/bind/named.conf.local

/etc/bind/named.conf.options

/etc/resolv.conf

/var/lib/bind

Step 1: Install Ubuntu dapper, or use your WORKING installation.

Step2: Install bind 9 and dnsutils:
Code: sudo apt-get install bind9 dnsutils

Step 3: Configure the main Bind files. Usually, if you install Bind from the source code, you will have to edit the file named.conf. However, Ubuntu provides you with a pre-configured Bind, so we will edit another file:
Code: sudo vi /etc/bind/named.conf.local
This is where we will insert our zones. By the way, a zone is a domain name that is referenced in the DNS server icon wink Dns server with bind9 and dnsutils on ubuntu 10.04
Insert this in the named.conf.local file:
Code:

# This is the zone definition. replace example.com with your domain name
zone "example.com" {
        type master;
        file "/etc/bind/zones/example.com.db";
        };

# This is the zone definition for reverse DNS.
replace 0.168.192 with your network address in
reverse notation - e.g my network address is 192.168.0
zone "0.168.192.in-addr.arpa" {
     type master;
     file "/etc/bind/zones/rev.0.168.192.in-addr.arpa";
};


Ok, now, let’s edit the options file:
Code: sudo vi /etc/bind/named.conf.options

We need to modify the forwarder. This is the DNS server to which your own DNS will forward the requests he cannot process.
Code:

forwarders {
      # Replace the address below with the address of your provider's DNS server
      123.123.123.123;
};


Now, let’s add the zone definition files (replace example.com with your domain name:
Code:
sudo mkdir /etc/bind/zones
sudo vi /etc/bind/zones/example.com.db


The zone definition file is where we will put all the addresses / machine names that our DNS server will know. You can take the following example:
Code:

// replace example.com with your domain name.
 do not forget the . after the domain name!
// Also, replace ns1 with the name of your DNS server
example.com.      IN      SOA     ns1.example.com. admin.example.com. (
// Do not modify the following lines!
                                                        2006081401
                                                        28800
                                                        3600
                                                        604800
                                                        38400
 )

// Replace the following line as necessary:
// ns1 = DNS Server name
// mta = mail server name
// example.com = domain name
example.com.      IN      NS              ns1.example.com.
example.com.      IN      MX     10       mta.example.com.

// Replace the IP address with the right IP addresses.
www              IN      A       192.168.0.2
mta              IN      A       192.168.0.3
ns1              IN      A       192.168.0.1


Now, let’s create the reverse DNS zone file:
Code:
sudo vi /etc/bind/zones/rev.0.168.192.in-addr.arpa
Copy and paste the following text, modify as needed:
Code:
//replace example.com with yoour domain name, ns1 with your DNS server name.
// The number before IN PTR example.com
is the machine address of the DNS server.
in my case, it's 1, as my IP address is 192.168.0.1.
@ IN SOA ns1.example.com. admin.example.com. (
                        2006081401;
                        28800;
                        604800;
                        604800;
                        86400
)

                     IN    NS     ns1.example.com.
1                    IN    PTR    example.com

Ok, now you just need to restart bind:
Code: sudo /etc/init.d/bind9 restart

We can now test the new DNS server…

Step 4: Modify the file resolv.conf with the following settings:
Code: sudo vi /etc/resolv.conf

enter the following:
Code:
// replace example.com with your domain name,
 and 192.168.0.1 with the address of your new DNS server.
search example.com
nameserver 192.168.0.1


Now, test your DNS:
Code: dig example.com


Read More Add your Comment 1 comments


How to configure Squid Proxy Server



Squid Server

Squid is a proxy server. HTTP requests are sent to Squid instead of being sent directly to the internet. 

Install Apache
# apt-get install apache2

Install Squid
# sudo apt-get install squid

Key File Locations


File
         Purpose

/etc/squid/squid.conf  
         Squid configuration file

/var/log/squid/access.log
         Squid access log file

# vi /etc/squid/squid.conf

Find the http_port tag, By default it reads
# http_port 3128

This is the default port that Squid will listen on for requests. If you want to change it, uncomment the line and set the correct port. If you want Squid to listen only on one specific NIC, you can also change the IP address – for example : 192.168.1.5:3128

Next, find the http_access section Uncomment these 2 lines:
acl our_networks src 192.168.1.0/24 192.168.2.0/24
http_access allow our_networks

NOTE: You'll need to change 192.168.1.0/24 to match your network. Unless you have a second subnet you can delete 192.168.2.0/24

# sudo /etc/init.d/squid start|restart|stop
 
On client PC, change the firefox/IE browsers proxy setting with the Squid server's
IP address (for eg 10.1.0.1) and port 3128. 


Read More Add your Comment 0 comments


What is a Zombie Process



Zombie Process

On Unix operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table, allowing the process that started it to read its exit status. The term zombie process derives from the common definition of zombie—an undead person. In the term's colorful metaphor, the child process has died but has not yet been reaped.

When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process's entry in the process table remains. The parent is sent a SIGCHLD signal indicating that a child has died; the handler for this signal will typically execute the wait system call, which reads the exit status and removes the zombie. The zombie's process ID and entry in the process table can then be reused. However, if a parent ignores the SIGCHLD, the zombie will be left in the process table. In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID.

A zombie process is not the same as an orphan process. Orphan processes don't become zombie processes; instead, they are adopted by init (process ID 1), which waits on its children.

Zombies can be identified in the output from the Unix ps command by the presence of a "Z" in the STAT column. Zombies that exist for more than a short period of time typically indicate a bug in the parent program. As with other leaks, the presence of a few zombies isn't worrisome in itself, but may indicate a problem that would grow serious under heavier loads.

To remove zombies from a system, the SIGCHLD signal can be sent to the parent manually, using the kill command. If the parent process still refuses to reap the zombie, the next step would be to remove the parent process. When a process loses its parent, init becomes its new parent. Init periodically executes the wait system call to reap any zombies with init as parent.
 $ ps -aef -H  (will list all processes with hierarchy structure.)
$ kill -9 5373  (Here 5343 is the process id)



Read More Add your Comment 0 comments


How to add an account to the sudoer list



Add an account to the sudoer list 


When logged in as a user with sudo privileges:

1) Terminal window

     sudo adduser name_of_user admin


2) Graphical Interface

Go to System--> Administration --> Users and Groups.


Then:


(1) Click on the name of the user that you want to elevate.

(2) Click on the properties button to open a new settings window.

(3) In the new window, click on the User Priviledges tab.

(4) Check the box next to "Executing system administration tasks".


Click OK all the way out, and that user should now be able to sudo.


Read More Add your Comment 0 comments


How to Install NFS Server



NFS Server

The Network File System (NFS) was developed to allow machines to mount a disk partition on a remote machine as if it were a local disk. It allows for fast, seamless sharing of files across a network.
It also gives the potential for unwanted people to access your hard drive over the network (and thereby possibly read your email and delete all your files as well as break into your system) if you set it up incorrectly.

$ sudo aptitude -P install nfs-kernel-server nfs-common portmap

When configuring portmap do =not= bind loopback. If you do you can either edit /etc/default/portmap by hand or run:

$ sudo dpkg-reconfigure portmap

 
If you have edited the file by hand you can restart portmap via:

$ sudo /etc/init.d/portmap restart

 
Note: It is not necessary to install NFS on client machines which are not going to be sharing any of their own directories. Sharing Local Folders To specify a folder you will need to edit /etc/exports, which can be done like (replace vi for your favorite editor):

$ sudo vi /etc/exports

 
For an example I will share, with full read/write and privileges, my share directory. This directory will be broadcasted to every local IP from 192.168.1.1 through 192.168.1.255.

$ /home/rohan/share 192.168.1.1/24(rw,no_root_squash,async)

To share a read only drive, for example on a Windows NTFS drive, you can use something like the following:

/media/songs/music 192.168.1.1/24(ro,async)


$ sudo /etc/init.d/nfs-kernel-server restart

 
After making changes to /etc/export you can make the shares effect by issuing the:

sudo exportfs -a 


*Use on the other  PC   - Last you will need to mount the volume on the other computer. So, ether shift screens or SSH to lab2 and open a terminal. You can only mount into another folder which must be created.

sudo mkdir ~/music

 
Now mount music from lab1 into ~/music at lab2.

$ sudo mount 192.168.1.2:/media/songs/music ~/music


Read More Add your Comment 0 comments


 

© 2010 Sharing things that I like...