1. Trang chủ
  2. » Thể loại khác

Tài Liệu - Võ Tấn Dũng (votandung) Unit8 Linux ITC

35 90 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Information Technology College of HoChiMinh city Faculty of Information Technology Course: Fundamentals of Linux OS Unit Backing Up, Restoring and Installing Lecturer: Võ Tấn Dũng votandung@yahoo.com http://sites.google.com/site/votandungsg/ Archiving and Compression Tools • A file archiving tool groups a set of files into a single standalone file that we can backup to several types of media, transfer across a network, or send via email • The most frequently used archiving utility in Linux is tar • When an archiving utility is used along with a compression tool, it allows to reduce the disk size that is needed to store the same files and information • Tar is normally used with a compression tool such as gzip, bzip2 to produce a compressed tarball • Some Compression and Un-compression Tools: gzip, gunzip, zip, unzip, bzip2, bunzip2 VÕ TẤN DŨNG tar Command • tar command (tape archiver) bundles a group of files together into a single archive (commonly called a tar file or tarball) • tar options: -A : Append tar files to existing archives -c : Create a new archive file -d : Compare archive with Specified filesystem -j : bzip the archive -r : append files to existing archives -t : list contents of existing archives -u : Update archive -x : Extract file from existing archive -z : gzip the archive delete : Delete files from existing archive VÕ TẤN DŨNG Create tar and tar.gz Archive File • Create tar Archive File: The below example command will create a tar archive file tecmint-14-09-12.tar for a directory /home/tecmint in current working directory # tar -cvf tecmint-14-09-12.tar /home/tecmint/ • Create tar.gz Archive File: To create a compressed gzip archive file we use the option as z For example the below command will create a compressed MyImages-14-0912.tar.gz file for the directory /home/MyImages # tar cvzf MyImages-14-09-12.tar.gz /home/MyImages VÕ TẤN DŨNG Create tar.bz2 Archive File • The bz2 feature compress and create archive file less than the size of the gzip The bz2 compression takes more time to compress and decompress files as compared to gzip which takes less time • To create highly compressed tar file we use option as j • The following example of command will create a Phpfilesorg.tar.bz2 file for a directory /home/php # tar cvfj Phpfiles-org.tar.bz2 /home/php VÕ TẤN DŨNG Untar an Archive File • To untar or extract a tar file, just issue following command using option x (extract) • For example the below command will untar the file public_html-14-09-12.tar in present working directory # tar -xvf public_html-14-09-12.tar • If you want untar in a different directory then use option as -C (specified directory) # tar -xvf public_html-14-09-12.tar -C /home/public_html/videos/ VÕ TẤN DŨNG Uncompress an Archive File • To Uncompress tar.gz archive file: just run following command If would like to untar in different directory just use option -C and the path of the directory, like we shown in the above example # tar -xvf thumbnails-14-09-12.tar.gz • Uncompress tar.bz2 Archive File: to Uncompress highly compressed tar.bz2 file, just use the following command The below example command will untar all the flv files from the archive file # tar -xvf videos-14-09-12.tar.bz2 VÕ TẤN DŨNG List Content of an Archive File • List Content of tar Archive File: to list the content of tar archive file, just run the following command with option t (list content) The below command will list the content of uploadprogress.tar file # tar -tvf uploadprogress.tar • List Content tar.gz Archive File: use the following command to list the content of tar.gz file # tar -tvf staging.tecmint.com.tar.gz • List Content tar.bz2 Archive File: to list the content of tar.bz2 file, issue the following command # tar -tvf Phpfiles-org.tar.bz2 VÕ TẤN DŨNG Untar Single file • Untar Single file from tar File: to extract a single file called cleanfiles.sh from cleanfiles.sh.tar use the following command # tar -xvf cleanfiles.sh.tar cleanfiles.sh • Untar Single file from tar.gz File: to extract a single file tecmintbackup.xml from tecmintbackup.tar.gz archive file, use the command as follows # tar -zxvf tecmintbackup.tar.gz tecmintbackup.xml • Untar Single file from tar.bz2 File: to extract a single file called index.php from the file Phpfiles-org.tar.bz2 use the following option # tar -jxvf Phpfiles-org.tar.bz2 home/php/index.php VÕ TẤN DŨNG Untar Multiple files • To extract or untar multiple files from the tar, tar.gz and tar.bz2 archive file For example the below command will extract “file 1” “file 2” from the archive files # tar -xvf tecmint-14-09-12.tar "file 1" "file 2“ # tar -zxvf MyImages-14-09-12.tar.gz "file 1" "file 2“ # tar -jxvf Phpfiles-org.tar.bz2 "file 1" "file 2" 14 • To extract a group of files we use wildcard based extracting For example, to extract a group of all files whose pattern begins with php from a tar, tar.gz and tar.bz2 archive file # tar -xvf Phpfiles-org.tar wildcards ‘*.php’ # tar -zxvf Phpfiles-org.tar.gz wildcards '*.php' # tar -jxvf Phpfiles-org.tar.bz2 wildcards '*.php' VÕ TẤN DŨNG Check an RPM Signature Package • Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is OK • Use the following command with –checksig (check signature) option to check the signature of a package called pidgin [root@tecmint]# rpm checksig pidgin-2.7.9-5.el6.2.i686.rpm pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK VÕ TẤN DŨNG RPM File Naming Convention While RPM will run just as well if a package file has been renamed, when the packages are created during RPM's build process, they follow a specific naming convention: name-version-release.architecture.rpm where: • name is a name describing the packaged software • version is the version of the packaged software • release is the number of times this version of the software has been packaged • architecture is a shorthand name describing the type of computer hardware the packaged software is meant to run on Example: Midnight Commander package mc-4.5.55-12.i586.rpm VÕ TẤN DŨNG Install an RPM Package • For installing an rpm software package, use the following command with -i option For example, to install an rpm package called pidgin-2.7.9-5.el6.2.i686.rpm [root@tecmint]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm Preparing ########################################### [100%] 1:pidgin ########################################### [100%] VÕ TẤN DŨNG Check dependencies of a Package • How to check dependencies of RPM Package before Installing: let’s say you would like to a dependency check before installing or upgrading a package For example, use the following command to check the dependencies of BitTorrent5.2.2-1-Python2.4.noarch.rpm package It will display the list of dependencies of package [root@tecmint]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm /usr/bin/python2.4 python >= 2.3 python(abi) = 2.4 python-crypto >= 2.0 python-psyco python-twisted >= 2.0 python-zopeinterface rpmlib(CompressedFileNames) = 2.6 VÕ TẤN DŨNG Install a Package Without Dependencies • How to Install a RPM Package Without Dependencies • If you know that all needed packages are already installed, you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package [root@tecmint]# rpm -ivh nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm Preparing ########################################### [100%] 1:BitTorrent ########################################### [100%] • The above command forcefully install rpm package by ignoring dependencies errors, but if those dependency files are missing, then the program will not work at all, until you install them VÕ TẤN DŨNG Using whereis command whereis command locates source or binary and manuals sections for specified files • If the whereis command is not found, use /usr/ucb/whereis to run the command # /usr/ucb/whereis vi vi: /usr/bin/vi /usr/ucb/vi /usr/man/man1/vi.1 VÕ TẤN DŨNG Check an Installed RPM Package How to check an Installed RPM Package? • Using -q option with package name, will show whether an rpm installed or not [root@tecmint]# rpm -q BitTorrent BitTorrent-5.2.2-1.noarch VÕ TẤN DŨNG List all files of an installed package How to List all files of an installed RPM package • To view all the files of an installed rpm packages, use the -ql (query list) with rpm command [root@tecmint]# rpm -ql BitTorrent /usr/bin/bittorrent /usr/bin/bittorrent-console /usr/bin/bittorrent-curses /usr/bin/bittorrent-tracker /usr/bin/changetracker-console /usr/bin/launchmany-console /usr/bin/launchmany-curses /usr/bin/maketorrent /usr/bin/maketorrent-console /usr/bin/torrentinfo-console VÕ TẤN DŨNG List Recently Installed Packages How to List Recently Installed RPM Packages • Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages [root@tecmint]# rpm -qa last BitTorrent-5.2.2-1.noarch pidgin-2.7.9-5.el6.2.i686 cyrus-sasl-devel-2.1.23-13.el6_3.1.i686 cyrus-sasl-2.1.23-13.el6_3.1.i686 cyrus-sasl-md5-2.1.23-13.el6_3.1.i686 cyrus-sasl-plain-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 05:14:06 PM BDT Tue 04 Dec 2012 05:13:51 PM BDT Tue 04 Dec 2012 04:43:06 PM BDT Tue 04 Dec 2012 04:43:05 PM BDT Tue 04 Dec 2012 04:43:04 PM BDT Tue 04 Dec 2012 04:43:03 PM BDT VÕ TẤN DŨNG List All Installed RPM Packages How to List All Installed RPM Packages • Type the following command to print the all the names of installed packages on your Linux system [root@tecmint]# rpm -qa initscripts-9.03.31-2.el6.centos.i686 polkit-desktop-policy-0.96-2.el6_0.1.noarch thunderbird-17.0-1.el6.remi.i686 VÕ TẤN DŨNG Upgrade a RPM Package How to Upgrade a RPM Package • If we want to upgrade any RPM package “–U” (upgrade) option will be used • One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again [root@tecmint]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm Preparing ########################################### [100%] 1:nx ########################################### [100%] VÕ TẤN DŨNG Remove a RPM Package How to Remove a RPM Package • To un-install an RPM package, for example we use the package name nx, not the original package name nx-3.5.02.el6.centos.i686.rpm • The -e (erase) option is used to remove package [root@tecmint]# rpm -ev nx VÕ TẤN DŨNG Remove a Package Without Dependencies How to Remove an RPM Package Without Dependencies • The nodeps (Do not check dependencies) option forcefully remove the rpm package from the system • But keep in mind removing particular package may break other working applications [root@tecmint]# rpm -ev nodeps vsftpd VÕ TẤN DŨNG Query a file that belongs which RPM Package How to Query a file that belongs which RPM Package • Let’s say, you have list of files and you would like to find out which package belongs to these files • For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686 [root@tecmint]# rpm -qf /usr/bin/htpasswd httpd-tools-2.2.15-15.el6.centos.1.i686 VÕ TẤN DŨNG END OF UNIT • remember to your homework (see http://sites.google.com/site/votandungsg/) VÕ TẤN DŨNG ... Linux system [root@tecmint]# rpm -qa initscripts-9.03.3 1-2 .el6.centos.i686 polkit-desktop-policy-0.9 6-2 .el6_0.1.noarch thunderbird-17. 0-1 .el6.remi.i686 VÕ TẤN DŨNG Upgrade a RPM Package How to... pidgin-2.7. 9-5 .el6.2.i686 cyrus-sasl-devel-2.1.2 3-1 3.el6_3.1.i686 cyrus-sasl-2.1.2 3-1 3.el6_3.1.i686 cyrus-sasl-md 5-2 .1.2 3-1 3.el6_3.1.i686 cyrus-sasl-plain-2.1.2 3-1 3.el6_3.1.i686 Tue 04 Dec 2012 05:14:06 PM BDT Tue... file xyz.txt and directory php to existing tecmint-1 4-0 9-1 2.tar archive file # tar -rvf tecmint-1 4-0 9-1 2.tar xyz.txt # tar -rvf tecmint-1 4-0 9-1 2.tar php • Add Files or Directories to tar.gz and

Ngày đăng: 15/12/2017, 16:50

TỪ KHÓA LIÊN QUAN