[translated] 20140818 What are useful CLI tools for Linux system admins.md

This commit is contained in:
Frank Zhang 2014-11-18 17:17:00 +08:00
parent 180844ee1f
commit 1085a2e168
2 changed files with 185 additions and 188 deletions

View File

@ -1,188 +0,0 @@
zpl1025
What are useful CLI tools for Linux system admins
================================================================================
System administrators (sysadmins) are responsible for day-to-day operations of production systems and services. One of the critical roles of sysadmins is to ensure that operational services are available round the clock. For that, they have to carefully plan backup policies, disaster management strategies, scheduled maintenance, security audits, etc. Like every other discipline, sysadmins have their tools of trade. Utilizing proper tools in the right case at the right time can help maintain the health of operating systems with minimal service interruptions and maximum uptime.
This article will present some of the most popular and useful CLI tools recommended for sysadmins in their day to day activities. If you would like to recommend any useful tool which is not listed here, don't forget to share it in the comment section.
### Network Tools ###
1. **ping**: Check end-to-end connectivity (RTT delay, jitter, packet loss) of a remote host with ICMP echo/reply. Useful to check system status and reachability.
2. **[phping][1]**: Network scanning and testing tool that can generate ICMP/TCP/UDP ping packets. Often used for advanced port scanning, firewall testing, manual path MTU discovery and fragmentation testing.
3. **traceroute**: Discover a layer-3 forwarding path from a local host to a remote destination host with TTL-limited ICMP/UDP/TCP probe packets. Useful to troubleshoot network reachability and routing problems.
4. **mtr**: A variation of traceroute which characterizes per-hop packet loss/jitter with running statistics. Useful to characterize routing path delays.
5. **[netcat][2]/[socat][3]**: A swiss army knife of TCP/IP networking, allowing to read/write byte streams over TCP/UDP. Useful to troubleshoot firewall policies and service availability.
6. **dig**: DNS troubleshooting tool that can generate forward queries, reverse queries, find authoritative name servers, check CNAME, MX and other DNS records. Can be instructed to query a specific DNS server of your choosing.
7. **nslookup**: Another DNS checking/troubleshooting tool. Works with all DNS queries and records. Can query a particular DNS server.
8. **dnsyo**: A DNS testing tool which checks DNS propagation by performing DNS lookup from over a number of open resolvers located across 1,500 different networks around the world.
9. **lsof**: Show information about files (e.g., regular files, pipes or sockets) which are opened by processes. Useful to monitor open network connections.
10. **iftop**: A ncurses-based TUI utility that can be used to monitor in real time bandwidth utilization and network connections for each network interfaces. Useful to keep track of bandwidth hogging applications, users, destinations and ports.
11. **netstat**: A network statistics utility that can show status information and statistics about open network connections (TCP/UDP ports, IP addresses), routing tables, TX/RX traffic and protocols. Useful for network related diagnosis and performance tuning.
12. **[tcpdump][4]**: A popular packet sniffer tool based on libpcap packet capture library. Can define packet capturing filters in Berkeley Packet Filters format.
13. **[tshark][5]**: Another CLI packet sniffer software with full compatibility with its GUI counterpart, Wireshark. Supports [1,000 protocols][6] and the list is growing. Useful to troubleshoot, analyze and store information on live packets.
14. **ip**: A versatile CLI networking tool which is part of iproute2 package. Used to check and modifying routing tables, network device state, and IP tunneling settings. Useful to view routing tables, add/remove static routes, configure network interfaces, and otherwise troubleshoot routing issues.
15. **ifup/ifdown**: Used to bring up or shut down a particular network interface. Often a preferred alternative to restarting the entire network service.
16. **[autossh][7]**: A program which create an SSH session and automatically restarts the session should it disconnect. Often useful to create a persistent reverse SSH tunnel across restrictive corporate networks.
17. **iperf**: A network testing tool which measures maximum bi-directional throughput between a pair of hosts by injecting customizable TCP/UDP data streams in between.
18. **[elinks][8]/[lynx][9]**: text-based web browsers for CLI-based server environment.
### Security Tools ###
19. **[iptables][10]**: A user-space CLI tool for configuring Linux kernel firewall. Provides means to create and modify rules for incoming, transit and outgoing packets within Linux kernel space.
20. **[nmap][11]**: A popular port scanning and network discovery tool used for security auditing purposes. Useful to find out which hosts are up and running on the local network, and what ports are open on a particular host.
21. **[TCP Wrappers][12]**: A host-based network ACL tool that can be used to filter incoming/outgoing reqeuests/replies. Often used alongside iptables as an additional layer of security.
22. **getfacl/setfacl**: View and customize access control lists of files and directories, as extensions to traditional file permissions.
23. **cryptsetup**: Used to create and manage LUKS-encrypted disk partitions.
24. **lynis**: A CLI-based vulnerability scanner tool. Can scan the entire Linux system, and report potential vulnerabilities along with possible solutions.
25. **maldet**: A malware scanner CLI tool which can detect and quarantine potentially malware-infected files. Can run as a background daemon for continuous monitoring.
26. **[rkhunter][13]/[chkrootkit][14]**: CLI tools which scan for potential rootkits, hidden backdoors and suspected exploits on a local system, and disable them.
### Storage Tools ###
27. **fdisk**: A disk partition editor tool. Used to view, create and modify disk partitions on hard drives and removable media.
28. **sfdisk**: A variant of fdisk which accesses or updates a partition table in a non-interactive fashion. Useful to automate disk partitioning as part of backup and recovery procedure.
29. **[parted][15]**: Another disk partition editor which can support disk larger than 2TB with GPT (GUID Partitioning Table). Gparted is a GTK+ GUI front-end of parted.
30. **df**: Used to check used/available storage and mount point of different partitions or file directories. A user-friendly variant dfc exists.
31. **du**: Used to view current disk usage associated with different files and directories (e.g., du -sh *).
32. **mkfs**: A disk formatting command used to build a filesystem on individual disk partitions. Filesystem-specific versions of mkfs exist for a number of filesystems including ext2, ext3, ext4, bfs, ntfs, vfat/fat.
33. **fsck**: A CLI tool used to check a filesystem for errors and repair where possible. Typically run automatically upon boot when necessary, but also invoked manually on demand once unmounting a partition.
34. **mount**: Used to map a physical disk partition, network share or remote storage to a local mount point. Any read/write in the mount point makes actual data being read/written in the correspoinding actual storage.
35. **mdadm**: A CLI tool for managing software RAID devices on top of physical block devices. Can create, build, grow or monitor RAID array.
36. **lvm**: A suite of CLI tools for managing volume groups and physical/logical volumes, which allows one to create, resize, split and merge volumes on top of multiple physical disks with minimum downtime.
### Log Processing Tools ###
37. **tail**: Used to monitor trailing part of a (growing) log file. Other variants include multitail (multi-window monitoring) and [ztail][16] (inotify support and regex filtering and coloring).
38. **logrotate**: A CLI tool that can split, compresse and mail old/large log files in a pre-defined interval. Useful for administration of busy servers which may produce a large amount of log files.
39. **grep/egrep**: Can be used to filter log content for a particular pattern or a regular expression. Variants include user-friendly ack and faster ag.
40. **awk**: A versatile text scanning and processing tool. Often used to extract certain columns or fields from text/log files, and feed the result to other tools.
41. **sed**: A text stream editor tool which can filter and transform (e.g., remove line/whitespace, substitute/convert a word, add numbering) text streams and pipeline the result to stdout/stderr or another tool.
### Backup Tools ###
42. **[rsync][17]**: A fast one-way incremental backup and mirroring tool. Often used to replicate a data repository to an offsite storage, optionally over a secure connection such as SSH or stunnel.
43. **[rdiff-backup][18]**: Another bandwidth-efficient, incremental backup tool. Maintains differential of two consecutive snapshots.
44. **duplicity**: An encrypted incremental backup utility. Uses GnuPG to encrypt a backup, and transfers to a remote server over SSH.
### Performance Monitoring Tools ###
45. **top**: A CLI-based process viewer program. Can monitor system load, process states, CPU and memory utilization. Variants include more user-friendly htop.
46. **ps**: Shows a snapshot of all running processes in the system. The output can be customized to show PID, PPID, user, load, memory, cummulative user/system time, start time, and more. Variants include pstree which shows
### processes in a tree hierarchy. ###
47. **[nethogs][19]**: A bandwidth monitoring tool which groups active network connections by processes, and reports per-process (upload/download) bandwidth consumption in real-time.
48. **ngxtop**: A web-server access log parser and monitoring tool whose interface is inspired by top command. It can report, in real time, a sorted list of web requests along with frequency, size, HTTP return code, IP address, etc.
49. **vmstat**: A simple CLI tool which shows various run-time system properties such as process count, free memory, paging status, CPU utilization, block I/O activities, interrupt/context switch statistics, and more.
50. **iotop**: An ncurses-based I/O monitoring tool which shows in real time disk I/O activities of all running processes in sorted order.
51. **iostat**: A CLI tool which reports current CPU utilization, as well as device I/O utilization, where I/O utilization (e.g., block transfer rate, byte read/write rate) is reported on a per-device or per-partition basis.
### Productivity Tools ###
52. **screen**: Used to split a single terminal into multiple persistent virtual terminals, which can also be made accessible to remote users, like teamviewer-like screen sharing.
53. **tmux**: Another terminal multiplexer tool which enables multiple persistent sessions, as well as horizontal/vertial splits of a terminal.
54. **cheat**: A simple CLI tool which allows you to read cheat sheets of many common Linux commands, conveniently right at your fingertips. Pre-built cheat sheets are fully customizable.
55. **apropos**: Useful when you are searching man pages for descriptions or keywords.
### Package Management Tools ###
56. **apt**: The de facto package manager for Debian based systems like Debain, Ubuntu or Backtrack. A life saver.
57. **apt-fast**: A supporting utility for apt-get, which can significantly improve apt-get's download speed by using multiple concurrent connections.
58. **apt-file**: Used to find out which .deb package a specific file belongs to, or to show all files in a particular .deb package. Works on both installed and non-installed packages.
59. **dpkg**: A CLI utility to install a .deb package manually. Highly advised to use apt whenever possible.
60. **yum**: The de facto automatic package manager for Red Hat based systems like RHEL, CentOS or Fedora. Yet another life saver.
61. **rpm**: Typically I use rpmyum something. Has some useful parameters like -q, -f, -l for querying, files and locations, respectively.
### Hardware Tools ###
62. **lspci**: A command line tool which shows various information about installed PCI devices, such as model names, device drivers, capabilities, memory address, PCI bus address.
63. **lshw**: A command line tool which queries and displays detailed information of hardware configuration in various categories (e.g., processor, memory, motherboard, network, storage). Supports multiple output formats: html, xml, json, text.
64. **[inxi][20]**: A comprehensive hardware reporting tool which gives an overview of various hardware components such as CPU, graphics card, sound card, network card, temperature/fan sensors, etc.
If you would like to recommend any useful tool which is not listed here, feel free to share it in the comment section.
--------------------------------------------------------------------------------
via: http://xmodulo.com/2014/08/useful-cli-tools-linux-system-admins.html
作者:[Sarmed Rahman][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/sarmed
[1]:http://www.hping.org/
[2]:http://netcat.sourceforge.net/
[3]:http://www.dest-unreach.org/socat/
[4]:http://www.tcpdump.org/
[5]:https://www.wireshark.org/docs/man-pages/tshark.html
[6]:https://www.wireshark.org/docs/dfref/
[7]:http://www.harding.motd.ca/autossh/
[8]:http://elinks.or.cz/
[9]:http://lynx.isc.org/
[10]:http://www.netfilter.org/projects/iptables/
[11]:http://nmap.org/
[12]:http://en.wikipedia.org/wiki/TCP_Wrapper
[13]:http://rkhunter.sourceforge.net/
[14]:http://www.chkrootkit.org/
[15]:http://www.gnu.org/software/parted/
[16]:https://hackage.haskell.org/package/ztail
[17]:http://rsync.samba.org/
[18]:http://www.nongnu.org/rdiff-backup/
[19]:http://nethogs.sourceforge.net/
[20]:http://code.google.com/p/inxi/

View File

@ -0,0 +1,185 @@
对Linux系统管理员有帮助的命令行工具
================================================================================
系统管理员sysadmins负责日常维护生产系统和服务。其中一个关键任务就是保证功能性服务能24小时工作。为了这个他们得很小心地计划备份方式灾难管理策略定时维护安全审查等等。和任意其他管理一样系统管理员也有他们的必备工具。在正确的时间正确的情况下使用合适的工具可以帮助维护操作系统的健壮达到最小的服务中断时间和最大的运行时间。
这篇文章会介绍一些系统管理员日常活动中最常用和有效的命令行工具。如果你想推荐其他没在这里列出来的好用的工具,别忘了在评论区里分享一下。
### 网络工具 ###
1. **ping**通过ICMP回应/回复报文来检查远端主机的端到端连接性RTT延时抖动丢包。用来检查系统状态和可连接性很不错。
2. **[phping][1]**网络扫描和检测工具可以产生ICMP/TCP/UDP ping数据包。常常用于高级端口扫描防火墙测试手动MTU路径发现和碎片测试。
3. **traceroute**通过TTL限定的ICMP/UDP/TCP侦测包来发现从本地主机到远端目标主机之间的第三层转发路径。用来调试网络连接性和路由问题。
4. **mtr**traceroute的一个变种能根据运行时统计数据整理出每一跳的包丢失/抖动。用来评估路由路径延时很不错。
5. **[netcat][2]/[socat][3]**TCP/IP网络里的瑞士军刀可以读/写TCP/UDP协议字节流。用来调试防火墙策略和服务可用性很不错。
6. **dig**DNS调试工具可以生成正向查询反向查询搜索域名服务器检查CNAMEMX和其他DNS记录。可以在侦错的时候查询特定的DNS服务器。
7. **nslookup**另外一个DNS检查/调试工具。支持所有DNS查询和记录。可以查询特定DNS服务器。
8. **dnsyo**一个DNS测试工具通过对全世界1500个不同网络中的大量开放解析器执行DNS查询来测试DNS传输。
9. **lsof**:显示进程打开的文件信息(例如,普通文件,管道或套接字)。用来监视网络连接很不错。
10. **iftop**一个基于ncurses的命令行界面应用可以实时监视各个网络物理接口上的网络连接和带宽占用。用来记录霸占带宽的应用、用户、目的地和端口等很不错。
11. **netstat**一个网络统计工具可以显示状态以及统计信息当前网络连接TCP/UDP端口IP地址、路由表、TX/RX traffic以及网络协议。用来做网络相关诊断和性能调试很不错。
12. **[tcpdump][4]**一个常用的基于libpcap抓包库的包侦测工具。可以按伯克利包过滤器格式定义抓包条件。
13. **[tshark][5]**另一个命令行抓包工具和它的GUI版本Wireshark完全兼容。支持[1000种协议][6]而且这个列表还在增加。用来调试、分析和保存实时网络封包信息很不错。
14. **ip**一个多功能的命令行网络工具是iproute2包的一部分。可以检查和修改路由表、网络设备状态以及IP隧道设置。用来查看路由表、增加/删除静态路由、配置网络接口、以及调试路由问题很有用。
15. **ifup/ifdown**:用来激活和关闭特定的网络接口。经常用于重启整个网络服务。
16. **[autossh][7]**一个能建立SSH连接并在断线后自动重新连接的程序。用来创建长时间保持的穿越严格企业网络的SSH隧道很有用。
17. **iperf**一个网络测试工具通过在发送自定义TCP/UDP数据流来衡量主机间双向最大吞吐量。
18. **[elinks][8]/[lynx][9]**:为基于命令行的服务器环境下使用的基于文字的网页浏览器。
### 安全工具 ###
19. **[iptables][10]**一个用户空间下的命令行工具用于配置Linux内核防火墙。可以创建和修改Linux内核空间的网络包接收、转发和发送规则。
20. **[nmap][11]**:一个常用的为了安全审查目的的端口扫描和网络发现工具。用来在本地网络中找出哪些主机开机并运行起来了以及某台特定主机打开了哪些端口很有用。
21. **[TCP Wrappers][12]**:一个主机端的网络访问控制列表工具,可以过滤进入/出去的网络请求/回复。经常配合iptables一起使用作为额外一层安全保护。
22. **getfacl/setfacl**:查看和定制文件和目录的访问控制列表,作为传统文件权限的扩展。
23. **cryptsetup**用于创建和管理LUKS加密磁盘分区。
24. **lynis**一个命令行的漏洞扫描工具。可以扫描整个Linux系统并汇报潜在的漏洞以及相关可能解决方案。
25. **maldet**:一个恶意软件扫描命令行工具,可以检测和隔离潜在的感染文件。可以在后台运行长期监视。
26. **[rkhunter][13]/[chkrootkit][14]**:一个命令行工具,可以扫描本地系统里的潜在木马、隐藏后门和可疑利用,并禁用它们。
### 存储工具 ###
27. **fdisk**:一个磁盘分区编辑工具。用于查看、创建和修改本地磁盘或可移动磁盘的分区。
28. **sfdisk**fdisk的一个变种能用一种非交互的方式访问或更新磁盘分区表。用来自动化备份和恢复过程中的磁盘分区很有用。
29. **[parted][15]**另一个磁盘分区编辑器支持超过2TB的磁盘的GPTGUID分区表格式。gparted是parted的一个前端GTK+图形界面。
30. **df**:用来查看不同分区或文件路径的已用/可用存储空间和挂载点。存在一个用户友好的变种dfc。
31. **du**用来查看不同文件和目录的当前磁盘占用情况例如du -sh *)。
32. **mkfs**一个磁盘格式化命令用来在独立磁盘分区上建立文件系统。有多个文件系统相关的版本ext2、ext3、ext4、bfs、ntfs、vfat/fat。
33. **fsck**:一个命令行工具,用来检查文件系统错误并尝试可能的修复。通常在启动时自动运行,但是在卸载一个分区后也可以根据需要手动运行。
34. **mount**:用来映射一个物理磁盘分区、网络共享或远程存储到一个本地挂载点。任何对挂载点里的读/写操作都是对应实际存储的实际数据读/写。
35. **mdadm**一个命令行工具用来管理物理块设备上的软件RAID设备。可以创建、构造、增长或监视RAID阵列。
36. **lvm**:一套命令行工具集,用来管理卷分组和物理/逻辑卷,可以用最小的停机时间在多个物理磁盘上创建、调整大小、拆分和合并卷。
### 日志访问工具 ###
37. **tail**用来查看一个增长中的日志文件的尾部。有几个变种包括multitail多窗口查看和[ztail][16]支持inotify和正则表达式过滤以及颜色
38. **logrotate**:一个命令行工具,可以在根据设定的时间段拆分、压缩并邮寄旧的/大的日志文件。用来管理可能产生大量日志文件的繁忙主机很有用。
39. **grep/egrep**可以通过特定的模式或正则表达式过滤日志内容。变种包括用户更友好的ack和速度更快的ag。
40. **awk**:一个多功能的文本扫描和处理工具。常用于从文本/日志文件中找出特定的列或内容,并输出给其他工具。
41. **sed**:一个文本流编辑工具,可以过滤和改变(例如,删除行/空格、替换/转换单词、增加计数文本流并通过管道连接到stdout/stderr或者其他工具。
### 备份工具 ###
42. **[rsync][17]**一个快速的单向增量备份和镜像工具。常用于复制一个数据仓库到线下存储可以选择通过SSH或stunnel的加密连接。
43. **[rdiff-backup][18]**:另一个有效利用带宽的增量备份工具。管理两个连续快照之间的差分。
44. **duplicity**一个加密的增量备份工具。使用GnuPG加密备份并通过SSH上传到远程服务器。
### 性能监视工具 ###
45. **top**一个命令行的进程查看程序。可以监视系统负载、进程状态、CPU和内存占用。有一个更用户友好的变种htop。
46. **ps**显示系统所有运行中进程的一个快照。输出可以定制成显示PID、PPID、用户、负载、内存、积累的用户/系统时间、启动时间、以及更多。有一个变种是pstree可以用树结构显示进程。
47. **[nethogs][19]**:一个带宽监视工具,按进程来分组显示活动网络连接,实时汇报每个进程占用的(上传/下载)带宽。
48. **ngxtop**一个网页服务器访问日志解析和监视工具界面是受top命令启发。它可以实时汇报整理过的页面请求列表包括频率、大小、HTTP返回值、IP地址等等。
49. **vmstat**一个简单的命令行工具可以显示多个实时系统特征例如进程数、剩余内存、分页状态、CPU占用、块设备I/O活动、中断/上下文切换统计、等等。
50. **iotop**一个基于ncurses的I/O监视工具可以实时排序显示所有运行中进程的磁盘I/O活动。
51. **iostat**一个命令行工具可以汇报当前CPU使用情况以及设备I/O使用情况这里的I/O使用情况例如块传输速度、字节读/写速度)是按设备或分区来汇报的。
### 效率工具 ###
52. **screen**用来把一个单一的终端拆分成多个持久的虚拟终端也支持远程用户访问类似teamviewer的屏幕分享功能。
53. **tmux**:另一个终端复用工具,可以支持多个长期会话,还可以横向/纵向拆分终端。
54. **cheat**一个简单的命令行工具可以让你查看多个常用Linux命令的备忘录就在手边非常方便。内建的备忘录也可以完全定制。
55. **apropos**:用来在帮助手册里查找描述或关键字很有用。
### 包管理工具 ###
56. **apt**基于Debian系统的事实上的包管理工具例如Debian、Ubuntu或Backtrack。一个救生圈。
57. **apt-fast**apt-get的一个支撑应用可以通过多个并行连接明显提高apt-get的下载速度。
58. **apt-file**:用来查看某个特定文件属于哪个.deb包或者显示一个特定.deb包里的所有文件。已安装和未安装的包都能支持。
59. **dpkg**:一个用来手动安装.deb包的命令行工具。强烈建议尽可能的使用apt。
60. **yum**基于红帽的系统的事实上的自动包管理工具比如RHEL、CentOS或Fedora。另一个救生圈。
61. **rpm**通常我都是rpmyum一下。有很多有用的参数比如-q、-f、-l可以分别用来查询、指定文件和路径。
### 硬件工具 ###
62. **lspci**一个命令行工具可以显示已安装的PCI设备的各种信息比如型号名称、设备驱动、设备功能、内存地址、PCI总线地址。
63. **lshw**一个命令行工具可以查询和显示不同分类下的硬件配置的详细信息例如处理器、内存、主板、网络、存储。支持多重输出格式html、xml、json、text。
64. **[inxi][20]**一个综合硬件查看工具可以提供不同硬件模块的总览例如CPU显卡声卡网卡温度/风扇传感器,等等。
如果你希望推荐没有列在这里的好用的工具,不要客气,在评论区里分享一下。
--------------------------------------------------------------------------------
via: http://xmodulo.com/2014/08/useful-cli-tools-linux-system-admins.html
作者:[Sarmed Rahman][a]
译者:[zpl1025](https://github.com/zpl1025)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/sarmed
[1]:http://www.hping.org/
[2]:http://netcat.sourceforge.net/
[3]:http://www.dest-unreach.org/socat/
[4]:http://www.tcpdump.org/
[5]:https://www.wireshark.org/docs/man-pages/tshark.html
[6]:https://www.wireshark.org/docs/dfref/
[7]:http://www.harding.motd.ca/autossh/
[8]:http://elinks.or.cz/
[9]:http://lynx.isc.org/
[10]:http://www.netfilter.org/projects/iptables/
[11]:http://nmap.org/
[12]:http://en.wikipedia.org/wiki/TCP_Wrapper
[13]:http://rkhunter.sourceforge.net/
[14]:http://www.chkrootkit.org/
[15]:http://www.gnu.org/software/parted/
[16]:https://hackage.haskell.org/package/ztail
[17]:http://rsync.samba.org/
[18]:http://www.nongnu.org/rdiff-backup/
[19]:http://nethogs.sourceforge.net/
[20]:http://code.google.com/p/inxi/