What is the difference between ctrl z and ctrl c in command line?

0 votes

Hi everyone,

I have been using ctrl z and ctrl c in several time. Can somebody tell me what is the actual meaning of these two and when to use?

Thank You

Feb 12 in Linux Administration by akhtar
• 10,150 points
370 views

1 answer to this question.

0 votes

Hi@akhtar,

Generally, these two commands are used to stop the process. First we will try with ctrl c and if it will not work, than we go with ctrl d to kill the process. But there are a small difference between these two commands. 

ctrl c is used to kill a process. It terminates your program.

[root@master ~]# ping goo.gle
PING goo.gle (67.199.248.12) 56(84) bytes of data.
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=1 ttl=55 time=98.7 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=2 ttl=55 time=20.3 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=3 ttl=55 time=144 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=4 ttl=55 time=58.5 ms
^C
--- goo.gle ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3015ms
rtt min/avg/max/mdev = 20.316/80.505/144.417/46.151 ms

ctrl z is used to pause the process. It will not terminate your program, it will keep your program in background. You can restart your program from that point where you used ctrl z.

[root@master ~]# ping goo.gle
PING goo.gle (67.199.248.12) 56(84) bytes of data.
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=1 ttl=55 time=22.5 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=2 ttl=55 time=124 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=3 ttl=55 time=37.4 ms
^Z
[1]+  Stopped                 ping goo.gle
[root@master ~]#

You can restart your program using the command fg. It means it will return your job in foreground again.

[root@master ~]# fg 1
ping goo.gle
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=4 ttl=56 time=24.2 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=5 ttl=56 time=95.5 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=6 ttl=56 time=19.3 ms
64 bytes from cname.bitly.com (67.199.248.12): icmp_seq=7 ttl=56 time=24.0 ms
^C
--- goo.gle ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 91406ms
rtt min/avg/max/mdev = 19.342/49.685/124.594/39.327 ms
[root@master ~]#

Hope it will clear your doubt.

Thank You

answered Feb 24 by MD
• 21,980 points
On my computer it not show like you comment above. I run it in powershell console and powershell as administrator when I press ctrl D or Z it nothing happened. it just keep running. Yes and ctrl C it stop the process.On the other hand in the command prompt when I press ctrl D or Z it also nothing happened but when I press ctrl C it stop and in the new command it show like this ^D^Z. Do you have any ideas on that case?best regard!

This will work properly in Linux system. And fg program is not available in windows system I think.

Related Questions In Linux Administration

0 votes
1 answer

Difference between root (/) and home directory (~) in terminal?

Root directory which is referred to as ...READ MORE

answered Jun 20, 2019 in Linux Administration by Vicky
3,547 views
0 votes
1 answer

What is absolute path in Ubuntu?

An absolute path is a path to ...READ MORE

answered Feb 9, 2019 in Linux Administration by Omkar
• 69,060 points
97 views
0 votes
1 answer

What is the meaning of 'errno'?

you can retrieve a complete list of ...READ MORE

answered May 20, 2019 in Linux Administration by Shubham
• 13,380 points
67 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to create one new partition in my hard disk in Linux?

Hi@akhtar, To create new partition you can follow ...READ MORE

answered Apr 7 in Linux Administration by MD
• 21,980 points
36 views
0 votes
1 answer

not able to run netstat-tnlp in Linux.

Hi@akhtar, In Linux system netstat-tnlp command comes from ...READ MORE

answered Apr 16 in Linux Administration by MD
• 21,980 points
24 views
0 votes
1 answer

How to break root password in CentOS/RHEL 8?

Hi@akhtar, Reboot the system and interrupt the boot ...READ MORE

answered May 11 in Linux Administration by MD
• 21,980 points
35 views
0 votes
1 answer

How to install python-poster in RedHat?

Hi@akhtar, To install python-poster in RedHat/CentOs, you can ...READ MORE

answered Feb 11 in Linux Administration by MD
• 21,980 points
73 views