Extract particular file/directory from tar archive

Filed Under (Linux) by WebScHoLaR on 11-12-2010

Tagged Under : , ,

tar files are the archive for the files/folders. Inorder to retrieve any file/folder from the archive, the archive needs to be extracted. If any specific file/folder is required then its useless to extract the complete archive. Its more suitable to just extract that specific file from the archive.

Lets say folder3.tar is the archive that has the file folder1/folder2/folder3/file_in_folder3 which needs to be extracted. In order to extract that specific file only and not the complete archive, this can be done as:

tar –extract –file=folder3.tar folder1/folder2/folder3/file_in_folder3

This will extract file_in_folder3 ONLY and not all files/folders in all other folders.

The command format is:

tar –extract –file=archive.tar path/to/file/folder/to/be/extracted

fatal: daemon() failed: No such device

Filed Under (Linux) by WebScHoLaR on 11-12-2010

Tagged Under : , ,

Recently I got an issue on CentOS 5 server. SSH was failing on the server. Tried to restart but SSH didn’t start. Checked /var/log/secure and noticed the following error:

Dec 10 10:58:05 vps sshd[23799]: fatal: daemon() failed: No such device

To fix this issue, I performed the following actions:

-bash-3.2# rm -vf /dev/null
removed `/dev/null’

-bash-3.2# mknod /dev/null c 1 3

Started SSH and the SSH started responding:

-bash-3.2# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]

-bash-3.2# service sshd status
openssh-daemon (pid 30608) is running…

Repair innodb corruption on cPanel mysql Server

Filed Under (cPanel/WHM, Linux, MySQL) by WebScHoLaR on 07-11-2010

Tagged Under : , , ,

1. Stop mysqld.
2. Backup /var/lib/mysql/ib*
3. Add the following line into /etc/my.cnf

innodb_force_recovery = 4

4. Restart mysqld.
5. Dump all tables:# mysqldump -A > dump.sql
6. Drop all databases which need recovery.
7. Stop mysqld.
8. Remove /var/lib/mysql/ib*
9. Comment out innodb_force_recovery in /etc/my.cnf
10. Restart mysqld. Look at mysql error log. By default it should be /var/lib/mysql/server/hostname.com.err to see how it creates new ib* files.
11. Restore databases from the dump:mysql < dump.sql

You can also run /scripts/mysqlup –force after step 8. as this will recreate the ibdata files. This is also unsupported and caution should be taken to not lose any vital customer data in the databases.

Configure: error: cannot run C compiled programs

Filed Under (cPanel/WHM, Linux) by WebScHoLaR on 07-11-2010

Tagged Under : , , , ,

/tmp drive is recommended to be mounted as noexec to prevent any exploitable scripts execution. If during installation, make fails with the error:

checking whether the C compiler works… configure: error: cannot run C compiled programs.
ERROR: `/root/tmp/xxxx/configure failed

It means that executable files cannot be created in /tmp. Mount options for /tmp can be checked as:
Read the rest of this entry »

Create swap on linux server

Filed Under (Linux) by WebScHoLaR on 10-10-2010

Tagged Under : ,

To create swapfile if theres no swap setup on the server (free -m will show zero swap)

1 – Create the required extra swap and make sure /home has enough free space. This will create a swapfile of 10GB.
# dd if=/dev/zero of=/home/swapfile bs=1024 count=10000000
2 – Make the swap file
# mkswap /home/swapfile
3 – Turn the swap on
# swapon /home/swapfile
4 – Verify that swap is added
# free -m
5 – Make sure this is loaded every time node is rebooted by adding the following line to /etc/rc.local
# /sbin/swapon /home/swapfile

Recursively get files from FTP server

Filed Under (Linux) by WebScHoLaR on 09-10-2010

Tagged Under : ,

FTP in conjunction with wget can be used to recursively download files from the servers. Use the following command to fetch all files in the FTP account provided:

# wget -r -nH -c -l0 ftp://ftp_username:ftp_password@ftp_host.com
If needing to use a username with an ‘@’ in it, you can use %40 instead of the @ and it will go through just fine.
# wget -r -nH -c -l0 ftp://user%40domain.com:ftppass@ftp_host.com

tmp files to check download speed

Filed Under (Linux) by WebScHoLaR on 09-10-2010

Tagged Under : , , ,

Most of the time, download speed needs to be checked. A temporary file with garbage data can be created and made available for the users to download and test the download speed. This can be created as:

# dd if=/dev/zero bs=1024 count=20000 of=/home/user/www/20mb.file
# chown user.user
/home/user/www/20mb.file

Then the URL http://www.domain.com/20mb.file can be provided to users to check the download speed.

NOTE: Make sure that the domain.com points to the same path where the file was created.

myisamchk Error: Disk is full writing ‘/tmp/xxxxxx

Filed Under (Linux, MySQL) by WebScHoLaR on 09-10-2010

Tagged Under : , ,

myisamchk utility is used to repair MySQL MyISAM tables. If the table is too large and the server tmp drive doesn’t have much space, you may encounter Disk full error. In that case, create a temporary folder at any server partition that has enough disk space available and run myisamchk as:

# mkdir /home/mysqltmp
# chown mysql.mysql /home/mysqltmp
# myisamchk -rf –tmpdir=/home/mysqltmp /var/lib/mysql/user_dbname/*.MYI

Once repaired, remove the /home/mysqltmp.

Video sharing modules Installation

Filed Under (Linux) by WebScHoLaR on 27-11-2008

Tagged Under : , ,

Nowadays everyone prefers watching a video rather than reading the text. Youtube has introduced a new concept for information sharing. There are several vendors who offer product to provide the  functionality like youtube and these softwares require some modules that are usually called video sharing modules. Here is a quick way to install these modules. Read the rest of this entry »

Reset Linux Root Password

Filed Under (Articles, Linux) by WebScHoLaR on 19-02-2008

Tagged Under : , ,

  • Reboot the system and wait for the GRUB screen to appear.
  • Highlight the kernel version you’re currently using (usually the newest version) from the GRUB list.
  • Press “e” to be taken to the boot commands edit screen, highlight the line which starts with kernel and press “e” again.
  • Add “single” to the end of the line, so it will look like this:

kernel /vmlinuz-kernel-version ro root=LABEL=/ rhgb quiet single

  • Press “Enter” to save the changes
  • Press “b” to boot in single user mode.

The system will begin loading and, at some point, you will be presented with a root bash prompt.

In the new prompt type “passwd” and choose a new password for root.When done, type reboot to restart the system. After reboot, GRUB will be back to normal so no further modifications are required.

NOTE: If you are asked for the root password before dropping you in a bash prompt in single user mode, you should follow the instructions above and append “single init=/bin/bash” to the kernel line, not just “single“.

Proudly Hosted by eServicesProvider