The difference and usage of Ctrl+z, Ctrl+c and Ctrl+d in Linux commands

The difference and usage of Ctrl+z, Ctrl+c and Ctrl+d in Linux commands

What does Ctrl+c, Ctrl+d, Ctrl+z mean in Linux?

Ctrl+c and ctrl+z are both interrupt commands, but their functions are different.

Ctrl+c is used to force the execution of the program to be interrupted.

Ctrl+z interrupts the task, but the task is not finished. It is still in progress and just remains in a suspended state.

[root@localhost ~]# ping baidu.com
PING baidu.com (220.181.57.217) 56(84) bytes of data.
64 bytes from 220.181.57.217: icmp_seq=1 ttl=128 time=58.7 ms
64 bytes from 220.181.57.217: icmp_seq=2 ttl=128 time=76.6 ms
64 bytes from 220.181.57.217: icmp_seq=3 ttl=128 time=54.6 ms
64 bytes from 220.181.57.217: icmp_seq=4 ttl=128 time=72.7 ms
64 bytes from 220.181.57.217: icmp_seq=5 ttl=128 time=51.3 ms
64 bytes from 220.181.57.217: icmp_seq=6 ttl=128 time=124 ms
64 bytes from 220.181.57.217: icmp_seq=7 ttl=128 time=71.2 ms
64 bytes from 220.181.57.217: icmp_seq=8 ttl=128 time=52.4 ms
64 bytes from 220.181.57.217: icmp_seq=9 ttl=128 time=51.7 ms
64 bytes from 220.181.57.217: icmp_seq=10 ttl=128 time=254 ms
64 bytes from 220.181.57.217: icmp_seq=12 ttl=128 time=64.2 ms
64 bytes from 220.181.57.217: icmp_seq=13 ttl=128 time=51.8 ms
64 bytes from 220.181.57.217: icmp_seq=14 ttl=128 time=92.5 ms
64 bytes from 220.181.57.217: icmp_seq=15 ttl=128 time=52.1 ms
64 bytes from 220.181.57.217: icmp_seq=16 ttl=128 time=51.8 ms
^Z
[1]+ Stopped ping baidu.com

Users can use fg/bg operations to continue the foreground or background tasks.

The fg command restarts the task that was interrupted in the foreground.

[root@localhost ~]# fg
ping baidu.com
64 bytes from 180.149.132.47: icmp_seq=6 ttl=128 time=59.0 ms
64 bytes from 180.149.132.47: icmp_seq=7 ttl=128 time=67.2 ms
64 bytes from 180.149.132.47: icmp_seq=8 ttl=128 time=54.5 ms
64 bytes from 180.149.132.47: icmp_seq=10 ttl=128 time=55.9 ms
64 bytes from 180.149.132.47: icmp_seq=12 ttl=128 time=56.8 ms
64 bytes from 180.149.132.47: icmp_seq=13 ttl=128 time=60.0 ms
64 bytes from 180.149.132.47: icmp_seq=14 ttl=128 time=155 ms
^Z
[1]+ Stopped ping baidu.com

The bg command puts the interrupted task into the background for execution.

For example: when you vi a file, if you need to use the shell to perform other operations, but you do not intend to close vi because you have to save and exit, you can simply press Ctrl+z, the shell will suspend the vi process~, when you end the shell operation, you can use the fg command to continue vi your file.

Ctrl+d does not send a signal, but represents a special binary value, indicating EOF.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Linux command to decompress rpm package and introduction to rpm command usage
  • Summary of ten Linux command aliases that can improve efficiency
  • Extract specific file paths in folders based on Linux commands
  • Example code of Linux command to create date folder or file
  • How to save command output to a file in Linux terminal
  • The most comprehensive collection of commonly used Linux commands (with examples)

<<:  Teach you step by step to develop a brick-breaking game with vue3

>>:  A brief understanding of MySQL SELECT execution order

Recommend

Detailed explanation of the workbench example in mysql

MySQL Workbench - Modeling and design tool 1. Mod...

Mobile Internet Era: Responsive Web Design Has Become a General Trend

We are in an era of rapid development of mobile In...

React's transition from Class to Hooks

Table of contents ReactHooks Preface WhyHooks? Fo...

JavaScript canvas to achieve raindrop effect

This article example shares the specific code for...

A comprehensive understanding of Vue.js functional components

Table of contents Preface React Functional Compon...

mysql 8.0.16 winx64.zip installation and configuration method graphic tutorial

This article shares the specific code of MySQL 8....

Sharing of SVN service backup operation steps

SVN service backup steps 1. Prepare the source se...

Linux uses lsof command to check file opening status

Preface We all know that in Linux, "everythi...

Detailed explanation of three commonly used web effects in JavaScript

Table of contents 1 element offset series 1.1 Off...

Example of how to quickly delete a 2T table in mysql in Innodb

Preface This article mainly introduces the releva...

Ubuntu 20.04 Chinese input method installation steps

This article installs Google Input Method. In fac...

MySQL implements an example method of logging in without a password

Specific method: Step 1: Stop the mysql service /...

Vue implements countdown function

This article example shares the specific code of ...

How to handle long data when displaying it in html

When displaying long data in HTML, you can cut off...