Drug preguntas

Command to Check Linux File System

Linux No Comments »

Type mount command to display filesystem type such as ext2, ext3 and so on…
Quote:
mount
Sample output:
Quote:
/dev/sdb1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
/dev/sdb5 on /media/docs type ext3 (rw)
/dev/sdb3 on /media/isomp3s type ext3 (rw)
/dev/sdc1 on /media/backup type ext3 (rw)
/dev/sdb1 is mounted on / and type is ext3 fs.

u can also use command
Code:

less /proc/mounts

Clean /tmp

Linux No Comments »

is it ok to clean up all directory n files on /tmp?

clean all I think no, becoz some are used by the system and your user.

You may need to use a command called tmpwatch which removes files which haven’t been accessed for a period of time. Normally, it’s used to clean up directories which are used for temporary holding space such as /tmp.

Following code will remove all files/dirs from /tmp if they are not accessed in last 2 weeks (24 * 14 days = 336)

tmpwatch –mtime –all 336 /tmp

also

tmpwatch -auv 1 /tmp

Make sure that you have installed “tmpwatch” in the server using yum or rpm method.

Backup mysql db using Cron.

MySql No Comments »
  • Backup mysql db using Cron.
    date=`date -I` ; mysqldump -uusername -pthepass .all-databases | gzip >
    /home/linux/mysql_$date.sql.gz
  • Replace username and thepass with the correct username and the pass.
  • The user need to have access to the database being taken for backup.

How To Create My SQL Database And CREATE And GRANT Privileges

MySql No Comments »

HOW TO CREATE THE MySQL DATABASE

This step is only necessary if you don’t already have a database set-up . In the following examples, ‘username’ is an example MySQL user which has the CREATE and GRANT privileges. Use the appropriate user name for your system.

First, you must create a new database for your site (here, ‘databasename’ is the name of the new database):

  mysqladmin -u username -p create databasename

MySQL will prompt for the ‘username’ database password and then create the initial database files. Next you must login and set the access database rights:

  mysql -u username -p

Again, you will be asked for the ‘username’ database password. At the MySQL prompt, enter following command:

  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES
  ON databasename.*  TO 'username'@'localhost' IDENTIFIED BY 'password';

  where

 'databasename' is the name of your database
 'username@localhost' is the username of your MySQL account
 'password' is the password required for that username

Note: Unless your database user has all of the privileges listed above, you will not be able to run site on that database.

If successful, MySQL will reply with:

  Query OK, 0 rows affected

To activate the new permissions, enter the following command:

  FLUSH PRIVILEGES;

MySql Access denined error.

MySql No Comments »

Check the URL http://dev.mysql.com/doc/refman/5.0/en/access-denied.html

Cpanel-perl-upgarde-steps

Cpanel No Comments »

Cpanel-perl-upgarde-steps

To check what is the perl version on your system, use

perl -v

If you need to upgrade your perl installation

* Copy and paste this to a file and run the file using sh command.

wget http://layer1.cpanel.net/perl587installer.tar.gz
tar xfz perl587installer.tar.gz
cd perl587installer
./install
/scripts/upcp
/usr/local/cpanel/bin/checkperlmodules
perl -v

Cpanel Latest Perl Installer And Latest C Panel WHM Build

Cpanel No Comments »

* Cpanel Latest Perl installer and Latest cPanel/WHM Build

Please visit the url layer2.cpanel.net

Recompile PHP With GD Support Installing GD For PHP On Linux

PHP No Comments »

cd /usr/local/
wget http://www.boutell.com/gd/http/gd-2.0.9.tar.gz
tar -xvzf gd-2.0.9.tar.gz
cd gd-2.0.9
cd ..
ln -s gd2.0 gd

Adding GD Support to PHP

Use the configure command used last time and add –with-gd=/usr/local/gd

If you already have an older version of gd in /usr/lib and /usr/include, you may wish to use:

./configure –prefix=/usr

To ensure that your new installation overwrites the old.

What-is-su EXEC ?

Apache No Comments »

* What is suEXEC?

The suEXEC feature — introduced in Apache 1.2 — provides Apache users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web-server. Normally, when a CGI or SSI program executes, it runs as the same user who is running the web server.

Used properly, this feature can reduce considerably the security risks involved with allowing users to develop and run private CGI or SSI programs. However, if suEXEC is improperly configured, it can cause any number of problems and possibly create new holes in your computer’s security. If you aren’t familiar with managing setuid root programs and the security issues they present, we highly recommend that you not consider using suEXEC.

Premature End Of Script Headers Error

Apache No Comments »

Sample hello world script

#!/usr/local/bin/perl
# hello.pl — my first perl script!
print “Content-type: text/html\n\n”;
print “Hello, world!\n”;
——————————————–

* Check domain/apache error log file.
* Check /var/log/apache/suexec.log file that should give a solution.
* Upload your Perl script in ASCII mode.
* Set the permission of the file to 755, which allows the script to be executed by everybody.

Tracking Errors in the Script

perl -wc helloworld.pl

Will cause the Perl interpreter to check your script for syntax errors.

Running it without the syntax check options:

perl -w helloworld.pl

* If something strange has gone wrong with your program and youâre not sure where you should look for help, try the -w switch first. It will often point out exactly where the trouble is.

How do I verify which ports are listening?

Linux No Comments »

After installing a new Linux system or after configuring a new network services/server, you may need to verify which ports are listing on systems network interface including binding.

Use any one of the following command to find this information:
Code:

lsof -i
nmap localhost
netstat -an
netstat -tulpn
nmap -sT -O localhost

If you find or see unwanted open port, it can be confirmation of an intrusion or cracker in your system.

For more advance usage or adventure with these commends read man pages of corresponding commands.

Mount a USB flash or pen drive as a normal user

Linux No Comments »

New user often gets confused with Linux security permissions. Simple mounting of a USB flash drive as a normal user (non-root) can be hard task.

Truth:
The mount command can be issued only as the root user.

Solution:
Give permission to normal user to mount a USB pen or flash drive.

#1: Create a directory

# mkdir /mnt/usbpen

#2: Find out USB pen drive name

# fdisk -l

Output of fdisk -l command:
Disk /dev/hdb: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 2432 19535008+ 83 Linux
/dev/hdb2 2433 2554 979965 82 Linux swap / Solaris
/dev/hdb3 2555 6202 29302560 83 Linux
/dev/hdb4 6203 9733 28362757+ 5 Extended
/dev/hdb5 6203 9733 28362726 83 Linux

Disk /dev/sda: 256 MB, 256901120 bytes
8 heads, 62 sectors/track, 1011 cylinders
Units = cylinders of 496 * 512 = 253952 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 1011 250697 b W95 FAT32

In the above output, /dev/sda1 is my flash drive.

#3: Open /etc/fstab file
Append following line:

/dev/sda1 /mnt/usbpen auto noauto,user,rw,exec 0 0

#4: Save the file and login as the normal user:

$ mount /mnt/usbflash

How to watch television on Linux computer?

Linux No Comments »

Recently I decided to use my old TV card with linux. So Here are quick commands to get start with it.

First make sure your card is suppored and listed in Linux kernel /usr/src/linux/Documentation/video4linux/CARDLIST.tuner or in /usr/src/linux/Documentation/video4linux/CARDLIST.bttv files and support compiled in kernel.

Turn off computer and add Tv Tuner card.

Turn on computer and boot into Linux

Make sure your card is listed and understood by Linux

lspci | less
dmesg | less

If you can see your card listed then you can move to next step i.e. load the drivers for TV Tuner card with following commands

modprobe bttv
modprobe tuner

Start to watch tv

xawtv &

Note if xawtv is not installed then use apt-get or yum to load it

apt-get install xawtv

If u have a fedora or redhat then use yum:

yum install xawtv

Script Delete Core files from server

Scripts No Comments »

This script is a little more elaborate and has the feel of a professional Perl program called findcore. The contents of findcore are as follows:
#!/usr/bin/perl
print “Looking for core files…\n”;
#find command looks from / for real files (no dirs, symlinks, etc.)
#named core
@core = `find / -type f -name core 2>/dev/null`;
chop (@core);
$num = @core;

if (@core) {
if ($num == 1) {
print “Found $num core file… removing…\n”;
} else {
print “Found $num core files… removing…\n”;
}
foreach $file (@core) {
# if we have write (-w) permission for file, we can delete it
if (-w $file) {
system(”rm -rf $file”);
print “Deleted $file.\n”;
} else {
print “You do not have permission to delete $file!\n”;
}
}
} else {
print “No core files found!\n”;
}
exit(0);

This script is relatively simple to write and use. Simply give it execute permissions and run it like this
chmod 755 findcore
./findcore

Wordpress Themes by Natty WP. Web Hosting
Images by our golf tips desEXign.