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

MySQL paging performance exploration

Several common paging methods: 1. Escalator metho...

Comprehensive summary of Vue3.0's various listening methods

Table of contents Listener 1.watchEffect 2.watch ...

Complete steps to implement location punch-in using MySQL spatial functions

Preface The project requirement is to determine w...

Summary of Creating and Using Array Methods in Bash Scripts

Defining an array in Bash There are two ways to c...

How to change the tomcat port number in Linux

I have several tomcats here. If I use them at the...

MySQL 8.0.17 installation and simple configuration tutorial under macOS

If you don’t understand what I wrote, there may b...

How to open port 8080 on Alibaba Cloud ECS server

For security reasons, Alibaba Cloud Server ECS co...

Implementation of ssh non-secret communication in linux

What is ssh Administrators can log in remotely to...

How to make a centos base image

Preface Now the operating system used by my compa...

SQL implementation of LeetCode (183. Customers who have never placed an order)

[LeetCode] 183.Customers Who Never Order Suppose ...

How does MySQL ensure data integrity?

The importance of data consistency and integrity ...

How to start jar package and run it in the background in Linux

The Linux command to run the jar package is as fo...

One minute to experience the smoothness of html+vue+element-ui

Technology Fan html web page, you must know vue f...

Solution to mysql error when modifying sql_mode

Table of contents A murder caused by ERR 1067 The...