mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-28 23:20:10 +08:00
commit
ae2c5e92a3
@ -1,127 +0,0 @@
|
||||
Translating by FSSlc
|
||||
|
||||
4 Steps to Setup Local Repository in Ubuntu using APT-mirror
|
||||
================================================================================
|
||||
Today we will show you how to setup a local repository in your Ubuntu PC or Ubuntu Server straight from the official Ubuntu repository. There are a lot benefit of creating a local repository in your computer if you have a lot of computers to install software, security updates and fixes often in all systems, then having a local Ubuntu repository is an efficient way. Because all required packages are downloaded over the fast LAN connection from your local server, so that it will save your Internet bandwidth and reduces the annual cost of Internet..
|
||||
|
||||
You can setup a local repository of Ubuntu in your local PC or server using many tools, but we'll featuring about APT-Mirror in this tutorial. Here, we'll be mirroring packages from the default mirror to our Local Server or PC and we'll need at least **120 GB** or more free space in your local or external hard drive. It can be configured through a **HTTP** or **FTP** server to share its software packages with local system clients.
|
||||
|
||||
We'll need to install Apache Web Server and APT-Mirror to get our stuffs working out of the box. Here are the steps below to configure a working local repository:
|
||||
|
||||
### 1. Installing Required Packages ###
|
||||
|
||||
First of all, we are going to pull whole packages from the public repository of Ubuntu package server and save them in our local Ubuntu server hard disk.
|
||||
|
||||
We'll first install a web server to host our local repository. We'll install Apache web server but you can install any web server you wish, web server are necessary for the http protocol. You can additionally install FTP servers like proftpd, vsftpd,etc if you need to configure for ftp protocols and Rsync for rsync protocols.
|
||||
|
||||
$ sudo apt-get install apache2
|
||||
|
||||
And then we'll need to install apt-mirror:
|
||||
|
||||
$ sudo apt-get install apt-mirror
|
||||
|
||||
![apt-mirror-installation](http://blog.linoxide.com/wp-content/uploads/2014/12/apt-mirror-install.png)
|
||||
|
||||
**Note: As I have already mentioned that we'll need at least 120 GBs free space to get all the packages mirrored or download.**
|
||||
|
||||
### 2. Configuring APT-Mirror ###
|
||||
|
||||
Now create a directory on your harddisk to save all packages. For example, let us create a directory called “/linoxide”. We are going to save all packages in this directory:
|
||||
|
||||
$ sudo mkdir /linoxide
|
||||
|
||||
![repo-dir](http://blog.linoxide.com/wp-content/uploads/2014/12/mkdir-linoxide.png)
|
||||
|
||||
Now, open the file **/etc/apt/mirror.list** file
|
||||
|
||||
$ sudo nano /etc/apt/mirror.list
|
||||
|
||||
![apt-mirror-edit](http://blog.linoxide.com/wp-content/uploads/2014/12/edit-mirror-list-300x7.png)
|
||||
|
||||
Copy the below lines of configuration to mirror.list and edit as your requirements.
|
||||
|
||||
############# config ##################
|
||||
#
|
||||
set base_path /linoxide
|
||||
#
|
||||
# set mirror_path $base_path/mirror
|
||||
# set skel_path $base_path/skel
|
||||
# set var_path $base_path/var
|
||||
# set cleanscript $var_path/clean.sh
|
||||
# set defaultarch <running host architecture>
|
||||
# set postmirror_script $var_path/postmirror.sh
|
||||
# set run_postmirror 0
|
||||
set nthreads 20
|
||||
set _tilde 0
|
||||
#
|
||||
############# end config ##############
|
||||
|
||||
deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
|
||||
deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
|
||||
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
|
||||
#deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
|
||||
#deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
|
||||
|
||||
deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
|
||||
deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
|
||||
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
|
||||
#deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
|
||||
#deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
|
||||
|
||||
clean http://archive.ubuntu.com/ubuntu
|
||||
|
||||
![mirror-list-config](http://blog.linoxide.com/wp-content/uploads/2014/12/mirror-list-config.png)
|
||||
|
||||
**Note: You can replace the above official mirror server url by the nearest one, you can get your nearest server by visiting the page [Ubuntu Mirror Server][1]. If you are not in hurry and can wait for the mirroring, you can go with the default official one.**
|
||||
|
||||
Here, we are going to mirror package repository of the latest and greatest LTS release of Ubuntu ie. Ubuntu 14.04 LTS (Trusty Tahr) so, we have configured trusty. If you need to mirror of Saucy or other version of Ubuntu, please edit it as its codename.
|
||||
|
||||
Now, we'll have to run apt-mirror which will now get/mirror all the packages in the repository.
|
||||
|
||||
sudo apt-mirror
|
||||
|
||||
It will take time to download all the packages from the Ubuntu Server which depends upon the connection speed and performance with respect to you and the mirror server. I have interrupted the download as I have already done that...
|
||||
|
||||
![downloading-packages](http://blog.linoxide.com/wp-content/uploads/2014/12/downloading-index.png)
|
||||
|
||||
### 3.Configuring Web Server ###
|
||||
|
||||
To be able to access the repo from other computers you need a webserver. You can also do it via ftp but I choose to use a webserver as I mentioned in above step 1. So, we are now gonna configure Apache Server:
|
||||
|
||||
We will create a symlink from our local repo's directory to a directory ubuntu in the hosting directory of Apache ie /var/www/ubuntu
|
||||
|
||||
$ sudo ln -s /linoxide /var/www/ubuntu
|
||||
$ sudo service apache2 start
|
||||
|
||||
![symlinks-apache2](http://blog.linoxide.com/wp-content/uploads/2014/12/symblink-apache2.png)
|
||||
|
||||
The above command will allow us to browse our Mirrored Repo from our localhost ie http://127.0.0.1 by default.
|
||||
|
||||
### 4. Configuring Client Side ###
|
||||
|
||||
Finally, we need to add repository source in other computers which will fetch the packages and repository from our computer. To do that, we'll need to edit /etc/apt/sources.list and add the following lines.
|
||||
|
||||
$ sudo nano /etc/apt/sources.list
|
||||
|
||||
Add this line in /etc/apt/sources.list and save.
|
||||
|
||||
deb http://192.168.0.100/ubuntu/ trusty main restricted universe
|
||||
|
||||
**Note: here 192.168.0.100 is the LAN IP address of our server computer, you need to replace that with yours.**
|
||||
|
||||
$ sudo apt-get update
|
||||
|
||||
Finally, we are done. Now you can install the required packages using sudo apt-get install packagename from your local Ubuntu repository with high speed download and with low bandwidth.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/ubuntu-how-to/setup-local-repository-ubuntu/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
||||
[1]:https://launchpad.net/ubuntu/+archivemirrors
|
@ -1,231 +0,0 @@
|
||||
Translating by FSSlc
|
||||
|
||||
Best Known Linux Archive / Compress Tools
|
||||
================================================================================
|
||||
Sending and receiving large files and pictures over the internet is a headache many times. Compression and decompression tools are meant to address this problem. Lets take a quick overview of a few open source tools that are available to make our jobs simpler.
|
||||
|
||||
Tar
|
||||
gzip, gunzip
|
||||
bzip2, bunzip2
|
||||
7-Zip
|
||||
|
||||
### Tar ###
|
||||
|
||||
Tar is derived from 'Tape archiver' as this was initially used for archiving and storing files on magnetic tapes. It is a GNU software. It can compress a set of files (archives), extract them and manipulate those which already exist. It is useful for storing, backing up and transporting files. Tar can preserve file and directory structure while creating the archives. Files archived using tar have '.tar' extensions.
|
||||
|
||||
Basic Usage
|
||||
|
||||
#### a) Creating an archive (c / --create) ####
|
||||
|
||||
tar --create --verbose --file=archive.tar file1 file2 file3
|
||||
|
||||
OR
|
||||
|
||||
tar cvf archive.tar file1 file2 file3
|
||||
|
||||
![tar cvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-cvf.png)
|
||||
|
||||
creating an archive
|
||||
|
||||
#### b) Listing an archive ( t / --list) ####
|
||||
|
||||
tar --list archive.tar
|
||||
|
||||
![tar tvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-tvf.png)
|
||||
|
||||
Listing the contents
|
||||
|
||||
#### c) Extracting an archive (x / --extract) ####
|
||||
|
||||
tar xvf archive.tar
|
||||
|
||||
tar xvf archive.tar --wildcards '*.c' - extracts files with only *.c extension from the archive.
|
||||
|
||||
![tar xvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-xvf.png)
|
||||
|
||||
Extracting files
|
||||
|
||||
![tar xvf --wildcards](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-wildcard.png)
|
||||
|
||||
Extract only the required files
|
||||
|
||||
#### d) Updating an archive ( u / --update) ####
|
||||
|
||||
tar uvf archive.tar newfile.c - updates the archive by adding newfile.c if its version is newer than the existing one.
|
||||
|
||||
![tar uvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-uvf.png)
|
||||
|
||||
Updating an archive
|
||||
|
||||
#### e) Delete from an archive (--delete) ####
|
||||
|
||||
tar--delete -f archive.tar file1.c - deletes 'file1.c' from the tar ball 'archive.tar'
|
||||
|
||||
![tar --delete](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-delete.png)
|
||||
|
||||
Deleting files
|
||||
|
||||
Refer to [tar home page][1] for its detailed usage
|
||||
|
||||
### Gzip / Gunzip ###
|
||||
|
||||
Gzip stands for GNU zip. It is a compression utility that is commonly available in Linux operating system. Compressed files have an extension of '*.gz'
|
||||
|
||||
**Basic Usage**
|
||||
|
||||
#### a) Compressing files ####
|
||||
|
||||
gzip file(s)
|
||||
|
||||
Each file gets compressed individually
|
||||
|
||||
![gzip](http://blog.linoxide.com/wp-content/uploads/2015/01/gzip.png)
|
||||
|
||||
Compress files
|
||||
|
||||
This generally deletes the original files after compression. We can keep the original file by using the -c option.
|
||||
|
||||
gzip -c file > file.gz
|
||||
|
||||
![gzip-c](http://blog.linoxide.com/wp-content/uploads/2015/01/gzip-c.png)
|
||||
|
||||
Keep original files after compressing
|
||||
|
||||
We can also compress a group of files into a single file
|
||||
|
||||
cat file1 file2 file3 | gzip > archieve.gz
|
||||
|
||||
![gz group](http://blog.linoxide.com/wp-content/uploads/2015/01/gz-group.png)
|
||||
|
||||
Compressing a group of files
|
||||
|
||||
#### b) Checking compression ratio ####
|
||||
|
||||
Compression ratio of the compressed file(s) can be verified using the '-l' option.
|
||||
|
||||
gzip -l archieve.gz
|
||||
|
||||
![gzip -l](http://blog.linoxide.com/wp-content/uploads/2015/01/gzip-l.png)
|
||||
|
||||
Checking compression ratio
|
||||
|
||||
#### c) Unzipping files ####
|
||||
|
||||
Gunzip is used for unzipping files. Here also, original files are deleted after decompression. Use the -c option to retain original files.
|
||||
|
||||
gunzip -c archieve.gz
|
||||
|
||||
![gunzip -c](http://blog.linoxide.com/wp-content/uploads/2015/01/gunzip-c.png)
|
||||
|
||||
Unzipping files
|
||||
|
||||
Using '-d' option with gzip command has the same effect of gunzip on compressed files.
|
||||
|
||||
More details can be obtained from [gzip home page][2]
|
||||
|
||||
### Bzip2 / Bunzip2 ###
|
||||
|
||||
[Bzip2][3] is also a compression tool like gzip but can compress files to smaller sizes than that is possible with other traditional tools. But the drawback is that it is slower than gzip.
|
||||
|
||||
**Basic Usage**
|
||||
|
||||
#### a) File Compression ####
|
||||
|
||||
Generally, no options are used for compression and the files to be compressed are passed as arguments. Each file gets compressed individually and compressed files will have the extension 'bz2'.
|
||||
|
||||
bzip2 file1 file2 file3
|
||||
|
||||
![bzip2](http://blog.linoxide.com/wp-content/uploads/2015/01/bzip2.png)
|
||||
|
||||
File Compression
|
||||
|
||||
Use '-k' option to keep the original files after compression / decompression.
|
||||
|
||||
![bzip2 -k](http://blog.linoxide.com/wp-content/uploads/2015/01/bzip2-k.png)
|
||||
|
||||
Retaining original files after compression
|
||||
|
||||
'-d' option is used for forced decompression.
|
||||
|
||||
![bzip2 -d](http://blog.linoxide.com/wp-content/uploads/2015/01/bzip2-d.png)
|
||||
|
||||
Delete files using -d option
|
||||
|
||||
#### b) Decompression ####
|
||||
|
||||
bunzip2 filename
|
||||
|
||||
![bunzip2](http://blog.linoxide.com/wp-content/uploads/2015/01/bunzip2.png)
|
||||
|
||||
Decompressing files
|
||||
|
||||
bunzip2 can decompress files with extensions bz2, bz, tbz2 and tbz. Files with tbz2 and tbz will end up with '.tar' extension after decompression.
|
||||
|
||||
bzip2 -dc performs the function of decompressing files to the stdout
|
||||
|
||||
### 7-zip ###
|
||||
|
||||
[7-zip][4] is another open source file archiver. It uses 7z format which is a new compression format and provides high-compression ratio. Hence, it is considered to be better than the previously mentioned compression tools. It is available under Linux as p7zip package. The package includes three binaries – 7z, 7za and 7zr. Refer to the [p7zip wiki][5] for differences between these binaries. In this article, we will be using 7zr to explain the usage. Archived files will have '.7z' extension.
|
||||
|
||||
**Basic usage**
|
||||
|
||||
#### a) Creating an archive ####
|
||||
|
||||
7zr a archive-name.7z file-name(s) / directory-name(s)
|
||||
|
||||
![7zr a](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-a.png)
|
||||
|
||||
Creating an archive
|
||||
|
||||
#### b) Listing an archive ####
|
||||
|
||||
7zr l archive-name.7z
|
||||
|
||||
![7zr l](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-l.png)
|
||||
|
||||
Listing an archive
|
||||
|
||||
#### c) Extracting an archive ####
|
||||
|
||||
7zr e archive-name.7z
|
||||
|
||||
![7zr e](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-e.png)
|
||||
|
||||
Extracting an archive
|
||||
|
||||
#### d) Updating an archive ####
|
||||
|
||||
7zr u archive-name.7z new-file
|
||||
|
||||
![7zr u](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-u.png)
|
||||
|
||||
Updating an archive
|
||||
|
||||
#### e) Deleting files from an archive ####
|
||||
|
||||
7zr d archive-name.7z file-to-be-deleted
|
||||
|
||||
![7zr d](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-d.png)
|
||||
|
||||
Deleting files
|
||||
|
||||
![7zr l](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-d-l.png)
|
||||
|
||||
Verifying file deletion
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/tools/linux-compress-decompress-tools/
|
||||
|
||||
作者:[B N Poornima][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/bnpoornima/
|
||||
[1]:http://www.gnu.org/software/tar/
|
||||
[2]:http://www.gzip.org/
|
||||
[3]:http://www.bzip.org/
|
||||
[4]:http://www.7-zip.org/
|
||||
[5]:https://wiki.archlinux.org/index.php/p7zip
|
@ -0,0 +1,125 @@
|
||||
在 Ubuntu中使用 APT-mirror 简单四步配置本地软件仓库
|
||||
================================================================================
|
||||
今天,我们将向你展示如何在你的 Ubuntu 个人电脑 或 Ubuntu 服务器 中,直接通过 Ubuntu 官方软件仓库来配置本地软件仓库。在你的电脑中创建一个本地软件仓库有着许多的好处。假如你有许多电脑需要安装软件,安全升级和修复,那么配置一个本地软件仓库是一个高效的方法。因为,所有需要安装的软件包都可以通过快速局域网连接从你的本地服务器中下载,这样可以节省你的网络带宽,降低互联网的年度开支 ...
|
||||
|
||||
你可以使用多种工具在你的本地个人电脑或服务器中配置一个 Ubuntu 的本地软件仓库,但在本教程中,我们将为你介绍 APT-Mirror。这里,我们将把默认的镜像包镜像到 我们本地的服务器或个人电脑中,并且在本地或外置硬盘中,我们至少需要 **120 GB** 或更多的可用空间。 上面的任务可以通过配置一个 **HTTP** 或 **FTP** 服务器来 与本地系统客户端共享软件包。
|
||||
|
||||
我们需要安装 Apache 网络服务器和 APT-Mirror 来使得我们的工作得以开始。下面是配置一个可工作的本地软件仓库的步骤:
|
||||
|
||||
### 1. 安装需要的软件包 ###
|
||||
|
||||
首先,我们需要从 Ubuntu 的公共软件包仓库中取得所有的软件包,然后在我们本地的 Ubuntu 服务器硬盘中保存它们。
|
||||
|
||||
首先我们安装一个网络服务器来承载我们的本地软件仓库。这里我们将安装 Apache 网络服务器,但你可以安装任何你中意的网络服务器,对于 http 协议,网络服务器是必须的。假如你需要配置 ftp 协议 及 rsync 协议,你还可以再分别额外安装 FTP 服务器,如 proftpd, vsftpd 等等 和 Rsync 。
|
||||
|
||||
$ sudo apt-get install apache2
|
||||
|
||||
然后我们需要安装 apt-mirror:
|
||||
|
||||
$ sudo apt-get install apt-mirror
|
||||
|
||||
![apt-mirror-installation](http://blog.linoxide.com/wp-content/uploads/2014/12/apt-mirror-install.png)
|
||||
|
||||
**注: 正如我先前提到的,我们需要至少 120 GB 的可用空间来使得所有的软件包被镜像或下载。**
|
||||
|
||||
### 2. 配置 APT-Mirror ###
|
||||
|
||||
现在,在你的硬盘上创建一个目录来保存所有的软件包。例如,我们创建一个名为 `/linoxide`的目录,我们将在这个目录中保存所有的软件包:
|
||||
|
||||
$ sudo mkdir /linoxide
|
||||
|
||||
![repo-dir](http://blog.linoxide.com/wp-content/uploads/2014/12/mkdir-linoxide.png)
|
||||
|
||||
现在,打开文件 **/etc/apt/mirror.list** :
|
||||
|
||||
$ sudo nano /etc/apt/mirror.list
|
||||
|
||||
![apt-mirror-edit](http://blog.linoxide.com/wp-content/uploads/2014/12/edit-mirror-list-300x7.png)
|
||||
|
||||
复制下面的命令行配置到 `mirror.list`文件中并按照你的需求进行修改:
|
||||
|
||||
############# config ##################
|
||||
#
|
||||
set base_path /linoxide
|
||||
#
|
||||
# set mirror_path $base_path/mirror
|
||||
# set skel_path $base_path/skel
|
||||
# set var_path $base_path/var
|
||||
# set cleanscript $var_path/clean.sh
|
||||
# set defaultarch <running host architecture>
|
||||
# set postmirror_script $var_path/postmirror.sh
|
||||
# set run_postmirror 0
|
||||
set nthreads 20
|
||||
set _tilde 0
|
||||
#
|
||||
############# end config ##############
|
||||
|
||||
deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
|
||||
deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
|
||||
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
|
||||
#deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
|
||||
#deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
|
||||
|
||||
deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
|
||||
deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
|
||||
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
|
||||
#deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
|
||||
#deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
|
||||
|
||||
clean http://archive.ubuntu.com/ubuntu
|
||||
|
||||
![mirror-list-config](http://blog.linoxide.com/wp-content/uploads/2014/12/mirror-list-config.png)
|
||||
|
||||
**注: 你可以将上面的官方镜像服务器网址更改为离你最近的服务器的网址,而这可以访问 [Ubuntu Mirror Server][1]来得到。假如你并不着急并可以等待镜像的完成,你可以沿用默认的官方镜像服务器网址。**
|
||||
|
||||
这里,我们将要镜像 最新和最大的 Ubuntu LTS 发行版 --- 即 Ubuntu 14.04 LTS (Trusty Tahr) --- 的软件包仓库,所以在上面的配置中发行版本号为 trusty 。假如我们需要镜像 Saucy 或其他的 Ubuntu 发行版本,请修改上面的 trusy 为相应的代号。
|
||||
|
||||
现在,我们必须运行 apt-mirror 来下载或镜像 官方仓库中的所有软件包。
|
||||
|
||||
sudo apt-mirror
|
||||
|
||||
从 Ubuntu 服务器中下载所有的软件包所花费的时间取决于 你和镜像服务器之间的网络连接速率和性能。我已经中断了下载,因为我已经下载好了 ...
|
||||
|
||||
![downloading-packages](http://blog.linoxide.com/wp-content/uploads/2014/12/downloading-index.png)
|
||||
|
||||
### 3.配置网络服务器 ###
|
||||
|
||||
为了使得其他的电脑能够取得这个软件仓库,你需要一个网络服务器。你也可以通过 ftp 来完成这件事,但我选择使用一个网络服务器因为在上面的步骤 1 中我提及到使用网络服务器。因此,我们现在要对 Apache 服务器进行配置:
|
||||
|
||||
我们将为我们本地的软件仓库目录 建立一个到 Apache 托管目录 --- 即 `/var/www/ubuntu` --- 的符号链接。
|
||||
|
||||
$ sudo ln -s /linoxide /var/www/ubuntu
|
||||
$ sudo service apache2 start
|
||||
|
||||
![symlinks-apache2](http://blog.linoxide.com/wp-content/uploads/2014/12/symblink-apache2.png)
|
||||
|
||||
上面的命令将允许我们从本地主机(localhost) --- 即 http://127.0.0.1(默认情况下) --- 浏览我们的镜像软件仓库。
|
||||
|
||||
### 4. 配置客户端 ###
|
||||
|
||||
最后,我们需要在其他的电脑中添加软件源,来使得它们可以从我们的电脑中取得软件包或软件仓库。为达到此目的,我们需要编辑 `/etc/apt/sources.list` 文件并添加下面的命令:
|
||||
|
||||
$ sudo nano /etc/apt/sources.list
|
||||
|
||||
添加下面的一行到` /etc/apt/sources.list`中并保存。
|
||||
|
||||
deb http://192.168.0.100/ubuntu/ trusty main restricted universe
|
||||
|
||||
**注: 这里的 192.168.0.100 是我们的服务器电脑的 局域网 IP 地址,你需要替换为你的服务器电脑的局域网 IP 地址**
|
||||
|
||||
$ sudo apt-get update
|
||||
|
||||
最终,我们完成了任务。现在,你可以使用`sudo apt-get install packagename` 命令来从你的本地 Ubuntu 软件仓库中安装所需的软件包,这将会是高速的且消耗很少的带宽。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/ubuntu-how-to/setup-local-repository-ubuntu/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[FSSlc](https://github.com/FSSlc)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
||||
[1]:https://launchpad.net/ubuntu/+archivemirrors
|
@ -0,0 +1,229 @@
|
||||
Linux 下最为人熟知的归档/压缩工具
|
||||
================================================================================
|
||||
很多时候,通过互联网发送或接收大文件和图片是一件令人头疼的事。压缩及解压缩工具正好可以应对这个问题。下面让我们快速浏览一些可以使得我们的工作更加轻松的开源工具。
|
||||
|
||||
Tar
|
||||
gzip, gunzip
|
||||
bzip2, bunzip2
|
||||
7-Zip
|
||||
|
||||
### Tar ###
|
||||
|
||||
Tar 由 'Tape archiver' 衍生而来,最初被用来在磁带上归档和存储文件。Tar 是一个 GNU 软件,它可以压缩一组文件(归档),或提取它们以及对已经存在的压缩文件进行相关操作。在存储、备份以及转移文件方面,它是很有帮助的。在创建归档文件时,Tar 可以保持原有文件和目录结构不变。通过 Tar 归档的文件的后缀名为 ‘.tar’。
|
||||
|
||||
基本用法
|
||||
|
||||
#### a) 创建归档 (c / --create) ####
|
||||
|
||||
tar --create --verbose --file=archive.tar file1 file2 file3
|
||||
|
||||
或
|
||||
|
||||
tar cvf archive.tar file1 file2 file3
|
||||
|
||||
![tar cvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-cvf.png)
|
||||
|
||||
创建一个归档
|
||||
|
||||
#### b) 列出归档文件内容 ( t / --list) ####
|
||||
|
||||
tar --list archive.tar
|
||||
|
||||
![tar tvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-tvf.png)
|
||||
|
||||
列出归档中包含的文件
|
||||
|
||||
#### c) 提取归档 (x / --extract) ####
|
||||
|
||||
tar xvf archive.tar
|
||||
|
||||
tar xvf archive.tar --wildcards '*.c' - 从归档中提取后缀名为 *.c 的文件。
|
||||
|
||||
![tar xvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-xvf.png)
|
||||
|
||||
提取文件
|
||||
|
||||
![tar xvf --wildcards](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-wildcard.png)
|
||||
|
||||
只提取需要的文件
|
||||
|
||||
#### d) 对归档进行更新 ( u / --update) ####
|
||||
|
||||
tar uvf archive.tar newfile.c - 假如归档的版本比先前存在的版本新,通过添加文件 newfile.c 来更新归档.
|
||||
|
||||
![tar uvf](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-uvf.png)
|
||||
|
||||
更新一个归档
|
||||
|
||||
#### e) 从归档中删除文件 (--delete) ####
|
||||
|
||||
tar--delete -f archive.tar file1.c - 从压缩包'archive.tar' 中删除文件'file1.c'
|
||||
|
||||
![tar --delete](http://blog.linoxide.com/wp-content/uploads/2015/01/tar-delete.png)
|
||||
|
||||
删除文件
|
||||
|
||||
更加具体的使用方法请参考[tar 主页][1]。
|
||||
|
||||
### Gzip / Gunzip ###
|
||||
|
||||
Gzip 代表 GNU zip,它是一个被广泛用于 Linux 操作系统中的压缩应用,被其压缩的文件的后缀名为'*.gz' 。
|
||||
|
||||
** 基本用法 **
|
||||
|
||||
#### a) 压缩文件 ####
|
||||
|
||||
gzip file(s)
|
||||
|
||||
每个文件将被单独压缩。
|
||||
|
||||
![gzip](http://blog.linoxide.com/wp-content/uploads/2015/01/gzip.png)
|
||||
|
||||
压缩文件
|
||||
|
||||
通常在压缩完成后,它会将原来的文件删除。我们可以使用 `-c` 选项来保留原来的文件。
|
||||
|
||||
gzip -c file > file.gz
|
||||
|
||||
![gzip-c](http://blog.linoxide.com/wp-content/uploads/2015/01/gzip-c.png)
|
||||
|
||||
压缩后保留原有文件
|
||||
|
||||
我们也可以将一组文件压缩到一个单独的文件中
|
||||
|
||||
cat file1 file2 file3 | gzip > archieve.gz
|
||||
|
||||
![gz group](http://blog.linoxide.com/wp-content/uploads/2015/01/gz-group.png)
|
||||
|
||||
压缩一组文件
|
||||
|
||||
#### b) 检查压缩比 ####
|
||||
|
||||
被压缩文件的压缩比可以使用 ‘-l’ 选项来进行检验。
|
||||
|
||||
gzip -l archieve.gz
|
||||
|
||||
![gzip -l](http://blog.linoxide.com/wp-content/uploads/2015/01/gzip-l.png)
|
||||
|
||||
检查压缩率
|
||||
|
||||
#### c) 解压文件 ####
|
||||
|
||||
Gunzip 被用来解压文件,在这里,原有文件在被解压后同样会被删除。使用 `-c`选项来保留原始文件。
|
||||
|
||||
gunzip -c archieve.gz
|
||||
|
||||
![gunzip -c](http://blog.linoxide.com/wp-content/uploads/2015/01/gunzip-c.png)
|
||||
|
||||
解压文件
|
||||
|
||||
gzip 加上'-d'选项 和 gunzip 对压缩文件有同样的效果。
|
||||
|
||||
更多细节可以从 [gzip 主页][2] 得到。
|
||||
|
||||
### Bzip2 / Bunzip2 ###
|
||||
|
||||
同 gzip 一样,[Bzip2][3] 也是一个压缩工具,与其他传统的工具相比,它可以将文件压缩到更小,但其缺点为:运行速度比 gzip 慢。
|
||||
|
||||
** 基本用法 **
|
||||
|
||||
#### a) 压缩文件 ####
|
||||
|
||||
一般情况下,针对压缩而言,Bzip2 没有选项可供选择,将被压缩的文件被传递为它的参数。每个文件被单独压缩,且压缩文件以 'bz2' 为后缀名。
|
||||
|
||||
bzip2 file1 file2 file3
|
||||
|
||||
![bzip2](http://blog.linoxide.com/wp-content/uploads/2015/01/bzip2.png)
|
||||
|
||||
文件压缩
|
||||
|
||||
使用 '-k' 选项可以使得 在压缩或解压缩之后保留原有的文件。
|
||||
|
||||
![bzip2 -k](http://blog.linoxide.com/wp-content/uploads/2015/01/bzip2-k.png)
|
||||
|
||||
在压缩后保留原有文件。
|
||||
|
||||
'-d' 选项被用来强制解压缩。
|
||||
|
||||
![bzip2 -d](http://blog.linoxide.com/wp-content/uploads/2015/01/bzip2-d.png)
|
||||
|
||||
使用 -d 选项删除文件 (!! 注:我(FSSlc)认为 这里的图片说明有误,可以参考 manpage或bzip 的官网来校对一下。)
|
||||
|
||||
#### b) 解压 ####
|
||||
|
||||
bunzip2 filename
|
||||
|
||||
![bunzip2](http://blog.linoxide.com/wp-content/uploads/2015/01/bunzip2.png)
|
||||
|
||||
解压文件
|
||||
|
||||
bunzip2 可以解压后缀名为 bz2, bz, tbz2 和 tbz 的文件。带有 tbz2 和 tbz 的文件在压缩后,后缀名将变为'.tar' 。
|
||||
|
||||
bzip2 -dc 执行解压文件到标准输出的功能。
|
||||
|
||||
### 7-zip ###
|
||||
|
||||
[7-zip][4] 是另一个开源压缩软件。它使用 7z 这种新的压缩格式,并支持高压缩比。因此,它被认为是比先前提及的压缩工具更好的软件。在 Linux 下,可以通过 p7zip 软件包得到,该软件包里包含 3 个二进制文件 – 7z, 7za 和 7zr,读者可以参考 [p7zip wiki][5] 来了解这三个二进制文件之间的不同。在本篇中,我们将使用 7zr 来解释 7-zip 的用法。归档文件以 '.7z' 为后缀名。
|
||||
|
||||
** 基本用法 **
|
||||
|
||||
#### a) 创建归档 ####
|
||||
|
||||
7zr a archive-name.7z file-name(s) / directory-name(s)
|
||||
|
||||
![7zr a](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-a.png)
|
||||
|
||||
创建一个归档文件
|
||||
|
||||
#### b) 列出归档包含文件 ####
|
||||
|
||||
7zr l archive-name.7z
|
||||
|
||||
![7zr l](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-l.png)
|
||||
|
||||
列出归档中包含的文件
|
||||
|
||||
#### c) 提取归档文件 ####
|
||||
|
||||
7zr e archive-name.7z
|
||||
|
||||
![7zr e](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-e.png)
|
||||
|
||||
提取归档
|
||||
|
||||
#### d) 更新归档文件 ####
|
||||
|
||||
7zr u archive-name.7z new-file
|
||||
|
||||
![7zr u](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-u.png)
|
||||
|
||||
更新一个归档文件
|
||||
|
||||
#### e) 从归档文件中删除文件 ####
|
||||
|
||||
7zr d archive-name.7z file-to-be-deleted
|
||||
|
||||
![7zr d](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-d.png)
|
||||
|
||||
删除文件
|
||||
|
||||
![7zr l](http://blog.linoxide.com/wp-content/uploads/2015/01/7zr-d-l.png)
|
||||
|
||||
确认文件删除
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/tools/linux-compress-decompress-tools/
|
||||
|
||||
作者:[B N Poornima][a]
|
||||
译者:[FSSlc](https://github.com/FSSlc)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/bnpoornima/
|
||||
[1]:http://www.gnu.org/software/tar/
|
||||
[2]:http://www.gzip.org/
|
||||
[3]:http://www.bzip.org/
|
||||
[4]:http://www.7-zip.org/
|
||||
[5]:https://wiki.archlinux.org/index.php/p7zip
|
Loading…
Reference in New Issue
Block a user