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

Linux Intern Report

This document serves as a comprehensive guide to Linux, covering its introduction, installation methods, basic commands, file management, user management, process management, and shell scripting. It details the installation process through normal means and VirtualBox, along with essential Linux commands and their functionalities. The document is structured with a table of contents, providing a clear outline of topics and page numbers for easy navigation.

Uploaded by

kgruchitha
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)
6 views

Linux Intern Report

This document serves as a comprehensive guide to Linux, covering its introduction, installation methods, basic commands, file management, user management, process management, and shell scripting. It details the installation process through normal means and VirtualBox, along with essential Linux commands and their functionalities. The document is structured with a table of contents, providing a clear outline of topics and page numbers for easy navigation.

Uploaded by

kgruchitha
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/ 44

lOMoARcPSD|28502170

TABLE OF THE CONTENTS

TOPIC PAGE
NO

1. INTRODUCTION TO LINUX 09

2. INSTALLATION OF LINUX 10 - 22

2.1: NORMAL INSTALLATION


2.2: INSTALLATION THROUGH VIRTUAL BOX
3. LINUX BASIC COMMANDS 23 -26
4. WORKING WITH FILES 27 - 33
4.1: LISTING FILES
4.2: GRANTING PERMISSION
5. USER MANAGEMENT 34 - 37
5.1: ADDING AND DELETING USER
5.2: ADDING AND DELETING HOME DIRECTORY
6. PROCESS MANAGEMENT 38 -41
6.1: LIST OF COMMANDS AND THEIR USES /
SWITCH OPERATION
7. SHELL SCRIPTING 42- 48
7.1: STEPS TO SCRIPT SHELL
7.2: LIST OF PROGRAM OF SHELL SCRIPTING
8. SUMMARY 49
9. REFERENCE 50

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

1. INTRODUCTION TO LINUX

Linux is an open source operating system (OS).


An operating system is the software that directly manages a
system’s hardware and resources, like CPU, memory, and stor-
age. The OS sits between applications and hardware and
makes the connections between all of your software and the
physical resources that do the work.

Think about an OS like a car engine. An engine can run


on its own, but it becomes a functional car when it’s connected
with a transmission, axles, and wheels. Without the engine run-
ning properly, the rest of the car won’t work.

How does Linux work?

Linux was designed to be similar to UNIX, but has


evolved to run on a wide variety of hardware from phones
to supercomputers. Every Linux-based OS involves the Linux
kernel—which manages hardware resources—and a set of
software packages that make up the rest of the operating sys-
tem.

The OS includes some common core components, like


the GNUtools, among others. These tools give the user a way
to manage the resources provided by the kernel, install addi-
tional software, configure performance and security settings,
and more.

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

2. INSTALLATION OF LINUX

THERE ARE THREE WAYS OF INSTALLING LINUX:-


2.1 NORMAL INSTALLATION
2.2 INSTALLATION THROUGH VIRTUAL BOX

1. The first way is to download the Linux distribution


you want and burn it into a DVD or USB stick and boot
your machine with it and complete the installation process.

2. The Second way is to install it virtually on a virtual ma-


chine like VirtualBox or VMware without touching your Win-
dows or Mac system, so your Linux system will be contained
in a window you can minimize and continue working on your
real system.
For me, I prefer VirtualBox, it’s free and runs very fast on my
PC than VMware, and support installing Windows, Linux and
Mac OS with all versions.

10

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

We can install it in windows in the following


ways:-

Open the Virtual Box website.

Go to https://www.Virtual Box.org/ in your


computer's Internet browser. This is the website from
which you'll download the VirtualBox setup file.

11

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click Download VirtualBox.


It's a blue button in the middle of the page. Doing so
will open the downloads page.

12

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click Windows hosts.

You'll see this link below the "Virtual Box 5.2.8


platform packages" heading. The Virtual Box EXE file
will begin downloading onto your computer.

Open the Virtual Box EXE file.

Go to the location to which the EXE file down-


loaded and double-click the file. Doing so will open the
Virtual Box installation window.

13

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Navigate through the installation prompts.

Do the following:

 Click next on the first three pages.


 Click Yes when prompted.
 Click Install
 Click Yes when prompted.

14

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click Install when prompted.

Doing so will allow VirtualBox to begin installing


on your computer.

15

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click Finish when prompted.

It's in the lower-right side of the window. Doing so will


close the installation window and open Virtual Box. Now that
you've installed and opened Virtual Box, you can create a
virtual machine in order to run any operating system on your
PC.

 Make sure that you don't uncheck the "Start" box before
doing this.

16

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

CREATING A VIRTUAL MACHINE


 Gather your installation disc(s) or files.
When creating a virtual machine, you will need to
install the operating system just like you would on a regular
computer. This means that you will need the installation
disc(s) for the operating system you want to install on the
virtual machine.
You can also install an operating system by using
its ISO file.

17

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click.

New. This will open the wizard that will guide


you through the process to create your first virtual
machine.

 Identify the operating system.

On the first screen of the wizard, you will be


asked to give the new virtual machine a name as well as
choose what operating system you will be installing.
Choose the type of operating system from the "Type"
menu, and then choose which version you are installing
from the "Version" menu.
18

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click Next.

It's at the bottom of the window.

 Set the amount of RAM.

You will need to designate how much of your


computer's RAM will be allocated to your virtual machineYou
can only go as high as the amount of RAM physically
installed in your system.

19

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click Next.

 Create a virtual hard drive.


Select a virtual hard drive option and click Create,
then click through the prompts and click Create again. Your
virtual machine will need a virtual hard drive in order to
install the operating system and any programs.

20

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

 Start the operating system installation.

Once the virtual machine has been


configured, the wizard will close and you will be
taken back to the Virtual Box main window. Double-
click your new machine in the left menu, then do one
of the following:

i. If you are installing from a disc, insert it into


your computer, click the "Host drive" drop-down
box and click the correct drive letter from the
drop-down menu.
ii. If you are installing from an image file, click the
folder-shaped icon to browse through your
computer for the installation image file.
21

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Click Start.

It's at the bottom of the window. This will prompt


VirtualBox to begin reading your disk or file.

 Install the operating system.


After selecting the installation media, the operating
system installation will begin. Installation proceeds the same
way it would as if you were installing the operating system on
a regular computer. See the following guides for instructions
on installing the operating system of your choice:

 Boot up your virtual machine.

Once the operating system is installed, your virtual


machine is ready to go. Simply double-click the name of your
virtual machine in the left menu of the Virtual Box main page
to start it up. The virtual computer will boot and load into the
operating system that you installed.

 Your virtual machine will run in a window.


Whenever the virtual machine window has focus,
any keystrokes or mouse clicks will affect the virtual machine
and not your physical computer.

22

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

3. Linux Basic Command

Let’s start with some simple commands.

1) pwd Command
‘pwd’ command prints the absolute path to current working
directory.

$ pwd
/home/raghu

2) cal command
Displays the calendar of the current month.
$ cal
July 2012
Su Mo Tu We ThFr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

23

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

‘cal ’ will display calendar for the specified month and year.
$ cal 08 1991
August 1991
Su Mo Tu We ThFr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

3) echo command
This command will echo whatever you provide it.

$ echo "linoxide.com"
linoxide.com

The ‘echo’ command is used to display the values of a vari-


able. One such variable is ‘HOME’. To check the value of a
variable precede the variable with a $ sign.
$ echo $HOME
/home/raghu
4) date command
Displays current time and date.

$ date
Fri Jul 6 01:07:09 IST 2012

If you are interested only in time, you can use 'date +%T' (in
hh:mm:ss):

24

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

$ date +%T
01:13:14
5) tty command
Displays current terminal.
$ tty
/dev/pts/0

6) whoami command
This command reveals the user who is currently logged in.
$ whoami
raghu

7) id command
This command prints user and groups (UID and GID) of the
current user.
$ id
uid=1000(raghu) gid=1000(raghu)
groups=1000(raghu),4(adm),20(dialout),24(cdrom)
,46(plugdev),112(lpadmin),120(admin),122(sam-
bashare)

By default, information about the current user is displayed. If


another username is provided as an argument, information
about that user will be printed:
$ id root
uid=0(root) gid=0(root) groups=0(root)

8) clear command
This command clears the screen.

25

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

9) help option
With almost every command, ‘--help’ option shows usage
summary for that command.
$ date --help
Usage: date [OPTION]... [+FORMAT] or: date [-u|--utc|--univer-
sal] [MMDDhhmm[[CC]YY][.ss]]

10) Display the current time


in the given FORMAT, or set the system date.

What is command
This command gives a one line description about the com-
mand. It can be used as a quick reference for any command.
$ whatis date
date (1) - print or set the system date and
time
$ whatiswhatis
whatis (1) - display manual page descriptions

•Manual Pages
‘--help’ option and ‘whatis’ command do not provide thorough
information about the command. For more detailed informa-
tion, Linux provides man pages and info pages. To see a com-
mand's manual page, man command is used.

26

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

4. WORKING WITH FILES

4.1 LISTING FILES


To list the files and directories stored in the current
directory, use the following command −
$ls
Here is the sample output of the above command −
$ls

bin hosts lib res.03


ch07 hw1 pub test_results
ch07.bak hw2 res.01 users
docs hw3 res.02 work

The command ls support the -l option which


would help you to get more information about the listed files

$ls -l
total 1962188

drwxrwxr-x 2amroodamrood 4096 Dec 25 09:59 uml


-rw-rw-r-- 1 amroodamrood 5341 Dec 25 08:38 uml.jpg
drwxr-xr-x 2amroodamrood 4096 Feb 15 2006 univ
drwxr-xr-x 2 root root 4096 Dec 9 2007 urls-
pedia
-rw-r--r-- 1 root root 276480 Dec 9 2007 urls-
pedia.tar
drwxr-xr-x 8 root root 4096 Nov 25 2007 usr
drwxr-xr-x 2 200 300 4096 Nov 25 2007
webthumb-1.01
-rwxr-xr-x 1 root root 3192 Nov 25 2007
webthumb.php
-rw-rw-r-- 1 amroodamrood 20480 Nov 25 2007
webthumb.tar

27

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

-rw-rw-r-- 1 amroodamrood 5654 Aug 9 2007 your-


file.mid
-rw-rw-r-- 1 amroodamrood 166255 Aug 9 2007 your-
file.swf
drwxr-xr-x 11 amroodamrood 4096 May 29 2007 zlib-
1.2.3
$

Here is the information about all the listed columns –

 First Column − Represents the file type and the per-


mission given on the file. Below is the description of all
type of files.
 Second Column − Represents the number of memory
blocks taken by the file or directory.
 Third Column − Represents the owner of the file.
This is the Unix user who created this file.
 Fourth Column − Represents the group of the owner.
Every Unix user will have an associated group.
 Fifth Column − Represents the file size in bytes.
 Sixth Column − Represents the date and the time
when this file was created or modified for the last time.
 Seventh Column − Represents the file or the directory
name.

28

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

HOME DIRECTORY

The directory in which you find yourself when


you first login is called your home directory.

You will be doing much of your work in your


home directory and subdirectories that you'll be creating to or-
ganize your files.

You can go in your home directory anytime using


the following command −
$cd ~
$
Here ~ indicates the home directory. Suppose you have to
go in any other user'shome directory, use the following command −
$cd ~username
$
To go in your last directory, you can use the following
command −
$cd -
$

29

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

 LISTING DIRECTORIES
To list the files in a directory, you can use the follow-
ing syntax −
$lsdirname
Following is the example to list all the files contained
in /usr/local directory −
$ls /usr/local
X11 bin gimp jikessbin
ace doc include lib share
atalketc info man ami

 CREATING DIRECTORIES
We will now understand how to create directories.
Directories are created by the following command –

$mkdirdirname

Here, directory is the absolute or relative pathname


of the directory you want to create. For example, the command

$mkdirmydir
$

Creates the directory mydir in the current directory.


Here is another example −
$mkdir /tmp/test-dir
$

This commandcreates the directory test-dir in


the /tmp directory.
The mkdir command produces no output if it successfully cre-
ates the requested directory.
30

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

If we give more than one directory on the command


line, mkdir creates each of the directories. For example, −

$mkdir docs pub


$

Creates the directories docs and pub under the current


directory.

CREATING PARENT DIRECTORIES

We will now understand how to create parent directo-


ries. Sometimes when we want to create a directory, its parent
directory or directories might not exist. In this case, mkdir is-
sues an error message as follows –

$mkdir /tmp/amrood/test
mkdir: Failed to make directory
"/tmp/amrood/test";
No such file or directory
$
In such cases, you can specify the -p option to
the mkdir command. It creates all the necessary directories for
you. For example –

$mkdir -p /tmp/amrood/test
$
The above command creates all the required parent directories.

 REMOVING DIRECTORIES
Directories can be deleted using the rmdir command
as follows −
$rmdirdirname
$

31

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Note − To remove a directory,we should make sure it is empty which


means there should not be any file or sub-directory inside this directory.

4.2GRANTING PERMISSIONS

To change directory permissions in Linux, use the following :-

 chmod +rwx filename to add permissions.

 chmod -rwxdirectoryname to remove permissions.

 chmod +x filename to allow executable permissions.

 chmod -wx filename to take out write and executable permis-


sions.

Note that “r” is for read, “w” is for write, and “x” is
for execute.

This only changes the permissions for the owner of the


file.

32

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

We may need to know how to change permissions in


numeric code in Linux, so to do this you use numbers instead of
“r”, “w”, or “x”.

 0 = No Permission
 1 = Execute
 2 = Write
 4 = Read

Basically, we add up the numbers depending on the


level of permission we want to give.

Permission numbers are:

 0 = ---
 1 = --x
 2 = -w-
 3 = -wx
 4 = r-
 5 = r-x
 6 = rw-
 7 = rwx

33

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

5. USER MANAGEMENT

User management includes everything from creating a


user to deleting a user on your system. User management can be
done in three ways on a Linux system.

Graphical tools are easy and suitable for new users, as


it makes sure you'll not run into any trouble.

Command line tools includes commands like useradd,


userdel, passwd, etc. These are mostly used by the server admin-
istrators.

Third and very rare tool is to edit the local configura-


tion files directly using vi.

ROOT

The root user is the superuser and have all the powers
for creating a user,deleting a user and can even login with the
other user's account.

34

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

5.1 ADDING AND DELETING USER

USERADD
With useradd commands you can add a user.

Syntax:
useradd -m -d /home/<userName> -c "<userName>" <userName>

Example:
useradd -m -d /home/xyz -c "xyz" xyz

USERDEL

To delete a user account userdel command is used.

Syntax:
userdel -r <userName>

Example:
userdel -r xyz

35

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

5.2 ADDING AND DELETING HOME


DIRECTORIES
By using userdel -r option, you can delete home directory along
with user account.
Syntax:
userdel -r <userName>

Example:
userdel -r john

USERMOD
The command usermod is used to modify the properties of an
existing user.
Syntax:
usermod -c <'newName'> <oldName>

Example:
usermod -c 'jhonny' john

36

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Linux/Unix Process Management: ps, kill, top, df, free,


nice Commands

37

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

6. PROCESS MANAGEMENT
WHAT IS A PROCESS?

An instance of a program is called a Process. In simple


terms, any command that you give to your Linux machine starts
a new process.

When using the Terminal, you will have to wait, until the
foreground process runs.

38

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

 RUNNING A BACKGROUND PROCESS


If you start a foreground program/process from the termi-
nal, then you cannot work on the terminal, till the program is up
and running.
Particular, data-intensive tasks take lots of processing
power and may even take hours to complete. You do not want
your terminal to be held up for such a long time.
To avoid such a situation, you can run the program and
send it to the background so that terminal remains available to
you. Let's learn how to do this input.

39

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

6.1 LIST OF COMMANDS AND THEIR USES / SWITCH


OPERATION

FG

You can use the command "fg" to continue a program


which was stopped and bring it to the foreground.
The simple syntax for this utility is:

PS

This command stands for 'Process Status'. It is similar to


the "Task Manager" that pop-ups in a Windows Machine when
we use Cntrl+Alt+Del. This command is similar to 'top' com-
mand but the information displayed is different.
To check all the processes running under a user, use the
command -
psux

You can also check the process status of a single process,


use the syntax -
ps PID

40

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

KILL

This command terminates running processes on a


Linux machine.
To use these utilities you need to know the PID (process
id) of the process you want to kill
 Syntax -
 kill PID
 To find the PID of a process simply type
pidof Process name

Let us try it with an example.

41

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

7. SHELL SCRIPTING

7.1 Steps to write and execute a script

1. Open the terminal. Go to the directory where you want to


create your script.
2. Create a file with .sh extension.
3. Write the script in the file using an editor.
4. Make the script executable with command chmod +x <file-
Name>.
5. Run the script using ./<fileName>.

A shell script is a computer program designed to be run by


the Unix/Linux shell which could be one of the following:
 The Bourne Shell
 The C Shell
 The Korn Shell
 The GNU Bourne-Again Shell
A shell is a command-line interpreter and typical operations
performed by shell scripts include file manipulation, program
execution, and printing text.
The following script uses the read command which takes the
input from the keyboard and assigns it as the value of the
variable PERSON and finally prints it on STDOUT.
42

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

43

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

#!/bin/sh

# Author : Zara Ali


# Copyright (c) Tutorialspoint.com
# Script follows here:

echo"What is your name?"


read PERSON
echo"Hello, $PERSON"
Here is a sample run of the script −
$./test.sh
What is your name?
Zara Ali
Hello, Zara Ali
$

44

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

7.2 LIST OF PROGRAM OF SHELL


SCRIPTING

Q1 Write a shell script to enter length & width of square


and calculate its area & perimeter and display them.

45

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Q2 write a shell script to check whether a number


is positive, negative or zero.

46

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Q3 write a shell script to print all natural numbers


in recursive ( from n to 1 ). – using while loop.

47

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Q4 Write a shell script to calculate factorial of a


number.

48

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

Q5 Write a shell script to input file name and check if


file found ask user to enter some text and save it into
file, if not found display message not found.

49

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

8. SUMMARY

 Any running program or a command given to a Linux sys-


tem is called a process
 A process could run in foreground or background
 The priority index of a process is called Nice in Linux. Its
default value is 0, and it can vary between 20 to -19
 The lower the Niceness index, the higher would be priority
given to that task

Command Description
bg To send a process to the background
fg To run a stopped process in the foreground
top Details on all Active Processes
ps Give the status of processes running for a user
ps PID Gives the status of a particular process
pidof Gives the Process ID (PID) of a process
kill PID Kills a process
nice Starts a process with a given priority
renice Changes priority of an already running process
df Gives free hard disk space on your system
free Gives free RAM on your system

9. REFERENCES

50

Downloaded by Chethan raj.c (chethanraj016@gmail.com)


lOMoARcPSD|28502170

1. (https://en.wikipedia.org/wiki/Unix) − A brief description of Unix


Operating system.

2. (https://www.linux.org/) − Linux is a free Unix-type operating system


originally created by Linus Torvalds with the assistance of developers
around the world.

3.(https://help.ubuntu.com/) – Ubuntu Official DocumentationLearning the


bash Shell: Unix Shell Programming (In a Nutshell (O'Reilly)) UNIX and Linux
System Administration Handbook (5th Edition)

4. www.geeksforgeeks.org

5. www.tutorialspoint.com

6. www.youtube.com

7. www.Virtual Box.org

51

Downloaded by Chethan raj.c (chethanraj016@gmail.com)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy