Archive

Archive for the ‘Cpanel/Linux Internals’ Category

General Linux Commands.

October 6th, 2009

The followings are most commonly used commands in Linux.

1. traceroute - Print the route taken to a network host.

Summary:
Traceroute command is used to print the network path from your
computer to a remote computer and time taken to reach that remote
computer. Read the man page to more technical details.

Examples:
$ traceroute domainname/ipaddress — Trace the route for Google Server.

$ traceroute -v domainname/ipaddress — Show more details.

$ traceroute -n domainname/ipaddress — Print the HOP Address in numeric form.

$ traceroute -I domainname/ipaddress — Use ICMP ECHO instead of UDP datagrams.

# traceroute -i eth0 domainname/ipaddress — Use eth0 for send the probe packets.

$ traceroute domainname/ipaddress 100 — Sent 100 Bytes packet instead of default 40 Bytes packet.

Read: man traceroute

2. netstat — Display the Network subsystem informations.

Summary:

Netstat prints information about the Linux networking subsystem, like
network connections, routing tables, interface statistics, masquerade
connections, and multicast memberships. It is very useful monitoring
tool.

Examples:

$ netstat — List all open sockets.

$ netstat -c — Run continuously and show output for every 1 sec.

$ netstat -r — Display the Kernel routing table.

$ netstat -i — List the interfaces table.

$ netstat -s — Display summary statistics for each protocol.

$ netstat -n — Show the host info in IP address.

$ netstat -p — Show the program to which each socket belongs.

$ netstat -l — Show only listening sockets.

$ netstat -a — Show all sockets.

$ netstat -t — Show only TCP connections.

$ netstat -u — Show only UDP connections.

To get more useful output, try this commands as a Superuser.

Read: man netstat

3. host — DNS Look-up Utility

Summary:

host is a simple utility for performing DNS (Domain Name Service)
lookups. It is normally used to convert names to IP addresses and
vice versa.

Examples:

$ host domain.com — Show the IP Address of domain.com .

$ host -v google.com — Show detailed output.

$ host -a google.com — Show more details.

$ host Ipaddress — Do reverse lookup and Show the host name.

$ host -l domain.com — List all hosts available in Domain.

Read: man host

4. lsof — List Open Files.

Summary:

lsof lists all open files belonging to all active processes. An open
file may be a regular file, a Dir, a special file, an executing text
reference, a library, a stream or a network file (Internet socket, NFS
file or UNIX domain socket).

Examples:

$ lsof — List all open files.

$ lsof -i — List all open Internet files.

$ lsof -U — List all open Unix Domain files.

$ lsof -u user1 — List all files opened by User1.

$ lsof -p 1234 — List all files opened by process with PID of 1234.

$ lsof /dev/hda2 — List all open files on device /dev/hda2.

$ lsof -s — List all open files with size.

$ lsof -r 5 — Repeat the command for every 5 Sec.

Read: man lsof (More examples are available)

Cpanel/Linux Internals

How uptime command works.

October 6th, 2009

The most frequently used uptime command just reads the system statistics files /proc/loadavg and /proc/uptime and displays it.

The file /proc/loadavg has the following :

root@svr39 [/var/log]# cat /proc/loadavg
2.60 2.53 2.23 3/118 23356

The first 3 numbers are the load information for the last 1 minute, 5 minutes, 15 minutes and the number after that i.e 3/118 is the number of processes running from the processes which are waiting in queue and the last number is the PID of the last process run.

And the file /proc/uptime has the following :

root@svr39 [/var/log]# cat /proc/uptime
3899640.01 1107773.42

The first number is number of seconds the sytem has been up this is formatted as number of days, hours and minutes and displayed on uptime output and the next number is the number of seconds the system has been idle

Cpanel/Linux Internals

Setting up NAGIOS

October 6th, 2009

Nagios is a free Web-based monitoring software for Linux. It keeps a tab on your system and network services and sends alerts through e-mail, instant-message and SMS in case of over-use of resources or errors.
You can track about 50 different services, including HTTP, SMTP, NNTP, POP3, PING, processor load and disk usage. The software is a little difficult to configure, but it’s worth the labor.

Installing Nagios:

You need a Linux machine with C Compiler to install Nagios. To use the Web interface, you need a Web server (preferably Apache) and gd library 1.6.3 or higher. To start the installation, download and untar the following two files from the following links:

http://switch.dl.sourceforge.net/sourceforge/nagios/nagios-1.0.tar.gz
http://switch.dl.sourceforge.net/sourceforge/nagiosplug/nagiosplug-1.3-beta1.tar.gz

#tar -zxvf nagios-1.0.tar.gz
#tar -zxvf nagiosplug-1.3.tar.gz

This will create two new directories—nagios-1.0 and nagiosplug-1.3—containing the core installation components and the installer for executable binary commands, respectively. You’ll need to make a separate directory to install Nagios.

The Nagios configuration file also searches for a default Nagios user. So, add one as follows.

#adduser nagios

Set the password by running ‘passwd’ command

Now go to nagios-1.0 and nagiosplug-1.3 directories and issue the following commands in each.

#./configure
#make all
#make install

This will install the Nagios core and the command files. At this moment Nagios doesn’t have any script files from where it can take information about hosts and services. You must, therefore, create the configuration files. The easiest way is to install the sample config files by running the following command from your nagios-1.0 directory.

#make install-config

This will install all the configuration files by the name filename.cfg-sample just edit the file and rename the file to filname.cfg.

The main directories you will find under the nagios directory are :

/bin - Nagios core program
/etc - Main resource and CGI configuration files
/sbin - Various CGI scripts used by Nagios
/share - HTML files ( for web interface and online documentation )
/var - for logging

Adding Hotsts and Host groups :

To add hosts open the file hosts.cfg file

root@svr80 [~]# vi /home/nagios/public_html/etc/hosts.cfg

And add the following to it

define host{
host_name svr76
alias 67.15.94.77
address 67.15.94.77
max_check_attempts 3
event_handler_enabled 0
notification_interval 0
notification_period 24×7
notification_options n
active_checks_enabled 1
passive_checks_enabled 0
check_period 24×7
obsess_over_host 0
check_freshness 0
contact_groups linux-admins
}

You can add multiple hosts in this file.

To add a host to a group, open the hostgroups.cfg file and add the following entries.

root@svr80 [~]# vi /home/nagios/public_html/etc/hostgroups.cfg

define hostgroup{
hostgroup_name Reseller-Servers
alias all Reseller servers
members svr22,svr20,svr18,svr17,svr15,svr14,svr10,svr9,svr7,server5,server-4,svr82,svr80,svr23,svr25,svr26,svr28,svr29,svr31,svr33,svr34,svr37,svr39,svr42,svr45,svr47,svr49,svr51,svr54,svr57,svr59,svr64,svr66,svr69,svr72,svr75,svr78,svr85
}

On our nagios we have two hostgroups one is General-servers and the other is Reseller-Servers.

Adding Services :

You can add the services you want to monitor in services.cfg file

root@svr80 [~]# vi /home/nagios/public_html/etc/services.cfg

define service{
hostgroup_name Reseller-Servers,General - Servers
service_description APACHE
check_command check_http
max_check_attempts 3
normal_check_interval 5
retry_check_interval 2
check_period 24×7
notification_interval 10
notification_period 24×7
notification_options w,u,c
contact_groups linux-admins

}

Here hostgroup_name is the name of the host(s) on which the service will run, service_description is the description of the service and check_command contains the comands located in the /home/nagios/libexec directory.

Alert staff

Next, give the contact information of people who will recive all the alerts. Go to contacts.cfg, and by default you will find an entry for the user nagios as follows.

root@svr80 [~]# vi /home/nagios/public_html/etc/contacts.cfg

define contact {
contact_name nagios
alias Nagios Admin
host_notification_period 24×7
service_notification_period 24×7
host_notification_options d,u,r
service_notification_options w,u,c,r
host_notification_commands host-notify-by-email,host-notify-by-epager
service_notification_commands notify-by-email
email nagios-admin@localhost
}

Configuring web interface.

To configure the web interface just add the following lines to the apache configuration file i.e. httpd.conf file.

<VirtualHost 66.98.220.64>
ServerAlias nagios.4bigravi.com
ServerAdmin webmaster@rsanetworks.net
DocumentRoot /home/nagios/public_html
BytesLog domlogs/monitor.rsanetworks.net-bytes_log
<IfModule mod_php4.c>
php_admin_value open_basedir “/home/nagios/:/usr/lib/php:/usr/local/lib/php:/tmp”
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir “/home/nagios/:/usr/lib/php:/usr/local/lib/php:/tmp”
</IfModule>
ServerName monitor.rsanetworks.net
User nagios
Group nagios
CustomLog domlogs/nagios.ravikumar.in combined
ScriptAlias /cgi-bin/ /home/nagios/public_html/sbin/
</VirtualHost>

Start monitoring

You are now ready to start Nagios. Just restart the Web server and run the following command from /usr/local/nagios/bin directory.

#./nagios /home/nagios/public_html/etc/nagios.cfg

Open Web browser and type the following address.

“http://yourmachine/nagios”

where yourmachine is the name or the IP address of your Nagios server.

Everything on the Web interface is self-evident. Just click on the various menu items on the left to view different kinds of information about the hosts being monitored.

Cpanel/Linux Internals

How ssh works

October 6th, 2009

Ssh is set of programs which employ public/private key technology for authenticating and encrypting sessions between user accounts on distributed hosts on the Internet.
Ssh can also be used as a way to “tunnel” other protocols, such as the X Window System protocol, adding encryption to the channel to improve security against packet sniffing and “man in the middle” attacks. When used with X, ssh looks like a normal (albeit a proxy) X server on the local machine which redirects X protocol communication across an encrypted channel to the actual X server on the other end.

Ssh works by the exchange and verification of information, using public and private keys, to identify hosts and users. It then provides encryption of subsequent communication, also by the use of public/private key cryptography.

As a user, you generate an “identity” on the client system by running the ssh-keygen program. This program creates a subdirectory $HOME/.ssh and inserts in it two files named identity and identity.pub which contain your private and public keys for your account on the client system. This latter file can then be appended to a file $HOME/.ssh/authorized_keys that should reside on any/all servers where you will make ssh connections.

As a system administrator, you generate a public and private key pair for the system itself. By use of this information contained within the system itself, the possibility of someone spoofing the system’s identity by faking IP addresses or munging up DNS records that associate IP addresses and domain names is removed. You would have to break into the system and steal its private key in order to sucessfully pretend to be that system. This is a big improvement in security.

Once you generate your public/private key on your local system you can place your public key in the authorized_keys of the server so you can bypass the login procedure and directly login into the server without the password.

When you ssh to a machine by the following command :

ssh -l admin -p 78 svrxx.domain.com

The first step performed is authentication of the server to the client and client to the server i.e first the server checks whether its publci key is contained in the file $HOME/.ssh/known_hosts this procedure is known as host validation if the key is present in the known_hosts file it will proceed with the subsequent authentication.

Else if it is not matching or not present will display the following message :

The authenticity of host ’svrxx.domain.com (67.75.52.50)’ can’t be established.
RSA key fingerprint is bd:e7:14:30:13:ba:74:77:47:b3:2a:b3:a1:07:2e:7a.
Are you sure you want to continue connecting (yes/no)?

Once you say yes then the public key of the server will be placed in the known_hosts file and you will not see this message again.

And once the host validation is complete the subsequent communcication will be encrypted using the private key that was generated from ssh-keygen command.

Cpanel/Linux Internals

Cron guide

October 6th, 2009

For those unfamiliar with “cron”, this means being able to create a firing schedule such as: “At 8:00am every Monday through Friday” or “At 1:30am every last Friday of the month”.

A “Cron-Expression” is a string comprised of 6 or 7 fields separated by white space. The 6 mandatory and 1 optional fields are as follows:
Field Name Allowed Values Allowed Special Characters
Seconds 0-59 , - * /
Minutes 0-59 , - * /
Hours 0-23 , - * /
Day-of-month 1-31 , - * ? / L W C
Month 1-12 or JAN-DEC , - * /
Day-of-Week 1-7 or SUN-SAT , - * ? / L C #
Year (Optional) empty, 1970-2099 , - * /

The ‘*’ character is used to specify all values. For example, “*” in the minute field means “every minute”.

The ‘?’ character is allowed for the day-of-month and day-of-week fields. It is used to specify ‘no specific value’. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.

The ‘-’ character is used to specify ranges For example “10-12″ in the hour field means “the hours 10, 11 and 12″.

The ‘,’ character is used to specify additional values. For example “MON,WED,FRI” in the day-of-week field means “the days Monday, Wednesday, and Friday”.

The ‘/’ character is used to specify increments. For example “0/15″ in the seconds field means “the seconds 0, 15, 30, and 45″. And “5/15″ in the seconds field means “the seconds 5, 20, 35, and 50″. Specifying ‘*’ before the ‘/’ is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The “/” character simply helps you turn on every “nth” value in the given set. Thus “7/6″ in the month field only turns on month “7″, it does NOT mean every 6th month, please note that subtlety.

The ‘L’ character is allowed for the day-of-month and day-of-week fields. This character is short-hand for “last”, but it has different meaning in each of the two fields. For example, the value “L” in the day-of-month field means “the last day of the month” - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means “7″ or “SAT”. But if used in the day-of-week field after another value, it means “the last xxx day of the month” - for example “6L” means “the last friday of the month”. When using the ‘L’ option, it is important not to specify lists, or ranges of values, as you’ll get confusing results.

The ‘W’ character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify “15W” as the value for the day-of-month field, the meaning is: “the nearest weekday to the 15th of the month”. So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify “1W” as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not ‘jump’ over the boundary of a month’s days. The ‘W’ character can only be specified when the day-of-month is a single day, not a range or list of days.

The ‘L’ and ‘W’ characters can also be combined for the day-of-month expression to yield ‘LW’, which translates to “last weekday of the month”.

The ‘#’ character is allowed for the day-of-week field. This character is used to specify “the nth” XXX day of the month. For example, the value of “6#3″ in the day-of-week field means the third Friday of the month (day 6 = Friday and “#3″ = the 3rd one in the month). Other examples: “2#1″ = the first Monday of the month and “4#5″ = the fifth Wednesday of the month. Note that if you specify “#5″ and there is not 5 of the given day-of-week in the month, then no firing will occur that month.

The ‘C’ character is allowed for the day-of-month and day-of-week fields. This character is short-hand for “calendar”. This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of “5C” in the day-of-month field means “the first day included by the calendar on or after the 5th”. A value of “1C” in the day-of-week field means “the first day included by the calendar on or after sunday”.

The legal characters and the names of months and days of the week are not case sensitive.

Here are some full examples:
Expression Meaning
“0 0 12 * * ?” Fire at 12pm (noon) every day
“0 15 10 ? * *” Fire at 10:15am every day
“0 15 10 * * ?” Fire at 10:15am every day
“0 15 10 * * ? *” Fire at 10:15am every day
“0 15 10 * * ? 2005″ Fire at 10:15am every day during the year 2005
“0 * 14 * * ?” Fire every minute starting at 2pm and ending at 2:59pm, every day
“0 0/5 14 * * ?” Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
“0 0/5 14,18 * * ?” Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day
“0 0-5 14 * * ?” Fire every minute starting at 2pm and ending at 2:05pm, every day
“0 10,44 14 ? 3 WED” Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
“0 15 10 ? * MON-FRI” Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
“0 15 10 15 * ?” Fire at 10:15am on the 15th day of every month
“0 15 10 L * ?” Fire at 10:15am on the last day of every month
“0 15 10 ? * 6L” Fire at 10:15am on the last Friday of every month
“0 15 10 ? * 6L” Fire at 10:15am on the last Friday of every month
“0 15 10 ? * 6L 2002-2005″ Fire at 10:15am on every last friday of every month during the years 2002, 2003, 2004 and 2005
“0 15 10 ? * 6#3″ Fire at 10:15am on the third Friday of every month

Pay attention to the effects of ‘?’ and ‘*’ in the day-of-week and day-of-month fields!

NOTES:

* Support for the features described for the ‘C’ character is not complete.
* Support for specifying both a day-of-week and a day-of-month value is not complete (you’ll need to use the ‘?’ character in on of these fields).
* Be careful when setting fire times between mid-night and 1:00 AM - “daylight savings” can cause a skip or a repeat depending on whether the time moves back or jumps forward.

Cpanel/Linux Internals

Troubleshooting crash signals

October 6th, 2009

Errors:Troubleshooting crash signals

Signals are used to communicate an important event to a process. Once a process has received
a signal it will stop whatever it was doing, hence a software interrupt, and will either ignore it if possible, or execute some special code, a signal handler. Every signal has a default handler, although a process can use a customized handler instead.

As a user, when you see a crashed program you are really seeing the action of a signal handler
which is often the default handler for a fatal signal. Many OS’es use the same set of signals and
signal numbers as defined in a POSIX specification. However beyond that set is often
implementation dependent. The following list is the current Linux 2.6 kernel with glibc 2.4.

1) SIGHUP Signal HangUp

SIGHUP is received when a process that started this application has died or when the command
line, known as the controlling terminal for this process was using, has received a hangup request.

On some systems, logging in, running an application and then exiting would generate this signal
which would often result in your application exiting. Adding the nohup to the start of command
would prevent the signal from being received by the application and allow it to continue running.

System processes like cron are happy to receive SIGHUP. SIGHUP instructs the cron process to
reload its configuration files.

2) SIGINT Signal Interrupt

SIGINT is normally generated from a keyboard, the default is often ctrl-c and it is sent to process
running on that controlling terminal, ie in the foreground. Many applications will exit when
receiving a SIGINT

3) SIGQUIT Signal Quit

SIGQUIT, often configured as ctrl \ is used to tell the process in this controlling terminal to nominally
exit. It however is often trapped by applications and in the case of many Java JVMs they use it
as a trigger to generate a Java stack trace and to not quit at all. Like SIGHUP, nohup can be
used to prevent applications from also receiving SIGQUIT

4) SIGILL Signal Illegal Instruction

SIGILL is fairly rare but says what it implies. An opcode for the machine architecture is actually
invalid. This signal is actually generated from the hardware trap handler to the kernel. Either the
machine code sent to the chip was corrupted or wasn’t compatible with the chipset or a buggy
compiler or an interpreter environment were the cause of something this bad.

5) SIGTRAP Signal Trap

A signal resulting from a trace or breakpoint being set. Process tracing tools,like ptrace and strace
are consumers of these events, as are debug tools.

6) SIGABRT Signal Abort

Terminate process and dump a core file image. Often called by an application itself by use of the
abort() system call

7) SIGBUS Signal Bus Error

A hardware derived signal that is received by the kernel. The hardware found an address alignment
issue, ADRALN or an address that did not exist, ADRERR or an underlying error reported by a
file object, OBJERR when accessing the memory bus. In the case of OBJERR more details are
reported from the object itself. Often like many other signals you may here developers refer to this as simply a SIGBUS error or BUS error.

8) SIGFPE Signal Floating Point Exception

A hardware derived signal from the floating point unit. Normally an overflow or underflow of the value
being computed or more commonly a divide by zero in application code.

9) SIGKILL Signal Kill

Terminate a process without any cleanup. Process are not able to ignore SIGKILL although there are
some circumstances where a program may not receive a SIGKILL as the system is
unstable, the kernel for example is IO bound.

10) SIGUSR1 Signal User 1

The first of 2 signals that are used by applications themselves to signal user defined operations

11) SIGSEGV Signal Segmentation Violation

A SIGSEGV is a very common signal, often the result of a trying to access an invalid segment of
memory, most typically 0. However some applications such as a JVM use SIGSEGV to manage
has exhausted its currently memory. The default handler will try and dump an image of the
process when the signal was caught, this image or core file can then be used with a debug tool
and the original application to generate a trace of the fault when it occurred. As a process can
consume a large amount of memory some operating systems reset the size of a core file to 0
using the ulimit command. You can remove this restriction using ulimit -c unlimited. As for SIGBUS, developers often refer to this signal simply as SEGV, or a SEGV error.

12) SIGUSR2 Signal User 2

The second of 2 signals that are used by applications themselves to signal user defined operations

13) SIGPIPE Signal Pipe

A process has tried to write to a socket or a unix pipe yet there was no other process reading from
that pipe. This signal indicates a broken pipe which can occur when the server side process has
died, leaving the process file descriptor ids still live.

14) SIGALRM Signal Alarm

The alarm signal is used by timing operations such as sleep to notify that a timer has expired. The
time unit used by SIGALRM is wall clock time.

15) SIGTERM Signal Terminate

Gently terminate this process and call any exit handlers

17) SIGCHLD Signal Child

The forked child process reported a status change, such as an exit

18) SIGCONT Signal Continue

Make a process continue after a request to stop. Often used by debugging tools

19) SIGSTOP Signal Stop

Stop the process. Often used by debugging tools, if the signal is from the terminal then SIGTSTP is
used instead.

20) SIGTSTP Signal Terminal Stop

This signal is often generated using the suspend key sequence, ie ctrl-Z

21) SIGTTIN Signal Stopped on TTY Input

This signal is most commonly generated when a process cannot read from the terminal because it
has been placed into the process background.

22) SIGTTOU Signal Stopped on TTY Output

This signal is most commonly generated when a process cannot write to the controlling terminal
because it has been placed into the process background.

23) SIGURG Signal Urgent

Urgent data is available on the socket.

24) SIGXCPU Signal Exceeded CPU limit

Exceeded CPU time quota limit.

25) SIGXFSZ Signal Exceeded File Size

Exceeded maximum file size quota

26) SIGVTALRM Signal Virtual Alarm

Signal when virtual time is expired. Virtual time uses process time and not wall clock time.

27) SIGPROF Signal Profiling

Used by profiling tools. Sends a signal when the time has expired for this process including system

28) SIGWINCH Signal Window Changed Size

The terminal window has changed size, more important for graphical curses based applications.

29) SIGIO Signal IO

IO data has become available

30) SIGPWR Signal Power Failure

Power has failed and process is now using UPS

31) SIGSYS Signal System Call

A system call to the kernel has failed

34) SIGRTMIN Signal Real Time Minimum

Cpanel/Linux Internals

How to restart the cpanel ssl services.

October 6th, 2009

Whenever you start the cpanel service through “service cpanel restart”
, sometimes cpanel ssl service do not start. The o/p comes like :-
=================================================
Starting cPanel ssl services: [ FAILED ]
=================================================

So, To start the cpanel ssl service you have to follow the below steps.

1. pkill stunnel .
2. run “service cpanel restart” . Yop will get the o/p like
==================================================
Starting cPanel ssl services: [ OK ]
==================================================
3. run
/usr/bin/stunnel-4.04local /usr/local/cpanel/etc/stunnel/mycabundle/stunnel.conf.run

Cpanel/Linux Internals

What is stunnel.

October 6th, 2009

Stunnel is Universal SSL Wrapper.

Stunnel is a program that allows you to encrypt arbitrary TCP connections inside SSL (Secure Sockets Layer) available on both Unix and Windows. Stunnel can allow you to secure non-SSL aware daemons and protocols (like POP, IMAP, LDAP, etc) by having Stunnel provide the encryption, requiring no changes to the daemon’s code.

The Stunnel source code is not a complete product — you still require a functioning SSL library such as OpenSSL or SSLeay in order to compile stunnel. This means that stunnel can support whatever (and only) that which your SSL library can, without making any changes in the Stunnel code.

The Stunnel source code is available under the GNU General Public License, meaning it is free to use in both commercial and non commercial applications as you see fit, as long as you provide source code (and any modifications) with the software. Your compiled Stunnel binary is ‘restricted’ by whatever license your chosen SSL library is under, however both OpenSSL and SSLeay are open source and similarly liberal in their licensing.

Cpanel/Linux Internals

common cPanel commands

October 6th, 2009

This article is a compilation of cPanel commands commonly used. If you see any that are missing please make a reply.

Tail Apache log:

tail -f /usr/local/apache/logs/error_log

Updates the server software:

/scripts/upcp

Reinstalls exim:

/scripts/exim4

View traffic or if you think a site is being DDoS:

cd /usr/local/apache/domlogs
tail -f targetsite.com

Bandwidth issues

/scripts/cleanbw

To fix problem in webalizer that stop updating stats

/scripts/fixwebalizer

Self Explanatory

/scripts/fixcommonproblems
/scripts/fixeverything

Fixing Mail List MailMan

/usr/local/cpanel/bin/convertmailman2

Reinstall MailMan

/scripts/reinstallmailman

/scripts/fixhome

pico /etc/my.cnf

Edit php.ini

pico /usr/local/lib/php.ini

Edit Apache Conf

pico /etc/httpd/conf/httpd.conf

Checking Real Time Top Processes Login to SSH and run

top

Run cpanel backup

/scripts/cpbackup

To try and fix domain controller

/scripts/fixndc

Quotas

/scripts/initquotas - takes a while to run
/scripts/resetquotas
/scripts/fixquotas - takes a while to run

Add a Dns Entry

/scripts/adddns

Install Frontpage Mail Exts

/scripts/addfpmail

Add JavaServlets to an account (jsp plugin required)

/scripts/addservlets

Add a User

/scripts/adduser

Run WHM Lite

/scripts/admin

Add Rlimits (cpu and mem limits) to apache

/scripts/apachelimits

Resync with a master DNS Server

/scripts/dnstransfer

Edit A User’s Quota

/scripts/editquota

Search For Trojans in /dev

/scripts/finddev

Locate Trojan Horses

/scripts/findtrojans

Suggest Usage

/scripts/findtrojans &gt; /var/log/trojans

/scripts/fixtrojans /var/log/trojans

Make Interchange work with suexec

/scripts/fixcartwithsuexec

Fix Most Problems with Interchange

/scripts/fixinterchange

Run on a trojans horse file created by findtrojans to remove them

/scripts/fixtrojans

Run this if a user’s stats stop working

/scripts/fixwebalizer

Fix a broken valias file

/scripts/fixvaliases

Turn on DMA and 32bit IDE hard drive access (once per boot)

/scripts/hdparamify

Re-scan quotas. Usually fixes Disk space display problems

/scripts/initquotas

Turn on SUEXEC (probably a bad idea)

/scripts/initsuexec

Display Ipusage Report

/scripts/ipusage

Terminate an Account

/scripts/killacct

Delete “Security Problem Infested RPMS”

/scripts/killbadrpms

Fix Various Mail Permission Problems

/scripts/mailperm

Attempt to Troubleshoot a Mail Problem

/scripts/mailtroubleshoot

Change a Mysql Password

/scripts/mysqlpasswd

Kill Potential Security Problem Services

/scripts/quicksecure

Rebuild Ip Address Pool

/scripts/rebuildippool

Delete Nasty SSL entry in apache default httpd.conf

/scripts/remdefssl

Restart a Service (valid services: httpd,proftpd,exim,sshd,cppop,bind,mysql)

/scripts/restartsrv?? (example: /scripts/restartsrv httpd)

Syncup Security Updates from RedHat/Mandrake

/scripts/rpmup

Force a webalizer/analog update

/scripts/runlogsnow

Remove non-important suid binaries

/scripts/secureit

Install Frontpage 4+ on an account

/scripts/setupfp4

Return a Simple process list. Useful for finding where cgi scripts are running from

/scripts/simpleps

Suspend an account

/scripts/suspendacct

Syncup Cpanel RPM Updates

/scripts/sysup

Unblock an IP

/scripts/unblockip

UnSuspend an account

/scripts/unsuspendacct

Update Cpanel

/scripts/upcp

Update /scripts

/scripts/updatenow

Create a New Account

/scripts/wwwacct

Awstats to run manually

/scripts/runweblogs account_username

License Not working

rdate -s rdate.ehostpros.com

Sometimes such behavior of apache/httpd (taking more and more memory until it dies or crashes the server) can be caused by corrupted MySQL database. Try to do the following:
1) Kill the mysql server
/etc/rc.d/init.d/mysql stop

2) Repair all SQL databases:
myisamchk -r /var/lib/mysql/*/*.MYI

3) Start mysql again:
/etc/rc.d/init.d/mysql start

——————————————————————————-

Restarting cpanel

/etc/rc.d/init.d/cpanel restart

To run your clients stats now

/scripts/runlogsnow

Restart the background proccess that runs the stats for your clients

/usr/local/cpanel/startup

To run your clients stats now

/scripts/runstatsonce

To run one clients stats:

/scripts/runweblogsnow username

Shut down http

httpd stop

Start http with SSL

httpd startssl

Start http

httpd start

/scripts/runweblogs

Restart chkservd:

/etc/init.d/chkservd restart

Cpanel/Linux Internals