分类 技术 下的文章

linux中的tar命令

tar(磁带归档)命令是linux系统中被经常用来将文件存入到一个归档文件中的命令。

其常见的文件扩展包括:.tar.gz 和 .tar.bz2, 分别表示通过了gzip或bzip算法进一步进行了压缩。

在本教程中我们会管中窥豹一下在linux桌面或服务器版本中使用tar命令来处理一些创建和解压归档文件的日常工作的例子。

使用tar命令

tar命令在大部分linux系统默认情况下都是可用的,所以你不用单独安装该软件。

tar命令具有两个压缩格式,gzip和bzip,该命令的“z”选项用来指定gzip,“j”选项用来指定bzip。同时也可以创建非压缩归档文件。

1.解压一个tar.gz归档

一般常见的用法是用来解压归档文件,下面的命令将会把文件从一个tar.gz归档文件中解压出来。

$ tar -xvzf tarfile.tar.gz

这里对这些参数做一个简单解释-

x - 解压文件

v - 冗长模式,在解压每个文件时打印出文件的名称。

z - 该文件是一个使用 gzip 压缩的文件。

f - 使用接下来的tar归档来进行操作。

这些就是一些需要记住的重要选项。

解压 tar.bz2/bzip 归档文件

具有bz2扩展名的文件是使用bzip算法进行压缩的,但是tar命令也可以对其进行处理,但是需要通过使用“j”选项来替换“z”选项。

$ tar -xvjf archivefile.tar.bz2

2.将文件解压到一个指定的目录或路径

为了将文件解压到一个指定的目录中,使用“-C”选项来指定路径,此处的“C”是大写“C”。

$ tar -xvzf abc.tar.gz -C /opt/folder/

然后,首先需要确认目标目录是否存在,毕竟tar命令并不会为你创建目录,所以如果目标目录不存在的情况下该命令会失败。

3. 提取出单个文件

为了从一个归档文件中提取出单个文件,只需要将文件名按照以下方式将其放置在命令后面。

$ tar -xz -f abc.tar.gz "./new/abc.txt"

在上述命令中,可以按照以下方式来指定多个文件。

$ tar -xz -f abc.tar.gz "./new/cde.txt" "./new/abc.txt"

4.使用通配符来解压多个文件

通配符可以用来解压于给定通配符匹配的一批文件,例如所有以".txt"作为扩展名的文件。

$ tar -xz -f abc.tar.gz --wildcards "*.txt"

5. 列出并检索tar归档文件中的内容

如果你仅仅想要列出而不是解压tar归档文件的中的内容,使用“-t”(test)选项, 下面的命令用来打印一个使用gzip压缩过的tar归档文件中的内容。

$ tar -tz -f abc.tar.gz
./new/
./new/cde.txt
./new/subdir/
./new/subdir/in.txt
./new/abc.txt
...

可以将输出通过管道定向到grep来搜索一个文件,或者定向到less命令来浏览内容列表。 使用"v"冗长选项将会打印出每个文件的额外详细信息。

对于 tar.bz2/bzip文件,需要使用"j"选项。

结合上述的命令和grep命令来检索归档文件,如下所示。简单吧!

$ tar -tvz -f abc.tar.gz | grep abc.txt
-rw-rw-r-- enlightened/enlightened 0 2015-01-13 11:40 ./new/abc.txt

6.创建一个tar/tar.gz归档文件

现在我们已经学过了如何解压一个tar归档文件,是时候开始创建一个新的tar归档文件了。tar命令可以用来将所选的文件或整个目录放入到一个归档文件中,以下是相应的样例。

下面的命令使用一个目录来创建一个tar归档文件,它会将该目录中所有的文件和子目录都加入到归档文件中。

$ tar -cvf abc.tar ./new/
./new/
./new/cde.txt
./new/abc.txt

上述命令不会创建一个压缩的的归档文件,只是一个普通的归档文件,只是将多个文件放入到一个归档文件中并没有真正地压缩每个文件。

为了使用压缩,可以分别使用“z”或“j”选项进行gzip或bzip压缩算法。

$ tar -cvzf abc.tar.gz ./new/
文件的扩展名其实并不真正有什么影响。“tar.gz” 和“tgz”是gzip压缩算法压缩文件的常见扩展名。 “tar.bz2”和“tbz”是bzip压缩算法压缩文件的常见扩展名(LCTT 译注:归档是否是压缩的和采用哪种压缩方式并不取决于其扩展名,扩展名只是为了便于辨识。)。

7. 在添加文件之前进行确认

一个有用的选项是“w”,该选项使得tar命令在添加每个文件到归档文件之前来让用户进行确认,有时候这会很有用。

使用该选项时,只有用户输入“y”时的文件才会被加入到归档文件中,如果你不输入任何东西,其默认表示是一个“n”。

# 添加指定文件

$ tar -czw -f abc.tar.gz ./new/*
add ‘./new/abc.txt’?y
add ‘./new/cde.txt’?y
add ‘./new/newfile.txt’?n
add ‘./new/subdir’?y
add ‘./new/subdir/in.txt’?n

#现在列出所有被加入的文件

$ tar -t -f abc.tar.gz 
./new/abc.txt
./new/cde.txt
./new/subdir/

8. 加入文件到存在的归档文件中

“r”选项可以被用来将文件加入到已存在的归档文件中,而不用创建一个新的归档文件,下面是一个简单的样例:

$ tar -rv -f abc.tar abc.txt
文件并不能加入到已压缩的归档文件中(gz 或 bzip)。文件只能被加入到普通的归档文件中。

9. 将文件加入到压缩的归档文件中(tar.gz/tar.bz2)

之前已经提到了不可能将文件加入到已压缩的归档文件中,然而依然可以通过简单的一些把戏来完成。使用gunzip命令来解压缩归档文件,然后将文件加入到归档文件中后重新进行压缩。

$ gunzip archive.tar.gz
$ tar -rf archive.tar ./path/to/file
$ gzip archive.tar

对于bzip文件分别使用bzip2和bunzip2。

10.通过tar来进行备份

一个真实的场景是在固定的时间间隔内来备份目录,tar命令可以通过cron调度来实现这样的一个备份,以下是一个样例 :

$ tar -cvz -f archive-$(date +%Y%m%d).tar.gz ./new/

使用cron来运行上述的命令会保持创建类似以下名称的备份文件 :'archive-20150218.tar.gz'。

当然,需要确保日益增长的归档文件不会导致磁盘空间的溢出。

11. 在创建归档文件时进行验证

"W"选项可以用来在创建归档文件之后进行验证,以下是一个简单例子。

$ tar -cvW -f abc.tar ./new/
./new/
./new/cde.txt
./new/subdir/
./new/subdir/in.txt
./new/newfile.txt
./new/abc.txt
Verify ./new/
Verify ./new/cde.txt
Verify ./new/subdir/
Verify ./new/subdir/in.txt
Verify ./new/newfile.txt                                                                                                                              
Verify ./new/abc.txt

需要注意的是验证动作不能在压缩过的归档文件上进行,只能在非压缩的tar归档文件上执行。

这次就先到此为止,可以通过“man tar”命令来查看tar命令的的手册。


via: http://www.binarytides.com/linux-tar-command/

作者:Silver Moon 译者:theo-l 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出

通常,大多数默认设置安装的web服务器存在信息泄露,这其中之一就是PHP。PHP 是如今流行的服务端html嵌入式语言(之一?)。在如今这个充满挑战的时代,有许多攻击者会尝试发现你服务端的漏洞。因此,我会简单描述如何在Linux服务器中隐藏PHP信息。

默认上expose\_php默认是开的。关闭“expose\_php”参数可以使php隐藏它的版本信息。

[root@centos66 ~]# vi /etc/php.ini

在你的php.ini, 定位到含有expose\_php的那行把On设成Off:

expose_php = Off

在此之前,web服务器头看上去就像这样:

[root@centos66 ~]# curl -I http://www.ehowstuff.com/

HTTP/1.1 200 OK
Server: nginx
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.3
X-Pingback: http://www.ehowstuff.com/xmlrpc.php
Date: Wed, 11 Feb 2015 14:10:43 GMT
X-Page-Speed: 1.9.32.2-4321
Cache-Control: max-age=0, no-cache

更改并重启 Web 服务后,php就不会在web服务头中显示版本了:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 11 Feb 2015 15:38:14 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
X-Pingback: http://www.ehowstuff.com/xmlrpc.php
Date: Wed, 11 Feb 2015 14:10:43 GMT
X-Page-Speed: 1.9.32.2-4321
Cache-Control: max-age=0, no-cache

LCTT译注:除了 PHP 的版本之外,Web 服务器也会默认泄露版本号。如果使用 Apache 服务器,请参照此文章关闭Apache 版本显示;如果使用 Nginx 服务器,请在 http 段内加入server_tokens off; 配置。以上修改请记得重启相关服务。


via: http://www.ehowstuff.com/how-to-hide-php-version-in-linux/

作者:skytech 译者:geekpi 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出

大多数情况下你可以从BIOS、产品目录或者干脆手动找出你的系统所持的最大内存。这里,我们介绍一种简单有用的技巧——使用dmidecode来找出系统支持的最大内存,这样你就无需打开机箱或者参照BIOS和产品目录了。

什么是 dmidecode?

就像你可能知道的一样, dmidecode是一个将计算机DMI(又名SMBIOS)表的内容转换为可读格式的工具。这个表包含了系统硬件组件的介绍以及其他一些如序列号和IOS版本等有用的信息。使用dmidecode你能够获取此项信息,而无需去探测真实的硬件。

找出你的系统所支持的最大内存

请确定你已经在系统中安装了dmidecode,我觉得你的操作系统应该已经自动安装过了,不过并不非常确定。

在基于Deb的系统中安装

sudo apt-get install dmidecode

在基于RPM的系统中安装

sudo yum install dmidecode

在SUSE/openSUSE中安装

sudo zypper in dmidecode

好了,我们已经安装了dmidecode,接下来让我们找出支持的最大内存。输入以下命令:

sudo dmidecode -t 16

输出样本

# dmidecode 2.12
SMBIOS 2.6 present.

Handle 0x0014, DMI type 16, 15 bytes
Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: None
    Maximum Capacity: 16 GB
    Error Information Handle: Not Provided
    Number Of Devices: 2

就像你看到的,我的系统支持最大内存到16G,并且有两个内存插槽,简单吧?

接下来,让我们找出现在已经安装的内存的详细信息。

sudo dmidecode -t 17

输出样本

# dmidecode 2.12
SMBIOS 2.6 present.

Handle 0x0017, DMI type 17, 28 bytes
Memory Device
    Array Handle: 0x0014
    Error Information Handle: 0x0000
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: DIMM_B
    Bank Locator: BANK 2
    Type: Unknown
    Type Detail: None
    Speed: Unknown
    Manufacturer: Not Specified
    Serial Number: Not Specified
    Asset Tag: Not Specified
    Part Number: Not Specified
    Rank: Unknown

Handle 0x0015, DMI type 17, 28 bytes
Memory Device
    Array Handle: 0x0014
    Error Information Handle: 0x0000
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 4096 MB
    Form Factor: SODIMM
    Set: None
    Locator: DIMM_A
    Bank Locator: BANK 0
    Type: DDR3
    Type Detail: Synchronous
    Speed: 1067 MHz
    Manufacturer: 014F
    Serial Number: 00092AF2
    Asset Tag: 54114000     
    Part Number: JM1066KSN-4G      
    Rank: Unknown

就像上边输出的一样,我在插槽1里边安装了一个内存条。内存大小为4G,类型为DDR3,速度为1067 MHz

同样的,我们可以通过下边命令得到完整的内存信息。

sudo dmidecode -t memory
sudo dmidecode -t memory | less
sudo dmidecode -t memory | more

输出样本

# dmidecode 2.12
SMBIOS 2.6 present.

Handle 0x0014, DMI type 16, 15 bytes
Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: None
    Maximum Capacity: 16 GB
    Error Information Handle: Not Provided
    Number Of Devices: 2

Handle 0x0017, DMI type 17, 28 bytes
Memory Device
    Array Handle: 0x0014
    Error Information Handle: 0x0000
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: DIMM_B
    Bank Locator: BANK 2
    Type: Unknown
    Type Detail: None
    Speed: Unknown
    Manufacturer: Not Specified
    Serial Number: Not Specified
    Asset Tag: Not Specified
    Part Number: Not Specified
    Rank: Unknown

Handle 0x0015, DMI type 17, 28 bytes
Memory Device
    Array Handle: 0x0014
    Error Information Handle: 0x0000
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 4096 MB
    Form Factor: SODIMM
    Set: None
    Locator: DIMM_A
    Bank Locator: BANK 0
    Type: DDR3
    Type Detail: Synchronous
    Speed: 1067 MHz
    Manufacturer: 014F
    Serial Number: 00092AF2
    Asset Tag: 54114000     
    Part Number: JM1066KSN-4G      
    Rank: Unknown

如果你好奇想要知道整个系统的详细信息,例如主板、内存、BIOS等,那么可以输入以下命令来获取。

sudo dmidecode

输出样本

# dmidecode 2.12
SMBIOS 2.6 present.
48 structures occupying 2173 bytes.
Table at 0x000EB840.

Handle 0xDA00, DMI type 218, 251 bytes
OEM-specific Type
    Header and Data:
        DA FB 00 DA B2 00 0D 5F 0F 37 40 7D 00 00 00 00
        00 7E 00 01 00 00 00 DC 01 00 80 02 00 DD 01 00
        80 03 00 75 01 01 80 01 00 76 01 02 80 01 00 2D
        01 03 80 01 00 2E 01 03 80 00 00 81 01 07 80 00
        00 82 01 07 80 01 00 83 01 08 80 00 00 84 01 08
        80 01 00 85 01 06 80 00 00 86 01 06 80 01 00 58
        02 05 80 00 00 57 02 05 80 01 00 9C 00 02 00 01
        00 9B 00 02 00 00 00 8A 01 03 00 01 00 89 01 03
        00 00 00 7F 01 04 00 00 00 80 01 04 00 01 00 53
        01 05 00 00 00 52 01 05 00 01 00 7B 01 06 00 00
        00 7C 01 06 00 01 00 94 01 07 00 00 00 93 01 07
        00 01 00 7D 00 08 00 00 00 2D 00 09 00 01 00 2E
        00 09 00 00 00 6E 00 0A 00 00 00 95 00 0B 00 01
        00 96 00 0B 00 00 00 2F 02 0C 00 01 00 30 02 0C
        00 00 00 50 02 0D 00 00 00 51 02 0D 00 01 00 52
        02 0D 00 02 00 FF FF 00 00 00 00

Handle 0xDA01, DMI type 218, 59 bytes
OEM-specific Type
    Header and Data:
        DA 3B 01 DA B2 00 0D 5F 0F 37 40 53 02 0D 00 03
        00 54 02 0D 00 04 00 56 02 0D 00 05 00 4B 01 0E
        00 01 00 4A 01 0E 00 00 00 EA 00 0F 00 01 00 EB
        00 0F 00 00 00 FF FF 00 00 00 00

Handle 0x0004, DMI type 4, 42 bytes
Processor Information
    Socket Designation: CPU 1
    Type: Central Processor
    Family: Core i3
    Manufacturer: Intel            
    ID: A7 06 03 01 FF FB AB BE
    Signature: Type 0, Family 6, Model 42, Stepping 7
    Flags:
        FPU (Floating-point unit on-chip)
        VME (Virtual mode extension)
        DE (Debugging extension)
        PSE (Page size extension)
        TSC (Time stamp counter)
        MSR (Model specific registers)
        PAE (Physical address extension)
        MCE (Machine check exception)
        CX8 (CMPXCHG8 instruction supported)
        APIC (On-chip APIC hardware supported)
        SEP (Fast system call)
        MTRR (Memory type range registers)
        PGE (Page global enable)
        MCA (Machine check architecture)
        CMOV (Conditional move instruction supported)
        PAT (Page attribute table)
        PSE-36 (36-bit page size extension)
        CLFSH (CLFLUSH instruction supported)
        DS (Debug store)
        ACPI (ACPI supported)
        MMX (MMX technology supported)
        FXSR (FXSAVE and FXSTOR instructions supported)
        SSE (Streaming SIMD extensions)
        SSE2 (Streaming SIMD extensions 2)
        SS (Self-snoop)
        HTT (Multi-threading)
        TM (Thermal monitor supported)
        PBE (Pending break enabled)
    Version: Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz       
    Voltage: 1.1 V
    External Clock: 100 MHz
    Max Speed: 2300 MHz
    Current Speed: 2300 MHz
    Status: Populated, Enabled
    Upgrade: Other
    L1 Cache Handle: 0x0005
    L2 Cache Handle: 0x0006
    L3 Cache Handle: 0x0007
    Serial Number: To Be Filled By O.E.M.
    Asset Tag: To Be Filled By O.E.M.
    Part Number: To Be Filled By O.E.M.
    Core Count: 2
    Core Enabled: 1
    Thread Count: 2
    Characteristics:
        64-bit capable

Handle 0x0005, DMI type 7, 19 bytes
Cache Information
    Socket Designation: L1-Cache
    Configuration: Enabled, Not Socketed, Level 1
    Operational Mode: Write Back
    Location: Internal
    Installed Size: 64 kB
    Maximum Size: 64 kB
    Supported SRAM Types:
        Other
    Installed SRAM Type: Other
    Speed: Unknown
    Error Correction Type: None
    System Type: Unified
    Associativity: 8-way Set-associative

Handle 0x0006, DMI type 7, 19 bytes
Cache Information
    Socket Designation: L2-Cache
    Configuration: Enabled, Not Socketed, Level 2
    Operational Mode: Varies With Memory Address
    Location: Internal
    Installed Size: 512 kB
    Maximum Size: 512 kB
    Supported SRAM Types:
        Other
    Installed SRAM Type: Other
    Speed: Unknown
    Error Correction Type: None
    System Type: Unified
    Associativity: 8-way Set-associative

Handle 0x0007, DMI type 7, 19 bytes
Cache Information
    Socket Designation: L3-Cache
    Configuration: Enabled, Not Socketed, Level 3
    Operational Mode: Varies With Memory Address
    Location: Internal
    Installed Size: 3072 kB
    Maximum Size: 3072 kB
    Supported SRAM Types:
        Other
    Installed SRAM Type: Other
    Speed: Unknown
    Error Correction Type: None
    System Type: Unified
    Associativity: Other

Handle 0x0008, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J1A1
    Internal Connector Type: None
    External Reference Designator: PS2Mouse
    External Connector Type: PS/2
    Port Type: Mouse Port

Handle 0x0009, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J1A1
    Internal Connector Type: None
    External Reference Designator: Keyboard
    External Connector Type: PS/2
    Port Type: Keyboard Port

Handle 0x000A, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J2A2B
    Internal Connector Type: None
    External Reference Designator: Video
    External Connector Type: DB-15 female
    Port Type: Video Port

Handle 0x000B, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J3A1
    Internal Connector Type: None
    External Reference Designator: USB1
    External Connector Type: Access Bus (USB)
    Port Type: USB

Handle 0x000C, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J3A1
    Internal Connector Type: None
    External Reference Designator: USB2
    External Connector Type: Access Bus (USB)
    Port Type: USB

Handle 0x000D, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J3A1
    Internal Connector Type: None
    External Reference Designator: USB3
    External Connector Type: Access Bus (USB)
    Port Type: USB

Handle 0x000E, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J5A1
    Internal Connector Type: None
    External Reference Designator: LAN
    External Connector Type: RJ-45
    Port Type: Network Port

Handle 0x000F, DMI type 9, 17 bytes
System Slot Information
    Designation: J6B2
    Type: x16 PCI Express
    Current Usage: In Use
    Length: Long
    ID: 0
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:00:01.0

Handle 0x0010, DMI type 9, 17 bytes
System Slot Information
    Designation: J6B1
    Type: x1 PCI Express
    Current Usage: In Use
    Length: Short
    ID: 1
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:00:1c.3

Handle 0x0012, DMI type 11, 5 bytes
OEM Strings
    String 1: Dell System
    String 2: 5[0003]
    String 3: 13[P18F]

Handle 0x0013, DMI type 12, 5 bytes
System Configuration Options
    Option 1: To Be Filled By O.E.M.

Handle 0x001C, DMI type 21, 7 bytes
Built-in Pointing Device
    Type: Touch Pad
    Interface: Bus Mouse
    Buttons: 2

Handle 0x001D, DMI type 22, 26 bytes
Portable Battery
    Location: Sys. Battery Bay
    Manufacturer: Sanyo              
    Serial Number: 5390     
    Name: DELL 4YRJH22
    Chemistry: Lithium Ion
    Design Capacity: 45000 mWh
    Design Voltage: 10800 mV
    SBDS Version: 1.0                
    Maximum Error: 2%
    SBDS Manufacture Date: 2012-02-28
    OEM-specific Information: 0x00000001

Handle 0x001E, DMI type 32, 20 bytes
System Boot Information
    Status: No errors detected

Handle 0x0020, DMI type 27, 12 bytes
Cooling Device
    Type: Fan
    Status: OK
    OEM-specific Information: 0x00000000

Handle 0x0021, DMI type 28, 20 bytes
Temperature Probe
    Description: CPU Internal Temperature
    Location: Processor
    Status: OK
    Maximum Value: 127.0 deg C
    Minimum Value: 0.0 deg C
    Resolution: 1.000 deg C
    Tolerance: 0.5 deg C
    Accuracy: Unknown
    OEM-specific Information: 0x00000000

Handle 0xB000, DMI type 176, 5 bytes
OEM-specific Type
    Header and Data:
        B0 05 00 B0 00

Handle 0xB100, DMI type 177, 12 bytes
OEM-specific Type
    Header and Data:
        B1 0C 00 B1 1A 0E 00 00 00 00 00 00

Handle 0x0025, DMI type 209, 12 bytes
OEM-specific Type
    Header and Data:
        D1 0C 25 00 00 00 00 03 05 01 00 03

Handle 0x0026, DMI type 210, 12 bytes
OEM-specific Type
    Header and Data:
        D2 0C 26 00 00 00 00 03 05 20 01 03

Handle 0x0027, DMI type 211, 13 bytes
OEM-specific Type
    Header and Data:
        D3 0D 27 00 01 00 00 00 00 02 03 04 04
    Strings:
        Front               

Handle 0x0028, DMI type 212, 57 bytes
OEM-specific Type
    Header and Data:
        D4 39 28 00 70 00 71 00 01 49 50 48 9C 00 49 FC
        01 9B 00 49 FC 00 7F 01 4A FB 04 80 01 4A FB 00
        53 01 4A F7 08 52 01 4A F7 08 7B 01 4A EF 10 7C
        01 4A EF 10 FF FF 00 00 00

Handle 0x002A, DMI type 217, 8 bytes
OEM-specific Type
    Header and Data:
        D9 08 2A 00 01 02 00 00
    Strings:                                       

Handle 0x002B, DMI type 219, 11 bytes
OEM-specific Type
    Header and Data:
        DB 0B 2B 00 00 01 02 03 00 04 05
    Strings:                                                                                                    

Handle 0x002C, DMI type 220, 22 bytes
OEM-specific Type
    Header and Data:
        DC 16 2C 00 01 F0 00 00 02 F0 00 00 00 00 03 F0
        04 F0 00 00 00 00

Handle 0x002D, DMI type 221, 19 bytes
OEM-specific Type
    Header and Data:
        DD 13 2D 00 00 00 00 00 00 03 00 00 00 00 00 00
        00 00 00

Handle 0x002E, DMI type 222, 16 bytes
OEM-specific Type
    Header and Data:
        DE 10 2E 00 01 08 FF FF 00 00 00 00 00 00 00 00

Handle 0x0014, DMI type 16, 15 bytes
Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: None
    Maximum Capacity: 16 GB
    Error Information Handle: Not Provided
    Number Of Devices: 2

Handle 0x0016, DMI type 20, 19 bytes
Memory Device Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x000FFFFFFFF
    Range Size: 4 GB
    Physical Device Handle: 0x0015
    Memory Array Mapped Address Handle: 0x0018
    Partition Row Position: 1
    Interleave Position: 1
    Interleaved Data Depth: 1

Handle 0x0017, DMI type 17, 28 bytes
Memory Device
    Array Handle: 0x0014
    Error Information Handle: 0x0000
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: DIMM_B
    Bank Locator: BANK 2
    Type: Unknown
    Type Detail: None
    Speed: Unknown
    Manufacturer: Not Specified
    Serial Number: Not Specified
    Asset Tag: Not Specified
    Part Number: Not Specified
    Rank: Unknown

Handle 0x0018, DMI type 19, 15 bytes
Memory Array Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x000FFFFFFFF
    Range Size: 4 GB
    Physical Array Handle: 0x0014
    Partition Width: 2

Handle 0x002F, DMI type 13, 22 bytes
BIOS Language Information
    Language Description Format: Abbreviated
    Installable Languages: 1
        eng
        Currently Installed Language: eng

Handle 0x0030, DMI type 131, 64 bytes
OEM-specific Type
    Header and Data:
        83 40 30 00 31 00 00 00 00 00 00 00 00 00 00 00
        F8 00 4B 1C FF FF FF FF 01 00 00 00 00 00 07 00
        AD 04 04 00 00 00 00 00 C8 00 FF FF 00 00 00 00
        00 00 00 00 32 00 00 00 76 50 72 6F 00 00 00 00

Handle 0x0029, DMI type 216, 9 bytes
OEM-specific Type
    Header and Data:
        D8 09 29 00 01 02 01 00 00
    Strings:
        INTEL
        0000

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
    Vendor: Dell Inc.
    Version: A05
    Release Date: 08/03/2012
    Address: 0xF0000
    Runtime Size: 64 kB
    ROM Size: 2048 kB
    Characteristics:
        MCA is supported
        PCI is supported
        BIOS is upgradeable
        BIOS shadowing is allowed
        ESCD support is available
        Boot from CD is supported
        Selectable boot is supported
        BIOS ROM is socketed
        EDD is supported
        5.25"/1.2 MB floppy services are supported (int 13h)
        3.5"/720 kB floppy services are supported (int 13h)
        3.5"/2.88 MB floppy services are supported (int 13h)
        Print screen service is supported (int 5h)
        8042 keyboard services are supported (int 9h)
        Serial services are supported (int 14h)
        Printer services are supported (int 17h)
        CGA/mono video services are supported (int 10h)
        ACPI is supported
        USB legacy is supported
        ATAPI Zip drive boot is supported
        BIOS boot specification is supported
        Targeted content distribution is supported
    BIOS Revision: 0.5
    Firmware Revision: 0.5

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
    Manufacturer: Dell Inc.
    Product Name: 01HXXJ
    Version: A05
    Serial Number: .JSQ7PA1.CN7117623M00J2.
    Asset Tag: Not Specified
    Features:
        Board is a hosting board
        Board is replaceable
    Location In Chassis: To Be Filled By O.E.M.
    Chassis Handle: 0x0003
    Type: Motherboard
    Contained Object Handles: 0

Handle 0x0003, DMI type 3, 21 bytes
Chassis Information
    Manufacturer: Dell Inc.
    Type: Portable
    Lock: Not Present
    Version: Not Specified
    Serial Number: JSR1
    Asset Tag: Not Specified
    Boot-up State: Safe
    Power Supply State: Safe
    Thermal State: Safe
    Security Status: None
    OEM Information: 0x00000000
    Height: Unspecified
    Number Of Power Cords: 1
    Contained Elements: 0

Handle 0x0001, DMI type 1, 27 bytes
System Information
    Manufacturer: Dell Inc.
    Product Name: Inspiron N5050
    Version: Not Specified
    Serial Number: JSR1
    UUID: 4C4C4544-0053-5110-8029-CAC05241
    Wake-up Type: Power Switch
    SKU Number: To be filled by O.E.M.
    Family:                       

Handle 0x0024, DMI type 208, 12 bytes
OEM-specific Type
    Header and Data:
        D0 0C 24 00 02 05 FE 00 04 05 01 02
    Strings:
        20120323
        20120323

Handle 0x0011, DMI type 10, 6 bytes
On Board Device Information
    Type: Video
    Status: Enabled
    Description: Mobile Intel SandyBridge HD Graphics

Handle 0x0015, DMI type 17, 28 bytes
Memory Device
    Array Handle: 0x0014
    Error Information Handle: 0x0000
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 4096 MB
    Form Factor: SODIMM
    Set: None
    Locator: DIMM_A
    Bank Locator: BANK 0
    Type: DDR3
    Type Detail: Synchronous
    Speed: 1067 MHz
    Manufacturer: 014F
    Serial Number: 0009F2
    Asset Tag: 54114000     
    Part Number: JM1066-4G      
    Rank: Unknown

Handle 0x0031, DMI type 127, 4 bytes
End Of Table

好了,就是这样。


via: http://www.unixmen.com/linux-basics-how-to-find-maximum-supported-ram-by-your-system/

作者:SK 译者:mr-ping 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出

大家好,今天我们会在CentOS 7.0 上为 subversion(SVN)安装Web 界面 WebSVN。(subverion 是 apache 的顶级项目,也称为 Apache SVN 或 SVN)

WebSVN 将 Svbverion 的操作你的仓库的各种功能通过 Web 界面提供出来。通过它,我们可以看到任何给定版本的任何文件或者目录的日志,并且可看到所有文件改动、添加、删除的列表。我们同样可以查看两个版本间的差异来知道特定版本改动了什么。

特性

WebSVN提供了下面这些特性:

  • 易于使用的用户界面
  • 可定制的模板系统
  • 色彩化的文件列表
  • 追溯视图
  • 日志信息查询
  • RSS支持
  • 更多

由于其使用PHP写成,WebSVN同样易于移植和安装。

现在我们将为Subverison安装WebSVN。请确保你的服务器上已经安装了 SVN。如果你还没有安装,你可以按本教程安装。

安装完SVN后,你需要以下几步。

1. 下载 WebSVN

你可以从官方网站 http://www.websvn.info/download/ 中下载 WebSVN。我们首先进入 /var/www/html/ 并在这里下载安装包。

$ sudo -s

请在shell或者终端中执行上面的命令,因为我们需要切换到root权限来对系统限制区域有访问权。

# cd /var/www/html
# wget http://websvn.tigris.org/files/documents/1380/49057/websvn-2.3.3.zip

downloading websvn package

这里,我下载的是最新的2.3.3版本的 websvn。你可以从上面这个网站找到下载链接,用适合你的包的链接来替换上面的链接。

2. 解压下载的zip

# unzip websvn-2.3.3.zip

# mv websvn-2.3.3 websvn

extracting websvn

3. 安装php

# yum install php

yum install php

4. 编辑WebSVN配置

现在,我们需要拷贝位于 /var/www/html/websvn/include 的 distconfig.php 为 config.php,并且接着编辑该配置文件。

# cd /var/www/html/websvn/include
# cp distconfig.php config.php
# nano config.php

现在我们需要按如下改变文件。完成之后,请保存并退出。

// Configure these lines if your commands aren't on your path.
//
 $config->setSVNCommandPath('/usr/bin'); // e.g. c:\\program files\\subversion\\bin
 $config->setDiffPath('/usr/bin');

// For syntax colouring, if option enabled...
 $config->setEnscriptPath('/usr/bin');
 $config->setSedPath('/bin');

// For delivered tarballs, if option enabled...
 $config->setTarPath('/bin');

// For delivered GZIP'd files and tarballs, if option enabled...
 $config->setGZipPath('/bin');

//
 $config->parentPath('/svn/');

$extEnscript[".pl"] = "perl";
$extEnscript[".py"] = "python";
$extEnscript[".sql"] = "sql";
$extEnscript[".java"] = "java";
$extEnscript[".html"] = "html";
$extEnscript[".xml"] = "html";
$extEnscript[".thtml"] = "html";
$extEnscript[".tpl"] = "html";
$extEnscript[".sh"] = "bash";

websvn config file

5. 启动 WebSVN

现在,我们将近完成了。现在需要重启Apache服务。你可以用下面的命令。

# systemctl restart httpd.service

接着我们在浏览器中打开WebSVN,输入 http:// IP地址/websvn ,或者你在本地的话,你可以输入 http://localhost/websvn

websvn successfully installed

注意: 如果你遇到一个像"Unable to find "enscript" tool at location "/usr/bin/enscript"这样的问题,那么你需要使用“yum install enscript”安装enscript来修复这个问题。

总结

好了,我们已经在CentOS 7上完成WebSVN的安装了。这个教程同样适用于RHEL 7。

如果你有任何问题、评论、反馈请在下面的评论栏中留下,来让我们知道该添加什么和改进。谢谢! 用用看吧。:-)


via: http://linoxide.com/linux-how-to/install-websvn-subversion-centos-7/

作者:Arun Pyasi 译者:geekpi 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出

通常在你在虚拟机中添加一块新硬盘时,你可能会看到新硬盘没有自动加载。这是因为连接到硬盘的SCSI总线需要重新扫描来使得新硬盘可见。这里有一个简单的命令来重新扫描SCSI总线和SCSI设备。下面这几步在CentOS 7 和RHEL 7 中测试过。

  1. 在ESXi或者vCenter中添加一块新的20G硬盘:

  1. 显示当前磁盘分区:
[root@centos7 ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006b96a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
  1. 确定主机总线号
[root@centos7 ~]# ls /sys/class/scsi_host/
host0  host1  host2
  1. 重新扫描SCSI总线来添加设备
[root@centos7 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@centos7 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@centos7 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
  1. 验证磁盘和分区并确保20GB硬盘已经添加了。在本例中,出现了下面这行 “Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors” 并且可以确认没有重启服务器就添加了新盘:
[root@centos7 ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006b96a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

via: http://www.ehowstuff.com/how-to-add-a-new-hard-disk-without-rebooting-on-centos-7-rhel-7/

作者:skytech 译者:geekpi 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出

如果你正在管理Debian或者Ubuntu服务器,你也许会经常使用dpkg 或者 apt-get命令。这两个命令用来安装、卸载和更新包。

在本篇中,让我们看下如何在基于DEB的系统下检查是否安装了一个包。

要检查特定的包,比如firefox是否安装了,使用这个命令:

dpkg -s firefox

示例输出:

 Package: firefox
 Status: install ok installed
 Priority: optional
 Section: web
 Installed-Size: 93339
 Maintainer: Ubuntu Mozilla Team <[email protected]>
 Architecture: amd64
 Version: 35.0+build3-0ubuntu0.14.04.2
 Replaces: kubuntu-firefox-installer
 Provides: gnome-www-browser, iceweasel, www-browser
 Depends: lsb-release, libasound2 (>= 1.0.16), libatk1.0-0 (>= 1.12.4), libc6 (>= 2.17), libcairo2 (>= 1.2.4), libdbus-1-3 (>= 1.0.2), libdbus-glib-1-2 (>= 0.78), libfontconfig1 (>= 2.9.0), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.37.3), libgtk2.0-0 (>= 2.24.0), libpango-1.0-0 (>= 1.22.0), libpangocairo-1.0-0 (>= 1.14.0), libstartup-notification0 (>= 0.8), libstdc++6 (>= 4.6), libx11-6, libxcomposite1 (>= 1:0.3-1), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxrender1, libxt6
 Recommends: xul-ext-ubufox, libcanberra0, libdbusmenu-glib4, libdbusmenu-gtk4
 Suggests: ttf-lyx
 Conffiles:
 /etc/firefox/syspref.js 09e457e65435a1a043521f2bd19cd2a1
 /etc/apport/blacklist.d/firefox ee63264f847e671832d42255912ce144
 /etc/apport/native-origins.d/firefox 7c26b75c7c2b715c89cc6d85338252a4
 /etc/apparmor.d/usr.bin.firefox f54f7a43361c7ecfa3874abca2f292cf
 Description: Safe and easy web browser from Mozilla
 Firefox delivers safe, easy web browsing. A familiar user interface,
 enhanced security features including protection from online identity theft,
 and integrated search let you get the most out of the web.
 Xul-Appid: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}

如上所见,firefox已经安装了。

同样,你可以使用dpkg-query 命令。这个命令会有一个更好的输出,当然,你可以用通配符。

dpkg-query -l firefox

示例输出:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                 Architecture            Description
+++-====================================-=======================-=======================-=============================================================================
ii  firefox                              35.0+build3-0ubuntu0.14 amd64                   Safe and easy web browser from Mozilla

要列出你系统中安装的所有包,输入下面的命令:

dpkg --get-selections

示例输出:

abiword                        install
abiword-common                    install
accountsservice                    install
acl                        install
adduser                        install
alsa-base                    install
alsa-utils                    install
anacron                        install
app-install-data                install
apparmor                    install
.
.
.
zeitgeist                    install
zeitgeist-core                    install
zeitgeist-datahub                install
zenity                        install
zenity-common                    install
zip                        install
zlib1g:amd64                    install
zlib1g:i386                    install

上面的输出可能会非常长,这依赖于你的系统已安装的包。

你同样可以通过grep来过滤割到更精确的包。比如,我想要使用dpkg命令查看系统中安装的gcc包:

dpkg --get-selections | grep gcc

示例输出:

gcc                        install
gcc-4.8                        install
gcc-4.8-base:amd64                install
gcc-4.8-base:i386                install
gcc-4.9-base:amd64                install
gcc-4.9-base:i386                install
libgcc-4.8-dev:amd64                install
libgcc1:amd64                    install
libgcc1:i386                    install

此外,你可以使用“-L”参数来找出包中文件的位置。

dpkg -L gcc-4.8

示例输出:

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/gcc-4.8-base
/usr/share/doc/gcc-4.8-base/README.Bugs
/usr/share/doc/gcc-4.8-base/NEWS.html
/usr/share/doc/gcc-4.8-base/quadmath
/usr/share/doc/gcc-4.8-base/quadmath/changelog.gz
/usr/share/doc/gcc-4.8-base/gcc
.
.
.
/usr/bin/x86_64-linux-gnu-gcc-4.8
/usr/bin/x86_64-linux-gnu-gcc-ar-4.8
/usr/bin/x86_64-linux-gnu-gcov-4.8

就是这样了。希望这篇对你有用。

美好的一天!


via: http://www.unixmen.com/linux-basics-check-package-installed-not-ubuntu/

作者:SK 译者:geekpi 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出