Lab Basics
Lab Basics
1 Introduction
This report will guide you through the essentials of using Linux commands,
Nano editor, and compiling and running a C program.
To list files and directories in the current directory, use the ls command:
1 ls
Changing Directories
To change the current working directory, use the cd command followed by the
path to the desired directory:
1 cd / path / to / directory
Creating Directories
To create a new directory, use the mkdir command followed by the name of the
new directory:
1 mkdir new_directory
1
2.3 File Operations
Copying Files
To copy a file, use the cp command followed by the source file and the desti-
nation:
1 cp source_file destination_file
Moving Files
To change file permissions, use the chmod command. For example, to set per-
missions to 755:
1 chmod 755 filename
2
• Using the Application Menu: Open the application menu (often acces-
sible by clicking the icon in the lower-left corner of the screen), search for
Terminal or Console, and click on it.
• Using a Right-Click Option: In some desktop environments, you can
right-click on the desktop or within a file manager and select Open Terminal
or Open in Terminal.
4 Nano Editor
• Move Cursor:
– Arrow keys: Move the cursor in the direction of the arrow.
– Ctrl + A: Move to the beginning of the line.
– Ctrl + E: Move to the end of the line.
– Ctrl + Y: Move up one page.
3
– Ctrl + V: Move down one page.
• Scroll Through Document:
– Page Up and Page Down: Scroll up or down one screen at a time.
5 Compiling C Code
To compile C code in the terminal, you will use the gcc compiler, which is the
GNU Compiler Collection for C language.
3 int main () {
4 printf ( " Hello , ␣ World !\ n " ) ;
5 return 0;
6 }
To compile the C program, open the terminal and navigate to the directory
containing hello.c. Use the following command:
1 gcc -o hello hello . c
Here, -o hello specifies the output file name, which will be hello.
4
This should display:
1 Hello , World !