0% found this document useful (0 votes)
21 views48 pages

Coverpdf

The document discusses familiarizing with Unix/Linux operating system. It covers topics like logging in and out, using basic commands, using vim editor, GUI interfaces, and developing simple shell programs using bash shell. Experiments are performed on a virtual machine to learn these concepts.
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)
21 views48 pages

Coverpdf

The document discusses familiarizing with Unix/Linux operating system. It covers topics like logging in and out, using basic commands, using vim editor, GUI interfaces, and developing simple shell programs using bash shell. Experiments are performed on a virtual machine to learn these concepts.
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/ 48

CENTRAL UNIVERSITY OF HARYANA

Department of Computer Science and Engineering

UNIX AND LINUX PROGRAMMING LAB


BT CS 627

Submitted by
Roshan Singh
Roll No- 211587 (B.Tech. 6th Sem.)

Submitted to
Dr. Nitin Goyal
Assistant Professor
Department of Computer Science and Engineering, CUH
‭Table of Content‬
‭S.No.‬ ‭Aim‬ ‭Page no‬ ‭Signature‬

‭1.‬ ‭ amiliarize with Unix/Linux‬


F
‭with logging/logout and simple‬
‭commands.‬

‭2.‬ ‭ amiliarize with vim editor and‬


F
‭linux GUIs.‬

‭3.‬ ‭Using Bash shell develop‬


‭simple shell programs.‬

‭4.‬ ‭ evelop advaced shell‬


D
‭programs using awk and grep.‬

‭5.‬ ‭Compile and debug various C‬


‭programs using different‬
‭options‬

‭6.‬ ‭Learning of installation and‬


‭upgradation of Linux operating‬
‭system‬

‭7.‬ ‭Install Linux on a PC having‬


‭some other previously installed‬
‭operating. All OSs should be‬
‭usable.‬

‭8.‬ ‭As supervisor create and‬


‭maintain user accounts, learn‬
‭package installation, taking‬
‭backups, creation of scripts for‬
‭file and user management,‬
‭creation of startup and‬
‭shutdown scripts using at, cron‬
‭etc.‬
‭Lab - 1‬
‭Aim :‬‭Familiarize with Unix/Linux with logging/logout‬‭and simple‬
‭commands.‬

‭Tools/Liabilities :‬‭Virtual Machine , Ubuntu‬


‭H/W Used :‬‭Normal(Standard) PC‬
‭Inputs :‬‭Logins and Passwords‬
‭Post-Conditions :‬‭Login Successful‬
‭Logging & Logout‬‭:‬
‭Logging in, with command “sudo su” & “su”‬

‭Logging out, with command “who” command - can know‬‭about the user who already logged in,‬
‭command “exit” - to exit the terminal‬
‭Simple Commands :‬
‭Date: Date commands prints the systems date and‬‭time‬
‭Syntax‬‭:‬‭date[option] [+%Format]‬
‭Date format can be‬
‭%D Date - MM/DD/YY‬
‭%H Hour - 00 to 23‬
‭%I Hour - 00 to 11‬
‭%M Minute - 00 to 59‬
‭%s Second - 00 to 59‬
‭%T Time - HH:MM:SS‬
‭%y Year’s last 2 digits‬
‭%w Day of the week‬
‭%r Time in AM/PM‬

‭To see history of previously executed commands‬


‭Command used to check the history is “history”‬

‭Clear‬
‭to clear the last commands used, commands used is “clear”‬
‭Expr‬
‭this command is used to perform the arithmetic operations (operation +‬
‭addition, - subtraction, * multiplication, % remainder, / division is used) on‬
‭integers.‬

‭Make Directory‬
‭Syntax : mkdir <directory-name>‬
‭Creating a new directory -‬‭[root@localhost~]# mkdir‬‭<directory_name>‬
‭This command will create a new subdirectory with name‬
‭<directory_name> of current directory‬
‭Creating more than one directory‬
‭[root@localhost~]# mkdir x y z‬‭, this will create‬‭3 directories having name‬
‭x y z‬‭respectively‬

‭Remove Directory‬
‭This command is used to remove a directory. Directory‬‭should be empty before‬
‭deletion.‬

‭Syntax: rmdir <directo‬ ‭ry_name>‬

‭Present Working‬
‭This command will display full path name for present‬‭working directory.‬
‭Syntax: pwd‬
‭Calendar‬
‭This command is used to print the calendar for the current year‬
‭Lab - 2‬
‭Aim‬‭:‬‭Familiarize with “vim” editor and Linux GUIs.‬

‭Tools/Liabilities :‬‭Bash shell, vi editor‬

‭H/W Used :‬‭Normal (Standard) PC‬

‭Inputs :‬‭Modes of operation of vim, File name and commands‬

‭Post- Conditions:‬

‭Some open source editor available i.e. ED, EX, VI‬

‭ED and EX are the line editor. Where as VI is the text editor or screen editor. It‬
‭shows as much of the file as it can fit on screen. It is the first full screen editor.‬
‭Which allows the user to view and an edit the entire document at a time.‬
‭Creating and editing file becomes easier using vi editor.‬

‭Modes Of Operation:‬

‭1.‬ ‭Command mode:‬‭In this mode all the keys pressed by user are interpreted to‬
‭the editor commands that is for moving cursor for left right top bottom etc. in‬
‭this the key pressed are not displayed on the screen.‬
‭2.‬ ‭Insert Mode‬‭: this mode permits insertion of new text editing existing text.‬
‭Insertion mode is also know as i/p mode‬
‭3.‬ ‭Execution mode‬‭: It permits to give command at the command line. Bottom‬
‭line of screen is called command line.‬

‭I)‬‭Starting VI or To invoke VI:‬

‭To create a file‬

‭e.g. $ vi roshan.txt‬

‭to invoke the vi type vi and file name that we want to create. When we type‬
‭the vi and the file name and press enter key then vi clears the screen and‬
‭display a window in which we can enter and edit text.‬

‭II)‬‭To Add text to a File:‬

‭‘I’ command :‬‭to enter in insert mode ‘I’ key is pressed.‬‭To add the text to a file‬
‭the following steps are required:‬

‭i.‬ ‭Press the “I” key.‬


‭ii.‬ ‭Type the text. The text we have typed goes into a place in memory as‬
‭buffer.‬
‭iii.‬ ‭Press Esc key after finishing text to leave the insert mode and return to‬
‭command mode.‬

‭III)‬ ‭To Save the File to the Disk: to save the file and quit for the VI holds the shift‬
‭key and press z twice (shift + zz). Another to save file is to use: w and: q for saving‬
‭and quitting. This command that begins with colons is given in Ex- command‬
‭mode. We can combine two commands to save and quit.‬

‭IV)‬ ‭To Edit a File: the edit and existing file you can add, change and delete text,‬
‭before you can perform these task you must load the file from the disk to buffer and‬
‭then move to the part of the file you want to edit.‬

‭To Edit a File:‬

‭Loading the file : vi file name‬


‭Move: The cursor to the point on the screen, to‬‭begin the correction, Keys are‬
‭used‬
‭H: Moves the cursor one character to the left‬
‭L: Moves the cursor one character to the right‬
‭J: This key move the cursor down on line.‬

‭K: moves the cursor up line.‬

‭V)‬‭Editing Text to Existing Text:‬

‭Following commands to edit the text in Existing File:‬

‭O: to go to the next line‬


‭a : insert after a space‬
‭esc : to exit out of any mode‬

‭shift + : is used to come to the end of file‬


‭r : replace‬
‭d : delete the line‬
‭u : undo‬
‭x : remove one character‬
‭/ : forward search‬
‭? : backward search‬

‭VI)‬‭Quitting From VI :‬

‭to save the change and quit from vi then type vi‬‭press shift + zz in command‬
‭mode and: wq in Ex - mode‬
‭Not to save changes and quit VI then type : q!‬‭in Ex-mode and press the enter‬
‭key‬
‭Backward Search‬
‭wq - This command is used to save and exit‬

‭Forward Search‬
‭Backward search‬

‭Less myFile :‬‭this command is used to display the file in real mode.‬

‭GUI ( Graphical User Interface ):‬


‭1.‬ ‭Desktop Environments‬
‭Linux distributions offer various desktop environments,‬‭each with its own look, feel,‬
‭and features.‬
‭Some popular desktop environments include GNOME,‬‭KDE Plasma, Xfce, LXQt,‬
‭Cinnamon, and MATE.‬
‭GNOME is known for its modern design and simplicity,‬‭while KDE Plasma offers‬
‭extensive customization options and a more traditional desktop layout.‬
‭Xfce and LXQt are lightweight desktop environments suitable for older hardware‬
‭or users who prefer a simpler interface.‬
‭Cinnamon and MATE provide more traditional desktop experiences similar to older‬
‭versions of Windows‬

‭2.‬ ‭Common Components :‬

‭Linux GUIs typically include components such as‬‭a file manager, application‬
‭launcher, taskbar or panel, system tray, and settings manager.‬
‭File‬ ‭managers‬ ‭like‬ ‭Nautilus‬ ‭(GNOME),‬ ‭Dolphin‬ ‭(KDE),‬ ‭Thunar‬ ‭(Xfce),‬ ‭and‬ ‭Nemo‬
‭(Cinnamon)‬ ‭allow‬ ‭users‬ ‭to‬ ‭browse‬ ‭files‬ ‭and‬ ‭folders,‬ ‭manage‬ ‭files,‬ ‭and‬ ‭perform‬
‭basic file operations.‬

‭Application launchers provide quick access to installed‬‭applications and often‬


‭include search functionality to find and launch programs eminently.‬
‭Taskbars or panels display open applications, system‬‭notifications, and quick access‬
‭to frequently used tools and settings.‬
‭System trays house icons for system and application notifications, volume‬

‭control, network status, and other system utilities.‬

‭3.‬ ‭Customization:‬
‭Many Linux desktop environments allow extensive‬‭customization to tailor the user‬
‭experience to individual preferences.‬
‭Users can customize desktop themes, icons, fonts,‬‭window decorations, and‬
‭desktop backgrounds.‬
‭Some desktop environments offer built-in tools for customization, while others may‬
‭rely on third-party applications or manual configuration.‬

‭4.‬ ‭Applications:‬
‭Linux GUIs support a wide range of applications‬‭for productivity, multimedia,‬
‭internet browsing, gaming, development, and system administration.‬
‭Lab - 3‬
‭AIM :‬‭Using bash shell develop a simple shell program‬

‭TITLE : Unix / Linux programming‬

‭TOOLS / LIABILITIES : Bash shell, vi editor‬

‭H / D USED : Standard PC‬

‭INPUT : shell script‬

‭1)‬ ‭TO PERFORM ARITHEMETIC OPERATION.‬

‭echo “enter 2 numbers:‬


‭” read a‬
‭read b‬
‭echo -ne “Addition is: ”‬
‭expr $a + $b‬
‭echo -ne “Difference is:‬
‭” expr $a - $b‬
‭echo -ne “Multiplication is: ”‬
‭expr $a \* $b‬
‭echo -ne “Division is: ”‬
‭expr $a / $b‬
‭echo -ne “Reminder is: ”‬
‭expr $a % $b‬

‭Output :‬
‭2)‬‭TO PRINT A MULTIPLICATION TABLE‬

‭echo “Enter the number - ” read‬


‭n‬

‭i = 1‬
‭while [ $i -le 10 ]‬
‭do‬

‭res = `expr $i \* $n`‬


‭echo “$n * $i = $res”‬
‭((++i))‬
‭done‬

‭Output :‬

‭3)‬‭TO CHECK WHETHER NUMBER IS PALINDROME OR NOT‬

‭#!/bin/bash‬

‭echo "Enter a number:"‬


‭read num‬

‭reverse=""‬
‭temp=$num‬

‭while [ $num -gt 0 ]‬


‭do‬
‭remainder=$(( $num % 10 ))‬
‭num=$(( $num / 10 ))‬
‭reverse="${reverse}${remainder}"‬
‭done‬

‭if [ $temp -eq $reverse ]‬


‭then‬
‭echo "The number $temp is a palindrome."‬
‭else‬
‭echo "The number $temp is not a palindrome."‬

‭fi‬

‭Output :‬

‭4)‬‭TO CHECK WHEATHER A NUMBER IS PRIME OR NOT.‬

‭#!/bin/bash‬

‭echo "Enter a number:"‬


‭read num‬

‭if [ $num -le 1 ]; then‬


‭echo "$num is not a prime‬
‭number." exit‬

‭fi‬
‭is_prime=true‬
‭for (( i=2; i<=num/2; i++ ))‬
‭do‬
‭if [ $((num%i)) -eq 0 ]; then‬
‭is_prime=false‬
‭break‬

‭fi‬
‭done‬

‭if [ $is_prime = true ]; then‬


‭echo "$num is a prime number."‬
‭else‬
‭echo "$num is not a prime number."‬
‭fi‬

‭Output :‬
‭5)‬‭TO FIND THE FACTORIAL OF A NUMBER.‬

‭#!/bin/bash‬

‭echo "Enter a number:"‬


‭read num‬

‭factorial=1‬

‭if [ $num -lt 0 ]; then‬


‭echo "Factorial is not defined for negative numbers."‬
‭exit‬

‭ ‬
fi
‭for (( i=1; i<=$num; i++‬
‭)) do‬
‭factorial=$((factorial *‬
‭i)) done‬
‭echo "Factorial of $num is: $factorial"‬

‭Output :‬
‭Lab - 4‬
‭AIM :‬‭Develop advanced shell program using awk and grep‬

‭TITLE :‬‭Work instruction Sheet Unix and Linux programming‬

‭TOOLS / SOFTWARE USED :‬‭ZSH shell, vi editor, Windows‬‭H/W‬

‭USED :‬‭Standard PC‬

‭INPUT :‬‭shell script‬

‭POST CONDITION :‬‭Able to design shell program using awk and grep‬

‭g‭r‬ ep Command‬

‭grep stands for Global Regular Expression Print is a useful command to search for‬
‭matching patterns in a file. grep is short for “global regular expression print”.‬

‭system admin needs to scrape through log files or a developer trying to find certain‬
‭occurrences in the code file, then grep is a powerful command to use.‬

‭The Basic Syntax of the grep command:‬

‭The syntax of the grep command is as follows:‬

‭grep [OPTION...] PATTERNS [FILE...]‬

‭grep searches for PATTERNS in each FILE. Grep finds each line that matches that‬
‭provided PATTERN. It is a good practice to close the PATTERN in quotes when grep is‬
‭used in a shell command.‬

‭the following option that can be used with grep:‬

‭-i, --ignore-case:‬‭Ignores case distinctions in patterns and input data.‬


‭-v, --invert-match:‬‭Select the non-matching lines of the provided input pattern‬
‭-n, --line-number:‬‭Prefix each line of the matching output with the line number‬
‭in the input file.‬
‭-w:‬‭Find the exact matching word from the input file or string.‬
‭-c:‬‭Count the number of occurrences of the provided pattern.‬
‭create a flle and put data:‬‭To create a file in‬‭the command line, we use the touch‬
‭command.‬
‭To ignore the upper and lower case :‬‭Ex ; grep‬‭-i “keyword” filename‬

‭o search everything except given keyword:‬‭Ex; grep -v “keyword”filename‬

‭To print how many times given keyword is present in flle:‬‭ex; grep -c‬
‭“keyword” filename‬
‭To search for exact match of the given keyword in a flle:‬‭ex; grep -w‬
‭“keyword” filename‬

‭●‬ ‭To flnd in which line the given keyword is in a flle:‬‭ex; grep -n‬
‭“keyword”filename‬

‭To print the matching line which start with the given keyword in a flle:‬
‭ex; grep “^keyword” filename‬

‭To print the matching line which end with the given keyword in a flle:‬
‭ex ; grep “keyword” filename‬

‭We can use egrep command for the multiple keywords search:‬‭ex;‬
‭egrep “key1|key2|key3” filename‬
‭awk command‬

‭awk is a scripting language, and it is helpful when working in the command line. It’s‬
‭also a widely used command for text processing.‬

‭When using awk, we are able to select data - one or more pieces of individual text -‬
‭based on a pattern we provide.‬

‭The Basic Syntax of the awk command:‬

‭The‬ ‭awk‬ ‭command‬ ‭is‬ ‭followed‬ ‭by‬ ‭a‬ ‭set‬ ‭of‬ ‭single‬ ‭quotation‬ ‭marks‬ ‭and‬ ‭a‬ ‭set‬ ‭of‬
‭curly‬ ‭braces,‬ ‭with‬ ‭the‬ ‭name‬ ‭of‬ ‭the‬ ‭file‬ ‭we‬ ‭want‬ ‭to‬ ‭search‬ ‭through‬ ‭mentioned‬
‭last.‬

‭awk ‘{action}’ file_name‬

‭create a flle and put data:‬‭using touch command‬‭and cat>>file_name to put‬


‭data into the file‬

‭print all the content of the flle using awk:‬‭To‬‭print all the content of a file, the‬
‭action we specify inside the curly brace is print $0‬
‭To print speciflc columns using awk:‬‭When using awk, we can specify certain‬
‭columns we want print. Ex ; awk ‘{print $1}’ file_name‬

‭If we would like each line to have a line-number count, we would use the NR‬
‭built-in variable:‬‭Ex ; awk ‘{print NR, $0}’ file_name.‬
‭To print the last fleld, we can also use $NF which represent the‬‭last‬‭fleld in‬
‭the record:‬‭Ex ; awk ‘{print $NF}’ file_name.‬

‭Print speciflc lines of a column:‬‭you can also specify the line we want printed‬
‭from our chosen column, print the first column. Then the output of that‬
‭command is piped, using the pipe symbol |, to the head command, where its‬
‭-num argument selects the first num lines of the column. Ex : awk ‘{print $1}’‬
‭file_name | head -num.‬

‭Print out lines with a speciflc pattern in awk:‬‭we can print a line that starts‬
‭with a specific letter, we use the up arrow symbol (^) first, which indicates the‬
‭beginning of a line, and then the letter we want a line to start with. Ex : awk‬
‭‘/^0/’ file_name‬
‭If we want to print out the lines the end in a 0‬‭- the $ symbol is used after a‬
‭character to signify how a line will end.‬
‭Ex ; awk ‘/0$/’ file_name‬

‭If we want to print out the lines with particular keywords:‬


‭Ex ; awk ‘/keyword/’ filename‬

‭To count the lines in a flle:‬‭Ex ; awk ‘END {print NR}’ file_name‬
‭Lab - 5‬

‭ IM :‬‭Compile and debug various C programs using different‬‭options‬


A
‭TITLE :‬‭C Programming: Compilation and Debugging‬
‭TOOLS / LIABILITIES :‬‭GCC Compiler, Text Editor (e.g.,‬‭Vi, Nano)‬
‭H / D USED : Standard PC‬

‭Checking GCC Version:‬


‭To check the version of GCC installed on your system, execute the following‬
‭command in the terminal:‬
‭gcc --version‬

‭Making a file for writing C programs:‬


‭Create a new file with a ".c" extension using a text editor of your choice. For example,‬
‭using Vi editor:‬
‭$ vi filename.c‬
‭Lab5.c is visible on desktop screen:‬
‭Checking for other C codes::‬

‭1.Programs to Print a Number Given by a User in C:‬

‭Input:‬

‭#include <stdio.h>‬

‭int main() {‬
‭int number;‬

‭// Prompt the user to enter a number‬


‭printf("Enter a number: ");‬
‭scanf("%d", &number);‬

‭// Print the number entered by the user‬


‭printf("You entered: %d\n", number);‬
‭return 0;‬
‭}‬

‭Output:‬
‭}‬

‭2. C Program to Add Two Numbers:‬

‭ include <stdio.h>‬
#
‭int main() {‬
‭int num1, num2, sum;‬
‭printf("Enter the first number: ");‬
‭scanf("%d", &num1);‬
‭printf("Enter the second number: ");‬
‭scanf("%d", &num2);‬
‭// Calculate the sum‬
‭sum = num1 + num2;‬
‭// Print the result‬
‭printf("The sum of %d and %d is %d\n", num1, num2, sum);‬
‭}‬

‭3.To Check Whether a Number is Prime or Not:‬

‭#include <stdio.h>‬

‭int main() {‬
‭int num, i, flag = 0;‬

‭printf("Enter a number: ");‬

‭scanf("%d", &num);‬

‭for (i = 2; i <= num / 2; ++i) {‬

‭if (num % i == 0) {‬

‭flag = 1;‬

‭break; } }‬

‭if (flag == 0)‬

‭printf("%d is a prime number.\n", num);‬

‭else‬

‭printf("%d is not a prime number.\n", num);‬

‭return 0;‬

‭}‬

‭4.To Find Factorial of a Number:‬

‭##include <stdio.h>‬

‭// Function to calculate the factorial of a number‬


‭unsigned long long factorial(int n) {‬

‭unsigned long long fact = 1;‬

‭for (int i = 1; i <= n; i++) {‬

‭fact *= i; }‬

‭return fact;‬

‭}‬

‭int main() {‬

‭int num;‬

‭// Prompt the user to enter a number‬

‭printf("Enter a number: ");‬

‭scanf("%d", &num);‬

‭if (num < 0) {‬

‭printf("Factorial is not defined for negative numbers.\n");‬

‭} else {‬

‭// Calculate factorial and print the result‬

‭unsigned long long fact = factorial(num);‬

‭printf("Factorial of %d is %llu\n", num, fact);‬

‭}‬

‭return 0;‬

‭}‬
;‬

}‬

‭LAB 6‬
‭Objective:‬

‭ his lab experiment empowers you to gain practical expertise in installing‬


T
‭and upgrading a Linux operating system. You'll delve into various installation‬
‭methods, partitioning strategies, package selection nuances, and essential‬
‭post-installation configuration steps.‬

‭Theoretical Underpinnings:‬

‭ inux Installation Methods:‬‭Linux offers a multitude of installation‬


L
‭approaches, catering to diverse environments and requirements. You can‬
‭leverage a bootable DVD, USB drive, or even network protocols like NFS, FTP,‬
‭or HTTP for the installation process.‬
‭Booting from Installation Media:‬‭Initiate the installation by booting‬
‭from a bootable DVD, USB drive, or a network boot server, as per your chosen‬
‭method.‬
‭Installation Method Selection: Opt for the installation method that‬
‭aligns most effectively with your specific setup and needs.‬
‭Partitioning‬ ‭the‬ ‭Hard‬ ‭Drive:‬ ‭This‬ ‭step‬ ‭involves‬ ‭carving‬ ‭out‬ ‭space‬‭on‬
‭your‬ ‭hard‬ ‭drive‬ ‭to‬ ‭accommodate‬ ‭Linux.‬ ‭This‬ ‭might‬ ‭entail‬ ‭resizing‬ ‭existing‬
‭partitions or creating entirely new ones to suit your desired layout.‬
‭Package Selection:‬‭Meticulously choose the software‬‭components‬
‭to be installed during the process. This selection can range from a‬
‭minimalist installation for efficiency to a full-fledged desktop environment‬
‭encompassing a broader spectrum of applications.‬
‭Installation:‬‭The installer meticulously copies the‬‭necessary files to‬
‭your hard drive, configures the bootloader to enable system startup, and‬
‭executes other essential tasks to complete the installation.‬
‭Post-Installation Configuration:‬‭Following installation,‬‭you might‬
‭need to perform additional configuration steps to tailor the system to your‬
‭preferences. This could involve creating user accounts, establishing‬
‭network connectivity, and more.‬
‭Linux Upgradation:‬‭Upgrading a Linux system entails‬‭updating it to a‬
‭more recent version. This process frequently allows you to avoid the need‬
‭for a complete reinstallation. Here's a breakdown of the typical upgrade‬
‭process:‬
‭Package List Update:‬‭As a preliminary step, it's crucial to update the‬
‭list of available packages and their corresponding versions from the‬
r‭ epositories. This ensures you're working with the most up-to-date‬
‭information.‬
‭Package Upgrade:‬‭Proceed to upgrade all currently installed packages‬
‭to their latest iterations accessible in the repositories.‬
‭Distribution Upgrade (if applicable):‬‭For significant version‬
‭upgrades, a distribution upgrade is often recommended. This process‬
‭meticulously addresses potential changes in dependencies between‬
‭package versions and might also involve the removal of obsolete packages‬
‭to streamline the system.‬
‭Installation Tasks:‬

‭ ownload:‬‭Navigate to the official website of your‬‭preferred Linux‬


D
‭distribution and download the ISO image file.‬
‭Bootable Media Creation:‬‭Employ a utility or tool‬‭to meticulously create‬
‭a bootable USB drive or DVD using the downloaded ISO image.‬
‭USB‬ ‭Booting:‬ ‭To‬‭initiate‬‭the‬‭installation‬‭process,‬‭restart‬‭your‬‭computer‬
‭and ensure it boots from the USB drive. You might need to press a specific‬
‭key (like F12, F10, or F2) during startup to modify the boot order if‬
‭necessary.‬

‭Language Selection:‬‭Upon the appearance of the welcome screen,‬


‭meticulously select your preferred language. Click on the "Install‬
‭Ubuntu" option to proceed.‬
‭ eyboard Layout:‬‭Choose‬‭the keyboard layout that aligns with your‬
K
‭physical keyboard and click on "Continue."‬

‭ pdates and Other Software:‬‭Determine whether you want to download‬


U
‭updates concurrently with the installation and if you wish to install‬
‭third-party software for graphics processing units (GPUs), Wi-Fi hardware,‬
‭Flash, MP3 playback, and other multimedia capabilities. Click on "Continue"‬
‭after making your selections.‬
I‭ nstallation Type:‬‭The installer will prompt you to choose the desired‬
‭installation type. If you intend to install Ubuntu alongside your existing‬
‭operating system, select "Install Ubuntu alongside them." If you're‬
‭prepared to erase your entire disk and dedicate it solely to Ubuntu, choose‬
‭"Erase disk and install Ubuntu." Exercise extreme caution with this option,‬
‭as it will permanently erase all data on the selected disk.‬

‭ ocation Specification:‬‭If you have an active internet connection, the‬


L
‭installer will attempt to automatically detect your location. Verify its‬
‭accuracy and click on "Continue" to proceed.‬
‭ ogin Information:‬‭Provide your name, the desired name for your‬
L
‭computer, create a username, establish a strong password, and choose‬
‭whether you want to log in automatically or require a password for‬
‭enhanced security. Click on "Continue" once you've entered this‬
‭information.‬

I‭ nstallation Process:‬‭The installation process will now commence. The‬


‭duration can vary depending on your system's specifications.‬
‭ omputer Restart:‬‭Upon successful installation completion, you'll be‬
C
‭prompted to restart your computer. Ensure the USB drive is removed,‬
‭Upgradation Tasks.‬

‭ ow that you've installed your Linux system, let's explore the process of‬
N
‭keeping it up-to-date with the latest security patches and features.‬

‭1.‬‭Update Package List‬

‭ aintaining an updated package list is crucial for a secure and efficient‬


M
‭system. This ensures you have access to the most recent information about‬
‭available packages and their versions. Open a terminal window (often‬
‭accessible through the Applications menu or a keyboard shortcut) and‬
‭execute the following command:‬
‭sudo apt update‬
‭2.‬‭Upgrade Packages (Optional)‬

I‭ f‬ ‭you‬ ‭only‬ ‭require‬ ‭upgrading‬ ‭individual‬ ‭packages‬ ‭or‬ ‭resolving‬ ‭minor‬


‭issues,‬ ‭you‬ ‭can‬ ‭use‬ ‭the‬ ‭following‬ ‭command‬ ‭to‬ ‭upgrade‬ ‭all‬ ‭installed‬
‭packages to their latest available versions:‬
‭sudo apt upgrade‬

‭ his command analyzes the current package list and downloads and‬
T
‭installs any updates for existing packages.‬

‭3.‬‭Distribution Upgrade (Recommended for Major Version Changes)‬

‭ or significant version upgrades of your Linux distribution, a distribution‬


F
‭upgrade is generally recommended. This process meticulously addresses‬
‭potential changes in dependencies between package versions and might‬
‭also involve the removal of obsolete packages to streamline the system. To‬
‭initiate a distribution upgrade, execute the following command:‬
‭sudo apt dist-upgrade‬
‭ he‬‭system‬‭will‬‭display‬‭a‬‭list‬‭of‬‭packages‬‭that‬‭will‬‭be‬‭upgraded,‬‭removed,‬
T
‭or‬ ‭newly‬ ‭installed.‬ ‭It's‬ ‭essential‬ ‭to‬ ‭carefully‬ ‭review‬ ‭this‬ ‭information‬
‭before‬‭proceeding.‬‭Once‬‭you're‬‭satisfied,‬‭type‬‭Y‬‭(yes)‬‭and‬‭press‬‭Enter‬‭to‬
‭confirm the upgrade process.‬

‭Additional Considerations:‬

‭ ackups:‬‭Before performing any significant upgrades,‬‭it's strongly‬


B
‭recommended to create a backup of your important data. This ensures you‬
‭can recover critical information in case of unexpected issues.‬
‭Network Connectivity:‬‭Ensure you have a stable internet‬‭connection‬
‭throughout the upgrade process to download essential updates and‬
‭packages.‬
‭System Resources: Upgrading can consume system resources, so it's‬
‭advisable to close any unnecessary applications before initiating the‬
‭process.‬

‭ y following these steps and considerations, you can effectively maintain‬


B
‭your Linux system up-to-date and benefit from the latest security‬
‭enhancements, bug fixes, and performance improvements.‬
‭Lab Experiment 7:‬
‭AIM:‬ ‭Install Linux on a PC having some other previously installed‬

‭operating system. All OSs should be usable‬

‭Objective:‬
‭The objective of this experiment is to install a Linux distribution on a PC that already has‬
‭another operating system installed, ensuring that all operating systems remain usable.‬

‭Theory:‬
‭a. Installation of Linux‬
‭Linux can be installed in various ways, including from a DVD, a USB stick, or over a‬
‭network using NFS, FTP, or HTTP. The installation process involves several steps:‬

‭1.‬‭Boot from Installation Media‬‭: This could be a bootable DVD, USB stick, or‬
‭network boot server.‬

‭2.‬‭Select Installation Method‬‭: Choose the method that best suits your‬
‭environment and needs.‬

‭3.‬‭Partitioning‬‭: Partition your hard drive to create space for Linux. This could‬
‭involve resizing existing partitions or creating new ones.‬

‭4.‬‭Package Selection‬‭: Choose the software to be installed. This could range‬


‭from a minimal installation to a full desktop environment.‬

‭5.‬‭Installation‬‭: The installer copies files to the hard drive, configures the‬
‭bootloader, and performs other necessary tasks.‬

‭6.‬‭Install Boot Loader:‬‭As part of the Linux installation, a boot loader (such as‬
‭GRUB) will be installed. This allows the user to choose which operating system‬
‭to boot into at startup.‬

‭7.‬‭Test‬‭the‬‭Installation:‬‭After‬‭the‬‭installation‬‭is‬‭complete,‬‭restart‬‭the‬‭PC.‬‭The‬
‭boot‬ ‭loader‬ ‭should‬ ‭present‬ ‭the‬ ‭option‬ ‭to‬ ‭boot‬ ‭into‬ ‭either‬ ‭the‬ ‭original‬
‭operating system or the newly installed Linux distribution‬
‭Installation Tasks‬
‭1.‬‭Download:‬‭the ISO image of your preferred Linux distribution from its official‬
‭website.‬

‭2.‬‭Create:‬‭a bootable USB stick or DVD with the downloaded ISO image.‬

‭3.‬‭Boot from USB‬‭: Restart your computer and boot from the USB drive. You‬
‭might need to press a key (often F12, F10, or F2) during startup to change the‬
‭boot order.‬

‭4.‬‭Choose Language‬‭: When the Ubuntu welcome window appears, select‬


‭your preferred language.‬
‭Click on “Install Ubuntu”. You will be presented with two options: “Try Ubuntu”‬
‭and “Install Ubuntu”. Choose “Install Ubuntu”.‬

‭5.‬‭Keyboard Layout‬‭: Choose your keyboard layout and click on “Continue”.‬

‭6.‬‭Updates and Other Software‬‭: Choose whether you want to download updates‬
‭while installing Ubuntu and whether you want to install third-party software for‬
‭graphics and Wi- Fi hardware, Flash, MP3, and other media. Then click on‬
‭“Continue”.‬
‭7.‬‭Installation Type‬‭: You’ll be asked what type of installation you want. If you want‬
‭to install Ubuntu alongside your existing operating system, choose “Install‬
‭Ubuntu alongside them”. If you want to erase your entire disk and install Ubuntu,‬
‭choose “Erase disk and install Ubuntu”. Be careful with this option as it will erase‬
‭all data on the disk!‬

‭8.‬‭Choose Your Location‬‭: If you are connected to the internet, your location will‬
‭be detected automatically. Check if it’s correct and click on “Continue”.‬
‭9.‬‭Enter Your Login Information‬‭: Enter your name, your computer’s name, pick a‬
‭username, enter a password, and choose whether you want to log in‬
‭automatically or require a password. Click on “Continue”.‬

‭10‬‭.Installation‬‭: The installation process will now start. It can take a while, so‬
‭you might want to grab a cup of coffee.‬
‭10.‬‭Restart Your Computer‬‭: Once the installation is complete, you’ll be‬
‭prompted to restart your computer. Make sure to remove the USB drive, then‬
‭click on “Restart Now”.‬

‭10.‬ ‭GRUB Boot loader‬‭: Now, after each restart you’ll see a new bootloader‬
‭(GNU GRUB - version 2.0). Here, you can select the operating system that you‬
‭want to boot on each boot.‬
‭Lab Assignment 8‬
‭Aim:‬‭As supervisor create and maintain user accounts, learn‬
‭ ackages installations, taking backups, creation of scripts for file and‬
p
‭user management, creation of startup and shutdown using at, crontab‬
‭etc.‬

‭Managing users:‬

‭ o create and maintain user accounts in Linux, you can use the‬
T
‭command line called ”useradd”.‬

‭Here are the steps to create a new user account.‬

‭Add the new user to a specific group by running the following‬

‭command:‬
‭ o view the existing list of user on your Linux system, you can run the‬
T
‭following command:‬

‭ ere is an example of creating a new user ” cadets ” and adding it to‬


H
‭the “sudo” group and then deleting the user:‬

‭Managing Groups:‬

‭ roups establish relationships in which they share a common set of‬


G
‭permissions. All the groups are listed in/etc/group file.‬
‭‬ T
● ‭ o view/etc/group‬
‭●‬ ‭cat /etc/group‬

‭Group Management Tools:‬

‭ here are several group management tools available in Linux. Here are‬
T
‭a few examples with their respective outputs.‬

‭1.‬ ‭groupadd:‬‭This command is used to create new group in Linux.‬

‭2.‬ ‭groupdel:‬‭This command is used to delete an existing group in‬


‭Linux.‬
‭ acking And Restoring Files:‬‭Your Linux system’s hard disk contains‬
B
‭everything needed to keep the system running as well as to keep‬
‭other files that you need to like documents and databases.‬
‭Back up utilities for Linux:‬

‭1.‬ C ‭ TAR: Backup and recovery software from UniTrends Software‬


‭Corporation.‬
‭2.‬ ‭Arkeia: Backup and recovery software from Knox software.‬
‭3.‬ ‭BRU: Backup and recovery from TOLIS group‬
‭4.‬ ‭LONE-TAR: Tape backup package from Lone Tar technology.‬

‭Tar command:‬

‭ he tar command is commonly used for creating backups of files and‬


T
‭directories in Linux. Here is an example output.‬

‭ sync‬‭is another tool for backing up files in Linux. To create a backup‬


R
‭of a directory using rsync, you can use the following command.‬
‭Crontab File:‬

‭ he crontab file contains a list of commands that are scheduled to run‬


T
‭at specific times.‬

‭ o view the current user’s crontab file, you can use the following‬
T
‭command “crontab-1”.‬

‭How to Perform Automated backups:‬

‭Step 1:‬‭Create a backup script.‬

‭Step 2:‬‭Make the backup script executable.‬

‭Step 3:‬‭Schedule the Backup using cron.‬

‭Step 4:‬‭Save and close the cron configuration file.‬

You might also like