How to install gcc on Linux.
There are two common methods to install GCC (GNU Compiler Collection) on a Linux system: through the command line or using a package manager.
- Install using the command line:
- Open the terminal and log in with root privileges or use the sudo command.
- To install GCC using package managers:
For Ubuntu and its derivatives (such as Debian), you can use apt:
sudo apt update
sudo apt install gccFor RHEL and its derivatives (such as CentOS), you can use yum:
sudo yum update
sudo yum install gcc - After installation is complete, you can use the gcc command to compile and run C or C++ programs.
- Install using package manager.
- For Debian-based systems, you can use the apt-get command: sudo apt-get install gcc.
- For RPM-based systems, you can utilize the yum command as follows: sudo yum install gcc.
- For systems based on Arch Linux, you can use the pacman command: sudo pacman -S gcc
- Other Linux distributions may have different package managers and commands, please refer to the documentation of the respective distribution.
The commands in the above method may require root privileges or the use of the sudo command to execute. Once completed, GCC will be successfully installed on the system, allowing you to use the gcc command to compile and run C or C++ programs.