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, 2020 in Linux Administration by akhtar
• 38,260 points
47,473 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.

Enroll with Linux training online and learn in detail about Linux.

Thanks.

answered Feb 24, 2020 by MD
• 95,460 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
0 answers

What is the difference between ''find .'' and ''find /'' on linux command

I am solving overthewire bandit. I looked ...READ MORE

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
434 views
0 votes
1 answer

What is the linux command to find Memory and CPU usage in percent for last 30 days?

Try the following: Cat proc/meminfo top top -i less /proc/memin ...READ MORE

answered Oct 14, 2020 in Linux Administration by Kim
2,492 views
0 votes
0 answers

Difference between ctrl-z and "&" in linux

My understanding is that when you are ...READ MORE

Apr 13, 2022 in Linux Administration by Soham
• 9,710 points
460 views
0 votes
0 answers

What is the difference between a symbolic link and a hard link?

Recently I was asked this during a ...READ MORE

Apr 13, 2022 in Linux Administration by Rahul
• 9,680 points
372 views
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, 2020 in Linux Administration by MD
• 95,460 points
1,180 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, 2020 in Linux Administration by MD
• 95,460 points
1,087 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, 2020 in Linux Administration by MD
• 95,460 points
1,909 views
0 votes
1 answer

What is Htpasswd in Linux?

Hi@akhtar, htpasswd is used to create and update ...READ MORE

answered Dec 2, 2020 in Linux Administration by MD
• 95,460 points
1,530 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP