LinuxHelps.com

A blog for Linux Lovers.

Posted by sibu on May 24, 2009

Required permissions and directories for Fantastico

Fantastico requires certain files and directories to have the following permissions:

NOTE: Depending on your server setup, the files may be in slightly different locations.

Files:
/bin/tar 0755
/bin/gzip 0755
/usr/bin/wget 0700
/bin/bash 0755

Directories (create if they do not exist):
/tmp 1777
/usr/local/cpanel/base/tmp 1777
/usr/local/cpanel/3rdparty/tmp 1777

Posted by sibu on May 24, 2009

Yum Commands

YUM packages updater (Fedora, RedHat and like)

yum install package_name download and install a rpm package
yum localinstall package_name.rpm That will install an RPM, and try to resolve all the dependencies for you using your repositories.
yum update update all rpm packages installed on the system
yum update package_name upgrade a rpm package
yum remove package_name remove a rpm package
yum list list all packages installed on the system
yum search package_name find a package on rpm repository
yum clean packages clean up rpm cache erasing downloaded packages
yum clean headers remove all files headers that the system uses to resolve dependency
yum clean all remove from the cache packages and headers files

Posted by sibu on May 24, 2009

RPM commands

rpm -ivh package.rpm install a rpm package
rpm -ivh –nodeps package.rpm install a rpm package ignoring dependencies requests
rpm -U package.rpm upgrade a rpm package without changing configuration files
rpm -F package.rpm upgrade a rpm package only if it is already installed
rpm -e package_name.rpm remove a rpm package
rpm -qa show all rpm packages installed on the system
rpm -qa | grep httpd show all rpm packages with the name “httpd”
rpm -qi package_name obtain information on a specific package installed
rpm -qg “System Environment/Daemons” show rpm packages of a group software
rpm -ql package_name show list of files provided by a rpm package installed
rpm -qc package_name show list of configuration files provided by a rpm package installed
rpm -q package_name –whatrequires show list of dependencies required for a rpm packet
rpm -q package_name –whatprovides show capability provided by a rpm package
rpm -q package_name –scripts show scripts started during installation / removal
rpm -q package_name –changelog show history of revisions of a rpm package
rpm -qf /etc/httpd/conf/httpd.conf verify which rpm package belongs to a given file
rpm -qp package.rpm -l show list of files provided by a rpm package not yet installed
rpm –import /media/cdrom/RPM-GPG-KEY import public-key digital signature
rpm –checksig package.rpm verify the integrity of a rpm package
rpm -qa gpg-pubkey verify integrity of all rpm packages installed
rpm -V package_name check file size, permissions, type, owner, group, MD5 checksum and last modification
rpm -Va check all rpm packages installed on the system - use with caution
rpm -Vp package.rpm verify a rpm package not yet installed
rpm2cpio package.rpm | cpio –extract –make-directories *bin* extract executable file from a rpm package
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm install a package built from a rpm source
rpmbuild –rebuild package_name.src.rpm build a rpm package from a rpm source

Posted by sibu on May 24, 2009

File search commands

find  / -name file1 - search file and directory into root filesystem from ‘/’
find / -user user1 - search files and directories belonging to ‘user1′
find /home/user1 -name \*.bin - search files with ‘. bin’ extension within directory ‘/ home/user1′
find /usr/bin -type f -atime +100 - search binary files are not used in the last 100 days
find /usr/bin -type f -mtime -10 - search files created or changed within 10 days
find / -name \*.rpm -exec chmod 755 ‘{}’ \;   - search files with ‘.rpm’ extension and modify permits
find / -xdev -name \*.rpm - search files with ‘.rpm’ extension ignoring removable partitions as cdrom, pen-drive, etc.…
locate \*.ps - find files with the ‘.ps’ extension - first run ‘updatedb’ command
whereis halt -  show location of a binary file, source or man
which halt  - show full path to a binary / executable

Posted by sibu on May 24, 2009

User management commands

Users and Groups

groupadd group_name create a new group
groupdel group_name delete a group
groupmod -n new_group_name old_group_name rename a group
useradd -c “Name Surname ” -g admin -d /home/user1 -s /bin/bash user1 create a new user belongs “admin” group
useradd user1 create a new user
userdel -r user1 delete a user ( ‘-r’ eliminates home directory)
usermod -c “User FTP” -g system -d /ftp/user1 -s /bin/nologin user1 change user attributes
passwd change password
passwd user1 change a user password (only by root)
chage -E 2005-12-31 user1 set deadline for user password
pwck check correct syntax and file format of ‘/etc/passwd’ and users existence
grpck check correct syntax and file format of ‘/etc/group’ and groups existence
newgrp group_name log in to a new group to change default group of newly created files.

Posted by sibu on May 24, 2009

How to check who are logged in whm/cpanel with ip and user name details?

There are two ways you can check who is currently logged into WHM or cPanel.

1) Log in to the server via SSH and run ps aux | grep whostmgrd to see who’s currently active in WHM, and ps aux | grep cpaneld to see who’s currently active in cPanel. If the users have been idle for some time, this method may not work.

2) This method is less than ideal, but if you know the IP address then you can tail -f /usr/local/cpanel/logs/access_log | grep ip.address to see what they are doing, again only if they are active within WHM or cPanel will this work.

You can check this from the login_log in /usr/local/cpanel/logs or /usr/local/cpanel/logs/access_log.

Posted by sibu on May 24, 2009

Difference between ‘mount’ and ‘mount -a’

There is a slight difference between the commands - “mount” and “mount -a”.

1. When you type “mount”, it will display the output of the file “/etc/mtab“.

For example,

# mount
/dev/sda5 on / type ext3 (rw,usrquota)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/sda7 on /home type ext3 (rw,usrquota)
/dev/sda8 on /tmp type ext3 (rw,noexec,nosuid)
/dev/sda3 on /usr type ext3 (rw,usrquota)
/dev/sda2 on /var type ext3 (rw,usrquota)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/tmp on /var/tmp type none (rw,noexec,nosuid,bind)

The content of the file “/etc/mtab” is:

# cat /etc/mtab
/dev/sda5 / ext3 rw,usrquota 0 0
none /proc proc rw 0 0
none /sys sysfs rw 0 0
none /dev/pts devpts rw,gid=5,mode=620 0 0
usbfs /proc/bus/usb usbfs rw 0 0
/dev/sda1 /boot ext3 rw 0 0
none /dev/shm tmpfs rw 0 0
/dev/sda7 /home ext3 rw,usrquota 0 0
/dev/sda8 /tmp ext3 rw,noexec,nosuid 0 0
/dev/sda3 /usr ext3 rw,usrquota 0 0
/dev/sda2 /var ext3 rw,usrquota 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
/tmp /var/tmp none rw,noexec,nosuid,bind 0 0

2. When you type the command “mount -a”, it will take the output of the file “/etc/fstab“.

# cat /etc/fstab

# This file is edited by fstab-sync - see ‘man fstab-sync’ for details
LABEL=/ / ext3 defaults,usrquota 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
LABEL=/home /home ext3 defaults,usrquota 1 2
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults,usrquota 1 2
LABEL=/var /var ext3 defaults,usrquota 1 2
LABEL=SWAP-sda6 swap swap pri=0,defaults 0 0

Note: The file “/etc/mtab” has the entries of temporary partitions such as USB drive. But, the file “/etc/fstab” has the entries of mounted partitions in the server.

Posted by sibu on May 24, 2009

Apache error: Invalid command ‘BytesLog’

If you receive the following error,

Invalid command ‘BytesLog’, perhaps mis-spelled or defined by a module not included in the server configuration

while restarting apache in cPanel servers , do the following steps.

# cd /usr/local/cpanel/apache
# /usr/local/apache/bin/apxs -iac mod_log_bytes.c
# /etc/rc.d/init.d/httpd restart

It will install the missing module and restart apache

Posted by sibu on May 24, 2009

Core Dump files..

A core file is created when a program terminates unexpectedly, due to a bug, or a violation of the operating system’s or hardware’s protection mechanisms. The operating system kills the program and creates a core file that programmers can use to figure out what went wrong. It contains a detailed description of the state that the program was in when it died. If would like to determine what program a core file came from, use the file command, like this: $ file core That will tell you the name of the program that produced the core dump. You may want to write the maintainer(s) of the program, telling them that their program dumped core. To Enable or Disable Core Dumps you must use the ulimit command in bash, the limit command in tcsh, or the rlimit command in ksh. See the appropriate manual page for details. This setting affects all programs run from the shell (directly or indirectly), not the whole system. If you wish to enable or disable core dumping for all processes by default, you can change the default setting in /usr/include/linux/sched.h. Refer to definition of INIT_TASK, and look also in /usr/include/linux/resource.h. PAM support optimizes the system’s environment, including the amount of memory a user is allowed. In some distributions this parameter is configurable in the /etc/security/limits.conf file.

Whether or not the operating system creates core files is controlled by the ulimit command. To see the current ulimit setting for core files, do the following:


#ulimit -c
0

or
#ulimit -a
core file size (blocks, -c) 1000000
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 4096
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 14335
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

If you don’t want core files at all, set “ulimit -c 0″ in your startup files. That’s the default on many systems; in /etc/profile you may find

ulimit -S -c 0 > /dev/null 2>&1

If you DO want core files, you need to reset that in your own .bash_profile:

ulimit -c 50000

would allow core files but limit them to 50,000 bytes.

The ulimit command sets limits on the resource available to the bash shell. The -c parameter controls the size of core files. The value 0 indicates that core files are not created. To enable core file creation, increase the size limit of core files to a number greater than zero. For example:

#ulimit -c 50000

You may also check in the file /etc/csh.cshrc for the following:

limit coredumpsize 0

This will limit the size of the largest core dump that will be created to 0 bytes.

But very imp step is as follows:

First you hash the following line in /etc/profile.

ulimit -S -c 0 > /dev/null 2>&1

Then in the file /etc/security/limits.conf , add the following line:

root soft core 10000

as you can see below:

#
#

#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
root soft core 10000

Instead of root we can give any user as juni, junitha etc…. We will have to either reboot or log off for these changes to take effect. Only if we unhash it in /etc/profile ,we can change these.

You have more control of core files in /proc/sys/kernel/

For example, you can do eliminate the tagged on pid by

echo “0″ > /proc/sys/kernel/core_uses_pid

Core files will then just be named “core”. People do things like that so that a user can choose to put a non-writable file named “core” in directories where they don’t want to generate core dumps. That could be a directory (mkdir core) or a file (touch core;chmod 000 core). One way to limit core file generation is to create a directory called “core” with 000 permissions in the directory in which you expect a core dump to occur.
But perhaps more interesting is that you can do:

mkdir /tmp/corefiles
chmod 777 /tmp/corefiles
echo “/tmp/corefiles/core” > /proc/sys/kernel/core_pattern

All corefiles then get tossed to /tmp/corefiles (don’t change core_uses_pid if you do this).

Test this with a simple script:

# script that dumps core
kill -s SIGSEGV $$

Posted by sibu on May 24, 2009

Apache Error: Unable to open logs

Sometimes apache will fail to start. It will show the following error message in apache error logs:

Unable to open logs

This is because of the low number of file descriptors. Check the current limit of file descriptors in the file /proc/sys/fs/file-max:

# cat /proc/sys/fs/file-max
1024

If fs.file-max is quite small (several thousands or so), it should be changed to a higher value.

# echo “65535″ > /proc/sys/fs/file-max

If you want this new value to survive across reboots you can add it to /etc/sysctl.conf.

# Maximum number of open files permited
fs.file-max = 65535

To load new values from the sysctl.conf file:

# sysctl -p /etc/sysctl.conf

Add `ulimit -n 65536` command to /etc/rc.d/init.d/httpd and /usr/sbin/apachectl apache startup scripts before other commands.

Now try to start httpd.

Powered By Wordpress - Theme Provided By Wordpress Themes - Auto Loan Credit