0% found this document useful (0 votes)
27 views22 pages

Linux Journal (2020) (E-Next - In)

Linux basics

Uploaded by

shivani
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)
27 views22 pages

Linux Journal (2020) (E-Next - In)

Linux basics

Uploaded by

shivani
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/ 22

Linux Journal

Practical No 1
Aim: Linux Installation

1. Install your choice of Linux distribution. E.g. Ubuntu.


2. Try different installation media like CD/DVD and USB drive to install.
3. Customize desktop environment by changing different default options like changing default
background, themes, and screensavers.

1. Linux
Linux is open-source, free to use kernel. It is used by programmers, organizations, profit and non-
profit companies around the world to create Operating systems to suit their individual requirements.

Ubuntu

This is the third most popular desktop operating system after Microsoft Windows and Apple Mac
OS. It is based on the Debian Linux Distribution, and it is known as its desktop environment.

2. Installing Linux using USB stick

This is one of the easiest methods of installing Ubuntu or any distribution on your computer. Follow
the steps.

Step 1) Download the .iso or the OS files on your computer from this
https://www.ubuntu.com/download/desktop.

Khan S. Alam 1 https://E-next.in

https://E-next.in
Linux Journal

Step 2) Download free software like 'Universal USB installer to make a bootable USB stick.

Step 3) Select an Ubuntu Distribution form the dropdown to put on your USB

Select your Ubuntu .iso file download in step 1.

Select the drive letter of USB to install Ubuntu and Press create button.

Khan S. Alam 2 https://E-next.in

https://E-next.in
Linux Journal

Step 4) Click YES to Install Ubuntu in USB.

Step 5) After everything has been installed and configured, a small window will appear
Congratulations! You now have Ubuntu on a USB stick, bootable and ready to go.

Khan S. Alam 3 https://E-next.in

https://E-next.in
Linux Journal

Installing Linux using CD-ROM

Those who like the way a CD runs should try using this method.

(image source)

Step 1) Download the .iso or the OS files onto your computer from this
link http://www.ubuntu.com/download/desktop.

Step 2) Burn the files to a CD.

Step 3) Boot your computer from the optical drive and follow the instructions.

Khan S. Alam 4 https://E-next.in

https://E-next.in
Linux Journal

3. Change Your Desktop and Lock Screen Background


In order to customize most of the features of your desktop, you will need to access
the Settings utility of Ubuntu OS. You can do so through the following ways:

a. Click the downward arrow located at the top right corner of your Ubuntu desktop
and then click the settings icon located at the bottom left corner:

b. Type Settings in the Ubuntu Dash as follows:

Khan S. Alam 5 https://E-next.in

https://E-next.in
Linux Journal

c. You can also open the Settings utility from the list of applications through the Show
Applications button.

d. In order to change your Desktop or Lock screen backgrounds, move to the Background tab
in the Settings window and click on either the Background or Lock Screen option from the
menu:

e. You can choose a picture as a background either from the available list of wallpapers,
upload one from your system, or use solid colors as your background.

Khan S. Alam 6 https://E-next.in

https://E-next.in
Linux Journal

Practical 2

Aim: Operations performed on a Linux Operating System:

1) Screen Resolution: Ascertain the current screen resolution of your desktop.

2) Networking: Get the current networking configuration for your desktop.

Are you on a wired or wireless connection? What wireless networks are available,

if any.

3) Time settings: Change the time zone of your system to (or New York Time if you are currently in Indian
time). How does the displayed time change? After noting the time change, change the time zone back to your
local time zone.

1. Screen resolution:
The resolution is the number of pixels (dots on the screen) in each direction that can be displayed.
Each resolution has an aspect ratio, the ratio of the width to the height. Wide-screen displays use a
16∶9 aspect ratio, while traditional displays use 4∶3. If you choose a resolution that does not match
the aspect ratio of your display, the screen will be letter boxed to avoid distortion, by adding black
bars to the top and bottom or both sides of the screen.

You can change how big (or how detailed) things appear on the screen by changing the
screen resolution. You can change which way up things appear (for example, if you have a
rotating display) by changing the rotation.
 Open the Activities overview and start typing Settings.
 Click on Settings.
 Click Devices in the sidebar.
 Click Displays in the sidebar to open the panel.
 If you have multiple displays and they are not mirrored, you can have different settings on
each display. Select a display in the preview area.
 Select the resolution or scale and choose the orientation.
 Click Apply. The new settings will be applied for 20 seconds before reverting back. That
way, if you cannot see anything with the new settings, your old settings will be
automatically restored. If you are happy with the new settings, click Keep Changes.

Khan S. Alam 7 https://E-next.in

https://E-next.in
Linux Journal

 For example:

2. Networking:
To set up most wired network connections, all you need to do is plug in a network cable.
The wired network icon ( ) is displayed on the top bar with three dots while the
connection is being established. The dots disappear when you are connected.
If this does not happen, you should first of all make sure that your network cable is plugged
in. One end of the cable should be plugged into the rectangular Ethernet (network) port on
your computer, and the other end should be plugged into a switch, router, network wall
socket or similar (depending on the network setup you have). Sometimes, a light beside the
Ethernet port will indicate that it is plugged in and active.
You cannot plug one computer directly into another one with a network cable (at least, not
without some extra setting-up). To connect two computers, you should plug them both into a
network hub, router or switch.
The steps are:
a) Open the settings.
b) Select the Network or Wireless Settings.
c) Select the network you want to use and enter the password.

Khan S. Alam 8 https://E-next.in

https://E-next.in
Linux Journal

For example:

3. Time settings:
If the date and time displayed on the top bar are incorrect or in the wrong format, you can
change them:
1) Open the Activities overview and start typing Settings.
2) Click on Settings.
3) Click Details in the sidebar.
4) Click Date & Time in the sidebar to open the panel.
5) If you have Automatic Date & Time set to ON, your date and time should update
automatically if you have an internet connection. To update your date and time manually, set
this to OFF.
6) Click Date & Time, then adjust the time and date.
7) You can change how the hour is displayed by selecting 24-hour or AM/PM for Time
Format.

Khan S. Alam 9 https://E-next.in

https://E-next.in
Linux Journal

For example:

Khan S. Alam 10 https://E-next.in

https://E-next.in
Linux Journal

Practical 3:
Aim: Installing and Removing Software:

1. Install gcc package. Verify that it runs, and then remove it.
It stands for GNU compiler collection.

A compiler is computer software that transforms computer code written in one programming
language into another programming language. Compilers are a type of translator that support digital
devices, primarily computers.

These are used for smart, quick, compilation of programming languages without having the actual
compilation software.

Initially only supported C programming languages.

Its other version is called extended GCC was developed for supporting C++ compilation.

As end number of languages have evolved , the GNU foundation has created a collection of
compilations called GCCS which supported the front-end support for java, FORTRAN, Ada

1. To install gcc:
Step 1: Open the terminal in Ubuntu

Step 2: Type in the command: sudo apt install gcc

Step 3: Enter y/n to continue using gcc.

Step 4: Check the version by: gcc –version.

This will check the version of gcc.

2. To verify that it runs:


Step 1:Execute three C- Programs

 Syntax:
//WAP a program to print hello world

#include <stdio.h>

void main()

printf("Hello World");

Compilation Method:

gcc -o hello.out Helloworld.c

./hello.out

Khan S. Alam 11 https://E-next.in

https://E-next.in
Linux Journal

Output:

 Syntax:
//WAP to find the factorial

#include <stdio.h>

void main()

int n,f=1;

printf("Enter a number");

scanf("%d",&n);

while(n>0)

f=f*n;

n--;

printf("The factorial is::%d",f);

Compilation Method:

gcc -o hello.out Fact.c

./hello.out

Output:

Khan S. Alam 12 https://E-next.in

https://E-next.in
Linux Journal

 Syntax:
//WAP to perform basic arithmetic.

#include <stdio.h>

void main()

int n,a,b,c;

printf("Menu");

printf("\n1)Addition");

printf("\n2)Subtraction:");

printf("\n3)Multiplication");

printf("\n4)Division");

printf("\nSelect any one of the options::");

scanf("%d",&n);

switch(n)

case 1:printf("Enter any two numbers");

scanf("%d %d",&a,&b);

c=a+b;

printf("Addittion::%d",c);

break;

case 2:printf("Enter any two numbers");

scanf("%d %d",&a,&b);

c=a-b;

printf("The subtraction is::%d",c);

break;

case 3:printf("Enter any two numbers");

scanf("%d %d",&a,&b);

c=a*b;

printf("The multiplication is::%d",c);

break;

Khan S. Alam 13 https://E-next.in

https://E-next.in
Linux Journal

case 4:printf("Enter any two numbers");

scanf("%d %d",&a,&b);

c=a/b;

printf("The division is::%d",c);

break;

default:printf("The input is invalid");

Compilation method:

gcc -o hello.out Arithmetic.c

./hello.out

Output:

3. To remove gcc:
Step 1: To completely remove gcc execute the following command:

sudo apt remove gcc

Khan S. Alam 14 https://E-next.in

https://E-next.in
Linux Journal

Practical 5

Command Line Operations

1. Install any new package on your system.


2. Remove the package installed.
3. Find the passwd file in / using find command.
4. Create a symbolic link to the file you found in the last step.
5. Create an empty file example.txt and move it in /tmp directory using relative path name.
6. Delete the file moved to /tmp in previous step using absolute path.
7. Find the location of ls, ps, bash commands.

1. Install any new package on your system.

Command: sudo apt install python

2. Remove the package installed.


Command: sudo apt remove python

3. Find the passwd file in / using find command.

Khan S. Alam 15 https://E-next.in

https://E-next.in
Linux Journal

Command: find /etc/passwd

4. Create a symbolic link to the file you found in the last step.

Command: ln -s ./etc/passwd

5. Create an empty file example.txt and move it in /tmp directory using relative path name.

Command: mv hi.txt /tmp

6. Delete the file moved to /tmp in previous step using absolute path.

Command: rm /tmp/hi.txt

Khan S. Alam 16 https://E-next.in

https://E-next.in
Linux Journal

Practical 7
Aim : Use environment

1. Which account are you logged in? How do you find out?
2. Display /etc/shadow using cat and understand the importance of shadow file. How is it
different than password file?
3. Get your current working directory
4. Explore different ways of getting command history, how to run previously executed
commands without typing it?
5. Create alias to most commonly used commands like.

1. Which account are you logged in? How do you find out?
Command : who
Output :

2. Display /etc/shadow using cat and understand the importance of shadow file. How is it
different than password file?
Command : sudo cat /etc/shadow
Output :

Khan S. Alam 17 https://E-next.in

https://E-next.in
Linux Journal

3. Get your current working directory


Command : pwd
Ouput:

4. Explore different ways of getting command history, how to run previously executed
commands without typing it?
Command : history
Output:

5. Create alias to most commonly used commands like.


Command : alias xyz = ‘ls -a’
Output :

Khan S. Alam 18 https://E-next.in

https://E-next.in
Linux Journal

Practical 8
Aim: Linux Editors: vim/emacs
1. Create, modify, search ,navigate a file in editor.
2. Learn all essential commands like search, search/replace, highlight, show line
numbers.
1. Create, modify, search navigate a file in editor.
i. Create : vi prac.txt
:i
This is practical 8
: wq

ii. Modify : vi prac.txt


Ctrl+c
New prac 8
:q!

iii. Search : vi prac.txt


Ctrl+c
/new
:q!

iv. Navigate : vi prac.txt


l
l
:q

Khan S. Alam 19 https://E-next.in

https://E-next.in
Linux Journal

2. Learn all essential commands like search, search/replace, highlight, show line
numbers.
i. Search : vi prac.txt
Ctrl+c
/new
:q!

ii. Replace : vi prac.txt


:%s/Line/changedLine
:wq

iii. Highlight : vi prac.txt


:set hlsearch
:q!

iv. Show line number : vi prac.txt


:set nu
:q!

Khan S. Alam 20 https://E-next.in

https://E-next.in
Linux Journal

Practical 9
Aim: Linux Security:
1. Use of sudo to change user privileges to root
2. Identify all operations that require sudo privileges
3. Create a new user and add it to sudo configuration file.
4. Set password for new user.
5. Modify the expiration date for new user using password ageing.
6. Delete newly added user.

1. Use of sudo to change user privileges to root


Command: sudo -i
Output:

2. Identify all operations that require sudo privileges


Command: sudo -h
Output:

Khan S. Alam 21 https://E-next.in

https://E-next.in
Linux Journal

3. Create a new user and add it to sudo configuration file.


Command: adduser cr7
Output:

4. Set password for new user.


Command: passwd cr7
Output:

5. Modify the expiration date for new user using password ageing.
Command: chage -M 28 CR7
Output:

6. Delete newly added user.


Command: userdel
Output:

Khan S. Alam 22 https://E-next.in

https://E-next.in

You might also like