Common Ubantu terminal commands, shortcut keys and basic operations (systematic learning day 2)

Table of contents

Preface

1. Commonly used commands

2. Commonly used shortcut keys

 3. Shortcut key customization settings

 Summarize


Preface

Common commands and shortcut keys in the Ubantu terminal are used for common usage scenarios such as system management, file operations, and software installation. Use them to increase productivity, streamline operations, and allow for more custom configuration and control. At the same time, you can also combine shell scripts and other tools to implement complex tasks and automated operations. In short, the commonly used Ubuntu terminal commands and shortcut keys cover many aspects of functions and operations.


1. Commonly used commands

The format of commonly used commands:

Command + [Option] + [Parameter] Options and parameters are optional

Options: Generally start with - 

Parameters can directly follow the command or option. The order of options and parameters has the same effect on the command implementation.

For example:

1. No options, no parameters:

ls ;pwd;cd  等。

2. There are options but no parameters.

ls -l;ls -a;ls-s 等。

3. No options, there are parameters       

touch hello.c;cd /etc;mkdir dir;

4. There are options and parameters

rm -r dir; mv -r dir ./subdir 等。

Here are some commonly used Ubuntu terminal commands and their functions:

  1. cd: used to switch the current working directory.

    • cd: Switch to the current user's home directory.
    • cd [目录路径]: Switch to the specified directory path.
  2. ls: List files and subdirectories in the current directory.

    • ls: Display all files and directories in the current directory.
    • ls -l: Display files and directories in the current directory with detailed information.
  3. pwd: Displays the path of the current working directory.

  4. mkdir: Create a new directory.

         mkdir [目录名]: Create a new subdirectory under the current directory.
  5. touch: Create a new empty file.

         touch [文件名]: Create a new empty file in the current directory.
  6. cp: Copy files or directories.

          cp [源文件路径] [目标文件路径]: Copy the source file to the specified target file path.
  7. mv: Move files or directories, and can also be used to rename files.

          mv [源文件路径] [目标文件路径]: Move the source file to the specified destination file path.
  8. rm: Delete a file or directory.

    • rm [文件或目录路径]: Delete the specified file or directory.
    • rm -r [目录路径]: Recursively delete the specified directory and its contents.
  9. cat: Display file contents in text form.

        cat [文件路径]: Display the text content of the specified file.
  10. grep: Search for a specific string in a file.

     grep [搜索词] [文件路径]: Search the specified file for lines containing the specified search term.
  11. chmod: Change the permissions of a file or directory.

     chmod [权限] [文件或目录路径]: Change the permissions of the specified file or directory.
  12. sudo: Execute the command as an administrator.

      sudo [命令]: Execute the specified command with administrator privileges.

2. Commonly used shortcut keys

1. Basic operations of terminal window
  serial number  Function   shortcut key
1 Create a new terminal window  Ctrl+Shift+N (This is to create a new terminal window under the same path)
/Ctrl+Alt+T
2 Create a new terminal tab   Shift+Ctrl+T
3 Close terminal window   Shift+Ctrl+Q
4  Close terminal tab (Same as above if it is the last tab) Shift+Ctrl+W
5 Switch terminal tabs   Alt+1/2/3/...
6 Front cut terminal tab page   Alt+Pg Up
7 Post-cut terminal tab Alt+Pg Dn
8 Move terminal tab forward  Shift+Alt+Pg Up
9 Move terminal tab back Shift+Alt+Pg Dn
10 Move terminal window back   Alt+Tab
11 Move terminal window forward  Shift+Alt+Tab 

2. Terminal window/font size operation
serial number Function shortcut key
1 full screen F11
2 get bigger Shift+Ctrl++
(next to non-numeric keys)
3 become smaller Ctrl+-
(next to non-numeric keys)
4 default size Ctrl+0
(next to non-numeric keys)

3. Editing operations in the terminal window
serial number Function shortcut key
1 copy Shift+Ctrl+C
2 Paste Shift+Ctrl+V
3 Jump to the beginning of the command line Ctrl+A
4 Jump to the end of the command line Ctrl+E
5 Delete characters from the beginning of the line to the cursor position Ctrl+U
6 Delete characters from the cursor position to the end of the line Ctrl+K

4. Terminal window special operations
serial number Function shortcut key
1 force end Ctrl+C
2 program hangs Ctrl+Z
3. Terminate input/exit shell Ctrl+D
4 Freeze window
(screen lock/stop output)
Ctrl+S
5 Unfreeze window
(screen unlock/re-export)
Ctrl+Q
6 discard output Ctrl+O
7 clear screen Ctrl+L

5. Terminal command input operation
serial number Function shortcut key
1 Jump to the beginning of the command line Ctrl+A
2 Jump to the end of the command line Ctrl+E
3. Delete characters from the beginning of the line to the cursor position Ctrl+U
4 Delete characters from the cursor position to the end of the line Ctrl+K
5 clear screen Ctrl+L或clear

  1. 编辑命令行:Ctrl + a(光标移到行首)、Ctrl + e(光标移到行尾)、Ctrl + b(光标往前移动一个字符)、Ctrl + f(光标往后移动一个字符)。

  2. 清除当前行:Ctrl + u(清除光标左边的内容)、Ctrl + k(清除光标右边的内容)。

  3. 删除单词:Ctrl + w(从光标位置开始删除一个单词)。

  4. 撤销操作:Ctrl + -(撤销最后一次操作)。

  5. 光标移动:Ctrl + l(清屏并将光标移到顶部)。

  6. 查找命令历史:Ctrl + r(反向搜索命令历史)、Ctrl + s(正向搜索命令历史)。

  7. 切换终端标签:Ctrl + PgUp(向左切换标签)、Ctrl + PgDn(向右切换标签)。

  8. 终止当前命令:Ctrl + c(终止当前正在运行的命令)。

  9. 重复上一条命令:Ctrl + p(上一条命令)、Ctrl + n(下一条命令)。

  10. 进入多重模式:Ctrl + z(将当前命令暂停并放到后台运行)。

注意事项: -在某些终端中,可能需要将"Ctrl"键替换为"Ctrl + Shift"键。 -某些终端可能具有其他自定义的快捷键,可以通过终端的设置界面进行配置。

修改快捷键设置: 可以通过编辑终端的配置文件来自定义快捷键。打开终端后,点击顶部菜单的"编辑",然后选择"首选项"。在弹出的窗口中,选择"快捷方式"选项卡。在这里,你可以添加、删除和编辑终端的快捷键。

在终端中设置的快捷键只适用于当前用户,如果你希望所有用户都能使用相同的快捷键,可以修改全局终端配置文件,该文件位于/etc/inputrc路径下。需要root权限来修改该文件。

 三、快捷键自定义设置

在终端任意位置点击鼠标右键并点击配置文件首先项

点击快捷键

 

 双击想要修改的快捷键即可进行修改


 总结

      总的来说,本篇文章适用于大多数刚入门Ubantu和Linux操作系统的朋友们进行学习并实践Ubantu终端常用命令、快捷键和基本操作。

      以后还会给大家展现更多关于Ubantu的其他重要的基础知识,感谢大家多多支持!

      希望这篇博客能给各位朋友们带来帮助,最后请来过的朋友们留下你们宝贵的三连以及关注,感谢你们!

Guess you like

Origin blog.csdn.net/weixin_58070962/article/details/132789424