linux执行多个命令

Using Linux command on a regular basis? Today we’ll look at 50+ Linux commands you must know! The commands listed below are some of the most useful and most frequently used Linux commands. Let’s get right into it!

定期使用Linux命令吗? 今天,我们将介绍您必须知道的 50多个Linux命令 ! 下面列出的命令是一些最有用和最常用的Linux命令。 让我们开始吧!

普通用户必须了解的前50个Linux命令 (Top 50 Linux Commands You Must Know as a Regular User)

  1. ls – The most frequently used command in Linux to list directoriesls – Linux中最常用的命令来列出目录
  2. pwd – Print working directory command in Linuxpwd – Linux中的打印工作目录命令
  3. cd – Linux command to navigate through directoriescd –用于浏览目录的Linux命令
  4. mkdir – Command used to create directories in Linuxmkdir –用于在Linux中创建目录的命令
  5. mv – Move or rename files in Linuxmv –在Linux中移动或重命名文件
  6. cp – Similar usage as mv but for copying files in Linuxcp –与mv类似,但用于在Linux中复制文件
  7. rm – Delete files or directoriesrm –删除文件或目录
  8. touch – Create blank/empty files触摸 –创建空白/空文件
  9. ln – Create symbolic links (shortcuts) to other filesln –创建指向其他文件的符号链接(快捷方式)
  10. cat – Display file contents on the terminalcat –在终端上显示文件内容
  11. clear – Clear the terminal display清除 –清除终端显示
  12. echo – Print any text that follows the commandecho –打印命令后的所有文本
  13. less – Linux command to display paged outputs in the terminalless – Linux命令在终端中显示页面输出
  14. man – Access manual pages for all Linux commandsman –访问所有Linux命令的手册页
  15. uname – Linux command to get basic information about the OSuname –用于获取有关操作系统基本信息的Linux命令
  16. whoami – Get the active usernamewhoami –获取活动的用户名
  17. tar – Command to extract and compress files in Linuxtar –在Linux中提取和压缩文件的命令
  18. grep – Search for a string within an outputgrep –在输出中搜索字符串
  19. head – Return the specified number of lines from the tophead –从顶部返回指定的行数
  20. tail – Return the specified number of lines from the bottomtail –从底部返回指定的行数
  21. diff – Find the difference between two filesdiff –查找两个文件之间的差异
  22. cmp – Allows you to check if two files are identicalcmp –允许您检查两个文件是否相同
  23. comm – Combines the functionality of diff and cmpcomm –结合了diff和cmp的功能
  24. sort – Linux command to sort the content of a file while outputtingsort – Linux命令在输出时对文件内容进行排序
  25. export – Export environment variables in Linux导出 –在Linux中导出环境变量
  26. zip – Zip files in Linuxzip – Linux中的Zip文件
  27. unzip – Unzip files in Linux解压缩 –在Linux中压缩文件
  28. ssh – Secure Shell command in Linuxssh – Linux中的Secure Shell命令
  29. service – Linux command to start and stop services服务 –用于启动和停止服务的Linux命令
  30. ps – Display active processesps –显示活动进程
  31. kill and killall – Kill active processes by process ID or namekill and killall –按进程ID或名称杀死活动进程
  32. df – Display disk filesystem informationdf –显示磁盘文件系统信息
  33. mount – Mount file systems in Linuxmount –在Linux中挂载文件系统
  34. chmod – Command to change file permissionschmod –更改文件权限的命令
  35. chown – Command for granting ownership of files or folderschown –授予文件或文件夹所有权的命令
  36. ifconfig – Display network interfaces and IP addressesifconfig –显示网络接口和IP地址
  37. traceroute – Trace all the network hops to reach the destinationtraceroute –跟踪所有网络跃点以到达目的地
  38. wget – Direct download files from the internetwget –从互联网直接下载文件
  39. ufw – Firewall commandufw –防火墙命令
  40. iptables – Base firewall for all other firewall utilities to interface withiptables –所有其他防火墙实用程序要与之交互的基本防火墙
  41. apt, pacman, yum, rpm – Package managers depending on the distroapt,pacman,yum,rpm –取决于发行版的软件包管理器
  42. sudo – Command to escalate privileges in Linuxsudo –在Linux中升级特权的命令
  43. cal – View a command-line calendarcal –查看命令行日历
  44. alias – Create custom shortcuts for your regularly used commands别名–为常用命令创建自定义快捷方式
  45. dd – Majorly used for creating bootable USB sticksdd –主要用于创建可启动的USB记忆棒
  46. whereis – Locate the binary, source, and manual pages for a commandwhereis –找到命令的二进制,源和手册页
  47. whatis – Find what a command is used forwhatis –查找命令的用途
  48. top – View active processes live with their system usage页首 –实时查看活动进程及其系统使用情况
  49. useradd and usermod – Add new user or change existing users datauseradd和usermod –添加新用户或更改现有用户数据
  50. passwd – Create or update passwords for existing userspasswd –为现有用户创建或更新密码

Now let’s dive a little deeper into each of these commands and understand them in more detail. We already have a lot of existing articles for each of those individual commands. For your convenience, we’ll add links to all the existing articles, and continue to update the article as new topics are covered.

现在让我们更深入地研究这些命令,并更详细地了解它们。 对于每个单独的命令,我们已经有很多现有的文章。 为了方便起见,我们将添加所有现有文章的链接,并在涵盖新主题时继续更新文章。

Linux中的ls命令 (The ls command in Linux)

The ls command is used to list files and directories in the current working directory. This is going to be one of the most frequently used Linux commands you must know of.

ls命令用于列出当前工作目录中的文件和目录。 这将成为您必须知道的最常用的Linux命令之一。

As you can see in the above image, using the command by itself without any arguments will give us an output with all the files and directories in the directory. The command offers a lot of flexibility in terms of displaying the data in the output.

如上图所示,不带任何参数的命令本身将为我们提供目录中所有文件和目录的输出。 该命令在显示输出中的数据方面提供了很大的灵活性。

Learn more about the ls command (link to full article)

了解有关ls命令的更多信息(链接到完整的文章)

Linux中的pwd命令 (The pwd command in Linux)

The pwd command allows you to print the current working directory on your terminal. It’s a very basic command and solves its purpose very well.

pwd命令允许您在终端上打印当前工作目录。 这是一个非常基本的命令,可以很好地解决其目的。

Now, your terminal prompt should usually have the complete directory anyway. But in case it doesn’t, this can be a quick command to see the directory that you’re in. Another application of this command is when creating scripts where this command can allow us to find the directory where the script has been saved.

现在,无论如何,您的终端提示符通常应该具有完整的目录。 但是如果没有,这可以是查看您所在目录的快速命令。该命令的另一个应用是在创建脚本时,该命令可以使我们找到保存脚本的目录。

Linux中的cd命令 (The cd command in Linux)

While working within the terminal, moving around within directories is pretty much a necessity. The cd command is one of the important Linux commands you must know and it will help you to navigate through directories. Just type cd followed by directory as shown below.

在终端中工作时,在目录中四处移动是非常必要的。 cd命令是您必须知道的重要Linux命令之一,它将帮助您浏览目录。 只需键入cd,然后键入目录,如下所示。


root@ubuntu:~# cd <directory path>

As you can see in the above command, I simply typed cd /etc/ to get into the /etc directory. We used the pwd command to print the current working directory.

如您在上面的命令中看到的,我只是键入cd / etc /进入/ etc目录。 我们使用pwd命令打印当前工作目录。

Linux中的mkdir命令 (The mkdir command in Linux)

The mkdir command allows you to create directories from within the terminal. The default syntax is mkdir followed by the directory name.

mkdir命令允许您从终端内部创建目录。 默认语法为mkdir,后跟目录名称。


root@ubuntu:~# mkdir <folder name>

As you can see in the above screenshot, we created the JournalDev directory with just this simple command.

如您在上面的屏幕快照中所见,我们仅使用此简单命令创建了JournalDev目录。

Learn more about the mkdir command (Link to article)

了解有关mkdir命令的更多信息(链接到文章)

cp和mv命令 (The cp and mv commands)

The cp and mv commands are equivalent to the copy-paste and cut-paste in Windows. But since Linux doesn’t really have a command for renaming files, we also make use of the mv command to rename files and folders.

cp和mv命令等效于Windows中的复制粘贴和剪切粘贴。 但是,由于Linux确实没有用于重命名文件的命令,因此我们还使用mv命令来重命名文件和文件夹。


root@ubuntu:~# cp <source> <destination>

In the above command, we created a copy of the file named Sample. Let’s see how what happens if we use the mv command in the same manner. For this demonstration, I’ll delete the Sample-Copy file.

在上面的命令中,我们创建了一个名为Sample的文件的副本。 让我们看看如果以相同的方式使用mv命令会发生什么。 对于此演示,我将删除Sample-Copy文件。


root@ubuntu:~# mv <source> <destination

In the above case, since we were moving the file within the same directory, it acted as rename. The file name is now changed.

在上述情况下,由于我们将文件移到同一目录中,因此它起了重命名的作用。 现在,文件名已更改。

Learn more about the cp command (Link to article) and mv command (Link to article).

了解有关cp命令(链接到文章)和mv命令(链接到文章)的更多信息 。

Linux中的rm命令 (The rm command in Linux)

In the previous section, we deleted the Sample-Copy file. The rm command is used to delete files and folders and is one of the important Linux commands you must know.

在上一节中,我们删除了Sample-Copy文件。 rm命令用于删除文件和文件夹,它是您必须知道的重要Linux命令之一。


root@ubuntu:~# rm <file name>
root@ubuntu:~# rm -r <folder/directory name>

To delete a directory, you have to add the -r argument to it. Without the -r argument, rm command won’t delete directories.

要删除目录,必须在其中添加-r参数。 如果没有-r参数,则rm命令不会删除目录。

Linux中的touch命令 (The touch command in Linux)

To create a new file, the touch command will be used. The touch keyword followed by the file name will create a file in the current directory.

要创建一个新文件,将使用touch命令。 touch关键字后跟文件名将在当前目录中创建一个文件。


root@ubuntu:~# touch <file name>

Linux中的ln命令 (The ln command in Linux)

To create a link to another file, we use the ln command. This is one of the important Linux commands that you should know if you’re planning to work as a Linux administrator.

要创建到另一个文件的链接,我们使用ln命令。 如果您打算以Linux管理员身份工作,这是您应该知道的重要Linux命令之一。


root@ubuntu:~# ln -s <source path> <link name>

The basic syntax involves using the -s parameter so we can create a symbolic link or soft link.

基本语法涉及使用-s参数,因此我们可以创建符号链接或软链接。

cat,echo和less命令 (The cat, echo, and less commands)

When you want to output the contents of a file, or print anything to the terminal output, we make use of the cat or echo commands. Let’s see their basic usage. I’ve added some text to our New-File that we created earlier.

当您要输出文件的内容或将任何内容打印到终端输出时,我们可以使用cat或echo命令。 让我们看看它们的基本用法。 我已经向我们先前创建的新文件中添加了一些文本。


root@ubuntu:~# cat <file name>
root@ubuntu:~# echo <Text to print on terminal>

As you can see in the above example, the cat command when used on our “New-File”, prints the contents of the file. At the same time, when we use echo command, it simply prints whatever follows after the command.

正如您在上面的示例中看到的那样,当在我们的“新文件”上使用cat命令时,将打印文件的内容。 同时,当我们使用echo命令时 ,它只是在命令后打印任何内容。

The less command is used when the output printed by any command is larger than the screen space and needs scrolling. The less command allows use to break down the output and scroll through it with the use of the enter or space keys.

当任何命令打印的输出大于屏幕空间并且需要滚动时,使用less命令 。 less命令允许使用回车或空格键分解输出并滚动输出。

The simple way to do this is with the use of the pipe operator (|).

最简单的方法是使用管道运算符( | )。


root@ubuntu:~# cat /boot/grub/grub.cfg  | less

Learn more about the echo command(Link to article) and cat command(Link to article).

了解有关echo命令(链接到文章)和cat命令(链接到文章)的更多信息 。

Linux中的man命令 (The man command in Linux)

The man command is a very useful Linux command you must know. When working with Linux, the packages that we download can have a lot of functionality. Knowing it all is impossible.

man命令是您必须知道的非常有用的Linux命令。 使用Linux时,我们下载的软件包可以具有很多功能。 知道这一切是不可能的。

The man pages offer a really efficient way to know the functionality of pretty much all the packages that you can download using the package managers in your Linux distro.

手册页提供了一种非常有效的方式来了解几乎所有可以使用Linux发行版中的软件包管理器下载的软件包的功能。


root@ubuntu:~# man <command>

uname和whoami命令 (The uname and whoami commands)

The uname and whoami commands allow you to know some basic information which comes really handy when you work on multiple systems. In general, if you’re working with a single computer, you won’t really need it as often as someone who is a network administrator.

使用uname和whoami命令,您可以了解一些基本信息,当您在多个系统上工作时,这些信息非常方便。 通常,如果您使用的是单台计算机,则实际上并不需要像网络管理员那样频繁地使用它。

Let’s see the output of both the commands and the way we can use these.

让我们看看命令的输出以及我们使用它们的方式。


root@ubuntu:~# uname -a

The parameter -a which I’ve supplied to uname, stands for “all”. This prints out the complete information. If the parameter is not added, all you will get as the output is “Linux”.

我提供给uname的参数-a代表“全部”。 这将打印出完整的信息。 如果未添加该参数,您将得到的所有结果都是“ Linux”。

tar,zip和unzip命令 (The tar, zip, and unzip commands)

The tar command in Linux is used to create and extract archived files in Linux. We can extract multiple different archive files using the tar command.

Linux中的tar命令用于在Linux中创建和提取存档文件。 我们可以使用tar命令提取多个不同的存档文件。

To create an archive, we use the -c parameter and to extract an archive, we use the -x parameter. Let’s see it working.

要创建档案,我们使用-c参数,并使用-x参数提取档案。 让我们看看它的工作原理。


#Compress
root@ubuntu:~# tar -cvf <archive name> <files seperated by space>
#Extract
root@ubuntu:~# tar -xvf <archive name>

In the first line, we created an archive named Compress.tar with the New-File and New-File-Link. In the next command, we have extracted those files from the archive.

在第一行中,我们使用New-File和New-File-Link创建了一个名为Compress.tar的存档。 在下一个命令中,我们从存档中提取了这些文件。

Now coming to the zip and unzip commands. Both these commands are very straight forward. You can use them without any parameters and they’ll work as intended. Let’s see an example below.

现在介绍zip和unzip命令。 这两个命令都非常简单。 您可以不带任何参数地使用它们,它们将按预期工作。 让我们看下面的例子。


root@ubuntu:~# zip <archive name> <file names separated by space>
root@ubuntu:~# unzip <archive name>

Since we already have those files in the same directory, the unzip command prompts us before overwriting those files.

由于我们已经在同一目录中拥有这些文件,因此unzip命令会在覆盖这些文件之前提示我们。

Learn more about the tar command (Link to article) and zip and unzip commands (Link to article)

了解有关tar命令(链接到文章)以及zip和unzip命令(链接到文章)的更多信息

Linux中的grep命令 (The grep command in Linux)

If you wish to search for a specific string within an output, the grep command comes into the picture. We can pipe (|) the output to the grep command and extract the required string.

如果您想在输出中搜索特定的字符串,则可以使用grep命令。 我们可以将输出|| )输送到grep命令并提取所需的字符串。


root@ubuntu:~# <Any command with output> | grep "<string to find>"

This was a simple demonstration of the command. Learn more about the grep command (Link to article)

这是该命令的简单演示。 了解有关grep命令的更多信息(链接到文章)

头尾命令 (The head and tail commands)

When outputting large files, the head and the tail commands come in handy. I’ve created a file named “Words” with a lot of words arranged alphabetically in it. The head command will output the first 10 lines from the file, while the tail command will output the last 10. This also includes any blank lines and not just lines with text.

输出大文件时,head和tail命令很方便。 我创建了一个名为“ Words”的文件,其中有许多单词按字母顺序排列。 head命令将输出文件的前10行,而tail命令将输出文件的后10行。这还包括任何空行,而不仅仅是带有文本的行。


root@ubuntu:~# head <file name>
root@ubuntu:~# tail <file name>

As you can see, the head command showed 10 lines from the top of the file.

如您所见,head命令从文件顶部显示了10行。

The tail command outputted the bottom 10 lines from the file.

tail命令从文件输出后10行。

Learn more about the tail command(Link to article)

了解有关tail命令的更多信息(链接到文章)

diff,comm和cmp命令 (The diff, comm, and cmp commands)

Linux offers multiple commands to compare files. The diff, comm, and cmp commands compare differences and are some of the most useful Linux commands you must know. Let’s see the default outputs for all the three commands.

Linux提供了多个命令来比较文件。 diff,comm和cmp命令比较差异,它们是您必须知道的一些最有用的Linux命令。 让我们看一下这三个命令的默认输出。


root@ubuntu:~# diff <file 1> <file 2>

As you can see above, I’ve added a small piece of text saying “This line is edited” to the New-File-Edited file.

如您在上面看到的,我在新文件编辑的文件中添加了一小段文字“此行已编辑”。


root@ubuntu:~# cmp <file 1> <file 2>

The cmp command only tells use the line number which is different. Not the actual text. Let’s see what the comm command does.

cmp命令仅告诉使用不同的行号。 不是实际的文字。 让我们看看comm命令的作用。


root@ubuntu:~# comm <file 1> <file2>

The text that’s aligned to the left is the text that’s only present in file 1. The center-aligned text is present only in file 2. And the right-aligned text is present in both the files.

左对齐的文本是仅存在于文件1中的文本。居中对齐的文本仅存在于文件2中。两个文件中都存在右对齐的文本。

By the looks of it, comm command makes the most sense when we’re trying to compare larger files and would like to see everything arranged together.

从外观上看,当我们尝试比较较大的文件并希望看到所有排列在一起的文件时,comm命令最有意义。

Linux中的sort命令 (The sort command in Linux)

The sort command will provide a sorted output of the contents of a file. Let’s use the sort command without any parameters and see the output.

sort命令将提供文件内容的排序输出。 让我们使用不带任何参数的sort命令并查看输出。

The basic syntax of the sort command is:

sort命令的基本语法为:


root@ubuntu:~# sort <filename>

Linux中的export命令 (The export command in Linux)

The export command is specially used when exporting environment variables in runtime. For example, if I wanted to update the bash prompt, I’ll update the PS1 environment variable. The bash prompt will be updated with immediate effect.

导出命令在运行时导出环境变量时特别使用。 例如,如果要更新bash提示,则将更新PS1环境变量。 bash提示将立即更新。


root@ubuntu:~# export <variable name>=<value>

If for some reason, your bash prompt doesn’t update, just type in bash and you should see the updated terminal prompt.

如果由于某种原因您的bash提示没有更新,只需键入bash ,您应该会看到更新后的终端提示。

Learn more about the export command(Link to article)

了解有关导出命令的更多信息(链接到文章)

Linux中的ssh命令 (The ssh command in Linux)

The ssh command allows us to connect to an external machine on the network with the use of the ssh protocol. The basic syntax of the ssh command is:

ssh命令允许我们使用ssh协议连接到网络上的外部计算机。 ssh命令的基本语法为:


root@ubuntu:~ -->> ssh username@hostname

Learn more about ssh command(Link to article)

了解有关ssh命令的更多信息(链接到文章)

Linux中的service命令 (The service command in Linux)

The service command in Linux is used for starting and stopping different services within the operating system. The basic syntax of the command is as below.

Linux中的service命令用于启动和停止操作系统中的不同服务。 该命令的基本语法如下。


root@ubuntu:~ -->> service ssh status
root@ubuntu:~ -->> service ssh stop
root@ubuntu:~ -->> service ssh start

As you can see in the image, the ssh server is running on our system.

正如您在图中所看到的,ssh服务器正在我们的系统上运行。

ps,kill和killall命令 (The ps, kill, and killall commands)

While we’re on the topic of processes, let’s see how we can find active processes and kill them. To find the running processes, we can simply type ps in the terminal prompt and get the list of running processes.

当我们讨论流程主题时,让我们看看如何找到活动的流程并杀死它们。 要查找正在运行的进程,我们只需在终端提示符下键入ps即可获取正在运行的进程的列表。


root@ubuntu:~ -->> ps
root@ubuntu:~ -->> kill <process ID>
root@ubuntu:~ -->> killall <process name>

For demonstration purposes, I’m creating a shell script with an infinite loop and will run it in the background.

出于演示目的,我正在创建一个具有无限循环的shell脚本,并将其在后台运行。

With the use of the & symbol, I can pass a process into the background. As you can see, a new bash process with PID 14490 is created.

通过使用符号,我可以将过程传递到后台。 如您所见,使用PID 14490创建了一个新的bash进程。

Now, to kill a process with the kill command, you can type kill followed b the PID of the process.

现在,要使用kill命令杀死进程,您可以在进程的PID后面键入kill

But if you do not know the process ID and just want to kill the process with the name, you can make use of the killall command.

但是,如果您不知道进程ID,而只想使用名称杀死该进程,则可以使用killall命令。

You will notice that PID 14490 stayed active. That is because both the times, I killed the sleep process.

您会注意到PID 14490保持活动状态。 那是因为两次,我都杀死了睡眠过程。

Learn more about ps command (Link to article).

了解有关ps命令的更多信息(链接到文章) 。

df和mount命令 (The df and mount commands)

When working with Linux, the df and mount commands are very efficient utilities to mount filesystems and get details of the file system.

当使用Linux时,df和mount命令是非常有效的实用程序,用于挂载文件系统并获取文件系统的详细信息。

When I say mount, it means that we’ll connect the device to a folder so we can access the files from our filesystem. The default syntax to mount a filesystem is below:

当我说挂载时,这意味着我们将设备连接到文件夹,以便可以从文件系统访问文件。 挂载文件系统的默认语法如下:


root@ubuntu:~ -->> mount /dev/cdrom /mnt
root@ubuntu:~ -->> df -h

In the above case, /dev/cdrom is the device that needs to be mounted. Usually, a mountable device is found inside the /dev folder. /mnt is the destination folder to mount the device to. You can change it to any folder you want but I’ve used /mnt as it’s pretty much a system default folder for mounting devices.

在上述情况下, / dev / cdrom是需要挂载的设备。 通常,可在/ dev文件夹中找到可安装的设备。 / mnt是将设备挂载到的目标文件夹。 您可以将其更改为所需的任何文件夹,但是我使用了/ mnt,因为它几乎是用于安装设备的系统默认文件夹。

To see the mounted devices and get more information about them, we make use of the df command. Just typing df will give us the data in bytes which is not readable. So we’ll use the -h parameter to make the data human-readable.

要查看已安装的设备并获取有关它们的更多信息,我们使用df命令。 只需输入df,就会以字节为单位提供不可读的数据。 因此,我们将使用-h参数使数据易于阅读。

Learn more about the df command(Link to article)

了解有关df命令的更多信息(链接到文章)

chmod和chown命令 (The chmod and chown commands)

The chmod and chown commands give us the functionality to change the file permissions and file ownership are the most important Linux commands you should know.

chmod和chown命令为我们提供了更改文件许可权和文件所有权的功能,这是您应该了解的最重要的Linux命令。

The main difference between the functions of the two commands is that the chmod command allows changing file permissions, while chown allows us to change the file owners.

这两个命令的功能之间的主要区别在于chmod命令允许更改文件许可权,而chown允许我们更改文件所有者。

The default syntax for both the commands is chmod <parameter> filename and chown <user:group> filename

这两个命令的默认语法均为chmod <parameter>文件名chown <user:group>文件名


root@ubuntu:~ -->> chmod +x loop.sh
root@ubuntu:~ -->> chmod root:root loop.sh

In the above example, we’re adding executable permissions to the loop.sh file with the chmod command. Apart from that, with the chown command, we’ve made it accessible only by root user and users within the root group.

在上面的示例中,我们使用chmod命令将可执行权限添加到loop.sh文件中。 除此之外,通过chown命令 ,我们使它只能由root用户和root组中的用户访问。

As you will notice, the root root part is now changed to www-data which is the new user who has full file ownership.

您将注意到, 根根部分现在更改为www-data ,这是具有完全文件所有权的新用户。

Learn more about the chmod command(Link to article) and chown command (Link to article)

了解有关chmod命令(链接到文章)和chown命令(链接到文章)的更多信息

ifconfig和traceroute命令 (The ifconfig and traceroute commands)

Moving on to the networking section in Linux, we come across the ifconfig and traceroute commands which will be frequently used if you manage a network.

转到Linux的网络部分,我们遇到了ifconfig和traceroute命令,如果您管理网络,这些命令将经常使用。

The ifconfig command will give you the list of all the network interfaces along with the IP addresses, MAC addresses and other information about the interface.

ifconfig命令将为您提供所有网络接口的列表以及IP地址,MAC地址和有关该接口的其他信息。


root@ubuntu:~ -->> ifconfig

There are multiple parameters that can be used but we’ll work with the basic command here.

可以使用多个参数,但是这里我们将使用基本命令。

When working with traceroute, you can simply specify the IP address, the hostname or the domain name of the endpoint.

使用traceroute时,您只需指定端点的IP地址,主机名或域名。


root@ubuntu:~ -->> traceroute <destination address>

Now obviously, localhost is just one hop (which is the network interface itself). You can try this same command with any other domain name or IP address to see all the routers that your data packets pass through to reach the destination.

现在显然,本地主机只是一跳(这是网络接口本身)。 您可以将这个命令与其他任何域名或IP地址一起尝试,以查看数据包通过的所有路由器到达目的地。

Learn more about the ifconfig command(Link to article)

了解有关ifconfig命令的更多信息(链接到文章)

Linux中的wget命令 (The wget command in Linux)

If you want to download a file from within the terminal, the wget command is one of the handiest command-line utilities available. This will be one of the important Linux commands you should know when working with source files.

如果要从终端内下载文件,则wget命令是可用的最方便的命令行实用工具之一。 这将是在处理源文件时应了解的重要Linux命令之一。

When you specify the link for download, it has to directly be a link to the file. If the file cannot be accessed by the wget command, it will simply download the webpage in HTML format instead of the actual file that you wanted.

指定下载链接时,它必须直接是文件的链接。 如果wget命令无法访问该文件,它将仅以HTML格式下载网页,而不是所需的实际文件。

Let’s try an example. The basic syntax of the wget command is :

让我们尝试一个例子。 wget命令的基本语法为:


root@ubuntu:~ -->> wget <link to file>
OR
root@ubuntu:~ -->> wget -c <link to file>

The -c argument allows us to resume an interrupted download.

-c参数允许我们恢复中断的下载。

ufw和iptables命令 (The ufw and iptables commands)

UFW and IPTables are firewall interfaces for the Linux Kernel’s netfilter firewall. IPTables directly passes firewall rules to netfilter while UFW configures the rules in IPTables which then sends those rules to netfilter.

UFW和IPTables是Linux内核的netfilter防火墙的防火墙接口。 IPTables直接将防火墙规则传递到netfilter,而UFW在IPTables中配置规则,然后将这些规则发送到netfilter。

Why do we need UFW when we have IPTables? Because IPTables is pretty difficult for a newbie. UFW makes things extremely easy. See the below example where we are trying to allow the port 80 for our webserver.

当拥有IPTables时,为什么需要UFW? 因为对于新手来说IPTables很难。 UFW使事情变得非常容易。 请参见下面的示例,其中我们尝试为Web服务器允许端口80。


root@ubuntu:~# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
root@ubuntu:~# ufw allow 80

I’m sure you now know why UFW was created! Look at how easy the syntax becomes. Both these firewalls are very comprehensive and can allow you to create any kind of configuration required for your network. Learn at least the basics of UFW or IPTables firewall as these are the Linux commands you must know.

我确定您现在知道为什么创建UFW! 看一下语法变得多么容易。 这两种防火墙都很全面,可以让您创建网络所需的任何类型的配置。 至少了解UFW或IPTables防火墙的基础知识,因为这些是您必须知道的Linux命令。

Learn more opening ports on Linux(Link to article)

了解更多有关在Linux上打开端口的信息(链接到文章)

Linux中的软件包管理器 (Package Managers in Linux)

Different distros of Linux make use of different package managers. Since we’re working on a Ubuntu server, we have the apt package manager. But for someone working on a Fedora, Red Hat, Arch, or Centos machine, the package manager will be different.

Linux的不同发行版使用不同的程序包管理器。 由于我们在Ubuntu服务器上工作,因此我们有了apt软件包管理器 。 但是对于在Fedora,Red Hat,Arch或Centos机器上工作的人,软件包管理器将有所不同。

  • Debian and Debian-based distros – apt install <package name>Debian和基于Debian的发行版 – apt install <程序包名称>
  • Arch and Arch-based distros – pacman -S <package name>Arch和基于Arch的发行版 – pacman -S <程序包名称>
  • Red Hat and Red Hat-based distros – yum install <package name>红帽和基于红帽的发行版 – yum install <程序包名称>
  • Fedora and CentOS – yum install <package>Fedora和CentOS – yum安装<package>

Getting yourself well versed with the package manager of your distribution will make things much easier for you in the long run. So even if you have a GUI based package management tool installed, try an make use of the CLI based tool before you move on to the GUI utility. Add these to your list of Linux commands you must know.

从长远来看,使自己熟悉发行版的软件包管理器将使事情变得简单得多。 因此,即使您安装了基于GUI的程序包管理工具,在继续使用GUI实用程序之前,请尝试使用基于CLI的工具。 将这些添加到您必须知道的Linux命令列表中。

Linux中的sudo命令 (The sudo command in Linux)

“With great power, comes great responsibility”

“拥有权利的同时也被赋予了重大的责任”

This is the quote that’s displayed when a sudo enabled user(sudoer) first makes use of the sudo command to escalate privileges. This command is equivalent to having logged in as root (based on what permissions you have as a sudoer).

这是启用了sudo的用户(sudoer)首次使用sudo命令升级特权时显示的报价。 此命令等效于以root用户身份登录(基于您作为sudoer拥有的权限)。


non-root-user@ubuntu:~# sudo <command you want to run>
Password:

Just add the word sudo before any command that you need to run with escalated privileges and that’s it. It’s very simple to use, but can also be an added security risk if a malicious user gains access to a sudoer.

只需在需要以提升的特权运行的任何命令之前添加sudo即可,仅此而已。 它非常易于使用,但是如果恶意用户获得对sudoer的访问权限,也可能带来额外的安全风险。

Learn more about the sudo command (Link to article)

了解有关sudo命令的更多信息(链接到文章)

Linux中的cal命令 (The cal command in Linux)

Ever wanted to view the calendar in the terminal? Me neither! But there apparently are people who wanted it to happen and well here it is.

是否曾经想在终端中查看日历? 我也不! 但是显然有人希望它发生,而且很好。

The cal command displays a well-presented calendar on the terminal. Just enter the word cal on your terminal prompt.

cal命令在终端上显示清晰的日历。 只需在终端提示上输入单词cal。


root@ubuntu:~# cal
root@ubuntu:~# cal May 2019

Even though I don’t need it, it’s a really cool addition! I’m sure there are people who are terminal fans and this is a really amazing option for them.

即使我不需要它,它也是一个非常酷的补充! 我敢肯定有些人是终端粉丝,这对他们来说真的是一个了不起的选择。

别名命令 (The alias command)

Do you have some commands that you run very frequently while using the terminal? It could be rm -r or ls -l, or it could be something longer like tar -xvzf. This is one of the productivity-boosting Linux commands you must know.

使用终端时,您是否有一些经常运行的命令? 可以是rm -rls -l ,也可以像tar -xvzf之类的更长的名称 。 这是您必须知道的提高生产力的Linux命令之一。

If you know a command that you run very often, it’s time to create an alias. What’s an alias? In simple terms, it’s another name for a command that you’ve defined.

如果您知道一个经常运行的命令,那么该创建别名了。 什么是别名? 简而言之,它是您定义的命令的另一个名称。


root@ubuntu:~# alias lsl="ls -l"
OR
root@ubuntu:~# alias rmd="rm -r"

Now every time you enter lsl or rmd in the terminal, you’ll receive the output that you’d have received if you had used the full commands.

现在,每次在终端中输入lslrmd ,您都会收到使用完整命令后收到的输出。

The examples here are for really small commands that you can still type by hand every time. But in some situations where a command has too many arguments that you need to type, it’s best to create a shorthand version of the same.

这里的示例适用于非常小的命令,您仍然可以每次手动键入。 但是在某些情况下,如果命令需要输入太多参数,则最好创建相同形式的简写形式。

Learn more about alias command (LInk to article)

了解有关别名命令的更多信息(查看文章)

Linux中的dd命令 (The dd command in Linux)

This command was created to convert and copy files from multiple file system formats. In the current day, the command is simply used to create bootable USB for Linux but there still are some things important you can do with the command.

创建此命令是为了转换和复制多种文件系统格式的文件。 如今,该命令仅用于为Linux创建可启动USB,但是您仍然可以使用该命令进行一些重要操作。

For example, if I wanted to back up the entire hard drive as is to another drive, I’ll make use of the dd command.

例如,如果我想将整个硬盘驱动器原样备份到另一个驱动器,则将使用dd命令。


root@ubuntu:~# dd if = /dev/sdb of = /dev/sda

The if and of arguments stand for input file and output file.

ifof参数代表输入文件输出文件

whereis和whatis命令 (The whereis and whatis commands)

The names of the commands make it very clear as to their functionality. But let’s demonstrate their functionality to make things more clear.

命令的名称使其功能非常清楚。 但是,让我们演示一下它们的功能,使事情变得更加清晰。

The whereis command will output the exact location of any command that you type in after the whereis command.

whereis命令将输出在whereis命令之后键入的任何命令的确切位置。


root@ubuntu:~# whereis sudo
sudo: /usr/bin/sudo /usr/lib/sudo /usr/share/man/man8/sudo.8.gz

The whatis command gives us an explanation of what a command actually is. Similar to the whereis command, you’ll receive the information for any command that you type after the whatis command.

whatis命令向我们解释了命令的实际含义。 与whereis命令类似,您将收到在whatis命令之后键入的任何命令的信息。


root@ubuntu:~# whatis sudo
sudo (8) - execute a command as another user

Linux中的最高命令 (The top command in Linux)

A few sections earlier, we talked about the ps command. You observed that the ps command will output the active processes and end itself.

在前面的几节中,我们讨论了ps命令。 您观察到ps命令将输出活动进程并结束自身。

The top command is like a CLI version of the task manager in Windows. You get a live view of the processes and all the information accompanying those processes like memory usage, CPU usage, etc.

top命令类似于Windows中任务管理器的CLI版本。 您可以实时查看进程以及与这些进程相关的所有信息,例如内存使用率,CPU使用率等。

To get the top command, all you need to do is type the word top in your terminal.

要获得top命令,您需要做的就是在终端中键入单词top

useradd和usermod命令 (The useradd and usermod commands)

The useradd or adduser commands are the exact same commands where adduser is just a symbolic link to the useradd command. This command allows us to create a new user in Linux.

useraddadduser命令是完全相同的命令,其中adduser只是到useradd命令的符号链接。 此命令允许我们在Linux中创建一个新用户。


root@ubuntu:~# useradd JournalDev -d /home/JD

The above command will create a new user named JournalDev with the home directory as /home/JD.

上面的命令将创建一个名为JournalDev的新用户,其主目录为/ home / JD

The usermod command, on the other hand, is used to modify existing users. You can modify any value of the user including the groups, the permissions, etc.

另一方面, usermod命令用于修改现有用户。 您可以修改用户的任何值,包括组,权限等。

For example, if you want to add more groups to the user, you can type in:

例如,如果要向用户添加更多组,可以输入:


root@ubuntu:~# usermod JournalDev -a -G sudo, audio, mysql

Learn more on how to create and manage users on Linux (Link to article)

了解有关如何在Linux上创建和管理用户的更多信息(链接到文章)

Linux中的passwd命令 (The passwd command in Linux)

Now that you know how to create new users, let’s also set the password for them. The passwd command lets you set the password for your own account, or if you have the permissions, set the password for other accounts.

现在您知道了如何创建新用户,让我们为他们设置密码。 使用passwd命令可以为自己的帐户设置密码,或者,如果您具有权限,则可以为其他帐户设置密码。

The command usage is pretty simple:

该命令的用法非常简单:


root@ubuntu:~# passwd
New password:

If you add the username after passwd, you can set passwords for other users. Enter the new password twice and you’re done. That’s it! You will have a new password set for the user!

如果在passwd之后添加用户名,则可以为其他用户设置密码。 输入两次新密码,操作完成。 而已! 您将为用户设置一个新密码!

最后说明 (Final Note)

This happened to be a very long article but I’m sure will be something you can refer to whenever required. As we add more articles to JournalDev, we will continue to add links to those articles here.

这是一篇很长的文章,但是我敢肯定,只要需要,您都可以参考。 当我们向JournalDev添加更多文章时,我们将继续在此处添加这些文章的链接。

We hope this article was useful to you. If you have any questions, feel free to comment down below.

我们希望本文对您有所帮助。 如有任何疑问,请随时在下方留言。

翻译自: https://www.journaldev.com/34067/linux-commands

linux执行多个命令

linux执行多个命令_您必须知道的前50多个Linux命令相关推荐

  1. sql查询前50条_您必须知道的前50条SQL查询

    sql查询前50条 In this article, we'll go over the most common SQL queries that you should know to be able ...

  2. kali linux 升级命令_作为高级Java,你应该了解的Linux知识

    原创:小姐姐味道(微信公众号ID:xjjdog),欢迎分享,转载请保留出处. 作为一个javaer,我以前写过很多关于Linux的文章.但经过多年的观察,发现其实对于大部分人,有些东西压根就用不着.用 ...

  3. bat fc命令_什么是批处理?Windows批处理(cmd/bat)常用命令合集

    什么是批处理?批处理(Batch),也称为批处理脚本.顾名思义,批处理就是对某对象进行批量的处理,通常被认为是一种简化的脚本语言,它应用于DOS和Windows系统中.批处理文件的扩展名为bat .目 ...

  4. docker run后台启动命令_如何查看docker 里某个容器的的启动命令

    1,在容器外部,物理机上,可以用docker inspect查看或者,docker inspect container. 2,如果在容器内部.可以用 ps -fe 查看.其中1号进程就是启动命令. 3 ...

  5. net cad自动发送命令_每周一喂丨网络安全九个常用的网络命令

    作为网络安全从业者,一些基本的网络常用命令是我们应该要掌握的,熟知这些命令有助于对攻击进行及时的反馈和防护.今天的内容,我们一起来学习九个常用的网络安全命令. 1.ping命令 ping是个使用频率极 ...

  6. git分支指的是_你一定知道的Git分支模型

    原标题:你一定知道的Git分支模型 写在前面 本文不是一篇Git入门指南,也不是 Git命令行使用技巧的讲解,而是谈谈作者在过往工作中使用的几种代码版本管理工具的一些体会,同时重点讲解一下Git的分支 ...

  7. ftpclient怎么获取到该目录下面得文件_你应该知道的10种Python文件系统方法

    使用os和shutil操作文件和文件夹 你可以编写Python程序来与文件系统进行交互来做很酷的事情.怎么做并不总是非常清楚.本文是当前和有抱负的开发人员和数据科学家的指南.我们将重点介绍10个基本的 ...

  8. java代码顺序执行命令_将小程序安装到Java卡的APDU命令的顺序是什么?

    While the oracle documentation proposes a different sequence of APDU commands for installing the .CA ...

  9. linux执行python不打印_在Python中执行shell程序而不打印到屏幕

    有没有一种方法可以让我从Python执行一个shell程序,它将输出打印到屏幕上,然后将它的输出读入变量而不在屏幕上显示任何内容?在 这听起来有点令人困惑,所以也许我可以用一个例子来解释它.在 假设我 ...

最新文章

  1. Python Web 框架:Django MVC搭建
  2. linux centos git 自动更新,centos 升级git到高级版本
  3. 2017电大c语言考试时间,2017年电大 《c语言程序设计》a课程考核说明.doc
  4. Python笔记-类装饰器
  5. SVN的配置与使用方法
  6. zabbix如何实现微信报警
  7. tp5部署到nginx后所有分页404的解决办法
  8. open ball、closed ball 与 open set、closed set(interior point,limit point)、dense set
  9. HttpComponents HttpCore 4.3 Alpha1 发布
  10. JAVA电影院售票系统毕业设计 开题报告
  11. [MLDN魔乐科技]Oracle视频教程
  12. Verilog设计参数化的译码器与编码器,以及设计4位格雷码计数器
  13. android自动计步_自动计步器app下载
  14. 论计算机维护论文,论计算机装与维护毕业论文.docx
  15. python入门之运算符的使用【educoder】
  16. java 弧度 转经纬度_GPS 经纬度转换为 经过旋转后的平面坐标详解
  17. 平均年龄c加加语音用switch_C语言中的SWITCH是什么意思?
  18. 浪潮信息边缘服务器测试,浪潮信息边缘AI服务器全面支持NVIDIA EGX平台
  19. 火车票能不能选座_12306 现在可以选座了,但这个选座可能和你想的不太一样
  20. 英语学习的方法(1)

热门文章

  1. Linux 系统下 /etc/group 档案结构
  2. NoSQL精粹pdf
  3. 【Java每日一题】20161228
  4. C++ Pitfalls 之 reference to an object in a dynamically allocated containter
  5. iOS8 获取通知设置状态
  6. 给员工授予svn相关权限
  7. LNMP环境下压力测试时的主要调试参数
  8. Android ViewPager 里有子ViewPager的事件冲突
  9. 如何对行 表 数据库加锁
  10. [转载] python删除dataframe行和列