Linux Prac
Linux Prac
-1
10. cp =
$ cp hello.txt ~/ggits/
Use the cp command to copy files through the command line.
It takes two arguments:
The first is the location of the file to be copied,
the second is where to copy.
11. mv =
$ mv hello.txt hello1.txt
The mv command is used to rename a file.
12. ping = $ ping www.google.com
Use ping to check your connection to a server.
The use of this command for simple users like us is to check your internet connection. If it
pings the Google server (in this case), you can confirm that your internet connection is active!
13. cat = $ cat hello.txt
Use the cat command to display the contents of a file. It is usually used to easily view
programs
14. wc = $ wc hello1.txt
The wc (word count) command in Unix/Linux operating systems is used to find out number
of newline count, word count, byte and characters count in a files
wc -l : Prints the number of lines in a file.
wc -w : prints the number of words in a file.
wc -c : Displays the count of bytes in a file.
wc -m : prints the count of characters from a file.
wc -L : prints only the length of the longest line in file
EXPERIMENT No.-2
AIM: Study & use of commands for performing various operations with
Unix/Linux Operators.
1. Arithmetic Operators
These operators are used to perform normal arithmetics/mathematical operations.
There are 7 arithmetic operators:
3. Multiplication (*)
x=8
y=2
echo $(( $x * $y ))
4. Division (/)
x=8
y=2
echo $(( $x / $y ))
-b file Checks if file is a block special file; if yes, then the condition
becomes true.
-c file Checks if file is a character special file; if yes, then the condition becomes
true.
-d file Checks if file is a directory; if yes, then the condition becomes true.
-f file Checks if file is an ordinary file as opposed to a directory or special file; if
yes, then the condition becomes true.
-g file Checks if file has its set group ID (SGID) bit set; if yes, then the condition
becomes true.
-k file Checks if file has its sticky bit set; if yes, then the condition becomes true.
-p file Checks if file is a named pipe; if yes, then the condition becomes true.
-t file Checks if file descriptor is open and associated with a terminal; if yes,
then the condition becomes true.
EXPERIMENT No.-3
AIM: Create a file called wlcc.txt with some lines and display how many
lines, words and characters are present in that file.
AIM:
Append ten more simple lines to the wlcc.txt file created above and split the
appended file into 3 parts.
> What will be the names of these split files?
> Display the contents of each of these files.
> How many lines will be there on the last file?
$ cat>wlcc.txt
Hello GGCT
How Are You
We are learning Linux
(Ctrl+d) will bring out from writing mode.
The wc (word count) command in Unix/Linux operating systems is used to find out number
of newline count, word count, byte and characters count in a files
wc -l : Prints the number of lines in a file.
wc -w : prints the number of words in a file.
wc -c : Displays the count of bytes in a file.
wc -m : prints the count of characters from a file.
wc -L : prints only the length of the longest line in a file.
TASK1-
Append ten more simple lines to the wlcc.txt file created above ( we have uploaded 05
lines)
Step 6 - TO APPEND LINES ,WE USE echo COMMAND
$ echo “Some Text Line” >> wlcc.txt
We have added
05 Lines in file
wlcc.txt
Check the file
$ cat wlcc.txt
$cat newab
$cat newac
B. How many lines will be there on the last file?
We have to use wc-l command to see line
$wc –l newac
EXPERIMENT No.-5
$ touch fileone.txt
$ touch filetwo.txt
$ cat> fileone.txt
Mohan
Sohan
Ajay
(Ctrl+d) will bring out from writing mode.
$ cat> filetwo.txt
Kishan
Pawan
Ajay
(Ctrl+d) will bring out from writing mode.
TASK1-
Create a program to display only those names that are found on both the
files.
$ comm fileone.txt filetwo.txt
Output Will be
Ajay
EXPERIMENT No.-6
➢ The inode stands for index node or index number is a data structure in a Linux
file system that stores information about a file and directory.
➢ File systems in general have two parts, those are metadata and actual data.
➢ Each file has an inode containing metadata about the file.
➢ Each file in a filesystem has a unique inode number. Inode numbers are
guaranteed to be unique only within a filesystem.
Practical
1. Create a file using touch command
$touch myfile.txt
2. Add content in file
$cat> myfile.txt
Hello there
We are learning
Linux Practical
rw- OWNER
Read the file
Write or edit the file
He cannot execute the file since the execute bit is set to '-'.
r-- GROUP
Read the file
Cannot Edit/Write the file as edit bit is set to –
Cannot Execute the file as execte bit is set to -
r-- WORLD
Read the file
Cannot Edit/Write the file as edit bit is set to –
Cannot Execute the file as execte bit is set to -
1. Absolute(Numeric) Mode
In this mode, file permissions are not represented as characters but a three-
digit octal number.
The table below gives numbers for all for permissions types.
1 Execute --x
2 Write -w-
4 Read r--
EXPERIMENT No.-8
Example
Step1- Create a file using touch command
$touch abc.txt
Step2- Write some words/lines in the file abc.txt
$cat>abc.txt
Hello There
I am learning Linux
(Ctrl+z)
STEP-2
To display and save the file we will combine two commands using > symbol
$who –q > userlist.txt
EXPERIMENT No.-9
To work on VI editor, you need to understand its operation modes. They can
be divided into two main parts.
➢ Vi Editor Command mode:
➢ vi Editor Insert mode:
(Ctrl+z)
Step3- Type vi with file name and press enter
$ vi abc.txt
Vi editor Screen will display.
File will open in vi editor
TO SAVE FILE
Press
Shift+zz - Save the file and quit
ESCAPE
Press esc key in keyboard
QUIT
Press Ctrl+z to move out from vi editor
VI Editing commands ?
You should be in the "command mode" to execute these commands. VI
editor is case-sensitive so make sure you type the commands in the right
letter-case.
i- Insert at cursor (goes into insert mode)
a - Write after cursor (goes into insert mode)
A - Write at the end of line (goes into insert mode)
ESC - Terminate insert mode
u - Undo last change
U - Undo all changes to the entire line
o - Open a new line (goes into insert mode)
dd - Delete line
3dd - Delete 3 lines.
D- Delete contents of line after the cursor
C - Delete contents of a line after the cursor and insert new text.
Press ESC key to end insertion.
dw - Delete word
4dw - Delete 4 words
cw - Change word
x - Delete character at the cursor
r- Replace character
R - Overwrite characters from cursor onward
s- Substitute one character under cursor continue to insert
S - Substitute entire line and begin to insert at the beginning of the line
~ - Change case of individual character
On the first screen, you will see the RHEL boot menu. The boot menu provides the
following three options.
The first option immediately starts the installation process. The second option checks
the integrity of the installation media before starting the installation process. The
checking process takes a significant amount of time. This is the default option. If
you do not select any option, Anaconda automatically selects this option after 60
seconds. Anaconda is the name of RHEL's installer program. The third option
provides options to troubleshoot the existing installation. It does not install RHEL.
You can use the Up and Down arrow keys to navigate between the options. To
select an option, press the Space key.
Select the first option, and press the Enter key.
The next screen shows a list of supported languages you can use during the
installation. The default is set to English. Keep the default language and click
the Continue button.
The next screen presents a single interface to configure all settings that the installer
program needs to install RHEL. Settings are classified into four sections:
Localization, Software, System, and User setting. There is no particular sequence
to configure these settings.
Compulsory settings are mentioned in red color with an icon. If you do not wish to
change optional settings, you can leave them, and the installer program will use
their default values.
Let's discuss these settings.
Keyboard
The default keyboard layout is English. If you want to add an additional keyboard
layout, you can use this option.
Language support
By default, the installer program supports only the language you have selected on
the previous screen. This option allows you to add support for an additional
language.
Installation source
This option allows you to change the installation media. Generally, this option is
used to perform a network installation. To perform a network installation, select
this option and specify the protocol, hostname, or IP address of the network server,
and the path to the files. To use the default source, leave this setting intact. The
default source is the source you used to start the installation.
Software selection
This option allows you to select the base environment and add-on software
packages. Base environments are predefined groups of software packages designed
for specific usages. Since we will use this system to practice for RHCSA/RHCE
exam, we will select the 'Server with GUI' base environment. This environment
includes all packages that we need to perform the tasks that need to be performed
on the RHCSA/RHCE exam.
Installation destination
This option allows you to specify an available local disk or a remote disk for
partitioning and installing RHEL on it. By default, the installer program
automatically selects the local disk for automatic partitioning. You only need to
approve the action. If you approve the action, the installer program will
automatically create all necessary partitions on the selected disk. The installer
program will use the entire disk for partitioning. Since we are preparing this
system for the practice of the RHCSA/RHCE exam, we need some free space on
the disk to practice disk management-related topics. To do this, we have to create
necessary partitions manually.
If you have multiple disks, select the disk you want to use for the partitioning.
Then, select the Custom option and click the Done button.
If we select the Custom option on the Installation Destination screen, the next
screen allows us to specify the manual layout of the disk. To set up the
environment that we need to practice, we will use the following disk layout.
Click the Add button, select the mount point /boot, specify the size 500M, and
click the Add mount point button.
Click the Add button again, select / from the drop-down options of the Mount
Point, specify 10G in the Desired Capacity input field, and click the Add mount
point button.
Repeat the same process and add the swap partition.
After creating all necessary partitions, click the Done button.
Before creating partitions on the disk, the installation wizard shows a summary of
partitions that you have created. If it all looks good, click the Accept
changes button to approve the new disk layout.
After getting approval from the user, the wizard writes the changes to the disk.
KDUMP
KDUMP is a service that creates a crash dump when the kernel crash. Due to any
reason, if the kernel crash, this service exports a memory image of the kernel to
debug and determine the cause of a crash. By default, this service is enabled. You
don't need to change this setting.
Virtual machines support the cloning feature that allows us to create a new virtual
machine from an existing machine. The new virtual machine will be the exact copy
of the existing machine. By using this feature, we can create as many RHEL virtual
machines as we need.
If you want to use the cloning feature, leave these settings. If you want to connect
the system to the network during the installation, configure these settings.
Security policy
This setting allows you to install RHEL under the several restrictions and
recommendations defined by Security Content Automation Protocol (SCAP).
Rules and recommendations are grouped into profiles. In the production
environment, you can select a profile that matches your requirements. But in the
lab environment, you should keep the default profile.
User settings
The next compulsory setting is the root password. The root user account is used for
the system administration. Since the root user account has the highest privilege on
the system, the installation wizard forces us to use a complex password. If you
want to use a simple password, you have to type and confirm it twice.
User creation
This setting allows you to add a normal user account. If you want to add a normal
user account, you can use this option to add it.
That's all settings we need on the installation summary screen. To begin the
installation, click the Begin Installation button.
Once you click the Begin Installation button, the installation wizard applies all
settings you have made on the Installation Summary screen and install RHEL on
the disk.
The installation process can take several minutes. At the end of this process, you
will see the following screen. Click the Reboot System button.
If you have installed RHEL on a virtual machine and want to use the cloning
feature, use this stage of the machine. At this stage, the machine contains the
default installation of RHEL without any system-specific setting.
If you haven't created a normal user account, the next few steps will force you to
create a user account to log in. Click the Next button on the Welcome screen.
The next screen has a privacy option for the location service. Click the Off button
to turn off this feature.
The next screen allows the user to connect to his online account. Click
the Skip button.
On the next screen. you have to enter the name of the user. From the entered name,
the wizard automatically generates the username. If you want to use another
username, you can change it. After typing the name and username, click
the Next button.
On the next screen, set a password for the user account.
The next screen confirms the user creation. Click the Start using Red Hat
Enterprise Linux button.
When the user login the first time, Gnome the default desktop of RHEL presents
several help videos on the first screen. This screen will not appear the next time.
RHEL installation process has been completed. Now, you can use the system.