Whether you are a sysadmin, developer, DevOps, security professional or operations staff... using Linux and its tools effectively is the most essential skill you can learn. Linux is the backbone of most of the world's servers and applications.
According to Statista: "47% of professional developers use Linux-based operating systems."
In most of the previous articles, you must have read many articles similar to "9 Linux commands you must know" or "Linux Commands Beginner's Guide". I found that almost all of these articles were aimed at beginners, teaching people how to use ls or echo. I believe that most of my readers are familiar with at least the basic commands provided by the Linux command line. This article will no longer be that article.
I will document and present a cheat sheet of commands that I use every day at work. This curated list goes beyond beginner level and focuses on commands that will help you advance further and more efficiently manage your Linux system and its key tools.
This article will be divided into two parts:
(1) Practical tools
1、rsync
Usage examples
$ rsync -vap --ignore-existing # Key flags: v = verbrose, r = recursive, p = preserve permissions, g = group, o = owner, a = archive, - -progress = progresss bar
Used to copy files and directories to a target location, similar to the cp command. However, it also allows copying to remote locations and can provide a progress bar, often used for backups.
2、mkpasswd
An example is as shown below:
mkpasswd is a simple but very useful command that can generate complex random passwords of a specified length.
3、screen
Usage example:
screen
$ screen # 启动screen 会话 $ screen -ls # 列出正在运行的服务 $ screen -r # 附加到会话
Screen is a full-screen window manager; it creates a single window with a running shell and allows multiple screen windows to be run in a single session. It's most beneficial when you're running a long task remotely and worry about your SSH session disconnecting and breaking everything. Even if the window is not visible to you, Screen will survive the disconnect and continue running your commands.
Related links: Tips on using the terminal multiplexer screen command under Linux https://www.linuxmi.com/linux-screen.html
4、Ldapsearch
Usage example:
$ ldapsearch -x -W -D # Key Flags -x = simple authentication, -W = prompt for password, - D = Use distinguished binddn name to bind to LDAP directory
If you frequently use LDAP databases, you must use the Ldapsearch tool. This tool opens a connection to an LDAP server and allows you to search, find, and debug entries in the database.
(2) Monitoring tools
1、Uptime
Uptime Returns metrics about server uptime, current time, number of users, and average memory usage. If there is a problem with the server, this is usually the first information to look at.
‘w’ – yes, only one letter. This is a great combination of running uptime and who commands back to back. $ w
2、Wall
Wall is a handy command for any system administrator; it allows you to send messages to all user terminals currently logged into the system. This is useful for system-wide announcements.
Send message "hi" to every user
linuxmi@linuxmi /home/linuxmi/www.linuxmi.com ⚡ wall hi
3、Top
As shown below:
The Top command can automatically refresh the process list showing CPU and critical memory usage and CPU usage metrics.
4、Ncdu
As shown below:
ncdu 命令可以快速方便地查看磁盘使用情况,让你可以快速轻松地查看哪些目录占用了最多的磁盘空间。
5、lsof
lsof 命令的一个基本目的是列出打开的文件,当出现文件被占用的挂载问题时,这个命令非常有用。它可以快速识别哪些进程正在使用哪些文件。
(三)网络工具
1、Netcat
Netcat 或 nc 主要用于端口扫描,但实际上它是一种很好的网络工具,系统管理员可以在任何任务中使用。Netcat 可以支持端口扫描、文件复制、端口转发、代理服务器和主机服务器等多种功能,可以说它非常多才多艺。
Netcat 非常可定制化,如果您想了解更多,请查看这个链接:https://www.linuxmi.com/linux-netcat.html
2、NetStat
使用示例:
$ netstat -a #列出所有网络端口 $ netstat -tlpn # 列出所有侦听端口# Key Flags -s = Show statistics, -v = verbrose, -r = show routing tables, -i display interface table, -g = show group memeberships
NetStat 返回各种网络详细信息,如路由表、网络连接、成员、统计数据、标志等。
相关:Linux 下 12 个监视网络连接的 ss 命令示例 https://www.linuxmi.com/linux-ss-command.html
3、Nslookup
使用示例:
$ nslookup www.93139.com/tags/devops# Key Flags -port = Change port number for connection, -type = Change type of query. -domain = Sets search list to name
Nslookup 是用于获取 Internet 或本地网络上的服务器信息的命令。它查询 DNS 以查找名称服务器信息,并可用于网络调试。
4、TCPDump
TCPDump 用于捕获和分析进出您系统的流量。它是一种强大而多才多艺的工具,专门用于调试和解决网络问题,但也可以用作安全工具。
相关:
OK,这就是本文的内容。如果还有什么疑问,请在下面的评论区告诉我们。
The above is the detailed content of The most important Linux command no one teaches you. For more information, please follow other related articles on the PHP Chinese website!