mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge branch 'master' of https://github.com/LCTT/TranslateProject
This commit is contained in:
commit
a11c650ab5
@ -2,11 +2,11 @@ Camicri Cube: 可离线的便携包管理系统
|
||||
================================================================================
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/camicri-cube-206x205.jpg)
|
||||
|
||||
众所周知,在系统中使用新立德包管理工具或软件中包管理工具来下载和安装应用程序的时候,我们必须得有互联网连接。但,如果您刚好没有网络或者是网络速度死慢死慢的呢?在您的 Linux 桌面系统中使用软件中心包管理工具来安装软件这绝对是一个头痛的问题。这种情况,您只能从相应的官网上手工下载应用程序包,并手工安装。但是,大多数的 Linux 用户并不知道他们希望安装的应用程序所需要的依赖关系包。如果您恰巧出现这种情况,应用怎么办呢?现在一切都不用担心了。今天,我们给您介绍一款非常棒的名叫 **Camicri Cube** 的离线包管理工具。
|
||||
众所周知,在系统中使用新立得包管理工具或软件中心下载和安装应用程序的时候,我们必须得有互联网连接。但,如果您刚好没有网络或者是网络速度死慢死慢的呢?在您的 Linux 桌面系统中使用软件中心包管理工具来安装软件绝对是一个头痛的问题。反而,您可以从相应的官网上手工下载应用程序包并手工安装。但是,大多数的 Linux 用户并不知道他们希望安装的应用程序所需要的依赖关系包。如果您恰巧出现这种情况,应用怎么办呢?现在一切都不用担心了。今天,我们给您介绍一款非常棒的名叫 **Camicri Cube** 的离线包管理工具。
|
||||
|
||||
您可以把此包管理工具装在联网的系统上,下载您所需要安装的软件,然后把他们安装到没联网的机器上,就可以安装了。听起来很不错吧?是的,它就是这样操作的。Cube 是一款像新立德和 Ubuntu 软件中心这样的包管理工具,但是一款便携式的。它在任何平台(Windows 系统、基于 Apt 的 Linux 发布系统)、在线状态、离线状态、在闪存或任何可移动设备上都是可以使用和运行的。我们这个实验项目的主要目的是使处在离线状态的 Linux 用户能很容易的下载和安装 Linux 应用程序。
|
||||
您可以把此包管理工具装在任何联网的系统上,下载您所需要安装的软件列表,然后把它们安装到没联网的机器上,就可以安装了。听起来很不错吧?是的,它就是这样操作的。Cube 是一款像新立得和 Ubuntu 软件中心这样的包管理工具,但是一款便携式的。它在任何平台(Windows 系统、基于 Apt 的 Linux 发布系统)、在线状态、离线状态、在闪存或任何可移动设备上都是可以使用和运行的。我们这个实验项目的主要目的是使处在离线状态的 Linux 用户能很容易的下载和安装 Linux 应用程序。
|
||||
|
||||
Cube 会收集您的离线电脑的完整的详细信息,如操作系统的详细信息、安装的应用程序等等。然后使用 USB 迷你盘对 cube 应用程序进行拷贝得到一副本,把其放在其它有网络连接的系统上使用,接着就可以下载您需要的应用程序包。下载完所有需要的软件包之后,回到您原来的计算机,并开始安装。Cube 是由 **Jake Capangpangan** 开发和维护的,是用 C++ 语言编写,而且已经集成了所有必须的包。因此,要使用它并不需要再安装其它额外的软件。
|
||||
Cube 会收集您的离线电脑的详细信息,如操作系统的详细信息、安装的应用程序等等。然后使用 USB 迷你盘对 cube 应用程序进行拷贝,得到一副本,把其放在其它有网络连接的系统上使用,接着就可以下载您需要的应用程序列表。下载完所有需要的软件包之后,回到您原来的计算机,并开始安装。Cube 是由 **Jake Capangpangan** 开发和维护的,是用 C++ 语言编写,而且已经集成了所有必须的包。因此,使用它并不需要再安装任何额外的软件。
|
||||
|
||||
### 安装 ###
|
||||
|
||||
@ -22,7 +22,7 @@ Cube 会收集您的离线电脑的完整的详细信息,如操作系统的详
|
||||
|
||||
### 使用 ###
|
||||
|
||||
这儿,我使用的的是两台装有 Ubuntu 系统的机器。原机器(离线-没有网络连接)上面跑着的是 **Ubuntu 14.04** 系统,有网络连接的机器跑着的是 **Lubuntu 14.04** 桌面系统。
|
||||
这儿,我使用的是两台装有 Ubuntu 系统的机器。原机器(离线-没有网络连接)上面跑着的是 **Ubuntu 14.04** 系统,有网络连接的机器跑着的是 **Lubuntu 14.04** 桌面系统。
|
||||
|
||||
#### 离线系统上的操作步骤: ####
|
||||
|
||||
@ -50,7 +50,7 @@ Cube 会收集您的离线电脑的完整的详细信息,如操作系统的详
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Camicri-Systems-%C2%A9-Cube-Portable-Package-Manager-1.0.9.2-sk_0033.png)
|
||||
|
||||
就是这样。现在新的项目已经创建好了,它会保存在我们的主 cube 目录里面。进入 Cube 目录,您就会发现一个名叫 Projects 的目录。这个目录会保存有您的离线系统的必要完整详细信息。
|
||||
就是这样。现在新的项目已经创建好了,它会保存在我们的主 cube 目录里面。进入 Cube 目录,您就会发现一个名叫 Projects 的目录。这个目录会保存有您的离线系统的必要完整详细信息。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Selection_004.png)
|
||||
|
||||
@ -75,7 +75,7 @@ Cube 会收集您的离线电脑的完整的详细信息,如操作系统的详
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Cube-Startup-Create-or-choose-a-project-to-be-managed_0014.png)
|
||||
|
||||
随后,cube 会询问这是否是您的项目所在的源机器。它并不是我们的源(离线)机器,所以我点击 **No**。
|
||||
随后,cube 会询问这是否是您的项目所在的源机器。它并不是我的源(离线)机器,所以我点击 **No**。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Camicri-Systems-%C2%A9-Cube-Portable-Package-Manager-1.0.9.2-sk_0024.png)
|
||||
|
||||
@ -95,7 +95,7 @@ Cube 会收集您的离线电脑的完整的详细信息,如操作系统的详
|
||||
|
||||
#### 下载新的应用程序 ####
|
||||
|
||||
例如,这儿我想下载 **apache2** 包。在**搜索**框里输入包的名字,点击搜索按纽。Cube 程序会获取您想查找的应用程序的详细信息。点击 “**Download this package now**”按纽,接着点击 **OK** 就开始下载了。
|
||||
例如,现在我想下载 **apache2** 包。在**搜索**框里输入包的名字,点击搜索按纽。Cube 程序会获取您想查找的应用程序的详细信息。点击 “**Download this package now**”按纽,接着点击 **OK** 就开始下载了。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Camicri-Systems-%C2%A9-Cube-Portable-Package-Manager-1.0.9.2-sk_008.png)
|
||||
|
||||
@ -136,7 +136,7 @@ Cube 将会下载 apache2 的安装包及所有的依赖包。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Camicri-Systems-%C2%A9-Cube-Portable-Package-Manager-1.0.9.2-sk_0035.png)
|
||||
|
||||
然后选中某个特定的包,点击 “Install this”按纽来安装或者如果想过后再安装它的话可以先点击 “Mark this” 按纽。
|
||||
然后双击某个特定的包,点击 “Install this”按纽来安装或者如果想过后再安装它的话可以先点击 “Mark this” 按纽。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Camicri-Systems-%C2%A9-Cube-Portable-Package-Manager-1.0.9.2-sk_0043.png)
|
||||
|
||||
@ -144,24 +144,25 @@ Cube 将会下载 apache2 的安装包及所有的依赖包。
|
||||
|
||||
### 结论 ###
|
||||
|
||||
这是我曾经使用过的一款最好、最有用的软件工具。但我在用 Ubuntu 14.04 测试盒子测试的时候,遇到了很多依赖问题,还经常会出现闪退的情况。也仅仅是在最新 Ubuntu 14.04 离线系统上使用没有遇到任何问题。希望这些问题在老版本的 Ubuntu 上不会发生。除了这些小问题,这个小工具对作向外推荐以及本职工作这些方面显得魅力十足。
|
||||
这是我曾经使用过的最好、最有用的软件工具之一。但我在用 Ubuntu 14.04 测试盒子测试的时候,遇到了很多依赖问题,还经常会出现闪退的情况。也仅仅是在最新 Ubuntu 14.04 离线系统上使用没有遇到任何问题。希望这些问题在老版本的 Ubuntu 上不会发生。除了这些小问题,这个小工具就如同宣传的一样,像魔法一样神奇。
|
||||
|
||||
欢呼吧!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.unixmen.com/camicri-cube-offline-portable-package-management-system/
|
||||
|
||||
原文作者:
|
||||
|
||||
![](http://1.gravatar.com/avatar/1ba62ac2b395f541750b6b4f873eb37b?s=70&d=monsterid&r=G)
|
||||
|
||||
[SK][a](Senthilkumar,又名SK,来自于印度的泰米尔纳德邦,Linux 爱好者,FOSS 论坛支持者和 Linux 板块顾问。一个充满激情和活力的人,致力于提供高质量的 IT 专业文章,非常喜欢写作和对 Linux、开源、电脑和互联网等新事物的探索。)
|
||||
[SK][a](Senthilkumar,又名SK,来自于印度的泰米尔纳德邦,Linux 爱好者,FOSS 论坛支持者和 Linux 板块顾问。一个充满激情和活力的人,致力于提供高质量的 IT 专业文章,非常喜欢写作以及探索 Linux、开源、电脑和互联网等新事物。)
|
||||
|
||||
译者:[runningwater](https://github.com/runningwater) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.unixmen.com/camicri-cube-offline-portable-package-management-system/
|
||||
|
||||
译者:[runningwater](https://github.com/runningwater) 校对:[Caroline](https://github.com/carolinewuyan)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.unixmen.com/author/sk/
|
||||
[1]:https://launchpad.net/camicricube
|
||||
[2]:http://sourceforge.net/projects/camicricube/
|
||||
[2]:http://sourceforge.net/projects/camicricube/
|
178
published/20140924 Unix----stat -- more than ls.md
Normal file
178
published/20140924 Unix----stat -- more than ls.md
Normal file
@ -0,0 +1,178 @@
|
||||
stat -- 获取比 ls 更多的信息
|
||||
================================================================================
|
||||
> 厌倦了 ls 命令,并且想查看更多有关你的文件的有趣的信息? 试一试 stat!
|
||||
|
||||
![](http://www.itworld.com/sites/default/files/imagecache/large_thumb_150x113/stats.jpg)
|
||||
|
||||
ls 命令可能是每一个 Unix 使用者第一个学习的命令之一, 但它仅仅显示了 stat 命令能给出的信息的一小部分。
|
||||
|
||||
stat 命令从文件的索引节点获取信息。 正如你可能已经了解的那样, 每一个系统里的文件都存有三组日期和时间, 它们包括最近修改时间(即使用 ls -l 命令时显示的日期和时间), 最近状态改变时间(包括对文件重命名)和最近访问时间。
|
||||
|
||||
使用长列表模式查看文件信息, 你会看到类似下面的内容:
|
||||
|
||||
$ ls -l trythis
|
||||
-rwx------ 1 shs unixdweebs 109 Nov 11 2013 trythis
|
||||
|
||||
使用 stat 命令, 你会看到下面这些:
|
||||
|
||||
$ stat trythis
|
||||
File: `trythis'
|
||||
Size: 109 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731691 Links: 1
|
||||
Access: (0700/-rwx------) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-09-09 19:27:58.000000000 -0400
|
||||
Modify: 2013-11-11 08:40:10.000000000 -0500
|
||||
Change: 2013-11-11 08:40:10.000000000 -0500
|
||||
|
||||
在上面的情形中, 文件的状态改变和文件修改的日期/时间是相同的, 而访问时间则是相当近的时间。 我们还可以看到文件使用了 8 个块, 以及两种格式显示的文件权限 -- 八进制(0700)格式和 rwx 格式。 在第三行显示的索引节点是 12731681. 文件没有其它的硬链接(Links: 1)。 而且, 这个文件是一个常规文件。
|
||||
|
||||
把文件重命名, 你会看到状态改变时间发生变化。
|
||||
|
||||
这里的 ctime 信息, 最早设计用来存储文件的创建(create)日期和时间, 但后来不知道什么时候变为用来存储状态修改(change)时间。
|
||||
|
||||
$ mv trythis trythat
|
||||
$ stat trythat
|
||||
File: `trythat'
|
||||
Size: 109 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731691 Links: 1
|
||||
Access: (0700/-rwx------) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-09-09 19:27:58.000000000 -0400
|
||||
Modify: 2013-11-11 08:40:10.000000000 -0500
|
||||
Change: 2014-09-21 12:46:22.000000000 -0400
|
||||
|
||||
改变文件的权限也会改变 ctime 域。
|
||||
|
||||
你也可以配合通配符来使用 stat 命令以列出一组文件的状态:
|
||||
|
||||
$ stat myfile*
|
||||
File: `myfile'
|
||||
Size: 20 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731803 Links: 1
|
||||
Access: (0640/-rw-r-----) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-08-23 03:00:36.000000000 -0400
|
||||
Modify: 2014-08-22 12:02:12.000000000 -0400
|
||||
Change: 2014-08-22 12:02:12.000000000 -0400
|
||||
File: `myfile2'
|
||||
Size: 20 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731806 Links: 1
|
||||
Access: (0640/-rw-r-----) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-08-23 03:00:36.000000000 -0400
|
||||
Modify: 2014-08-22 12:03:30.000000000 -0400
|
||||
Change: 2014-08-22 12:03:30.000000000 -0400
|
||||
File: `myfile3'
|
||||
Size: 40 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12730533 Links: 1
|
||||
Access: (0640/-rw-r-----) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-08-23 03:00:36.000000000 -0400
|
||||
Modify: 2014-08-22 12:03:59.000000000 -0400
|
||||
Change: 2014-08-22 12:03:59.000000000 -0400
|
||||
|
||||
如果我们喜欢的话, 我们也可以通过其他命令来获取这些信息。
|
||||
|
||||
向 ls -l 命令添加 "u" 选项, 你会看到下面的结果。 注意这个选项会显示最后访问时间, 而添加 "c" 选项则会显示状态改变时间(在本例中, 是我们重命名文件的时间)。
|
||||
|
||||
$ ls -lu trythat
|
||||
-rwx------ 1 shs unixdweebs 109 Sep 9 19:27 trythat
|
||||
$ ls -lc trythat
|
||||
-rwx------ 1 shs unixdweebs 109 Sep 21 12:46 trythat
|
||||
|
||||
stat 命令也可应用与文件夹。
|
||||
|
||||
在这个例子中, 我们可以看到有许多的链接。
|
||||
|
||||
$ stat bin
|
||||
File: `bin'
|
||||
Size: 12288 Blocks: 24 IO Block: 262144 directory
|
||||
Device: 18h/24d Inode: 15089714 Links: 9
|
||||
Access: (0700/drwx------) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-09-21 03:00:45.000000000 -0400
|
||||
Modify: 2014-09-15 17:54:41.000000000 -0400
|
||||
Change: 2014-09-15 17:54:41.000000000 -0400
|
||||
|
||||
在这里, 我们还可以查看一个文件系统。
|
||||
|
||||
$ stat -f /dev/cciss/c0d0p2
|
||||
File: "/dev/cciss/c0d0p2"
|
||||
ID: 0 Namelen: 255 Type: tmpfs
|
||||
Block size: 4096Fundamental block size: 4096
|
||||
Blocks: Total: 259366 Free: 259337 Available: 259337
|
||||
Inodes: Total: 223834 Free: 223531
|
||||
|
||||
注意 Namelen (文件名长度)域, 如果文件名长于 255 个字符的话, 你会很幸运地在文件名处看到心形符号!
|
||||
|
||||
stat 命令还可以一次显示所有我们想要的信息。 下面的例子中, 我们只想查看文件类型, 然后是硬连接数。
|
||||
|
||||
$ stat --format=%F trythat
|
||||
regular file
|
||||
$ stat --format=%h trythat
|
||||
1
|
||||
|
||||
在下面的例子中, 我们查看了文件权限 -- 分别以两种可用的格式 -- 然后是文件的 SELinux 安全环境。最后,我们我们可以以从 Epoch 开始的秒数格式来查看文件访问时间。
|
||||
|
||||
$ stat --format=%a trythat
|
||||
700
|
||||
$ stat --format=%A trythat
|
||||
-rwx------
|
||||
$ stat --format=%C trythat
|
||||
(null)
|
||||
$ stat --format=%X bin
|
||||
1411282845
|
||||
|
||||
下面全部是可用的选项:
|
||||
|
||||
%a 八进制表示的访问权限
|
||||
%A 可读格式表示的访问权限
|
||||
%b 分配的块数(参见 %B)
|
||||
%B %b 参数显示的每个块的字节数
|
||||
%d 十进制表示的设备号
|
||||
%D 十六进制表示的设备号
|
||||
%f 十六进制表示的 Raw 模式
|
||||
%F 文件类型
|
||||
%g 属主的组 ID
|
||||
%G 属主的组名
|
||||
%h 硬连接数
|
||||
%i Inode 号
|
||||
%n 文件名
|
||||
%N 如果是符号链接,显示器所链接的文件名
|
||||
%o I/O 块大小
|
||||
%s 全部占用的字节大小
|
||||
%t 十六进制的主设备号
|
||||
%T 十六进制的副设备号
|
||||
%u 属主的用户 ID
|
||||
%U 属主的用户名
|
||||
%x 最后访问时间
|
||||
%X 最后访问时间,自 Epoch 开始的秒数
|
||||
%y 最后修改时间
|
||||
%Y 最后修改时间,自 Epoch 开始的秒数
|
||||
%z 最后改变时间
|
||||
%Z 最后改变时间,自 Epoch 开始的秒数
|
||||
|
||||
针对文件系统还有如下格式选项:
|
||||
|
||||
%a 普通用户可用的块数
|
||||
%b 文件系统的全部数据块数
|
||||
%c 文件系统的全部文件节点数
|
||||
%d 文件系统的可用文件节点数
|
||||
%f 文件系统的可用节点数
|
||||
%C SELinux 的安全上下文
|
||||
%i 十六进制表示的文件系统 ID
|
||||
%l 文件名的最大长度
|
||||
%n 文件系统的文件名
|
||||
%s 块大小(用于更快的传输)
|
||||
%S 基本块大小(用于块计数)
|
||||
%t 十六进制表示的文件系统类型
|
||||
%T 可读格式表示的文件系统类型
|
||||
|
||||
这些信息都可以得到,stat 命令也许可以帮你以稍微不同的角度来了解你的文件。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.itworld.com/operating-systems/437351/unix-stat-more-ls
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
译者:[wangjiezhe](https://github.com/wangjiezhe)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.itworld.com/sandra-henry-stocker
|
@ -1,10 +1,10 @@
|
||||
Linux有问必答——如何检测并修复bash中的破壳漏洞
|
||||
Linux有问必答:如何检测并修复bash中的破壳漏洞
|
||||
================================================================================
|
||||
> **问题**:我想要知道我的Linux服务器是否存在bash破壳漏洞,以及如何来保护我的Linux服务器不受破壳漏洞侵袭。
|
||||
|
||||
2014年9月24日,一位名叫斯特凡·沙泽拉的安全研究者发现了一个名为“破壳”(也称为“bash门”或“Bash漏洞”)的bash漏洞。该漏洞如果被渗透,远程攻击者就可以在调用shell前通过在特别精心编制的环境中输出函数定义执行任何程序代码。然后,这些函数内的代码就可以在调用bash时立即执行。
|
||||
2014年9月24日,一位名叫斯特凡·沙泽拉的安全研究者发现了一个名为“破壳”(Shellshock,也称为“bash门”或“Bash漏洞”)的bash漏洞。该漏洞如果被渗透,远程攻击者就可以在调用shell前通过在特别精心编制的环境中输出函数定义执行任何程序代码。然后,这些函数内的代码就可以在调用bash时立即执行。
|
||||
|
||||
注意,破壳漏洞影响到bash版本1.14到4.3(当前版本)。虽然在写本文时还没有该漏洞权威而完整的修复方案,也尽管主要的Linux发行版([Debian][1],[Red Hat][2],[CentOS][3],[Ubuntu][4]和 [Novell/Suse][5])已经发布了用于解决与此漏洞相关的补丁([CVE-2014-6271][6]和[CVE-2014-7169][7]),并且建议尽快更新bash,并在随后数日内检查更新:
|
||||
注意,破壳漏洞影响到bash版本1.14到4.3(当前版本)。虽然在写本文时还没有该漏洞权威而完整的修复方案,也尽管主要的Linux发行版([Debian][1],[Red Hat][2],[CentOS][3],[Ubuntu][4]和 [Novell/Suse][5])已经发布了用于部分解决与此漏洞相关的补丁([CVE-2014-6271][6]和[CVE-2014-7169][7]),并且建议尽快更新bash,并在随后数日内检查更新(LCTT 译注,可能你看到这篇文章的时候,已经有了完善的解决方案)。
|
||||
|
||||
### 检测破壳漏洞 ###
|
||||
|
||||
@ -12,14 +12,13 @@ Linux有问必答——如何检测并修复bash中的破壳漏洞
|
||||
|
||||
$ env x='() { :;}; echo "Your bash version is vulnerable"' bash -c "echo This is a test"
|
||||
|
||||
(注:上面代码中echo "Your bash version is vulnerable"一句在发布时刷成红色)
|
||||
|
||||
如果你的Linux系统已经暴露给了破壳漏洞渗透,命令输出会像这样:
|
||||
|
||||
Your bash version is vulnerable
|
||||
This is a test
|
||||
|
||||
在上面的命令中,一个名为x的环境变量已经被设置可用于用户环境。就如我们所了解到的,它并没有赋值(是一个虚函数定义),后面跟了一个任意命令(红色)(注:red这个词在发布时刷成红色),该命令将在bash调用前执行。
|
||||
在上面的命令中,一个名为x的环境变量已经被设置可用于用户环境。就如我们所了解到的,它并没有赋值(是一个虚函数定义),后面跟了一个任意命令(红色),该命令将在bash调用前执行。
|
||||
|
||||
### 为破壳漏洞应用修复 ###
|
||||
|
||||
@ -62,7 +61,7 @@ CentOS:
|
||||
via: http://ask.xmodulo.com/detect-patch-shellshock-vulnerability-bash.html
|
||||
|
||||
译者:[GOLinux](https://github.com/GOLinux)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
@ -1,15 +1,15 @@
|
||||
实用免费图片查看器
|
||||
Linux 下的免费图片查看器
|
||||
================================================================================
|
||||
|
||||
我最喜欢的谚语之一是“一图胜千言”。它指一张静态图片可以传递一个复杂的想法。图像相比文字而言可以迅速且更有效地描述大量信息。它们捕捉回忆,永不让你忘记你所想记住的东西,并且让它时常在你的记忆里刷新。
|
||||
|
||||
图片是互联网日常使用的一部分,并且对社交媒体互动尤其重要。一个好的图片查看器是任何操作系统必不可少的一个组成部分。
|
||||
|
||||
Linux 系统提供了一个大量开源实用小程序的集合,其中这些程序提供了从显而易见到异乎寻常的各种功能。正是由于这些工具的高质量和可供选择帮助 Linux 在生产环境中而脱颖而出,尤其是当谈到图片查看器时。Linux 有如此多的图像查看器可供选择,以至于让挑选变得困难。
|
||||
Linux 系统提供了一个大量开源实用小程序的集合,其中这些程序提供了从显而易见到异乎寻常的各种功能。正是由于这些工具的高质量和多样选择帮助 Linux 在生产环境中而脱颖而出,尤其是当谈到图片查看器时。Linux 有如此多的图像查看器可供选择,以至于让选择困难症患者无所适从~
|
||||
|
||||
一个不该包括在这个综述中但是值得一提的软件是 Fragment Image Viewer。它在专有许可证下发行(是的,我知道!),所以不会预先安装在 Ubuntu 上。 但它无疑看起来十分有趣!它是明日之星,尤其如果它的开发者们将它在开源许可证下发布的话。
|
||||
一个不该包括在这个综述中但是值得一提的软件是 Fragment Image Viewer。它在专有许可证下发行(是的,我知道!),所以不会预先安装在 Ubuntu 上。 但它无疑看起来十分有趣!要是它的开发者们将它在开源许可证下发布的话,它将是明日之星!
|
||||
|
||||
现在,让我们亲眼探究一下这 13 款图像查看器。除了一个例外,它们中每个都是在开源协议下发行。由于有很多信息要阐述,我将这些详细内容从当前单一网页综述剥离,但作为替代,我为每一款图片查看器提供了一个单独页面,具有软件的完整描述,产品特点的详细分析,一张软件工作中的截图,以及相关资源和评论的链接。
|
||||
现在,让我们亲眼探究一下这 13 款图像查看器。除了一个例外,它们中每个都是在开源协议下发行。由于有很多信息要阐述,我将这些详细内容从当前单一网页综述剥离,但作为替代,我为每一款图片查看器提供了一个单独页面,包括软件的完整描述,产品特点的详细分析,一张软件工作中的截图,以及相关资源和评论的链接。
|
||||
|
||||
### 图片查看器 ###
|
||||
|
||||
@ -32,7 +32,7 @@ Linux 系统提供了一个大量开源实用小程序的集合,其中这些
|
||||
via: http://www.linuxlinks.com/article/20141018070111434/ImageViewers.html
|
||||
|
||||
译者:[jabirus](https://github.com/jabirus)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
52
sources/share/20141023 6 Minesweeper Clones for Linux.md
Normal file
52
sources/share/20141023 6 Minesweeper Clones for Linux.md
Normal file
@ -0,0 +1,52 @@
|
||||
6 Minesweeper Clones for Linux
|
||||
================================================================================
|
||||
### GNOME Mines ###
|
||||
|
||||
This is the GNOME Minesweeper clone, allowing you to choose from three different pre-defined table sizes (8×8, 16×16, 30×16) or a custom number of rows and columns. It can be ran in fullscreen mode, comes with highscores, elapsed time and hints. The game can be paused and resumed.
|
||||
|
||||
![](http://www.tuxarena.com/wp-content/uploads/2014/10/gnome-mines1.jpg)
|
||||
|
||||
### ace-minesweeper ###
|
||||
|
||||
This is part of a package that contains some other games too, like ace-freecel, ace-solitaire or ace-spider. It has a graphical interface featuring Tux, but doesn’t seem to come with different table sizes. The package is called ace-of-penguins in Ubuntu.
|
||||
|
||||
![](http://www.tuxarena.com/wp-content/uploads/2014/10/ace-minesweeper.jpg)
|
||||
|
||||
### XBomb ###
|
||||
|
||||
XBomb is a mines game for the X Window System with three different table sizes and tiles which can take different shapes: hexagonal, rectangular (traditional) or triangular. Unfortunately the current version in Ubuntu 14.04 crashes with a segmentation fault, so you may need to install another version to make it work.
|
||||
[Homepage][1]
|
||||
|
||||
![](http://www.tuxarena.com/wp-content/uploads/2014/10/xbomb.png)
|
||||
|
||||
([Image credit][1])
|
||||
|
||||
### KMines ###
|
||||
|
||||
KMines is the a KDE game, and just like GNOME Mines, there are three built-in table sizes (easy, medium, hard) and custom, support for themes and highscores.
|
||||
|
||||
![](http://www.tuxarena.com/wp-content/uploads/2014/10/kmines.jpg)
|
||||
|
||||
### freesweep ###
|
||||
|
||||
Freesweep is a Minesweeper clone for the terminal which allows you to configure settings such as table rows and columns, percentage of bombs, colors and also has a highscores table.
|
||||
|
||||
![](http://www.tuxarena.com/wp-content/uploads/2014/10/freesweep.jpg)
|
||||
|
||||
### xdemineur ###
|
||||
|
||||
Another graphical Minesweeper clone for X, Xdemineur is very much alike Ace-Minesweeper, with one predefined table size.
|
||||
|
||||
![](http://www.tuxarena.com/wp-content/uploads/2014/10/xdemineur.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tuxarena.com/2014/10/6-minesweeper-clones-for-linux/
|
||||
|
||||
作者:Craciun Dan
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.gedanken.org.uk/software/xbomb/
|
@ -1,3 +1,5 @@
|
||||
su-kaiyao translating
|
||||
|
||||
How to create and use Python CGI scripts
|
||||
================================================================================
|
||||
Have you ever wanted to create a webpage or process user input from a web-based form using Python? These tasks can be accomplished through the use of Python CGI (Common Gateway Interface) scripts with an Apache web server. CGI scripts are called by a web server when a user requests a particular URL or interacts with the webpage (such as clicking a "Submit" button). After the CGI script is called and finishes executing, the output is used by the web server to create a webpage displayed to the user.
|
||||
@ -154,4 +156,4 @@ via: http://xmodulo.com/create-use-python-cgi-scripts.html
|
||||
|
||||
[a]:http://xmodulo.com/author/joshua
|
||||
[1]:http://httpd.apache.org/docs/2.2/howto/cgi.html
|
||||
[2]:https://docs.python.org/2/library/cgi.html#module-cgi
|
||||
[2]:https://docs.python.org/2/library/cgi.html#module-cgi
|
||||
|
@ -1,63 +0,0 @@
|
||||
Linux FAQs with Answers--How to fix “sshd error: could not load host key”
|
||||
================================================================================
|
||||
> **Question**: When I try to SSH to a remote server, SSH client fails with "Connection closed by X.X.X.X". On the SSH server side, I see error messages: "sshd error: could not load host key." What is going on, and how can I fix this error?
|
||||
|
||||
The detailed symptom of this SSH connection error is as follows.
|
||||
|
||||
**SSH client side**: when you attempt to SSH to a remote host, you don't see login screen, and your SSH connection is closed right away with a message: "Connection closed by X.X.X.X"
|
||||
|
||||
**SSH server side**: in a system log, you see the following error messages (e.g., /var/log/auth.log on Debian/Ubuntu).
|
||||
|
||||
Oct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
|
||||
Oct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
|
||||
Oct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
|
||||
Oct 16 08:59:45 openstack sshd[1214]: fatal: No supported key exchange algorithms [preauth]
|
||||
|
||||
The root cause of this problem is that sshd daemon somehow is not able to load SSH host keys.
|
||||
|
||||
When OpenSSH server is first installed on Linux system, SSH host keys should automatically be generated for subsequent use. If, however, key generation was not finished successfully, that can cause SSH login problems like this.
|
||||
|
||||
Let's check if SSH host keys are found where they should be.
|
||||
|
||||
$ ls -al /etc/ssh/ssh*key
|
||||
|
||||
![](https://farm4.staticflickr.com/3931/15367231099_61b9087256_z.jpg)
|
||||
|
||||
If SSH host keys are not found there, or their size is all truncated to zero (like above), you need to regenerate SSH host keys from scratch.
|
||||
|
||||
### Regenerate SSH Host Keys ###
|
||||
|
||||
On Debian, Ubuntu or their derivatives, you can use dpkg-reconfigure tool to regenerate SSH host keys as follows.
|
||||
|
||||
$ sudo rm -r /etc/ssh/ssh*key
|
||||
$ sudo dpkg-reconfigure openssh-server
|
||||
|
||||
![](https://farm4.staticflickr.com/3931/15551179631_363e6a9047_z.jpg)
|
||||
|
||||
On CentOS, RHEL or Fedora, all you have to do is to restart sshd after removing existing (problematic) keys.
|
||||
|
||||
$ sudo rm -r /etc/ssh/ssh*key
|
||||
$ sudo systemctl restart sshd
|
||||
|
||||
An alternative way to regenerate SSH host keys is to manually generate them using ssh-keygen command.
|
||||
|
||||
$ sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
|
||||
$ sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
|
||||
$ sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
|
||||
|
||||
![](https://farm6.staticflickr.com/5603/15367844767_cdfd9716c8_z.jpg)
|
||||
|
||||
Once new SSH host keys are generated, make sure that they are found in /etc/ssh directory. There is no need to restart sshd at this point.
|
||||
|
||||
$ ls -al /etc/ssh/ssh*key
|
||||
|
||||
Now try to SSH again to the SSH server to see if the problem is gone.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/sshd-error-could-not-load-host-key.html
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -0,0 +1,255 @@
|
||||
What are useful Bash aliases and functions
|
||||
================================================================================
|
||||
As a command line adventurer, you probably found yourself repeating the same lengthy commands over and over. If you always ssh into the same machine, if you always chain the same commands together, or if you constantly run a program with the same flags, you might want to save the precious seconds of your life that you spend repeating the same actions over and over.
|
||||
|
||||
The solution to achieve that is to use an alias. As you may know, an alias is a way to tell your shell to remember a particular command and give it a new name: an alias. However, an alias is quickly limited as it is just a shortcut for a shell command, without the ability to pass or control the arguments. So to complement, bash also allows you create your own functions, which can be more lengthy and complex, and also accepts any number of arguments.
|
||||
|
||||
Naturally, like with soup, when you have a good recipe you share it. So here is a list with some of the most useful bash aliases and functions. Note that "most useful" is loosely defined, and of course the usefulness of an alias is dependent on your everyday usage of the shell.
|
||||
|
||||
Before you start experimenting with aliases, here is a handy tip: if you give an alias the same name as a regular command, you can choose to launch the original command and ignore the alias with the trick:
|
||||
|
||||
\command
|
||||
|
||||
For example, the first alias below replaces the ls command. If you wish to use the regular ls command and not the alias, call it via:
|
||||
|
||||
\ls
|
||||
|
||||
### Productivity ###
|
||||
|
||||
So these aliases are really simple and really short, but they are mostly based on the idea that if you save yourself a fraction of a second every time, it might end up accumulating years at the end. Or maybe not.
|
||||
|
||||
alias ls="ls --color=auto"
|
||||
|
||||
Simple but vital. Make the ls command output in color.
|
||||
|
||||
alias ll = "ls --color -al"
|
||||
|
||||
Shortcut to display in color all the files from a directory in a list format.
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
|
||||
Similarly, put some color in the grep output.
|
||||
|
||||
mcd() { mkdir -p "$1"; cd "$1";}
|
||||
|
||||
One of my favorite. Make a directory and cd into it in one command: mcd [name].
|
||||
|
||||
cls() { cd "$1"; ls;}
|
||||
|
||||
Similar to the previous function, cd into a directory and list its content: cls [name].
|
||||
|
||||
backup() { cp "$1"{,.bak};}
|
||||
|
||||
Simple way to make a backup of a file: backup [file] will create [file].bak in the same directory.
|
||||
|
||||
md5check() { md5sum "$1" | grep "$2";}
|
||||
|
||||
Because I hate comparing the md5sum of a file by hand, this function computes it and compares it using grep: md5check [file] [key].
|
||||
|
||||
![](https://farm6.staticflickr.com/5616/15412389280_8be57841ae_o.jpg)
|
||||
|
||||
alias makescript="fc -rnl | head -1 >"
|
||||
|
||||
Easily make a script out of the last command you ran: makescript [script.sh]
|
||||
|
||||
alias genpasswd="strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo"
|
||||
|
||||
Just to generate a strong password instantly.
|
||||
|
||||
![](https://farm4.staticflickr.com/3955/15574321206_dd365f0f0e.jpg)
|
||||
|
||||
alias c="clear"
|
||||
|
||||
Cannot do simpler to clean your terminal screen.
|
||||
|
||||
alias histg="history | grep"
|
||||
|
||||
To quickly search through your command history: histg [keyword]
|
||||
|
||||
alias ..='cd ..'
|
||||
|
||||
No need to write cd to go up a directory.
|
||||
|
||||
alias ...='cd ../..'
|
||||
|
||||
Similarly, go up two directories.
|
||||
|
||||
extract() {
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar e $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1 ;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*) echo "'$1' cannot be extracted via extract()" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
Longest but also the most useful. Extract any kind of archive: extract [archive file]
|
||||
|
||||
### System Info ###
|
||||
|
||||
Want to know everything about your system as quickly as possible?
|
||||
|
||||
alias cmount="mount | column -t"
|
||||
|
||||
Format the output of mount into columns.
|
||||
|
||||
![](https://farm6.staticflickr.com/5603/15598830622_587b77a363_z.jpg)
|
||||
|
||||
alias tree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'"
|
||||
|
||||
Display the directory structure recursively in a tree format.
|
||||
|
||||
sbs() { du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf "%.1f%s", $1>=2**30? ($1/2**30, "G"): $1>=2**20? ($1/2**20, "M"): $1>=2**10? ($1/2**10, "K"): ($1, "")}e';}
|
||||
|
||||
"Sort by size" to display in list the files in the current directory, sorted by their size on disk.
|
||||
|
||||
alias intercept="sudo strace -ff -e trace=write -e write=1,2 -p"
|
||||
|
||||
Intercept the stdout and stderr of a process: intercept [some PID]. Note that you will need strace installed.
|
||||
|
||||
alias meminfo='free -m -l -t'
|
||||
|
||||
See how much memory you have left.
|
||||
|
||||
![](https://farm4.staticflickr.com/3955/15411891448_0b9d6450bd_z.jpg)
|
||||
|
||||
alias ps? = "ps aux | grep"
|
||||
|
||||
Easily find the PID of any process: ps? [name]
|
||||
|
||||
alias volume="amixer get Master | sed '1,4 d' | cut -d [ -f 2 | cut -d ] -f 1"
|
||||
|
||||
Displays the current sound volume.
|
||||
|
||||
![](https://farm4.staticflickr.com/3939/15597995445_99ea7ffcd5_o.jpg)
|
||||
|
||||
### Networking ###
|
||||
|
||||
For all the commands that involve the Internet or your local network, there are fancy aliases for them.
|
||||
|
||||
alias websiteget="wget --random-wait -r -p -e robots=off -U mozilla"
|
||||
|
||||
Download entirely a website: websiteget [URL]
|
||||
|
||||
alias listen="lsof -P -i -n"
|
||||
|
||||
Show which applications are connecting to the network.
|
||||
|
||||
![](https://farm4.staticflickr.com/3943/15598830552_c7e5eaaa0d_z.jpg)
|
||||
|
||||
alias port='netstat -tulanp'
|
||||
|
||||
Show the active ports
|
||||
|
||||
gmail() { curl -u "$1" --silent "https://mail.google.com/mail/feed/atom" | sed -e 's/<\/fullcount.*/\n/' | sed -e 's/.*fullcount>//'}
|
||||
|
||||
Rough function to display the number of unread emails in your gmail: gmail [user name]
|
||||
|
||||
alias ipinfo="curl ifconfig.me && curl ifconfig.me/host"
|
||||
|
||||
Get your public IP address and host.
|
||||
|
||||
getlocation() { lynx -dump http://www.ip-adress.com/ip_tracer/?QRY=$1|grep address|egrep 'city|state|country'|awk '{print $3,$4,$5,$6,$7,$8}'|sed 's\ip address flag \\'|sed 's\My\\';}
|
||||
|
||||
Returns your current location based on your IP address.
|
||||
|
||||
### Useless ###
|
||||
|
||||
So what if some aliases are not all that productive? They can still be fun.
|
||||
|
||||
kernelgraph() { lsmod | perl -e 'print "digraph \"lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | dot -Tpng | display -;}
|
||||
|
||||
To draw the kernel module dependency graph. Requires image viewer.
|
||||
|
||||
alias busy="cat /dev/urandom | hexdump -C | grep "ca fe""
|
||||
|
||||
Make you look all busy and fancy in the eyes of non-technical people.
|
||||
|
||||
![](https://farm6.staticflickr.com/5599/15574321326_ab3fbc1ef9_z.jpg)
|
||||
|
||||
To conclude, a good chunk of these aliases and functions come from my personal .bashrc, and the awesome websites [alias.sh][1] and [commandlinefu.com][2] which I already presented in my post on the [best online tools for Linux][3]. So definitely go check them out, make your own recipes, and if you are so inclined, share your wisdom in the comments.
|
||||
|
||||
As a bonus, here is the plain text version of all the aliases and functions I mentioned, ready to be copy pasted in your bashrc.
|
||||
|
||||
#Productivity
|
||||
alias ls="ls --color=auto"
|
||||
alias ll="ls --color -al"
|
||||
alias grep='grep --color=auto'
|
||||
mcd() { mkdir -p "$1"; cd "$1";}
|
||||
cls() { cd "$1"; ls;}
|
||||
backup() { cp "$1"{,.bak};}
|
||||
md5check() { md5sum "$1" | grep "$2";}
|
||||
alias makescript="fc -rnl | head -1 >"
|
||||
alias genpasswd="strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo"
|
||||
alias c="clear"
|
||||
alias histg="history | grep"
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
extract() {
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar e $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1 ;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*) echo "'$1' cannot be extracted via extract()" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
#System info
|
||||
alias cmount="mount | column -t"
|
||||
alias tree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'"
|
||||
sbs(){ du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf "%.1f%s", $1>=2**30? ($1/2**30, "G"): $1>=2**20? ($1/2**20, "M"): $1>=2**10? ($1/2**10, "K"): ($1, "")}e';}
|
||||
alias intercept="sudo strace -ff -e trace=write -e write=1,2 -p"
|
||||
alias meminfo='free -m -l -t'
|
||||
alias ps?="ps aux | grep"
|
||||
alias volume="amixer get Master | sed '1,4 d' | cut -d [ -f 2 | cut -d ] -f 1"
|
||||
|
||||
#Network
|
||||
alias websiteget="wget --random-wait -r -p -e robots=off -U mozilla"
|
||||
alias listen="lsof -P -i -n"
|
||||
alias port='netstat -tulanp'
|
||||
gmail() { curl -u "$1" --silent "https://mail.google.com/mail/feed/atom" | sed -e 's/<\/fullcount.*/\n/' | sed -e 's/.*fullcount>//'}
|
||||
alias ipinfo="curl ifconfig.me && curl ifconfig.me/host"
|
||||
getlocation() { lynx -dump http://www.ip-adress.com/ip_tracer/?QRY=$1|grep address|egrep 'city|state|country'|awk '{print $3,$4,$5,$6,$7,$8}'|sed 's\ip address flag \\'|sed 's\My\\';}
|
||||
|
||||
#Funny
|
||||
kernelgraph() { lsmod | perl -e 'print "digraph \"lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | dot -Tpng | display -;}
|
||||
alias busy="cat /dev/urandom | hexdump -C | grep \"ca fe\""
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/useful-bash-aliases-functions.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://alias.sh/
|
||||
[2]:http://www.commandlinefu.com/commands/browse
|
||||
[3]:http://xmodulo.com/useful-online-tools-linux.html
|
@ -0,0 +1,115 @@
|
||||
What is a good command-line calculator on Linux
|
||||
================================================================================
|
||||
Every modern Linux desktop distribution comes with a default GUI-based calculator app. On the other hand, if your workspace is full of terminal windows, and you would rather crunch some numbers within one of those terminals quickly, you are probably looking for a **command-line calculator**. In this category, [GNU bc][1] (short for "basic calculator") is a hard to beat one. While there are many command-line calculators available on Linux, I think GNU bc is hands-down the most powerful and useful.
|
||||
|
||||
Predating the GNU era, bc is actually a historically famous arbitrary precision calculator language, with its first implementation dating back to the old Unix days in 1970s. Initially bc was a better known as a programming language whose syntax is similar to C language. Over time the original bc evolved into POSIX bc, and then finally GNU bc of today.
|
||||
|
||||
### Features of GNU bc ###
|
||||
|
||||
Today's GNU bc is a result of many enhancements of earlier implementations of bc, and now it comes standard on all major GNU/Linux distros. It supports standard arithmetic operators with arbitrary precision numbers, and multiple numeric base (e.g., binary, decimal hexadecimal) of input and output.
|
||||
|
||||
If you are familiar with C language, you will see that the same or similar mathematical operators are used in bc. Some of supported operators include arithmetic (+,-,*,/,%,++,--), comparison (<,>,==,!=,<=,>=), logical (!,&&,||), bitwise (&,|,^,~,<<,>>), compound assignment (+=,-=,*=,/=,%=,&=,|=,^=,&&=,||=,<<=,>>=) operators. bc comes with many useful built-in functions such as square root, sine, cosine, arctangent, natural logarithm, exponential, etc.
|
||||
|
||||
### How to Use GNU bc ###
|
||||
|
||||
As a command-line calculator, possible use cases of GNU bc are virtually limitless. In this tutorial, I am going to describe a few popular features of bc command. For a complete manual, refer to the [official source][2].
|
||||
|
||||
Unless you have a pre-written bc script, you typically run bc in interactive mode, where any typed statement or expression terminated with a newline is interpreted and executed on the spot. Simply type the following to enter an interactive bc session. To quit a session, type 'quit' and press Enter.
|
||||
|
||||
$ bc
|
||||
|
||||
![](https://farm4.staticflickr.com/3939/15403325480_d0db97d427_z.jpg)
|
||||
|
||||
The examples presented in the rest of the tutorial are supposed to be typed inside a bc session.
|
||||
|
||||
### Type expressions ###
|
||||
|
||||
To calculate an arithmatic expression, simply type the expression at the blinking cursor, and press Enter. If you want, you can store an intermediate result to a variable, then access the variable in other expressions.
|
||||
|
||||
![](https://farm6.staticflickr.com/5604/15403325460_b004b3f8da_o.png)
|
||||
|
||||
Within a given session, bc maintains a unlimited history of previously typed lines. Simply use UP arrow key to retrieve previously typed lines. If you want to limit the number of lines to keep in the history, assign that number to a special variable named history. By default the variable is set to -1, meaning "unlimited."
|
||||
|
||||
### Switch input/output base ###
|
||||
|
||||
Often times you want to type input expressions and display results in binary or hexadecimal formats. For that, bc allows you switch the numeric base of input or output numbers. Input and output bases are stored in ibase and obase, respectively. The default value of these special variables is 10, and valid values are 2 through 16 (or the value of BC_BASE_MAX environment variable in case of obase). To switch numeric base, all you have to do is to change the values of ibase and obase. For example, here are examples of summing up two hexadecimal/binary numbers:
|
||||
|
||||
![](https://farm6.staticflickr.com/5604/15402320019_f01325f199_z.jpg)
|
||||
|
||||
Note that I specify obase=16 before ibase=16, not vice versa. That is because if I specified ibase=16 first, the subsequent obase=16 statement would be interpreted as assigning 16 in base 16 to obase (i.e., 22 in decimal), which is not what we want.
|
||||
|
||||
### Adjust precision ###
|
||||
|
||||
In bc, the precision of numbers is stored in a special variable named scale. This variable represents the number of decimal digits after the decimal point. By default, scale is set to 0, which means that all numbers and results and truncated/stored in integers. To adjust the default precision, all you have to do is to change the value of scale variable.
|
||||
|
||||
scale=4
|
||||
|
||||
![](https://farm6.staticflickr.com/5597/15586279541_211312597b.jpg)
|
||||
|
||||
### Use built-in functions ###
|
||||
|
||||
Beyond simple arithmatic operations, GNU bc offers a wide range of advanced mathematical functions built-in, via an external math library. To use those functions, launch bc with "-l" option from the command line.
|
||||
|
||||
Some of these built-in functions are illustrated here.
|
||||
|
||||
Square root of N:
|
||||
|
||||
sqrt(N)
|
||||
|
||||
Sine of X (X is in radians):
|
||||
|
||||
s(X)
|
||||
|
||||
Cosine of X (X is in radian):
|
||||
|
||||
c(X)
|
||||
|
||||
Arctangent of X (The returned value is in radian):
|
||||
|
||||
a(X)
|
||||
|
||||
Natural logarithm of X:
|
||||
|
||||
l(X)
|
||||
|
||||
Exponential function of X:
|
||||
|
||||
e(X)
|
||||
|
||||
### Other goodies as a language ###
|
||||
|
||||
As a full-blow calculator language, GNU bc supports simple statements (e.g., variable assignment, break, return), compound statements (e.g., if, while, for loop), and custom function definitions. I am not going to cover the details of these features, but you can easily learn how to use them from the [official manual][2]. Here is a very simple function definition example:
|
||||
|
||||
define dummy(x){
|
||||
return(x * x);
|
||||
}
|
||||
dummy(9)
|
||||
81
|
||||
dummy(4)
|
||||
16
|
||||
|
||||
### Use GNU bc Non-interactively ###
|
||||
|
||||
So far we have used bc within an interactive session. However, quite popular use cases of bc in fact involve running bc within a shell script non-interactively. In this case, you can send input to bc using echo through a pipe. For example:
|
||||
|
||||
$ echo "40*5" | bc
|
||||
$ echo "scale=4; 10/3" | bc
|
||||
$ echo "obase=16; ibase=2; 11101101101100010" | bc
|
||||
|
||||
![](https://farm4.staticflickr.com/3943/15565252976_f50f453c7f_z.jpg)
|
||||
|
||||
To conclude, GNU bc is a powerful and versatile command-line calculator that really lives up to your expectation. Preloaded on all modern Linux distributions, bc can make your number crunching tasks much easy to handle without leaving your terminals. For that, GNU bc should definitely be in your productivity toolset.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/command-line-calculator-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://xmodulo.com/author/nanni
|
||||
[1]:http://www.gnu.org/software/bc/
|
||||
[2]:https://www.gnu.org/software/bc/manual/bc.html
|
@ -1,130 +0,0 @@
|
||||
Unix: stat -- 获取比 ls 更多的信息
|
||||
================================================================================
|
||||
> 厌倦了 ls 命令, 并且想查看更多有关你的文件的有趣的信息? 试一试 stat!
|
||||
|
||||
![](http://www.itworld.com/sites/default/files/imagecache/large_thumb_150x113/stats.jpg)
|
||||
|
||||
ls 命令可能是每一个 Unix 使用者第一个学习的命令之一, 但它仅仅显示了 stat 命令能给出的信息的一小部分.
|
||||
|
||||
stat 命令从文件的索引节点获取信息. 正如你可能已经了解的那样, 每一个系统里的文件都存有三组日期和时间, 它们包括最近修改时间(即使用 ls -l 命令时显示的日期和时间), 最近状态改变时间(包括重命名文件)和最近访问时间.
|
||||
|
||||
使用长列表模式查看文件信息, 你会看到类似下面的内容:
|
||||
|
||||
$ ls -l trythis
|
||||
-rwx------ 1 shs unixdweebs 109 Nov 11 2013 trythis
|
||||
|
||||
使用 stat 命令, 你会看到下面这些:
|
||||
|
||||
$ stat trythis
|
||||
File: `trythis'
|
||||
Size: 109 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731691 Links: 1
|
||||
Access: (0700/-rwx------) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-09-09 19:27:58.000000000 -0400
|
||||
Modify: 2013-11-11 08:40:10.000000000 -0500
|
||||
Change: 2013-11-11 08:40:10.000000000 -0500
|
||||
|
||||
在上面的情形中, 文件的状态改变和文件修改的日期/时间是相同的, 而访问时间则是相当近的时间. 我们还可以看到文件使用了 8 个块, 以及两种格式显示的文件权限 -- 八进制(0700)格式和 rwx 格式. 在第三行显示的索引节点是 12731681. 文件没有其它的硬链接(Links: 1). 而且, 这个文件是一个常规文件.
|
||||
|
||||
重命名文件, 你会看到状态改变时间发生变化.
|
||||
|
||||
这里的 ctime 信息, 最早设计用来存储文件的创建日期和时间, 但之前的某个时间变为用来存储状态修改时间.
|
||||
|
||||
$ mv trythis trythat
|
||||
$ stat trythat
|
||||
File: `trythat'
|
||||
Size: 109 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731691 Links: 1
|
||||
Access: (0700/-rwx------) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-09-09 19:27:58.000000000 -0400
|
||||
Modify: 2013-11-11 08:40:10.000000000 -0500
|
||||
Change: 2014-09-21 12:46:22.000000000 -0400
|
||||
|
||||
改变文件的权限也会改变 ctime 域.
|
||||
|
||||
你也可以配合通配符来使用 stat 命令以列出一组文件的状态:
|
||||
|
||||
$ stat myfile*
|
||||
File: `myfile'
|
||||
Size: 20 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731803 Links: 1
|
||||
Access: (0640/-rw-r-----) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-08-23 03:00:36.000000000 -0400
|
||||
Modify: 2014-08-22 12:02:12.000000000 -0400
|
||||
Change: 2014-08-22 12:02:12.000000000 -0400
|
||||
File: `myfile2'
|
||||
Size: 20 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12731806 Links: 1
|
||||
Access: (0640/-rw-r-----) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-08-23 03:00:36.000000000 -0400
|
||||
Modify: 2014-08-22 12:03:30.000000000 -0400
|
||||
Change: 2014-08-22 12:03:30.000000000 -0400
|
||||
File: `myfile3'
|
||||
Size: 40 Blocks: 8 IO Block: 262144 regular file
|
||||
Device: 18h/24d Inode: 12730533 Links: 1
|
||||
Access: (0640/-rw-r-----) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-08-23 03:00:36.000000000 -0400
|
||||
Modify: 2014-08-22 12:03:59.000000000 -0400
|
||||
Change: 2014-08-22 12:03:59.000000000 -0400
|
||||
|
||||
如果我们喜欢的话, 我们也可以通过其他命令来获取这些信息.
|
||||
|
||||
向 ls -l 命令添加 "u" 选项, 你会获得下面的结果. 注意这个选项会显示最后访问时间, 而添加 "c" 选项则会显示状态改变时间(在本例中, 是我们重命名文件的时间).
|
||||
|
||||
$ ls -lu trythat
|
||||
-rwx------ 1 shs unixdweebs 109 Sep 9 19:27 trythat
|
||||
$ ls -lc trythat
|
||||
-rwx------ 1 shs unixdweebs 109 Sep 21 12:46 trythat
|
||||
|
||||
stat 命令也可应用与文件夹.
|
||||
|
||||
在这个例子中, 我们可以看到有许多的链接.
|
||||
|
||||
$ stat bin
|
||||
File: `bin'
|
||||
Size: 12288 Blocks: 24 IO Block: 262144 directory
|
||||
Device: 18h/24d Inode: 15089714 Links: 9
|
||||
Access: (0700/drwx------) Uid: ( 263/ shs) Gid: ( 100/ unixdweebs)
|
||||
Access: 2014-09-21 03:00:45.000000000 -0400
|
||||
Modify: 2014-09-15 17:54:41.000000000 -0400
|
||||
Change: 2014-09-15 17:54:41.000000000 -0400
|
||||
|
||||
在这里, 我们查看一个文件系统.
|
||||
|
||||
$ stat -f /dev/cciss/c0d0p2
|
||||
File: "/dev/cciss/c0d0p2"
|
||||
ID: 0 Namelen: 255 Type: tmpfs
|
||||
Block size: 4096Fundamental block size: 4096
|
||||
Blocks: Total: 259366 Free: 259337 Available: 259337
|
||||
Inodes: Total: 223834 Free: 223531
|
||||
|
||||
注意 Namelen (文件名长度)域, 如果文件名长于 255 个字符的话, 你会很幸运地在文件名处看到心形符号!
|
||||
|
||||
stat 命令还可以一次显示所有我们想要的信息. 下面的例子中, 我们只想查看文件类型, 然后是硬连接数.
|
||||
|
||||
$ stat --format=%F trythat
|
||||
regular file
|
||||
$ stat --format=%h trythat
|
||||
1
|
||||
|
||||
在下面的例子中, 我们查看了文件权限 -- 分别以两种可用的格式 -- 然后是文件的 SELinux 安全环境.
|
||||
|
||||
译者注: 原文到这里就结束了, 但很明显缺少结尾. 最后一段的例子可以分别用
|
||||
|
||||
$ stat --format=%a trythat
|
||||
$ stat --format=%A trythat
|
||||
$ stat --format=%C trythat
|
||||
|
||||
来实现.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.itworld.com/operating-systems/437351/unix-stat-more-ls
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
译者:[wangjiezhe](https://github.com/wangjiezhe)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.itworld.com/sandra-henry-stocker
|
@ -0,0 +1,63 @@
|
||||
Linux有问必答——如何修复“sshd error: could not load host key”
|
||||
================================================================================
|
||||
> **问题**:当我尝试SSH到一台远程服务器时,SSH客户端登陆失败并提示“Connection closed by X.X.X.X”。在SSH服务器那端,我看到这样的错误消息:“sshd error: could not load host key.”。这发生了什么问题,我怎样才能修复该错误?
|
||||
|
||||
该SSH连接错误的详细症状如下。
|
||||
|
||||
**SSH客户端方面**:当你尝试SSH到一台远程主机时,你没有看见登录屏幕,你的SSH连接就立即关闭,并提示此消息:“Connection closed by X.X.X.X”。
|
||||
|
||||
**SSH服务器方面**:在系统日志中,你看到如下错误消息(如,在Debian/Ubuntu上,/var/log/auth.log)。
|
||||
|
||||
Oct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
|
||||
Oct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
|
||||
Oct 16 08:59:45 openstack sshd[1214]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
|
||||
Oct 16 08:59:45 openstack sshd[1214]: fatal: No supported key exchange algorithms [preauth]
|
||||
|
||||
导致该问题的根源是,sshd守护进程不知怎么地不能加载SSH主机密钥了。
|
||||
|
||||
当OpenSSH服务器第一次安装到Linux系统时,SSH主机密钥应该会自动生成以供后续使用。如果,不管怎样,密钥生成过程没有成功完成,那就会导致这样的SSH登录问题。
|
||||
|
||||
让我们检查能否在相应的地方找到SSH主机密钥。
|
||||
|
||||
$ ls -al /etc/ssh/ssh*key
|
||||
|
||||
![](https://farm4.staticflickr.com/3931/15367231099_61b9087256_z.jpg)
|
||||
|
||||
如果SSH主机密钥在那里找不到,或者它们的大小被切短成为0(就像上面那样),你需要从头开始重新生成主机密钥。
|
||||
|
||||
### 重新生成SSH主机密钥 ###
|
||||
|
||||
在Debian、Ubuntu或其衍生版上,你可以使用dpkg-reconfigure工具来重新生成SSH主机密钥,过程如下:
|
||||
|
||||
$ sudo rm -r /etc/ssh/ssh*key
|
||||
$ sudo dpkg-reconfigure openssh-server
|
||||
|
||||
![](https://farm4.staticflickr.com/3931/15551179631_363e6a9047_z.jpg)
|
||||
|
||||
在CentOS、RHEL或Fedora上,你所要做的是,删除现存(有问题的)密钥,然后重启sshd服务。
|
||||
|
||||
$ sudo rm -r /etc/ssh/ssh*key
|
||||
$ sudo systemctl restart sshd
|
||||
|
||||
另外一个重新生成SSH主机密钥的方式是,使用ssh-keygen命令来手动生成。
|
||||
|
||||
$ sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
|
||||
$ sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
|
||||
$ sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
|
||||
|
||||
![](https://farm6.staticflickr.com/5603/15367844767_cdfd9716c8_z.jpg)
|
||||
|
||||
在生成新的SSH主机密钥后,确保它们能在/etc/ssh目录中找到。此时,不必重启sshd服务。
|
||||
|
||||
$ ls -al /etc/ssh/ssh*key
|
||||
|
||||
现在,再试试SSH到SSH服务器吧,看看问题是否已经离你而去了。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/sshd-error-could-not-load-host-key.html
|
||||
|
||||
译者:[GOLinux](https://github.com/GOLinux)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user