0% found this document useful (0 votes)
4 views

Vi_Editor_and_GCC_Compiler_Paraphrased

The document provides an overview of the vi editor and GCC compiler in Linux, detailing their functionalities and usage. It explains the three modes of vi (Command, Insert, and Visual) and outlines the steps to create, edit, compile, and execute a C program using GCC. Additionally, it emphasizes the importance of file permissions management through the chmod command.

Uploaded by

punitmeme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Vi_Editor_and_GCC_Compiler_Paraphrased

The document provides an overview of the vi editor and GCC compiler in Linux, detailing their functionalities and usage. It explains the three modes of vi (Command, Insert, and Visual) and outlines the steps to create, edit, compile, and execute a C program using GCC. Additionally, it emphasizes the importance of file permissions management through the chmod command.

Uploaded by

punitmeme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Usage of vi Editor and GCC Compiler in Linux

Objectives:

- To explore the basic functionality and modes of the vi editor.

- To understand how to compile C programs using the GCC compiler.

Overview:

Introduction to the Vi Editor:

The "Visual Editor" (vi) is a highly efficient text editor commonly used in Linux and Unix systems.

Known for its versatility, it is popular among both novice and advanced users working in terminal-based

environments. Unlike standard editors, vi operates in distinct modes tailored for specific tasks, offering

precise control during text editing.

Vi has three primary modes:

1. Command Mode (default mode): Navigate, delete, and execute commands within the file.

2. Insert Mode: Enter this mode by pressing 'i' to add or modify text. Return to Command Mode by pressing

3. Visual Mode: Select text for actions like copying, cutting, or formatting by pressing 'v' in Command Mode

GCC Compiler:

The GNU Compiler Collection (GCC) is a robust, open-source compiler supporting multiple programming la

such as C, C++, and Fortran. It translates high-level programming code into machine-readable code throug

like preprocessing, compiling, assembling, and linking. GCC provides features like optimization (-O2) and d

(-g), enhancing performance tuning and troubleshooting. Its cross-platform compatibility and open-source n

make it a vital tool in software development.


Steps to Use vi Editor and GCC Compiler:

1. Create and Edit a File:

- Create a file with a .c extension and open it in the vi editor:

vi abc.c

2. Write a Simple Program:

- Example:

#include <stdio.h>

int main() {

printf("Hello world");

return 0;

3. Compile the Program:

- Use the GCC compiler to compile the file and create an output file:

gcc abc.c -o abc.out

4. Run the Program:

- Execute the output file:

./abc.out

5. Change File Permissions:

- Modify file permissions using chmod:

- chmod 400 abc.c: Only the owner can read the file (r--).

- chmod 000 abc.c: No permissions for anyone (---).

- chmod 777 abc.c: Full permissions for everyone (rwx).


Conclusion:

This lab illustrated the use of the vi editor and GCC compiler to write, edit, compile, and execute programs

Linux environment. It also highlighted the significance of file security using the chmod command to manage

permissions effectively.

You might also like