linux bash命令_Linux命令-您应该知道的基本Bash命令行技巧

linux bash命令

Linux has a ton of commands, but most people only use a fraction of them. Here are some of the most used Linux commands to use in the terminal.

Linux有很多命令,但是大多数人只使用其中的一小部分。 以下是一些在终端中最常用的Linux命令。

First, we'll cover some tips that will make the command line easier to use:

首先,我们将介绍一些使命令行更易于使用的技巧:

  • Use tab for autocompletion. After you start typing something in the Linux terminal, hit tab and it will suggest possible options that start with the string you have typed so far.

    使用选项卡进行自动补全。 在Linux终端中开始输入内容后,请点击tab,它会建议可能的选项,以您到目前为止所输入的字符串开头。
  • Use ctrl+r search_term to search commands you have previously used.

    使用ctrl+r search_term搜索以前使用的命令。

  • Quickly move to the beginning or end of a line with ctrl+a and ctrl+e.

    使用ctrl+actrl+e快速移至行的开头或结尾。

  • Reuse the previous command in the present command with !!.

    !!重用当前命令中的前一个命令!!

  • You can run multiple commands in a single line by separating commands with a ;.

    您可以使用;分隔命令,从而在一行中运行多个命令;

It's time to learn the common Linux commands. You can get more information about any of these commands by using the man command. This will bring up the manual page for a command. For example, if you type man cat into a linux terminal, you will get more information about the cat command.

是时候学习常见的Linux命令了。 您可以使用man命令来获取有关这些命令中任何一个的更多信息。 这将显示命令的手册页。 例如,如果您在Linux终端中键入man cat ,您将获得有关cat命令的更多信息。

ls (ls)

List directory contents.Example: ls /applications will display all the files and folders stored in the applications folder.

列出目录内容。 示例: ls /applications将显示存储在Applications文件夹中的所有文件和文件夹。

光盘 (cd)

Change to a directory.Example: Change from the current directory to /usr/local with cd /usr/local.

转到目录。 例如:改变当前目录为/ usr /本地cd /usr/local

mv Rename or move file(s) or directories.Example: the command mv todo.txt /home/qlarson/Documents would move "todo.txt" to the "Documents" directory.

mv重命名或移动文件或目录。 示例:命令mv todo.txt /home/qlarson/Documents会将“ todo.txt”移动到“ Documents”目录。

麦克迪尔 (mkdir)

Create a new directory.Example: mkdir freecodecamp will make a directory named "freecodecamp".

创建一个新目录。 示例: mkdir freecodecamp将创建一个名为“ freecodecamp”的目录。

rmdir (rmdir)

Delete empty directories.

删除空目录。

触摸 (touch)

Create an empty file with the specified name.

用指定的名称创建一个空文件。

R M (rm)

Remove file(s) and/or directories.Example: rm todo.txt will delete the file.

删除文件和/或目录。 示例: rm todo.txt将删除该文件。

定位 (locate )

Locate a specific file.Example: locate -i vacuum*mop command will search for any file that contains the word "vacuum" and "mop". The -i makes the search case-insensitive.

找到一个特定的文件。 示例: locate -i vacuum*mop命令将搜索包含单词“ vacuum”和“ mop”的任何文件。 -i使搜索不区分大小写。

明确 (clear)

Clear a command line screen/window for a fresh start.

清除命令行屏幕/窗口以重新开始。

cp (cp)

Copy files and directories.Example: the command cp todo.txt /home/qlarson/Documents would create a copy of "todo.txt" to the "Documents" directory.

复制文件和目录。 示例:命令cp todo.txt /home/qlarson/Documents将创建“ todo.txt”的副本到“ Documents”目录。

别名 (alias )

Create an alias for Linux commands. Example: alias search=grep will allow you to use search instead of grep.

为Linux命令创建别名。 示例: alias search=grep将允许您使用search代替grep

(cat)

Display the contents of a file on the screen. Example: cat todo.txt will show the text of "todo.txt" on the screen.

在屏幕上显示文件的内容。 示例: cat todo.txt将在屏幕上显示“ todo.txt”的文本。

wn (chown)

Change who owns a file.Example: chown qlarson todo.txt will make "qlarson" the owner of "todo.txt".

更改谁拥有文件。 示例: chown qlarson todo.txt将使“ qlarson”成为“ todo.txt”的所有者。

chmod (chmod)

Change a file’s permissions.Example: chmod 777 todo.txt will make "todo.txt" readable, writable, and executable by everyone. The digits in "777" specify the permissions for user, group, and others, in that order.

更改文件的权限。 例如: chmod 777 todo.txt将使“ todo.txt”对每个人都是可读,可写和可执行的。 “ 777”中的数字以该顺序指定用户,组和其他用户的权限。

须藤 (sudo)

Perform tasks that require administrative or root permissions.Example: Use sudo passwd quincy to change the password of user "quincy"."Sudo make me a sandwich."

执行需要管理或root权限的任务。 sudo passwd quincy :使用sudo passwd quincy更改用户“ quincy”的密码。 “须藤给我做一个三明治。”

(find )

Search for files matching a provided pattern. This command is for searching file(s) and folder(s) using filters such as name, size, access time, and modification time.Example: find /home/ -name todo.txt  will search for a file named "todo.txt" within the home directory and its subdirectories.

搜索与提供的模式匹配的文件。 此命令用于使用名称,大小,访问时间和修改时间等过滤器搜索文件和文件夹。 示例: find /home/ -name todo.txt将在主目录及其子目录中搜索名为“ todo.txt”的文件。

grep (grep )

Search files or output for a particular string or expression. This command searches for lines containing a specified pattern and, by default, writes them to the standard output.Example: grep run todo.txt will search for the word "run" in the "todo.txt" file. Lines that contain "run" will be displayed.

在文件或输出中搜索特定的字符串或表达式。 此命令搜索包含指定模式的行,并且默认情况下将其写入标准输出。 示例: grep run todo.txt将在“ todo.txt”文件中搜索单词“ run”。 将显示包含“运行”的行。

日期 (date)

Display or set the system date and time.

显示或设置系统日期和时间。

df (df)

Display report on the system’s disk space usage.

显示有关系统磁盘空间使用情况的报告。

(du)

Show how much space each file takes up. This will show the size in disk block numbers. If you want to see it in bytes, kilobytes, and megabytes, add the -h argument like this: du -h.

显示每个文件占用了多少空间。 这将显示磁盘块号的大小。 如果要以字节,千字节和兆字节为单位查看它,请添加-h参数,例如: du -h

文件 (file)

Determine the type of a file. Example: file todo.txt would likely show the type of "ASCII text".

确定文件的类型。 例如: file todo.txt可能会显示“ ASCII文本”的类型。

历史 (history )

Shows the command history.

显示命令历史记录。

(kill )

Stop a process.Example: Stop a process with a PID of 485 using the command kill 485. Use the ps command (below) to determine the PID of a process.

停止进程。 示例:使用命令kill 485停止PID为485的进程。 使用ps命令(如下)确定进程的PID。

(less)

View the contents of a file one page at a time.Example: less todo.txt will display the contents of "todo.txt".

一次一页查看文件内容。 示例: less todo.txt 将显示“ todo.txt”的内容。

ps Display a list of the currently running processes. This can be used to determine PIDs needed to kill processes.

ps显示当前正在运行的进程的列表。 这可以被用于确定所需要的PID kill进程。

密码 (pwd )

Display the pathname for the current directory. "print working directory"

显示当前目录的路径名。 “P RINT 瓦特工作会有d irectory”

ssh (ssh )

Remotely log in to another Linux machine, over the network. Example: ssh quincy@104.25.105.32 will login to 104.25.105.32 using the username "quincy".

通过网络远程登录到另一台Linux计算机。 示例: ssh quincy@104.25.105.32将使用用户名“ quincy”登录到104.25.105.32。

tail - Display the last 10 lines of a file. See fewer or more lines by using the -n (number) option.Example: tail -n 5 todo.txt will display the last 5 lines of "todo.txt".

tail-显示文件的最后10行。 使用-n(数字)选项可以查看更少或更多的行。 示例: tail -n 5 todo.txt将显示“ todo.txt”的最后5行。

柏油 (tar)

Store and extract files from a tarfile (.tar) or tarball (.tar.gz or .tgz).

从tarfile(.tar)或tarball(.tar.gz或.tgz)存储和提取文件。

最佳 (top )

Displays the resources being used on your system, similar to the task manager in Windows.

显示系统上正在使用的资源,类似于Windows中的任务管理器。

翻译自: https://www.freecodecamp.org/news/basic-linux-commands-bash-tips-you-should-know/

linux bash命令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值