mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
20150225-4 选题
This commit is contained in:
parent
d27fb2ce44
commit
e8c24536a2
@ -0,0 +1,148 @@
|
||||
Linux FAQs with Answers--How to disable IPv6 on Linux
|
||||
================================================================================
|
||||
> **Question**: I notice that one of my applications is trying to establish a connection over IPv6. But since our local network is not able to route IPv6 traffic, the IPv6 connection times out, and the application falls back to IPv4, which causes unnecessary delay. As I don't have any need for IPv6 at the moment, I would like to disable IPv6 on my Linux box. What is a proper way to turn off IPv6 on Linux?
|
||||
|
||||
IPv6 has been introduced as a replacement of IPv4, the traditional 32-bit address space used in the Internet, to solve the imminent exhaustion of available IPv4 address space. However, since IPv4 has been used by every host or device connected to the Internet, it is practically impossible to switch every one of them to IPv6 overnight. Numerous IPv4 to IPv6 transition mechanisms (e.g., dual IP stack, tunneling, proxying) have been proposed to facilitate the adoption of IPv6, and many applications are being rewritten, as we speak, to add support for IPv6. One thing for sure is that IPv4 and IPv6 will inevitably coexist for the forseeable future.
|
||||
|
||||
Ideally the [ongoing IPv6 transition process][1] should not be visible to end users, but the mixed IPv4/IPv6 environment might sometimes cause you to encounter various hiccups originating from unintended interaction between IPv4 and IPv6. For example, you may experience timeouts from applications such as apt-get or ssh trying to unsuccessfully connecting via IPv6, DNS server accidentally dropping AAAA DNS records for IPv6, or your IPv6-capable device not compatible with your ISP's legacy IPv4 network, etc.
|
||||
|
||||
Of course this doesn't mean that you should blindly disable IPv6 on you Linux box. With all the benefits promised by IPv6, we as a society want to fully embrace it eventually, but as part of troubleshooting process for end-user experienced hiccups, you may try turning off IPv6 to see if indeed IPv6 is a culprit.
|
||||
|
||||
Here are a few techniques allowing you to disable IPv6 partially (e.g., for a certain network interface) or completely on Linux. These tips should be applicable to all major Linux distributions including Ubuntu, Debian, Linux Mint, CentOS, Fedora, RHEL, and Arch Linux.
|
||||
|
||||
### Check if IPv6 is Enabled on Linux ###
|
||||
|
||||
All modern Linux distributions have IPv6 automatically enabled by default. To see IPv6 is activated on your Linux, use ifconfig or ip commands. If you see "inet6" in the output of these commands, this means your Linux has IPv6 enabled.
|
||||
|
||||
$ ifconfig
|
||||
|
||||
![](https://farm8.staticflickr.com/7282/16415082398_5fb0920506_b.jpg)
|
||||
|
||||
$ ip addr
|
||||
|
||||
![](https://farm8.staticflickr.com/7290/16415082248_c4e075548b_c.jpg)
|
||||
|
||||
### Disable IPv6 Temporarily ###
|
||||
|
||||
If you want to turn off IPv6 temporarily on your Linux system, you can use /proc file system. By "temporarily", we mean that the change we make to disable IPv6 will not be preserved across reboots. IPv6 will be enabled back again after you reboot your Linux box.
|
||||
|
||||
To disable IPv6 for a particular network interface, use the following command.
|
||||
|
||||
$ sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/<interface-name>/disable_ipv6'
|
||||
|
||||
For example, to disable IPv6 for eth0 interface:
|
||||
|
||||
$ sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6'
|
||||
|
||||
![](https://farm8.staticflickr.com/7288/15982511863_0c1feafe7f_b.jpg)
|
||||
|
||||
To enable IPv6 back on eth0 interface:
|
||||
|
||||
$ sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6'
|
||||
|
||||
If you want to disable IPv6 system-wide for all interfaces including loopback interface, use this command:
|
||||
|
||||
$ sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
|
||||
|
||||
### Disable IPv6 Permanently across Reboots ###
|
||||
|
||||
The above method does not permanently disable IPv6 across reboots. IPv6 will be activated again once you reboot your system. If you want to turn off IPv6 for good, there are several ways you can do it.
|
||||
|
||||
#### Method One ####
|
||||
|
||||
The first method is to apply the above /proc changes persistently in /etc/sysctl.conf file.
|
||||
|
||||
That is, open /etc/sysctl.conf with a text editor, and add the following lines.
|
||||
|
||||
# to disable IPv6 on all interfaces system wide
|
||||
net.ipv6.conf.all.disable_ipv6 = 1
|
||||
|
||||
# to disable IPv6 on a specific interface (e.g., eth0, lo)
|
||||
net.ipv6.conf.lo.disable_ipv6 = 1
|
||||
net.ipv6.conf.eth0.disable_ipv6 = 1
|
||||
|
||||
To activate these changes in /etc/sysctl.conf, run:
|
||||
|
||||
$ sudo sysctl -p /etc/sysctl.conf
|
||||
|
||||
or simply reboot.
|
||||
|
||||
#### Method Two ####
|
||||
|
||||
An alternative way to disable IPv6 permanently is to pass a necessary kernel parameter via GRUB/GRUB2 during boot time.
|
||||
|
||||
Open /etc/default/grub with a text editor, and add "ipv6.disable=1" to GRUB_CMDLINE_LINUX variable.
|
||||
|
||||
$ sudo vi /etc/default/grub
|
||||
|
||||
----------
|
||||
|
||||
GRUB_CMDLINE_LINUX="xxxxx ipv6.disable=1"
|
||||
|
||||
In the above, "xxxxx" denotes any existing kernel parameter(s). Add "ipv6.disable=1" after them.
|
||||
|
||||
![](https://farm8.staticflickr.com/7286/15982512103_ec5d940e58_b.jpg)
|
||||
|
||||
Finally, don't forget to apply the modified GRUB/GRUB2 settings by running:
|
||||
|
||||
On Debian, Ubuntu or Linux Mint:
|
||||
|
||||
$ sudo update-grub
|
||||
|
||||
On Fedora, CentOS/RHEL:
|
||||
|
||||
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
|
||||
Now IPv6 will be completely disabled once you reboot your Linux system.
|
||||
|
||||
### Other Optional Steps after Disabling IPv6 ###
|
||||
|
||||
Here are a few optional steps you can consider after disabling IPv6. This is because while you disable IPv6 in the kernel, other programs may still try to use IPv6. In most cases, such application behaviors will not break things, but you want to disable IPv6 for them for efficiency or safety reason.
|
||||
|
||||
#### /etc/hosts ####
|
||||
|
||||
Depending on your setup, /etc/hosts may contain one or more IPv6 hosts and their addresses. Open /etc/hosts with a text editor, and comment out all lines which contain IPv6 hosts.
|
||||
|
||||
$ sudo vi /etc/hosts
|
||||
|
||||
----------
|
||||
|
||||
# comment these IPv6 hosts
|
||||
# ::1 ip6-localhost ip6-loopback
|
||||
# fe00::0 ip6-localnet
|
||||
# ff00::0 ip6-mcastprefix
|
||||
# ff02::1 ip6-allnodes
|
||||
# ff02::2 ip6-allrouters
|
||||
|
||||
#### Network Manager ####
|
||||
|
||||
If you are using NetworkManager to manage your network settings, you can disable IPv6 on NetworkManager as follows. Open the wired connection on NetworkManager, click on "IPv6 Settings" tab, and choose "Ignore" in "Method" field. Save the change and exit.
|
||||
|
||||
![](https://farm8.staticflickr.com/7293/16394993017_21917f027b_o.png)
|
||||
|
||||
#### SSH server ####
|
||||
|
||||
By default, OpenSSH server (sshd) tries to bind on both IPv4 and IPv6 addresses.
|
||||
|
||||
To force sshd to bind only on IPv4 address, open /etc/ssh/sshd_config with a text editor, and add the following line. inet is for IPv4 only, and inet6 is for IPv6 only.
|
||||
|
||||
$ sudo vi /etc/ssh/sshd_config
|
||||
|
||||
----------
|
||||
|
||||
AddressFamily inet
|
||||
|
||||
and restart sshd server.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/disable-ipv6-linux.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
||||
[1]:http://www.google.com/intl/en/ipv6/statistics.html
|
@ -0,0 +1,97 @@
|
||||
Linux FAQs with Answers--How to fix “fatal error: lame/lame.h: No such file or directory” on Linux
|
||||
================================================================================
|
||||
> **Question**: I am trying to compile video encoder software on Linux, but the compilation fails with a message saying "fatal error: lame/lame.h: No such file or directory." How can I fix this error?
|
||||
|
||||
The following compilation error suggests that your Linux system does not have LAME library and its development files installed.
|
||||
|
||||
fatal error: lame/lame.h: No such file or directory
|
||||
|
||||
[LAME][1] (short for "LAME Ain't an MP3 Encoder") is a popular MP3 encoding codec licensed with LGPL. Many video encoding/ripping tools use or support LAME. Among them are [FFmpeg][2], VLC, [Audacity][3], K3b, RipperX, and many more.
|
||||
|
||||
To fix the compilation error, you need to install LAME library and its development files, as shown in the following.
|
||||
|
||||
### Install LAME Library and its Development Files on Debian, Ubuntu or Linux Mint ###
|
||||
|
||||
Debian and its derivative systems offer LAME library in their base repositories, so it is easy to install LAME with apt-get.
|
||||
|
||||
$ sudo apt-get install libmp3lame-dev
|
||||
|
||||
### Install LAME Library and its Development Files on Fedora, CentOS/RHEL ###
|
||||
|
||||
On Red Hat based distributions, the LAME encoder library is available via the RPM Fusion's free repository. Thus you first need to set up [RPM Fusion (free) repository][4] before proceeding.
|
||||
|
||||
Once RPM Fusion is set up, install LAME development files as follows.
|
||||
|
||||
$ sudo yum --enablerepo=rpmfusion-free-updates install lame-devel
|
||||
|
||||
As of February, 2015, RPM Fusion repository is not yet available for CentOS/RHEL 7. So this method will not be applicable on CentOS/RHEL 7. In that case, you can install LAME library by building it from the source (which is described below).
|
||||
|
||||
### Compile LAME Library from the Source on Debian, Ubuntu or Linux Mint ###
|
||||
|
||||
If you want to install customized LAME library with different compilation options, you need to build it yourself. Here is how you can compile and install LAME library (along with its header files) on your Debian-based system.
|
||||
|
||||
$ sudo apt-get install gcc git
|
||||
$ wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
|
||||
$ tar -xzf lame-3.99.5.tar.gz
|
||||
$ cd lame-3.99.5
|
||||
$ ./configure --enable-static --enable-shared
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
Note that when you run configure in the above steps, you can enable or disable various options based on your needs. Run the following command to see all available compilation options.
|
||||
|
||||
$ ./configure --help
|
||||
|
||||
The shared/static LAME libraries are installed in /usr/local/lib by default. To make the shared library accessible to other applications, complete this last step:
|
||||
|
||||
Open /etc/ld.so.conf with your favorite text editor, and append the following line.
|
||||
|
||||
/usr/local/lib
|
||||
|
||||
and then run the command below. This will add shared libraries in /usr/local/lib to the dynamic loader cache, thereby making shared LAME library accessible to other applications.
|
||||
|
||||
$ sudo ldconfig
|
||||
|
||||
### Compile LAME Library from the Source on Fedora or CentOS/RHEL ###
|
||||
|
||||
If your distribution (e.g., CentOS 7) does not offer a pre-built LAME library package, or you want to customize LAME library in any way, you need to build it from the source yourself. Here is how to compile and install LAME library and its development files on a Red Hat based system.
|
||||
|
||||
$ sudo yum install gcc git
|
||||
$ wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
|
||||
$ tar -xzf lame-3.99.5.tar.gz
|
||||
$ cd lame-3.99.5
|
||||
$ ./configure --enable-static --enable-shared
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
Before running make, feel free to customize compilation options by running configure with appropriate options. You can check available options with:
|
||||
|
||||
$ ./configure --help
|
||||
|
||||
Finally, you need to complete the last step because the shared LAME library installed in /usr/local/lib may not be visible to other applications.
|
||||
|
||||
Append the following line in /etc/ld.so.conf:
|
||||
|
||||
/usr/local/lib
|
||||
|
||||
and then run the command below. This will add shared libraries (including LAME) in /usr/local/lib to the dynamic loader cache, making them visible to other applications.
|
||||
|
||||
$ sudo ldconfig
|
||||
|
||||
![](https://farm8.staticflickr.com/7340/16534478445_abc97cb65a_c.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/fatal-error-lame-no-such-file-or-directory.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
||||
[1]:http://lame.sourceforge.net/
|
||||
[2]:http://ask.xmodulo.com/compile-ffmpeg-ubuntu-debian.html
|
||||
[3]:http://xmodulo.com/how-to-cut-split-or-edit-mp3-file-on-linux.html
|
||||
[4]:http://xmodulo.com/how-to-install-rpm-fusion-on-fedora.html
|
@ -0,0 +1,63 @@
|
||||
Linux FAQs with Answers--How to install a USB webcam in Raspberry Pi
|
||||
================================================================================
|
||||
> **Question**: Can I use a standard USB-based webcam on Raspberry Pi? How can I check if my USB webcam is compatible with Raspberry Pi, and how can I install it on Raspberry Pi?
|
||||
|
||||
If you want to take pictures or record videos using Raspberry Pi board, you can install [Raspberry Pi camera board][1]. If you do not want to shell out money just for the camera board module, there is yet another way, which is to utilize a commonly found [USB web camera][2]. You may already have one for your PC.
|
||||
|
||||
In this tutorial, we show how to set up a USB web camera on Raspberry Pi board. We assume that you are using Raspbian operation system.
|
||||
|
||||
Before we start, it is better to check if your USB web camera is [one of those][3] which are known to be compatible with Raspberry Pi. If your USB webcam is not found in the compatibility list, don't be discouraged, as there is still a chance that your USB web camera may be detected by Raspberry Pi.
|
||||
|
||||
### Check if a USB Webcam is Compatible with Raspberry Pi ###
|
||||
|
||||
To check whether your USB web camera is detected on Raspberry Pi or not, plug it into the USB port of your Raspberry Pi, and type lsusb command in the terminal.
|
||||
|
||||
$ lsusb
|
||||
|
||||
If the output of the command does not list your webcam, there is a possibility that this is because your Raspberry Pi doesn't supply enough power needed for your USB web camera. In this case, you can try using a separate power line for the USB web camera, such as [USB power hub][4], and then repeat the lsusb command. If the USB webcam is still not recognized, we can only suggest you buy another USB web camera which is supported by Raspberry Pi.
|
||||
|
||||
![](https://farm8.staticflickr.com/7408/16576646025_898f17f36e_o.png)
|
||||
|
||||
In the above screenshot, the USB web camera is detected as "1e4e:0102", but it doesn't show the maker or the name of the web camera. When we try it with Fedora 20 in a laptop, it is successfully detected as "1e4e:0102 Cubeternet GL-UPC822 UVC WebCam."
|
||||
|
||||
Another way to check if your USB web camera is supported by Raspberry Pi is by checking the /dev directory. If there is /dev/video0, this implies that your USB webcam is recognized by Raspberry Pi.
|
||||
|
||||
### Take a Picture with USB Webcam ###
|
||||
|
||||
After your USB webcam is successfully hooked up with Raspberry Pi, the next thing to do is to take some pictures to verify its functionality.
|
||||
|
||||
For this, you can install fswebcam, which is a small webcam application. You can install fswebcam directly from the Raspbian repository as follows.
|
||||
|
||||
$ sudo apt-get install fswebcam
|
||||
|
||||
Once fswebcam is installed, run the following command in a terminal to capture a picture from the USB webcam:
|
||||
|
||||
$ fswebcam --no-banner -r 640x480 image.jpg
|
||||
|
||||
This command will capture a picture with 640x480 resolution, and save it as image.jpg. It will not put any banner in the bottom part of the picture.
|
||||
|
||||
![](https://farm8.staticflickr.com/7417/16576645965_302046d230_o.png)
|
||||
|
||||
Here is the result from the fswebcam command with 640x480 resolution.
|
||||
|
||||
![](https://farm8.staticflickr.com/7345/16575497512_8d77f1b34c_o.jpg)
|
||||
|
||||
The next example picture is captured without defining the resolution. The picture color is blueish, and the default resolution is only 358x288.
|
||||
|
||||
![](https://farm8.staticflickr.com/7390/15954067124_760fbcdd9c_o.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/install-usb-webcam-raspberry-pi.html
|
||||
|
||||
作者:[Kristophorus Hadiono][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/kristophorus
|
||||
[1]:http://xmodulo.com/install-raspberry-pi-camera-board.html
|
||||
[2]:http://xmodulo.com/go/usb_webcam
|
||||
[3]:http://elinux.org/RPi_USB_Webcams
|
||||
[4]:http://xmodulo.com/go/usb_powerhub
|
@ -0,0 +1,58 @@
|
||||
Linux FAQs with Answers--How to install full kernel source on Debian or Ubuntu
|
||||
================================================================================
|
||||
> **Question**: I need to download and install a full kernel source tree to compile a custom kernel for my Debian or Ubuntu system. What is a proper way to download full kernel source on Debian or Ubuntu?
|
||||
|
||||
Before installing full kernel source on your Linux system, ask yourself whether you really need the full kernel source. If you are trying to compile a kernel module or a custom driver for your kernel, you do not need the full kernel source. You only need to install [matching kernel header files][1], and that's it.
|
||||
|
||||
You need the full kernel source tree only if you want to build a custom kernel after modifying the kernel code in any way and/or tweaking default kernel options.
|
||||
|
||||
Here is how to **download and install full kernel source tree from Debian or Ubuntu repositories**. While you can download the official kernel source code from [https://www.kernel.org/pub/linux/kernel/][2], using distro's repositories allows you to download a kernel source with the maintainer's patches applied to it.
|
||||
|
||||
### Install Full Kernel Source on Debian ###
|
||||
|
||||
Before downloading kernel source, install dpkg-dev, which contains a suite of development tools needed to build Debian source packages. Among other things, dpkg-dev contains dpgk-source tool which can extract a Debian source package and automatically apply patches.
|
||||
|
||||
$ sudo apt-get install dpkg-dev
|
||||
|
||||
Next, run the following command to download full kernel source.
|
||||
|
||||
$ apt-get source linux-image-$(uname -r)
|
||||
|
||||
Along with the full kernel source (linux_X.X.XX.orig.tar.xz), any available kernel patches (linux_X.X.X+XXX.debian.tar.xz) and source control file (linux_XXXX.dsc) will also be downloaded and stored in the current directory. The .dsc file instructs how the patches are applied to the kernel sources.
|
||||
|
||||
Upon the completion of download, the above command will automatically invoke dpkg-source tool, which will unpack the downloaded kernel source in the current directory, and apply downloaded patches according to .dsc file.
|
||||
|
||||
The final full kernel source tree will be available in the current directory as "linux-X.X.XX".
|
||||
|
||||
![](https://farm9.staticflickr.com/8676/16341110300_b4f059eeb0_b.jpg)
|
||||
|
||||
### Install Full Kernel Source on Ubuntu ###
|
||||
|
||||
If you want to install full kernel source, the Debian way described above should work on Ubuntu as well.
|
||||
|
||||
There is another way to download full kernel source on Ubuntu. You can actually check out the kernel source tree maintained by Canonical for different Ubuntu releases.
|
||||
|
||||
$ sudo apt-get install git
|
||||
$ git clone git://kernel.ubuntu.com/ubuntu/ubuntu-$(lsb_release --codename | cut -f2).git
|
||||
|
||||
For example, if you are using Ubuntu 14.04, the above command will check out code from "ubuntu-trusty" Git repository.
|
||||
|
||||
![](https://farm9.staticflickr.com/8642/16526856391_de636ff9b8_c.jpg)
|
||||
|
||||
Once you check out the Git repository, use the following command to install necessary development packages to meet the build dependencies for the kernel source tree.
|
||||
|
||||
$ sudo apt-get build-dep linux-image-$(uname -r)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/install-full-kernel-source-debian-ubuntu.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
||||
[1]:http://ask.xmodulo.com/install-kernel-headers-linux.html
|
||||
[2]:https://www.kernel.org/pub/linux/kernel/
|
Loading…
Reference in New Issue
Block a user