0% found this document useful (0 votes)
35 views26 pages

LINUX

Uploaded by

gojosatu23
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)
35 views26 pages

LINUX

Uploaded by

gojosatu23
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/ 26

LINUX

PRACTICAL FILE

SUBMITTED TO SUBMITTED BY

Ms. VIMMI KOCHHER ANSHIKA SHARMA

BSC IT (5TH SEMESTER)

A50504922002
TABLE OF CONTENT

PRACTICAL DATE TITLE PAGE SIGN


NO. NO.

1 02/09/24 Introduction and installation of linux 3

2 09/09/24 Basic commands of linux 10

3 16/09/24 Shell program 17

4 30/09/24 Grep command 18

5 14/10/24 If- else condition 19

6 21/10/24 Vi editor 20

7 11/11/24 Sum of 2 no. 24

8 18/11/24 Swapping of 2 no. 25

9 25/11/24 Fibonacci series 26


PRACTICAL – 1

Introduction to Linux
Linux is a powerful, open-source, and widely used operating system based on the
Unix architecture. It was first developed by Linus Torvalds in 1991 as a free
alternative to proprietary operating systems. Over the years, Linux has grown into
a versatile OS used in servers, desktops, embedded systems, and supercomputers
worldwide
Concept of Linux
Linux is a multi-user, multi-tasking operating system that allows multiple users
to perform various tasks simultaneously. Its open-source nature means the source
code is freely available for modification and distribution, making it highly
customizable.
Features of Linux
• Open Source: The Linux kernel is freely available and can be modified by
anyone, which fosters collaboration and innovation.
• Security: Linux is renowned for its robust security features, including user
permissions, firewalls, and encryption.
• Portability: Linux can run on a wide variety of hardware platforms, from
smartphones to servers.
• Stability: It is known for its high stability and uptime, making it ideal for
servers.
• Community Support: A large, active community provides extensive
resources and support for troubleshooting and development.

Components of Linux
Linux comprises three key components:
• Kernel: The core part of the operating system that interacts with the
hardware and manages system resources.
• System Utilities: Tools that manage tasks like file handling and process
control.
• Shell: The command-line interface for interacting with the kernel.

Uses of Linux
• Servers: Over 90% of web servers, such as those running Google,
Facebook, and Amazon, use Linux for its reliability and performance.
• Desktops: Popular distributions like Ubuntu and Fedora provide a user-
friendly desktop experience.
• Embedded Systems: Linux is widely used in smart TVs, routers, and IoT
devices.
• Supercomputers: Most supercomputers in the world use Linux due to its
scalability.

Popular Linux Distributions


• Ubuntu: A beginner-friendly distribution widely used for personal and
professional purposes.
• Fedora: A cutting-edge distribution with the latest features.
• CentOS/RHL: Used for enterprise environments.
• Debian: Known for its stability and extensive package repository.

Benefits of Linux
• Cost-Effective: Linux is free to use, unlike many proprietary operating
systems.
• Customizable: Users can modify it to suit their specific needs.
• Efficiency: Linux is lightweight and performs well even on older hardware.
• Developer-Friendly: With powerful tools, scripting capabilities, and
compilers, Linux is ideal for software development.
Contribution to Modern Technology
Linux powers a vast range of devices and systems:
• Android smartphones are based on the Linux kernel.
• Cloud computing services like AWS and Azure rely on Linux servers.
• It plays a critical role in Artificial Intelligence (AI) and machine learning
systems.

Conclusion
Linux is more than just an operating system; it is a philosophy of collaboration,
innovation, and openness. Its flexibility and reliability make it indispensable in
modern computing, ensuring its continued dominance across various sectors. For
students, developers, and IT professionals, learning Linux is a gateway to
understanding system-level computing and advanced technology trends.

Installation of UBUNTU

Step 1: Download Ubuntu Image from Official Site


Visit www.ubuntu.org . Click on 22.04 LTS release which has a new Ubuntu Desktp installer
and will be added to the future Ubuntu releases.

Step 2: Create a Bootable USB


For installing Ubuntu Desktop from usb, we need to write downloaded ISO to a USB Stick to
create the installation media. We'll use rufus which runs on windows to boot the USB. perform
the same operation we can use Balen Etcher which is available for Linux, windows, Mac OS.

Now, click on Close.


Step 3: Install Ubuntu OS from USB flash drive
• Plug in the USB flash drive to your laptop or PC where you want to install Ubuntu.
Then, either turn on your device or restart it.
• Usually, your computer should detect the USB drive automatically. If it doesn't, you can
try pressing the F12 key as your computer starts up.
• This will bring up a menu where you can manually select the USB device to boot.

Step 4: Choose Language Preference


After the installer has started up, you'll be asked to select your preferred language.
Step 5: Setup Installation
• When installing, choose between Normal and Minimal installation. Minimal is great
for smaller drives or fewer pre-installed apps.
• In Additional Options, select updates and third-party software for better device support
and performance.

Step 6: Choose Type of Installation


• On this screen, you can set up your installation. If you want Ubuntu to be the sole
operating system on your hard drive, choose "Erase disk and install Ubuntu."
• If your device already has another operating system, you'll get options to install Ubuntu
alongside it instead of replacing it.
Step 7: Ready to Install
• choose, clicking "Next" will lead you to a summary of your installation settings.
• This allows you to review your configuration before proceeding with the installation by
clicking "Install."

Step 8: Choose your Location


• Choose your location and timezone on the map screen, then click "Continue". If you're
connected to the internet, this information will be detected automatically.
Step 9: Create Your Login Details
• Here, you'll enter your name and your computer's name for network identification. Next,
create a username and a strong password.
• You can opt for automatic login or password requirement. If you're using your device
while traveling, it's advisable to keep "Require my password to log in" enabled.
Step 10: Complete the Installation
After the installation finishes, you'll be asked to restart your machine. Just click on "Restart
Now."
PRACTICAL 2

Basic Linux Commands and Their Uses

1. ls
o Description: Lists the contents of a directory.
o Example: ls -l (shows detailed information about files and directories).

2. mkdir
o Description: Creates a new directory.
o Example: mkdir folder_name.

3. rmdir
o Description: Removes an empty directory.
o Example: rmdir folder_name.
4. echo
o Description: Prints text or variables to the terminal.
o Example: echo "anshika".

5. cd
o Description: Changes the current directory.
o Example: cd /path/to/directory.
6. touch
o Description: Creates an empty file or updates the timestamp of an
existing file.
o Example: touch file_name.txt.

7. pwd
o Description: Displays the current working directory.
o Example: pwd.

8. cp
o Description: Copies files or directories.
o Example: cp file1.txt /destination_folder/.
9. mv
o Description: Moves or renames files and directories.
o Example: mv file1.txt file2.txt.

10.cat
• Description: Displays the contents of a file.
• Example: cat file_name.txt.

11.grep
• Description: Searches for patterns in a file.
• Example: grep "text" file_name.txt.
12.whoami
• Description: Shows the current logged-in user.
• Example: whoami.

13.chmod
• Description: Changes file permissions.
• Example: chmod 755 file_name.

14.chown
• Description: Changes the owner of a file or directory.
• Example: chown user_name file_name.
15.who
• Description: Shows information about logged-in users.
• Example: who.

16.sort
• Description: Sorts the contents of a file.
• Example: sort file_name.txt.

17.ifconfig
• Description: Displays or configures network interfaces.
• Example: ifconfig eth0.
18.date
• Description: Displays the current date and time.
• Example: date.

19.cal
• Description: Displays a calendar for the current month or year.
• Example: cal.

20.df
• Description: Displays disk space usage of filesystems.
• Example: df -h.
PRACTICAL 3

Q. Write a shell program to print “hello world”


Step 1 : First write the below command in terminal

Step 2 : After this, you will enter into the shell

Step 3: For exit press cntrl+x after that Y and then enter you will get exit from
shell and : enter the commands which are given below to get your desired result
Practical – 4

Q. Write a program to check which no is greater using If-else


condition
Step 1: Enter the shell using nano
For eg : here I used nano ifelse.sh (ifelse is my file name and . sh is an extention)

Step 2: after entering the shell write your query which is given below very
carefully remember to give space after every word so that you won’t get syntax
error

Step 3: For exit press cntrl+x after that Y and then enter you will get exit from
shell
Step 4: enter the commands which are given below to get your desired result
Practical - 5

Q. How to use Grep command in shell

Step 1: Enter the shell using nano


For eg : here I used nano ifelse.sh (anshika is my file name and . sh is an extention)
• write the below command in terminal

Step 2: After this, you will enter into the shell

Step 3: For exit press cntrl+x after that Y and then enter you will get exit from
shell and then enter the commands which are given below to get your desired result
Practical -6

Vi Editor in Linux
The default editor that comes with the Linux/UNIX operating system is
called vi (visual editor). Using vi editor, we can edit an existing file or create a new
file from scratch. we can also use this editor to just read a text file. The advanced
version of the vi editor is the vim editor.
Control Command (Scrolling) in vi Editor:
There are the following useful commands which can be used along with the
Control Key. These commands are helpful in saving time by navigating quickly in
a file without manually scrolling.

Command Description

CTRL+d moves the screen down by half a page.

CTRL+f moves the screen down by a full page.

CTRL+u moves the screen up by half a page.

CTRL+b moves the screen up by a full page.

CTRL+e moves the screen up by one line.

CTRL+y moves the screen down by one line.

CTRL+I redraw the screen.

Moving within a File (Navigation) in Vi Editor :


To move around within a file without affecting text must be in command mode
(press Esc twice). Here are some of the commands that can be used to move
around one character at a time.
Commands Description
`k` Moves the cursor up one line.
`j` Moves the cursor down one line.
`h` Moves the cursor to the left one-character position.

`l` Moves the cursor to the right one-character position.

`0` Positions cursor at beginning of line.


`$` Positions cursor at end of line.
`W` Positions cursor to the next word.
`B` Positions cursor to previous work.

`(` Positions cursor to beginning of current sentence.

`)` Positions cursor to beginning of next sentence.


`H` Move to top of screen.

`nH` Moves to nth line from the top of the screen.


`M` Move to middle of screen.

`L` Move to bottom of screen.

`nL` Moves to nth line from the bottom of the screen.

Colon followed by a The cursor on the line number is represented by the number
number position after the colon. For example, “:10” positions the cursor on
line 10.

Inserting and Replacing text in Vi Editor:


To edit the file, we need to be in the insert mode. There are many ways to enter
insert mode from the command mode.
Command Description
i Inserts text before current cursor location
a Insert text after current cursor location
A Insert text at the end of current line
o Creates a new line for text entry below cursor location and switches to
insert mode.

O Creates a new line for text entry above cursor location and switches to
insert mode.

s Replaces single character under the cursor with any number of


characters and switches to insert mode.

R Overwrites text from the cursor to the right, without switching to insert
mode.

Copy and Paste in Vi editor in Linux:


Copy lines or words from one place and paste them in another place by using the
following commands.
Commands Description

Yy Copies the current line.

9yy Yank current line and 9 lines below.

p Puts the copied text after the cursor.

P Put the yanked text before the cursor.

Deleting Characters and Lines in Vi Editor :


Here is the list of important commands which can be used to delete characters and
lines in an opened file.
Command Description

`X` (Uppercase) Deletes the character before the cursor location.

`x` (Lowercase) Deletes the character at the cursor location.


`Dw` Deletes from the current cursor location to the next word
`d^` Deletes from current cursor position to the beginning of the line.

`d$` Deletes from current cursor position to the end of the line.
`Dd` Deletes the line the cursor is on.

Save and Exit in Vi Editor in Linux:


Need to press [Esc] key followed by the colon (:) before typing the following
commands:
Commands Description

q Quit

q! Quit without saving changes i.e. discard changes.

r [file_name] Read data from file called [file_name]

wq Write and quit (save and exit).

w Write to file called [file_name] (save as).

w! Overwrite to file called [file_name] (save as forcefully).

!cmd Runs shell commands and returns to Command mode.


Practical – 7

Q. Write a program to add 2 number in a shell


Step 1: Enter the shell using nano followed by your file_name and with .sh
extension

Step 2: After entering the shell write your program which is given below very
carefully remember to give space after every word so that you won’t get syntax
error

Step 3: For exit press cntrl+x after that Y and then enter you will get exit from
shell and then enter the 1st and 2nd no and you will get the sum of it
Practical - 8

Q. Write a program to swap 2 numbers


Step 1: Enter the shell using nano followed by your file_name and with .sh
extension
Here it is nano swap.sh

Step 2: After entering the shell write your program carefully so that you won’t get
syntax error

Step 3: For exit press cntrl+x after that Y and then press enter you will get exit
from shell and then enter the 1st and 2nd no then the swapping would be done
Practical – 9

Q. Write a program to perform Fibonacci series


Step 1: Enter the shell using nano followed by your file_name and with .sh
extension (for eg: nano fbs.sh)

Step 2: After entering the shell write your formula of Fibonacci series carefully so
that you won’t get syntax error

Step 3: For exit press cntrl+x after that Y and then press enter you will get exit
from shell and then enter the 1st and 2nd no then the swapping would be done

You might also like