Hiển thị các bài đăng có nhãn Linux. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Linux. Hiển thị tất cả bài đăng

6/10/14

Vmware Linux Guest Add a New Hard Disk Without Rebooting Guest

Vmware Linux Guest Add a New Hard Disk Without Rebooting Guest

by  on JULY 18, 2009 · 40 COMMENTS· LAST UPDATED AUGUST 4, 2010
As a system admin, I need to use additional hard drives for to provide more storage space or to separate system data from user data. This procedure, adding physical block devices to virtualized guests, describes how to add a hard drive on the host to a virtualized guest using VMWare software running Linux as guest.
It is possible to add or remove a SCSI device explicitly, or to re-scan an entire SCSI bus without rebooting a running Linux VM guest. This how to is tested under Vmware Server and Vmware Workstation v6.0 (but should work with older version too). All instructions are tested on RHEL, Fedora, CentOS and Ubuntu Linux guest / hosts operating systems.

Step # 1: Add a New Disk To Vm Guest

First, you need to add hard disk by visiting vmware hardware settings menu.
Click on VM > Settings
Fig.01: Vmware Virtual Machine Settings
Fig.01: Vmware Virtual Machine Settings
Alternatively you can press CTRL + D to bring settings dialog box.
Click on Add+ to add new hardware to guest:
Fig.02: VMWare adding a new hardware
Fig.02: VMWare adding a new hardware
Select hardware type Hard disk and click on Next
Fig.03 VMware Adding a new disk wizard
Fig.03 VMware Adding a new disk wizard
Select create a new virtual disk and click on Next
Fig.04: Vmware Wizard Disk
Fig.04: Vmware Wizard Disk
Set virtual disk type to SCSI and click on Next
Fig.05: Vmware Virtual Disk
Fig.05: Vmware Virtual Disk
Set maximum disk size as per your requirements and click on Next
Fig.06: Finalizing Disk Virtual Addition
Fig.06: Finalizing Disk Virtual Addition
Finally, set file location and click on Finish.

Step # 2: Rescan the SCSI Bus to Add a SCSI Device Without rebooting the VM

A rescan can be issued by typing the following command:
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
tail -f /var/log/message

Sample outputs:
Linux Vmware Rescan New Scsi Disk Without Reboot
Fig.01:Linux Vmware Rescan New Scsi Disk Without Reboot

Replace host# with actual value such as host0. You can find scsi_host value using the following command:
# ls /sys/class/scsi_host
Output:
host0
Now type the following to send a rescan request:
echo "- - -" > /sys/class/scsi_host/host0/scan
fdisk -l
tail -f /var/log/message

Sample Outputs:
Jul 18 16:29:39 localhost kernel:   Vendor: VMware,   Model: VMware Virtual S  Rev: 1.0
Jul 18 16:29:39 localhost kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Jul 18 16:29:39 localhost kernel:  target0:0:1: Beginning Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:1: Domain Validation skipping write tests
Jul 18 16:29:39 localhost kernel:  target0:0:1: Ending Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:1: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 16:29:39 localhost kernel: SCSI device sdb: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdb: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdb: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdb: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel: SCSI device sdb: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdb: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdb: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdb: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel:  sdb: unknown partition table
Jul 18 16:29:39 localhost kernel: sd 0:0:1:0: Attached scsi disk sdb
Jul 18 16:29:39 localhost kernel: sd 0:0:1:0: Attached scsi generic sg1 type 0
Jul 18 16:29:39 localhost kernel:   Vendor: VMware,   Model: VMware Virtual S  Rev: 1.0
Jul 18 16:29:39 localhost kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Jul 18 16:29:39 localhost kernel:  target0:0:2: Beginning Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:2: Domain Validation skipping write tests
Jul 18 16:29:39 localhost kernel:  target0:0:2: Ending Domain Validation
Jul 18 16:29:39 localhost kernel:  target0:0:2: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jul 18 16:29:39 localhost kernel: SCSI device sdc: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdc: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdc: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdc: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel: SCSI device sdc: 2097152 512-byte hdwr sectors (1074 MB)
Jul 18 16:29:39 localhost kernel: sdc: Write Protect is off
Jul 18 16:29:39 localhost kernel: sdc: cache data unavailable
Jul 18 16:29:39 localhost kernel: sdc: assuming drive cache: write through
Jul 18 16:29:39 localhost kernel:  sdc: unknown partition table
Jul 18 16:29:39 localhost kernel: sd 0:0:2:0: Attached scsi disk sdc
Jul 18 16:29:39 localhost kernel: sd 0:0:2:0: Attached scsi generic sg2 type 0

How Do I Delete a Single Device Called /dev/sdc?

In addition to re-scanning the entire bus, a specific device can be added or existing device deleted using the following command:
# echo 1 > /sys/block/devName/device/delete
# echo 1 > /sys/block/sdc/device/delete

How Do I Add a Single Device Called /dev/sdc?

To add a single device explicitly, use the following syntax:
# echo "scsi add-single-device <H> <B> <T> <L>" > /proc/scsi/scsi
Where,
  • <H> : Host
  • <B> : Bus (Channel)
  • <T> : Target (Id)
  • <L> : LUN numbers
For e.g. add /dev/sdc with host # 0, bus # 0, target # 2, and LUN # 0, enter:
# echo "scsi add-single-device 0 0 2 0">/proc/scsi/scsi
# fdisk -l
# cat /proc/scsi/scsi

Sample Outputs:
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 02 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02

Step #3: Format a New Disk

Now, you can create partition using fdisk and format it using mkfs.ext3 command:
# fdisk /dev/sdc
# mkfs.ext3 /dev/sdc3

Step #4: Create a Mount Point And Update /etc/fstab

# mkdir /disk3
Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:
/dev/sdc3               /disk3           ext3    defaults        1 2
Save and close the file.

Optional Task: Label the partition

You can label the partition using e2label. For example, if you want to label the new partition /backupDisk, enter
# e2label /dev/sdc1 /backupDisk

Conclusion

The VMware guest now has an additional virtualized storage device. The procedure works for all physical block devices, this includes CD-ROM, DVD and floppy devices. Next, time I will write about adding an additional virtualized storage device using XEN software.

1/10/14

Cách fix lỗi bảo mật Bash shell Vulnerability trên CentOS/RedHat Server (CVE-2014-6271)

Theo thông tin cập nhật mới nhất, hiện nay các máy chủ (bao gồm máy chủ ảo và máy chủ riêng) sử dụng hệ điều hành CentOS/RedHat đang gặp phải lỗi bảo mật nghiêm trọng liên quan đến Bash shell. 



Lỗi này ảnh hưởng tới các phiên bản hệ điều hành sau:

Red Hat Enterprise Linux 7
Red Hat Enterprise Linux 6
Red Hat Enterprise Linux 5
Red Hat Enterprise Linux 4 (ELS)


Các phiên bản Bash shell dưới đây không bị ảnh hưởng:

RHSA-2014:1293
Red Hat Enterprise Linux 7 - bash-4.2.45-5.el7_0.2
Red Hat Enterprise Linux 6 - bash-4.1.2-15.el6_5.1
Red Hat Enterprise Linux 5 - bash-3.2-33.el5.1

RHSA-2014:1294
Red Hat Enterprise Linux 4 Extended Lifecycle Support - bash-3.0-27.el4.2
Red Hat Enterprise Linux 5.6 Long Life - bash-3.2-24.el5_6.1
Red Hat Enterprise Linux 5.9 Extended Update Support - bash-3.2-32.el5_9.2
Red Hat Enterprise Linux 6.2 Advanced Update Support - bash-4.1.2-9.el6_2.1
Red Hat Enterprise Linux 6.4 Extended Update Support - bash-4.1.2-15.el6_4.1

RHSA-2014:1295
SJIS for Red Hat Enterprise Linux 6 - bash-4.1.2-15.el6_5.1.sjis.1
SJIS for Red Hat Enterprise Linux 5 - bash-3.2-33.el5_11.1.sjis.1

Để kiểm tra phiên bản Bash shell hiện tại, bạn có thể sử dụng lệnh sau:

Code:
# rpm -qa bash
Để fix lỗi bảo mật này, bạn có thể cập nhật gói Bash lên phiên bản mới nhất bằng cách sử dụng lệnh sau:

Code:
# yum update bash
(Nếu sử dụng hệ điều hành Cloudlinux, sử dụng thêm lệnh sau: # cagefsctl --force-update)


Chia sẻ bởi Vinahost

Tham khảo:
https://access.redhat.com/security/cve/CVE-2014-6271

======================================

Bash shell Vulnerability in Red Hat Enterprise Linux ( CVE-2014-6271)

This issue affects all software that uses the Bash shell and parses values of environment variables. This issue is especially dangerous as there are many possible ways Bash can be called by an application. Quite often if an application executes another binary, Bash is invoked to accomplish this. Because of the pervasive use of the Bash shell, this issue is quite serious and should be treated as such.

Environment
Red Hat Enterprise Linux 7
Red Hat Enterprise Linux 6
Red Hat Enterprise Linux 5
Red Hat Enterprise Linux 4 (ELS)


In order to avoid exploitation from CVE-2014-6271, ensure that your system is updated to at least the following versions of Bash.
RHSA-2014:1293
Red Hat Enterprise Linux 7 - bash-4.2.45-5.el7_0.2
Red Hat Enterprise Linux 6 - bash-4.1.2-15.el6_5.1
Red Hat Enterprise Linux 5 - bash-3.2-33.el5.1

RHSA-2014:1294
Red Hat Enterprise Linux 4 Extended Lifecycle Support - bash-3.0-27.el4.2
Red Hat Enterprise Linux 5.6 Long Life - bash-3.2-24.el5_6.1
Red Hat Enterprise Linux 5.9 Extended Update Support - bash-3.2-32.el5_9.2
Red Hat Enterprise Linux 6.2 Advanced Update Support - bash-4.1.2-9.el6_2.1
Red Hat Enterprise Linux 6.4 Extended Update Support - bash-4.1.2-15.el6_4.1

RHSA-2014:1295
SJIS for Red Hat Enterprise Linux 6 - bash-4.1.2-15.el6_5.1.sjis.1
SJIS for Red Hat Enterprise Linux 5 - bash-3.2-33.el5_11.1.sjis.1


The only way to fix it is to install updated Bash packages:
# yum update bash

20/7/14

How to Clone/Backup Linux Systems Using – Mondo Rescue Disaster Recovery Tool

Mondo Rescue is an open source, free disaster recovery and backup utility that allows you to easily create complete system (Linux or Windows) Clone/Backup ISO Images to CD, DVD, Tape, USB devices, Hard Disk, and NFS. And can be used to quickly restore or redeploy working image into other systems, in the event of data loss, you will be able to restore as much as entire system data from backup media.
Mondo program is available freely for download and released under GPL (GNU Public License) and has been tested on a large number of Linux distributions.
This article describes Mondo installation and usage of Mondo Tools to backup of your entire systems. The Mondo Rescue is a Disaster Recovery and Backup Solutions for System Administrators to take full backup of their Linux and Windows file system partitions into CD/DVD, Tape, NFS and restore them with the help of Mondo Restore media feature that uses at boot-time.

Installing MondoRescue on RHEL / CentOS / Scientific Linux

The latest Mondo Rescue packages (current version of Mondo is 3.0.3-1) can be obtained from the “MondoRescue Repository“. Use “wget” command to download and add repository under your system. The Mondo repository will install suitable binary software packages such as afio, buffer, mindi, mindi-busybox, mondo and mondo-doc for your distribution, if they are available.

For RHEL/CentOS/SL 6,5,4 – 32-Bit

Download the MondoRescue repository under “/etc/yum.repos.d/” as file name “mondorescue.repo“. Please download correct repository for your Linux OS distribution version.
# cd /etc/yum.repos.d/

## On RHEL/CentOS/SL 6 - 32-Bit ##
# wget ftp://ftp.mondorescue.org/rhel/6/i386/mondorescue.repo

## On RHEL/CentOS/SL 5 - 32-Bit ##
# wget ftp://ftp.mondorescue.org/rhel/5/i386/mondorescue.repo

## On RHEL/CentOS/SL 4 - 32-Bit ##
# wget ftp://ftp.mondorescue.org/rhel/4/i386/mondorescue.repo

For RHEL/CentOS/SL 6,5,4 – 64-Bit

# cd /etc/yum.repos.d/

## On RHEL/CentOS/SL 6 - 64-Bit ##
# wget ftp://ftp.mondorescue.org/rhel/6/x86_64/mondorescue.repo

## On RHEL/CentOS/SL 5 - 64-Bit ##
# wget ftp://ftp.mondorescue.org/rhel/5/x86_64/mondorescue.repo

## On RHEL/CentOS/SL 4 - 64-Bit ##
# wget ftp://ftp.mondorescue.org/rhel/4/x86_64/mondorescue.repo
Once you successfully added repository, do “yum” to install latest Mondo tool.
# yum install mondo

Installing MondoRescue on Debian / Ubuntu / Linux Mint

Debian user’s can do “wget” to grab the MondoRescue repository for Debain 6 and 5 distributions. Run the following command to add “mondorescue.sources.list” to “/etc/apt/sources.list” file to install Mondo packages.

On Debian

## On Debian 6 ##
# wget ftp://ftp.mondorescue.org/debian/6/mondorescue.sources.list
# sh -c "cat mondorescue.sources.list >> /etc/apt/sources.list" 
# apt-get update 
# apt-get install mondo
## On Debian 5 ##
# wget ftp://ftp.mondorescue.org/debian/5/mondorescue.sources.list
# sh -c "cat mondorescue.sources.list >> /etc/apt/sources.list" 
# apt-get update 
# apt-get install mondo

On Ubuntu/Linux Mint

To install Mondo Rescue in Ubuntu 12.10, 12.04, 11.10, 11.04, 10.10 and 10.04 or Linux Mint 13, open the terminal and add the MondoRescue repository in “/etc/apt/sources.list” file. Run these following commands to install Mondo Resuce packages.
# wget ftp://ftp.mondorescue.org/ubuntu/`lsb_release -r|awk '{print $2}'`/mondorescue.sources.list
# sh -c "cat mondorescue.sources.list >> /etc/apt/sources.list" 
# apt-get update 
# apt-get install mondo

Creating Cloning or Backup ISO Image of System/Server

After installing Mondo, Run “mondoarchive” command as “root” user. Then follow screenshots that shows how to create an ISO based backup media of your full system.
# mondoarchive
Welcome to Mondo Rescue
Mondo Rescue Welcome Screen

Mondo Rescue Welcome Screen

Please enter the full path name to the directory for your ISO Images. For example: /mnt/backup/
Mondo Rescue Storage Directory

Mondo Rescue Storage Directory
Select Type of compression. For example: bzip, gzip or lzo.
Select Type of Compression

Select Type of Compression
Select the maximum compression option.
Mondo Rescue Compression Speed

Select Compression Speed
Please enter how large you want each ISO image in MB (Megabytes). This should be less than or equal to the size of the CD-R(W)’s (i.e. 700) and for DVD’s (i.e. 4480).
Mondo Rescue ISO Size

Define Mondo Rescue ISO Size
Please give a name of your ISO image filename. For example: tecmint1 to obtain tecmint-[1-9]*.iso files.
Mondo Rescue Prefix

Enter Name of Mondo Rescue
Please add the filesystems to backup (separated by “|“). The default filesystem is “/” means full backup.
Mondo Rescue Backup Paths

Enter Backup Paths
Please exclude the filesystem that you don’t want to backup (separated by “|“). For example: “/tmp” and “/proc” are always excluded or if you want full backup of your system, just hit enter.
Mondo Rescue Exclude Paths

Enter Exclude File System
Please enter your temporary directory path or select default one.
Mondo Rescue Temporary  Directory

Enter Temporary Directory Name
Please enter your scratch directory path or select default one.
Mondo Rescue Scratch  Directory Name

Enter Scratch Directory Name
If you would like to backup extended attributes. Just hit “enter“.
Mondo Rescue Extended Backup

Enter Extended Backup Attributes
If you want to Verify your backup, after mondo has created them. Click “Yes“.
Mondo Rescue Verify Backups

Verify Backups
If you’re using stable standalone Linux Kernel, click “Yes” or if you using other Kernel say “Gentoo” or “Debain” hit “No“.
Mondo Rescue Kernel

Select Stable Linux Kernel
Click “Yes” to proceed further.
Mondo Rescue Backup Process

Proceed Cloning Process
Creating a catalog of “/” filesystem.
Mondo Rescue Making Catalog

Creating Catalog for File System
Dividing filelist into sets.
Mondo Rescue Dividing File List

Dividing File List
Calling MINDI to create boot+data disk.
Mondo Rescue Boot Data Disk

Creating Boot Data Disk
Backing up filesytem. It may take a couple of hours, please be patient.
Mondo Rescue Backup Filesystem

Backing up File System
Backing up big files.
Mondo Rescue Big Files Backup

Big Files Backup
Running “mkisofs” to make ISO Image.
Mondo Rescue Creating ISO

Making ISO Image
Verifying ISO Image tarballs.
Mondo Rescue Verify ISO

Verify ISO
Verifying ISO Image Big files.
Mondo Rescue Verify Big Files

Verify Big Files
Finally, Mondo Archive has completed. Please hit “Enter” to back to the shell prompt.
Mondo Rescue Backup Completed

Backup Completed
If you’ve selected default backup path, you will see an ISO image under “/var/cache/mondo/“, that you can burnt into a CD/DVD for later restore.
To restore all files automatically, boot the system with Mondo ISO Image and at boot prompt type “nuke” to restore files. Here is the detailed video that demonstrates how to restore files automatically from CD/DVD media.

For other distributions, you can also grab Mondo Rescue packages at mondorescue.org download page.

19/2/13

Hướng dẫn cài đặt Smarty trên hệ điều hành Linux


    Cài đặt SMARTY LIBRARY


Copy các file thư viện Smarty vào
/usr/local/lib/php/Smarty/

$> cd YOUR_DOWNLOAD_DIRECTORY
$> gtar -zxvf Smarty-2.6.7.tar.gz
$> mkdir /usr/local/lib/php/Smarty
$> cp -r Smarty-2.6.7/libs/* /usr/local/lib/php/Smarty

Ta có các file và cấu trúc thư mục như sau:

/usr/local/lib/php/Smarty/
Config_File.class.php
debug.tpl
internals/
plugins/
Smarty.class.php
Smarty_Compiler.class.php

Cài đặt SMARTY DIRECTORIES


You will need four directories setup for Smarty to work. These files are for
templates, compiled templates, cached templates and config files. You may or
may not use caching or config files, but it is a good idea to set them up
anyways. It is also recommended to place them outside of the web server
document root. The web server PHP user will need write access to the cache and
compile directories as well.

In our example, the document root is /web/www.domain.com/docs and the
web server username is "nobody". We will keep our Smarty files under
/web/www.domain.com/smarty

$> cd /web/www.domain.com
$> mkdir smarty
$> mkdir smarty/templates
$> mkdir smarty/templates_c
$> mkdir smarty/cache
$> mkdir smarty/configs
$> chown nobody:nobody smarty/templates_c
$> chown nobody:nobody smarty/cache
$> chmod 775 smarty/templates_c
$> chmod 775 smarty/cache

SETUP SMARTY PHP SCRIPTS

Now we setup our application in the document root:

$> cd /web/www.domain.com/docs
$> mkdir myapp
$> cd myapp
$> vi index.php

Edit the index.php file to look like the following:

<?php

// put full path to Smarty.class.php
require('/usr/local/lib/php/Smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = '/web/www.domain.com/smarty/templates';
$smarty->compile_dir = '/web/www.domain.com/smarty/templates_c';
$smarty->cache_dir = '/web/www.domain.com/smarty/cache';
$smarty->config_dir = '/web/www.domain.com/smarty/configs';

$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');

?>

SETUP SMARTY TEMPLATE

$> vi /web/www.domain.com/smarty/templates/index.tpl

Edit the index.tpl file with the following:

<html>
<head>
<title>Smarty</title>
</head>
<body>
Hello, {$name}!
</body>
</html>

Now go to your new application through the web browser,
http://www.domain.com/myapp/index.php in our example. You should see the text
"Hello Ned!" in your browser.

Once you get this far, you can continue on to the Smarty Crash Course to learn
a few more simple things, or on to the documentation to learn it all.
Nguồn sưu tầm  

10/2/13

Backup dữ liệu trong linux


1. Tạo và restore file tar:
# tar -cvf <file_backup> <file, thư mục hoặc các thư mục (cách nhau bằng space)>
Lệnh này giúp tạo file tar của  file, thư mục hoặc các thư mục. Khi cần restore ta dùng lệnh như sau:
# tar -xvf <file_backup>
Giải thích các tham số:
-c: viết tắt của "create"
-v: viết tắt của "verbose". Khi có tham số này, quá trình tạo sẽ hiện ra màn hình, nếu không hệ thống sẽ âm thầm thực hiện và chỉ cho ra kết quả. (Có thể sử dụng hoặc không!)
-f: viết tắt của "file"
Ví dụ:
root@NG:/# mk /backup
root@NG:/# tar -cvf /backup/abc.tar /etc /home /root /var
2. Tạo và restore file .gz, .bz2:
-- Tác dụng là nén file backup, nhược điểm là chậm hơn một chút trong quá trình backup và restore.
-- Tạo file .gz
# tar -czvf <file_backup> <file, thư mục hoặc các thư mục cần backup>
-- Tạo file .bz2
# tar -cjvf <file_backup> <file, thư mục hoặc các thư mục cần backup>
-- Để restore ta dùng cú pháp lần lượt như sau:
# tar  -xzvf <file_backup>
và:
# tar -xjvf <file_backup>
Ví dụ:
root@ubuntu:/# tar -czvf /backup/abc.tar.gz /etc /home /root /var
root@ubuntu:/# tar -cjvf /backup/abc.tar.bz2 /etc /home /root /var
3. Tạo file backup bổ xung:
-- Việc tạo file backup toàn hệ thống tốn không ít thời gian. Bởi vậy, ta có nhu cầu tạo một file backup toàn bộ và thường xuyên chỉ tạo các file backup bổ xung các sự thay đổi mới. Cách làm như Ví dụ sau:
-- Tạo file backup đầy đủ:
root@NG:/# tar -czvg /backup/snapshot-file -f /backup/full-backup.tar.gz /etc /home /root /var
-- Tạo file backup bổ xung ngày thứ 2
root@NG:/# tar -czvg /backup/snapshot-file -f /backup/monday-backup.tar.gz /home /root /var
-- Restore file backup đầy đủ
root@NG:/# tar -xzvf /backup/full-backup.tar.gz
--Restore file backup ngày thứ 2
root@NG:/# tar -xzvf /backup/monday-backup.tar.gz
-- Hoạt động của lệnh tar trong trường hợp này như sau: Trước tiên, tar kiểm tra xem file snapshot-file có tồn tại hay không. Nếu không tồn tại thì tar sẽ tạo ra file snapshot-file chứa danh sách các file cần backup để lưu lại so sánh. Nếu tồn tại file snapshot-file, tar sẽ so sánh với danh sách trong đó để tìm ra sự khác biệt với thực tế. Mọi sự khác biệt đó sẽ được tar nén vào trong file backup mới.
-- Ngoài ra, lệnh tar còn được sử dụng để di chuyển "contents" giữa các thư mục bằng cú pháp sau:
tar -cC <thư mục cũ> . | tar -vxC <thư mục mới>
(tham số -C là tạo "content")
4. Backup sử dụng dd:
-- Khi ta có nhu cầu cần backup cả hệ thống file (như cả partition, disk, image...) thì dd là lựa chọn tiện lợi và mạnh mẽ. Cú pháp đơn giản như sau:
# dd if=<thiết bị vào> of=<thiết bị ra>
<thiết bị vào>: là thành phần cần được backup. Có thể là partition, ổ đĩa mềm, đĩa CD, USB, đĩa cứng...
<thiết bị ra>: là thành phần chứa dữ liệu backup. Có thể là partition khác, thẻ nhớ, file iso...
Ví dụ: Sao lưu y nguyên dữ liệu từ ổ cứng này (/dev/sda) sang ổ cứng khác (/dev/sdb) trên hệ thống:
# dd if=/dev/sda of=/dev/sdb
Ví dụ: Copy cd thành file iso (lưu lại boot sector)
# dd if=/dev/cdrom of=/mycd.iso
5. Backup sử dụng cpio:
-- cpio là tiện ích được sử dụng để copy file hay thư mục vào hoặc từ thiết bị lưu trữ. Để tạo file cpio, danh sách các file phải  được đưa vào lệnh cpio  bằng một đường ống (pipe) hoặc chuyển tiếp. Ví dụ:
-- Tạo file backup cho /etc:
# find /etc | cpio -o > etc.cpio
-- Restore từ file cpio
# cpio -i < /dev/tape
(restore từ băng từ, bây h không thấy còn sử dụng nhưng có thể áp dụng với usb, thẻ nhớ, thiết bị lưu trữ khác)
# cpio -i < /etc.cpio
(restore từ file)



6.backup voi rsync

example:

Thực hiện backup (/etc)
# mkdir /media/backup/linux
# rsync -avh /etc /media/backup/linux

Thực hiện sự khôi phục (/etc)

# rsync -avh /media/backup/linux/etc /etc

detail usage command: $ man rsync
nguổn:http://www.kmasec.com/forum/showthre...?p=222#post222

17/12/12

TẠO WEBSITE CHO NGƯỜI DÙNG


1.1.1.     TẠO WEBSITE CHO NGƯỜI DÙNG

Mô hình và yêu cầu bài tập

Hướng dẫn thực hiện

a.      Tạo userdir
1)     Khai báo UserDir
2)     Cập quyền hạn truy cập
b.      Reload web service
c.      Kiểm tra hoạt động của trang web

Các bước thực hiện

a)   Bước 1: Kiểm tra hoạt động của trang web http://www.serverlinux.vn
b)  Bước 2: Cấu hình tập tin httpd.conf cho phép tạo trang web cá nhân cho user. Thêm vào các dòng như bên dưới:
Dòng 355 đổi thành: UserDir www
Thêm vào code từ dòng 384 đến dòng 295
<Directory /home/*/www>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
      Order allow,deny
      Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
      Order deny,allow
      Deny from all
</LimitExcept>
</Directory>
c)   Bước 3: Tạo các user hv1 và hv2 bằng các câu lệnh như bên dưới:
[root@localhost ~]# useradd hv1
[root@localhost ~]# passwd hv1
Changing password for user hv1.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# useradd hv2
[root@localhost ~]# passwd hv2
Changing password for user hv2.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
d)  Bước 4: Tạo trang web cá nhân trên user hv1
-      Tạo thư mục www:
[hv1@Webserver ~]$ mkdir www
[hv1@Webserver ~]$ ls
bootstat.dat  explorer.scf  history.txt  JRE32.dll
explorer.exe  FaxSetup.log  index.html   www
-      Tạo tập tin www/index.html
[hv1@Webserver ~]$vi index.html
<html>
<body>
Day la trang web cua user hv1
</body>
</html>
-      Phân quyền truy cập
#chmod 711 /home/*
#chmod 755 /home/hv1/www.index.html
e)   Bước 5: Truy cập vào trang web http://www.serverlinux.vn/~hv1
f)    Bước 6: Làm tương tự cho user hv2

Bài đăng phổ biến