Stegnography
Stegnography
ROLL NO – 31401219026
SEM- 5TH
Group - A
Ans-
Data present in the original file will be Soft links only point to the file name, it
available in the hard links. does not retain data of the file.
Hard links are comparatively faster Soft links are comparatively slower.
Group – C
exec (): After forking the process, the address space of the child process is
overwritten by the new process data. This is done through exec call to the
system. No new process is created over here. The PID & PPID remains
unchanged.
Wait (): The parent then executes wait system call to wait for the child
process to complete its execution.
The important attributes that are inherited by the child process from its
parent are: Real UID and GID, PGID, Nice value, Environment setting,
Current working directory, memory segments etc.
When the process dies it immediately moves to the zombie state and
remains in the state until the parent picks it up to exit status.
• Create a file using a vi editor (or any other editor). Name script file with
extension.sh
Internal Commands: Commands which are built into the shell. For all the shell
built-in commands, execution of the same is fast in the sense that the shell
doesn’t have to search the given path for them in the path variable, and also no
process needs to be spawned for executing it.
External Commands: Commands which aren’t built into the shell. When an
external command has to be executed, the shell looks for its path given in the path
variable, and also a new process has to be spawned and the command gets
executed. They are usually located in/bin or /usr/bin. For example, when you
execute the “cat” command, which usually is at /usr/bin, the executable
/usr/bin/cat gets executed. Examples: ls, cat etc.
2. Define kill command. How you can kill the last background jobWhat
are the different environment variables in Unix? Explain ps command.
Ans-Kill command (located in bin/kill), is a built-in command which is used
to terminate processes manually. Kill command sends a signal to a process
which terminates the process. If the user doesn’t specify any signal which is
to be sent along with kill command, then default TERM signal is sent that
terminates the process.
To kill the last background job, the following command is used: $ kill $!The
system variable $! Stores the PID of the last background job. The other
method is first finding the PID using the ps command, then use kill
command to do the job.
Different environment variables in Unix are: -
$user: Gives current user’s name.
$PATH: Gives search path for commands.
$PWD: Gives the path of present working directory.
$HOME: Gives path of home directory
$HOSTNAME: Gives name of the host
$LANG: Gives the default system language
$EDITOR: Gives default file editor
$UID: Gives user ID of current user.
$SHELL: Gives location of current user’s shell program
Both egrep and fgrep are derived from the base grep command. The “egrep”
stands for “extended grep” while the fgrep stands for “fixed-string grep.”
An egrep command is used to search for multiple patterns inside a file or
other kind of data repository while fgrep is used to look for strings.
The term “egrep” is commonly expressed as “grep-e” while “fgrep” is
encoded as “grep-f”.
Screen editors: It is a computer software for editing text files using a textual or
graphical user interface which displays the content(text) in an easy to look at and
good view. i.e., it displays a portion of the opened file and updates it in real time.
By definition, all visual editors require a refreshable display and all editors with a
GUI are visual. In this type of editors, the user is able to see the cursor on the
screen and can make a copy, cut, paste operation easily. It is very easy to use
mouse pointer. Ex: vi, emacs, Notepad
b) Awk
Ans- Awk is a scripting language used for manipulating data and generating
reports. The awk command programming language requires no compiling and
allows the user to use variables, numeric functions, string functions, and logical
operators. Awk is a utility that enables a programmer to write tiny but effective
programs in the form of statements that define text patterns that are to be searched
for in each line of a document and the action that is to be taken when a match is
found within a line. Awk is mostly used for pattern scanning and processing. It
searched one or more files to see if they contain lines that matches with the
specified patterns and then perform the associated actions. This command is named
by using the first letter of the name of three people who wrote the original version
of this command in 1977. Their names are Alfred Aho, Peter Weinberger, and
Brain Kernighan and they were from AT & T Bell Laboratories.
c) tar
Ans- The Linux ‘tar’ stands for tape archive, is used to create Archive and extract
the Archive files. Tar command is one of the important commands which provides
archiving functionality. We can use tar command to create compressed or
uncompressed Archive files and also maintain and modify them.
Options:
An Archive file is a file that is composed of one or more files along with metadata.
Archive files are used to collect multiple data files together into a single file for
easier portability and storage, or simply to compress files to use less storage space.
Group - A
GROUP – B
Ans -Internal Commands: Commands which are built into the shell. For
all the shell built-in commands, execution of the same is fast in the sense
that the shell doesn’t have to search the given path for them in the PATH
variable, and no process needs to be spawned for executing it.
Examples: source, cd, fg, etc.
Ans-ls command: - This command will show the full list or content of our
directory.
ls-a command: - This command will enlist the whole list of the current
directory including the hidden files.
GROUP – C
1. A.Write the command you will give to set read, write, and execute
permissions, group member read and execute permission and others
only read permission for a file named zyx.txt.
Ans.-The command to set read, write, and execute permission is:
chmod rwx zyx.txt
The command to set read and execute permissions to group is:
chmod g+rx zyx.txt
The command to set only read permission to other is:
chmod o+r zyx.txt
B. State the importance of PID and PPID. Which process has the
maximum number of child processes?
Ans-Importance of PID: -
A process is given a unique number called process ID (PID) that identifies
that process to the system, when it is started. If we ever need to kill a
process, for an example, we can refer to it by its PID. As each PID is unique,
there is no ambiguity or risk of accidentally killing the wrong process
(unless we enter the wrong PID).
Importance of PPID: -
If any processes went wrong. We might try to quit a program only to find
that it has other intentions. The process might continue to run or use up
resources even though its interface closed. Sometimes, this leads to what is
called a zombie process, a process that is still running, but dead.
One effective way to kill a zombie process is to kill its parent process. This
involves using the ps command to discover the PPID of the zombie process
and then sending a kill signal to the parent. Of course, any other children of
the parent process will be killed as well.
C. Write a shell script to print all the odd numbers from 1 to 15.
B. Briefly state with syntax and example the following loops: while,
until, for.
Ans-
Syntax for while loop:
while command
do
Statement to be executed
Done
a=`expr $a + 1`
done
3. A.What is a process?
Ans-A program/command when executed, a special instance is provided by
the system to the process. This instance consists of all the services/resources
that may be utilized by the process under execution.
fsck: The fsck (File System Consistency Check) Linux utility checks file
systems for errors or outstanding issues. The tool is used to fix potential
errors and generate reports.
kill: The Kill command in UNIX or Linux operating system is used to send a
signal to the specified process or group.
4. A. How can you use ‘cat’ command to create a new file in UNIX?
Explain with example.
Ans-To create a new file, use the cat command followed by the redirection
operator (>) and the name of the file you want to create. Press Enter, type
the text and once you are done, press the ctrl+d to save the filE.
Example:
cat > file1.txt
read file
-r: Requests that the system be rebooted after it has been brought down.
-h: Requests that the system be either halted or powered off after it has been
brought down, with the choice as to which left up to the system.
Group - A
II. In Linux , to echo a string and keep the cursor on the same line, you have to
use
Ans- the escape sequence
III. The user startup file for Bourne shell is stored in the home directory with the
name
Ans- .startup
IV. The Unix file system is characterized by
Ans- a hierarchical structure
Ans- UNIX has a graphical user interface similar to the Windows operating system
that makes it easy for navigation and a good supportive environment. The internal
design view of this operating system can be known from its architecture.
Ans- The umask is a four-digit octal number that UNIX uses to determine the file
permission for newly created files. Every process has its own umask, inherited
from its parent process. The umask specifies the permissions you do not want
given by default to newly created files and directories. umask works by doing a
bitwise AND with the bitwise complement of the umask. Bits that are set in the
umask correspond to permissions that are not automatically assigned to newly
created files.
Ans- The touch command is a standard command used in UNIX operating system
which is used to create, change and modify timestamps of a file.it is used to create
a file without any content. The file created using touch command is empty. This
command can be used when the user doesn’t have data to store at the time of file
creation.
For e.g - initially, we are in home directory and this can be checked using the pwd
command. Checking the existing files using command ls and then long listing
command (ll) is used to gather more details about existing files. You can create a
single file at a time using touch command.
Ans- The inode is a data structure in a Unix-style file system that describes a file-
system object such as a file or a directory. Each inode stores the attributes and
disk block locations of the object's data. File-system object attributes may include
metadata (times of last change, access, modification), as well as owner and
permission data. It describes a file or a folder. It includes things like the owner,
the group, permissions, file size, created/modified/access timestamps, and more.
Disk inode - The inode is a data structure that describes a file. The inode is
actually a structure on file system. To open a file, the kernel copies the inode into
memory. As the file changes, the in-core inode is updated usually more often than
the on-disk copy. And the in-core inode has a few extra fields that are only
needed while the file is opened.
5. What is grep and sed command? Describe their function with example.
Ans- sed command- SED command in UNIX is stands for stream editor and it
can perform lots of function on file like, searching, find and replace insertion or
deletion. Though most common use of SED command in UNIX is for substitution
or for find and replace. By using SED you can edit files even without opening it,
which is much quicker way to find and replace something in file, than first
opening that file in VI Editor and then changing it. For e.g. - Sed command is
mostly used to replace the text in a file. The below simple sed command replaces
the word “unix” with “Linux” in the file.
$sed’s/unix/linux/' bcafile.txt
Input:
Output:
Grep command- The grep filter searches a file for a particular pattern of
characters, and displays all lines that contain that pattern. The pattern that is
searched in the file is referred to as the regular expression. For e.g.-Grep displays
the entire line which has the matched string. We can make the grep to display
only the matched string by using the -o option.
Output:
UNIX
UNIX
UNIX
UNIX
UNIX
UNIX
Group – C
$*- Expands to the positional parameters, starting from one. When the expansion
is not within double quotes, each positional parameter expands to a separate
word. In contexts where it is performed, those words are subject to further word
splitting and filename expansion. When the expansion occurs within double
quotes, it expands to a single word with the value of each parameter separated by
the first character of the IFS special variable.
$@- Expands to the positional parameters, starting from one. In contexts where
word splitting is performed, this expands each positional parameter to a separate
word; if not within double quotes, these words are subject to word splitting. In
contexts where word splitting is not performed, this expands to a single word
with each positional parameter separated by a space. When the expansion occurs
within double quotes, and word splitting is performed, each parameter expands to
a separate word.
Ans- The test command is used to check file types and compare values. Test is
used in conditional execution. It is also used for:
B. how can you make out whether two files are copied or linked?
Ans- Use the long listing functions of 'ls'. You will see a link count > 1 and a
reference to where the file is linked to if it is a link. Without a link it is a copy.
C. Describe the two main functions of Init what is the significance of run
level 0, 1, and 6?
Ans- Init is the parent of all processes, executed by the kernel during the booting of
a system. Its principle role is to create processes from a script stored in the file.
It usually has entries which cause Init to spawn Getty’s on each line that users
can log in. It controls autonomous processes required by any particular system.
Ans- The UNIX operating system consists of a kernel layer, a shell layer and a
utilities and applications layer. These three layers create a portable, multiuser,
multitasking operating system. There are multiple versions of the OS, but every
version has the exact same structure. UNIX is used by programmers, businesses,
universities and governments because of its stability and its ability to perform
many tasks simultaneously.
The UNIX kernel is the central core of the operating system. It provides an
interface to the hardware devices as well as to process, memory, and I/O
management. The kernel manages requests from users via system calls that
switch the process from user space to kernel space each time a user process
makes a system call such as read (), fork (), exec (),open (), and so on.
10. A. What is the difference between process run with & and run with nohup?
Ans- The nohup command is a signal-masking utility. It’s used to accept HUP
(hang up) signals that can be sent to a process by the kernel and block them. This
command is helpful when a user wants to start a long-running application and
then log out, or close the window in which the process was initiated. Either of
these actions normally prompts the kernel to hang up on the application, but a
nohup wrapper will allow the process to continue.
The & relates to job control in an active shell. It’s helpful for running a process in
a session in the background, so that the user can do additional work in the session
concurrently.
B. What do you mean by job scheduling in UNIX? Explain with the help of
proper example.
Ans- Job scheduling is the process of allocating system resources to many
different tasks by an operating system The system handles prioritized job queues
that are awaiting CPU time and it should determine which job to be taken from
which queue and the amount of time to be allocated for the job. This type of
scheduling makes sure that all jobs are carried out fairly and on time.
Most OSs like UNIX, Windows, etc., includes standard job-scheduling abilities.
For e.g- at Tuesday +2 hours /home/amit/scripts
Press: Ctrl + D
The job will run on each Tuesday after 2 hours of current time of scheduling.
11. A. write a shell script to print all prime numbers between 1 to n (must be
input by user).
Ans- clear
echo "enter the range"
read n
echo "the prime no are:"
m=2
while [ $m -le $n ] do
i=2 flag=0
while [ $i -le `expr $m / 2` ] do
if [ `expr $m % $i` -eq 0 ] then
flag=1 break fi
i=`expr $i + 1`
done
if [ $flag -eq 0 ]
then echo $m fi
m=`expr $m + 1`
done
c) Vi editor - Vi or the Visual Editor is the default text editor that comes with
most Linux systems. It is a Terminal-based text editor that users need to
learn, essentially when more user-friendly text editors are not available on
the system. Some other reasons to use Vi include:
d) Filter in UNIX - Filters are programs that take plain text(either stored in a
file or produced by another program) as standard input, transforms it into a
meaningful format, and then returns it as standard output. Linux has a
number of filters. Some of the most commonly used filters are explained
below:
Group – A
III. Which option of the kill command sends the given signal name to the
specified process?
Ans-S
Ans-Suspend
Ans-both A and B
VI. Which command wait for the specified process to complete and return the
exit status?
Ans-wait
VII. Which command prints the accumulated user and system times fro processes
run from the shell?
Ans- times
Ans -1
Ans- Iprm
GROUP - B
Ans-
Multi-Programming Multi-Tasking
Multiprogramming is implemented by Multitasking is implemented by using the
using the concept of context switching concept of time sharing.
In multiprogramming, to execute the In multirasking, to allot a task we need
processes, only one CPU is used. Multiple CPU’s.
Multiprogramming requires more times Multitasking requires less time to execute
to execute processes. processes.
$pwd
/etc
$cd..
$cd..
$pwd
Using this knowledge in practice where are the two commands useful? Cd
will jump back to your home directory, which is the same as doing cd~ or
doing cd $HOME. This means that if you are somewhere very very deep in
directory tree, you can quickly and easily go back to home directory. Here’s
an example:
$pwd
/sys/class/block/sda1/holders
$cd
$pwd
/home/xieerqi
$pwd
/sys/class/block/sda1/holders
/sys/class/
3. What are the different ways of using chmod?
Ans- The chmod command changes the access permissions of files and
folders. The chmod command, like other commands, can be executed from
the command line or through a script file.
Command Syntax
This is the proper syntax when the chmod command:
Below is a list of numerical permissions that can be set for the user, group,
and everyone else on the computer. Next to the number is the read, write,
and execute letter equivalent.
Command Examples
To change the permissions of the file participants so that everybody has full
access to it, enter:
The first 7 sets the permission for the user, the second 7 sets the permissions
for the group, and the third 7 sets the permissions for everybody else.
If you want to be the only one who can access it, use:
If you want to keep full access for yourself, but want to keep other people
from modifying the file, use:
The following uses the letters from above to change the permissions of
participants so that the owner can read and write to the file, but it doesn’t
change permissions for anyone else:
4. Draw the UNIX architecture. What are the different parts of it?
Ans-
The shell is an interface that interprets the command line input and calls the
necessary programs to do the work. The commands that you enter are programs
themselves, so once the work is done, the command line will return to a prompt
and await further input.
There are several different shells, and syntax and shortcuts vary between them. For
example, the "csh" shell listed in the image above is called "C shell" and has
syntax similar to the C programming language. All shells support similar basic
functions.
One example of how the shell and kernel work together is copying a file. If you
want to copy a file named "file1" and name the copy "file2", you would enter "cp
file1 file2" at the command line. The shell will search for the program "cp" and
then tell the kernel to run that program on "file 1" and name the output "file 2".
When the copying is finished, the shell returns you to the prompt and awaits more
commands
Ans- An inode (short for “index node”) is a data structure Linux uses to
store information about a file. Each node has a unique ID that identifies an
individual file or other object in the Linux file system.
File size
File pointer – addresses of the storage blocks that store the file contents.
6. What is filter? Describe the function of any two filters.
Ans- Filters are programs that take plain text(either stored in a file or
produced by another program) as standard input, transforms it into a
meaningful format, and then returns it as standard output. Linux has a
number of filters. Some of the most commonly used filters are explained
below:
2. head : Displays the first n lines of the specified text files. If the number of
lines is not specified then by default prints first 10 lines.
Syntax:
head [-number_of_lines_to_print] [path]
GROUP – C
1. A. Write a shell program to find prime numbers between 1 to n.
Ans-
echo "enter the range"
read n
echo "the prime no are:"
m=2
while [ $m -le $n ] do
i=2 flag=0
while [ $i -le `expr $m / 2` ] do
if [ `expr $m % $i` -eq 0 ] then
flag=1 break fi
i=`expr $i + 1`
done
if [ $flag -eq 0 ]
then echo $m fi
m=`expr $m + 1`
done
The kernel accesses the file through the file system independent vnode
interface which points to an associated inode structure if the file is stored in
a Unix file system. On a Unix File System, the first 12 entries address data
block locations directly on the storage device.
Now, as we can see that the above file contains multiple duplicate lines.
Now, lets’s use uniq command to remove them:
Thanks.
As you can see that we just used the name of input file in the above uniq
example and as we didn’t use any output file to store the produced output,
the uniq command displayed the filtered output on the standard output with
all the duplicate lines removed.
Field Description
C The processor utilization for scheduling. This field is not displayed when
the -c option is used.
CLS The scheduling class to which the process belongs: real-time, system, or
timesharing. This field is included only with the -c option.
PRI The kernel thread's scheduling priority. Higher numbers indicate a higher
priority.
WCH The address of an event or lock for which the process is sleeping.
AN
STIM The starting time of the process (in hours, minutes, and seconds).
E
TTY The terminal from which the process (or its parent) was started. A
question mark indicates that there is no controlling terminal.
TIME The total amount of CPU time used by the process since it began.
Field Description
Insert mode: This mode enables you to insert text into the file. Everything
that’s typed in this mode is interpreted as input and finally, it is put in the
file. The vi always starts in command mode. To enter text, you must be in
insert mode. To come in insert mode you simply type i. To get out of insert
mode, press the Esc key, which will put you back into command mode.
# Fibonacci Series
a=0
# Fibonacci Series
b=1
do
fn=$((a + b))
a=$b
b=$fn
done
Soft Link-A soft link is similar to the file shortcut feature which is used in
Windows Operating systems. Each soft linked file contains a separate Inode
value that points to the original file. As similar to hard links, any changes to
the data in either file is reflected in the other. Soft links can be linked across
different file systems, although if the original file is deleted or moved, the
soft linked file will not work
Group – A
I. $$ represents
Ans- PID of the current shell.
II. A file abc contains four columns , Roll No, Name, Marks and Grades. What
will be the output, if we apply the following command sort -n -r + -3 abc It
will.
Ans- numeric sorts in reverse order of the file abc on third column.
Group – B
1. What is relative and absolute permission? Explain with example. Where
the GID (both the number and name) is stored?
Ans-Relative permission is a permission where it changes the permission
specified in command and leaves other permission unchanged. In relative
mode we signify what we want to add or remove and to whom with single
letter abbreviations for example r for read, w for write, x for execute.
+(plus) means assign permission, -(minus) means remove permission, =
(equals to) means absolute permission for all.
syntax: chmod categorization permission filename
example chmod u+r file.txt
Absolute permission is a permission signified by numbers which have
special meanings. It uses numbers to represent file permissions. When we
change permissions by using the absolute mode, represent permissions for
each triplet by an octal mode number. It is specified by setting all nine
permission bits explicitly. In the chmod we used three octal number.
The GID (both the number and name) is stored in /etc/passwd and /etc/group.
5. What does the fork system call do? What does it return?
Ans -The fork system call is used to create new processes. The newly
created process is the child process. The process which calls fork and creates
a new process is the parent process. The child and parent processes are
executed concurrently.
But the child and parent processes reside on different memory spaces. These
memory spaces have same content and whatever operation is performed by
one process will not affect the other process.
When the child processes are created; now both the processes will have the
same Program Counter, so both of these processes will point to the same
next instruction. The files opened by the parent process will be the same for
child process.
Fork system call returns 0 in the child process and positive integer in the
parent process. Here, two outputs are possible because the parent process
and child process are running concurrently.
b) Who
Ans- who command is used to find out the following information the time of
last system boot, Current run level of the system, List of logged in users and
more. The who command is used to get information about currently logged
in user on to system. The who command displays the following information
for each user currently logged in to the system if no option is provided Login
name of the users, Terminal line numbers, Login time of the users into
system, Remote host name of the user
c) Passwd
Ans -passwd command in Linux is used to change the user account
passwords. The root user reserves the privilege to change the password for
any user on the system, while a normal user can only change the account
password for his or her own account.
Syntax:
Passwd [options] [username]
Group – C
2. Multitask System:
A single user may run multiple tasks concurrently. Example: Editing a file,
printing another on the printer & sending email to a person and browsing the net
too at the same time. The Kernel is designed to handle user’s multiple needs.
The important thing here is that only one job can be seen running in the
foreground, the rest all seems to run in the background. Users can switch between
them; terminate/suspend any of the jobs.
5. Pattern Matching :
Unix provides very sophisticated pattern matching features. The meta-char ‘*’ is
a special character used by the system to match several file names. There are
several other meta-char in UNIX. The matching is not confined to only filename.
Advanced tools use a regular expression that is framed with the characters from
this set.
6. Programming Facility:
Unix provides shell, which is also a programming language designed for
programmers, not for casual end-users. It has all the control structures, loops, and
variables required for programming purposes. These features are used to design
the shell scripts ( programs that can invoke the UNIX commands).
Many functions of the system can be controlled and managed by these shell
scripts.
7. Documentation:
It has a ‘man’ command that stands for the manual, which is the most important
reference for any commands and their configuration files. Apart from the online
documentation, there is a vast number of resources available on the Internet.
Ans-Absolute path: An absolute path refers to the complete details needed to locate
a file or folder, starting from the root element, and ending with the other
subdirectories. Absolute paths are used in websites and operating systems for
locating files and folders.
$pwd
/home/kt/abc
$cd ..
$pwd
/home/kt
Ans-Filters are programs that take plain text as standard input, transform it into a
meaningful format, and then return it as standard output. Some of the most used
filters are cat, head, tail, sort, uniq, grep etc.
To display the 5th to 10th line of a file f1 we run the following code :
(ii)General Users can’t login into other programs that ask users for credentials and
in case of successful authentication allows them to run programs with privilege of
their account.
(v)They can’t monitories the system for to ensure the correct operation.
Example: To change the account name mcmohd to mcmohd20 and to change home
directory accordingly, we will need to issue the following command :
There is only one argument or option available for the command .r, for removing
the account's home directory and mail file.
$ userdel -r mcmohd20
Ans- su is one of the core utilities in Linux. It allows users to execute commands as
another user. The most common use of the su is to get super user privileges. It is
often mistaken as an abbreviation for “super user”, but it is an abbreviation for
“substitute user”. The su command is used to switch to another user, in other words
change user ID during a normal login session.
su-aloke: Here target user is aloke and by running this command the password is
required to access.
Ans- The shutdown command in Linux is used to shut down the system in a safe
way. It brings the system down in a secure way. When the shutdown is initiated, all
logged-in users and processes are notified that the system is going down, and no
further logins are allowed.
• options – Shutdown options such as halt, power-off (the default option) or reboot
the system.
• time – The time argument specifies when to perform the shutdown process.
Options
-r : Requests that the system be rebooted after it has been brought down.
-h : Requests that the system be either halted or powered off after it has been
brought down, with the choice as to which left up to the system.
-H : Requests that the system be halted after it has been brought down.
-P : Requests that the system be powered off after it has been brought down.
-c : Cancels a running shutdown. TIME is not specified with this option, the first
argument is MESSAGE.
-k : Only send out the warning messages and disable logins, do not actually bring
the system down.
Ans) There are two main types of devices under all UNIX systems, character and
block devices.
Block Devices tend to be storage devices, capable of buffering output and storing
data for later retrieval.
Character Devices are things like audio or graphics cards, or input devices like
keyboard and mouse.
Character devices are those for which no buffering is performed, and block
devices are those which are accessed through a cache. Block devices must be
random access, but character devices are not required to be, though some are. File
systems can only be mounted if they are on block devices.
Ans- Run levels determine which programs can execute after the operating system
boots up. The Run level defines the state of the machine after boot. Run levels are
numbered from zero to six.
A symbolic link, also termed a soft link, is a special kind of file that points to
another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard
link, a symbolic link does not contain the data in the target file. It simply points to
another entry somewhere in the file system.
Symbolic links are needed because it uses all the time to link libraries and make
sure files are in consistent places without moving or copying the original. Links are
often used to “store” multiple copies of the same file in different places but still
reference to one file.
$uniq name.txt
My name is Megha.
I am from Jamshedpur.
$ Sort -r file.txt
Output:
Satish
rajan
naveen
harsh
abhishek
read file
echo "$W"
echo "$R"
echo "$X"
Ans - The wc command in UNIX is a command line utility for printing newline,
word and byte counts for file. It can return the number of lines in a file, the number
if characters and the no. of words.
Hard link - Hard Link acts like a mirror copy of the original file. These
links share the same inodes. Changes made to the original or hard-linked file
will reflect in the other. When we delete Hard Link, nothing will happen to
the other file. Hard links can't cross file systems. Each hard linked file is
assigned the same Inode value as the original; therefore they reference the
same physical file location. Hard links more flexible and remain linked
even if the original or linked files are moved throughout the file system,
although hard links are unable to cross different file systems.
ls -l command shows all the links with the link column shows number of
links. Links have actual file contents. Removing any link, just reduces the
link count, but doesn’t affect other links. Even if we change the filename of
the original file then also the hard links properly work.
We cannot create a hard link for a directory to avoid recursive loops.
If original file is removed, then the link will still show the content of the
file. The size of any of the hard link file is same as the original file and if
we change the content in any of the hard links then size of all hard link
files are updated. The disadvantage of hard links is that it cannot be created
for files on different file systems, and it cannot be created for special files
or directories.
Command to create a hard link is:
$ ln [original filename] [link name]
Ans- gzip is a file format and a software application used for file
compression and decompression. gzip command compresses files. Each
single file is compressed into a single file. The compressed file consists of a
GNU zip header and deflated data.
If given a file as an argument, gzip compresses the file, adds a “.gz” suffix,
and deletes the original file. With no arguments, gzip compresses the
standard input and writes the compressed file to standard output.
Syntax :
gzip [Options] [filenames]
Example:
$ gzip mydoc.txt