Unit I
Unit I
Unit I
3. What are the different points which make GUI more user friendly
compare to command line interface?
GUI CLI
It stands for Graphical User Interface It stands for Command Line
Interface.
A type of user interface that allows An interface for the user to issues
users to interact through graphical commands in the form of successive
icons and visual indicators. line of text or command lines to
perform the tasks.
Every user can easily handle. A user should have good knowledge
of commands.
Requirment of memory is more as it Requirement of memory is less.
contains many graphical components.
It is more flexible. It is less flexible.
It is slow It is fast.
There are many options to change the There are no options to change the
appearance. appearance.
4. Define different terminology used in Linux?
Following are the different terminology used in Linux:
1. Command: It enables you to give instruction to the operating system.
2. Shell : Shell is a command interpreter for checking syntax on command
prompt , passes to kernel for execution and throws exception if problem
in syntax.
3. Sservice: There are various services provided by Linux which can be
either be an background process or foreground process. You need to
start and stop services as and when needed.
Linux Notes Unit I
4. Desktop Environment: It is a GUI provided at the top of your
operating system. The command desktop environments in Linux are
GNOME and KDE.
5. Pacakages:Packages contain a program or part of a program that is
needed to r un any software on Linux. Packages can be installed using
terminal or a package.
6. Terminal: It is primary way, a interface , to interact with files and
programs. Terminal are used for executing commands, running scripts
and installing.
7. Root: Linux has user specific roles. A root account has full access to
the system, that is access to every command and file in the system. The
root user is also called super user.
8. Sudo: In Linux, sudo is used for executing commands as superuser
when you are logged in as any user.Sudo makes sure that core files are
accessed or changed by a user .
9. Repositories
Repositories are like the storage of a computer, served at online sources.
They contain packages and source code that we can download and use
in our system via software manager or package manager, and terminal.
10. Package Manager
Package Manager is a tool that provides you with a graphical interface
to help you find new packages, then install, update, and even configure
them.Two of the major package management system for Linux: dpkg
and rpm. The dpkg was originally for Debian systems but is now
employed by Ubuntu. RPM was created for Red Hat Linux distribution
but now is used by Fedora and others
11. Kernel
‘Kernels’ is the heart of Linux. kernel manages your system’s hardware,
along with all the programs on your computer. The base Linux kernel is
open-source, and it provides the core for a lot of distributions, some of
which modify that code to better suit their particular goals.
12. Distribution:
A distribution of Linux is a bundled variation of Linux. There are a
number of major distributions such as Ubuntu, Fedora, Debian
5. Explain in brief hard link and soft link with suitable example.
1. Hard Links
• 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.
• Links have actual file contents
• Removing any link, just reduces the link count, but doesn’t affect other
links.
• We cannot create a hard link for a directory to avoid recursive loops.
Linux Notes Unit I
• If original file is removed then the link will still show the content of the
file.
• Command to create a hard link is:
• $ ln [original filename] [link name]
2. Soft Links
• 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 correctly (called hanging link).
• Soft Link contains the path for original file and not the contents.
• Removing soft link doesn’t affect anything but removing original file, the
link becomes “dangling” link which points to nonexistent file.
• A soft link can link to a directory.
• Link across filesystems: If you want to link files across the filesystems,
you can only use symbolic links/soft links.
• Command to create a Soft link is:
$ ln -s [original filename] [link name]
6. What is the architecture of linux? Explain.
Linux Architecture
The Linux system works basically on 4 layers. First view the diagram below,
which is showing the architecture of a Linux System.
10. Command:
1. Pwd
Linux pwd (print working directory) command displays your location currently
you are working on. It will give the whole path starting from the root ending to
the directory.
Syntax:
pwd
2. cd
Linux cd command is used to change the current working directory ( i.e., in
which the current user is working). The "cd" stands for 'change directory.' It is
one of the most frequently used commands in the Linux terminal.
Syntax:
cd <dirname>
pwd
cd ~
cd /
3. Ls command
The ls is the list command in Linux. It will show the full list or content of your
directory. Just type ls and press the enter key. The whole content will be shown.
Syntax:
ls
Linux Notes Unit I
a. ls -a command
It will give you the whole list of a directory including the hidden files also.
In Linux, hidden files start with a dot (.) and can't be seen in the regular
directory.
Syntax:
ls -a
b. ls -l command
The ls command will only display the files. But if you want your files to be
displayed in a long list format, then you can use ls -l command.
Syntax:
ls -l
c. ls ~
Linux ls ~ command shows the contents of the home directory.
Linux Notes Unit I
Syntax:
ls ~
4. mkdir
The mkdir stands for 'make directory'. With the help of mkdir command, you
can create a new directory wherever you want in your system. Just type "mkdir
<dir name> , in place of <dir name> type the name of new directory, you want
to create and then press enter.
Syntax:
Linux Notes Unit I
mkdir <dirname>
5. rmdir
This command is used to delete a directory. But will not be able to delete a
directory including a sub-directory. It means, a directory has to be empty to be
deleted.
Syntax:
rmdir <dirname>
rmdir -p
This command will delete a directory including its sub-directories all at once. In
below picture, all sub-directories have been deleted with 'rmdir -p' command.
6. File command
Linux Notes Unit I
file command is used to determine the file type. It does not care about the
extension used for file. It simply uses file command and tell us the file type. It
has several options.
Syntax:
file <filename>
7. touch
touch command is a way to create empty files (there are some other mehtods
also). You can update the modification and access time of each file with the
help of touch command.
Syntax:
touch <filename>
touch -a command
touch command with option 'a' is used to change the access time of a file. By
default, it will take the current time of your system.
Syntax:
touch -a <filename>
Linux Notes Unit I
touch -m command
The touch '-m' option will help you to change only the modification time of a
file.
Syntax:
touch -m <filename>
touch -r
This command will update time with reference to the other mentioned
command.
Syntax:
touch -r demo.txt Demo.txt
Linux Notes Unit I
touch -t command
with this command, you can change the access time of a file by determining a
specified time to it.
8. rm
The 'rm' means remove. This command is used to remove a file. The command
line doesn't have a recycle bin or trash unlike other GUI's to recover the files.
Hence, be very much careful while using this command. Once you have deleted
a file, it is removed permanently.
Syntax:
rm <filename>
rm *extension
This command can be used to remove all the files ending with same extensions
like .pdf, .txt, .odt, .png, etc.
Syntax:
rm *<extension>
Linux Notes Unit I
rm -r
With rm '-r' option, you can delete a directory having sub directories inside it.
So you don't need to delete sub-directories manually.
Syntax:
rm -r <dirname>
rm -i
The option 'i' stands for 'interactivity'. Before deleting a file it will ask you
whether you want to delete it or not. To delete a file use command:
Linux Notes Unit I
Syntax:
rm -i
9. cp command
'cp' means copy. 'cp' command is used to copy a file or a directory.
To copy a file into the same directory syntax will be,
Syntax:
cp <existing file name> <new file name>
cp -r
Option 'r' with the copy command can be used to copy a directory including all
its content from a source directory to the destination directory.
Syntax:
cp -r <sourceDirectory> <destinationDirectory>
Linux Notes Unit I
10. mv command
Linux mv command is used to move existing file or directory from one location
to another. It is also used to rename a file or directory.
Rename a Directory
Directories can be renamed in the same way as the files. In this case also inode
number will remain the same.
mv -i
If you want to copy a file using 'mv' option and if that file already exists then it
will silently over write the existing file.But if you'll use 'i' option then it will
first ask for your permission to over write it.
a. head command
The 'head' command displays the starting content of a file. By default, it
displays starting 10 lines of any file.
Linux Notes Unit I
Syntax:
head <file name>
Linux head -n
The 'head -n' option displays specified number of lines.
Syntax:
head -n <file name>
b. tail command
Linux tail command is used to display the last ten lines of one or more files. Its
main purpose is to read the error message. By default, it displays the last ten
lines of a file.
Syntax:
tail <file name>
c. Cat Command
The 'cat' command is the most universal and powerful tool. It is considered to
be one of the most frequently used commands. It can be used to display the
content of a file, copy content from one file to another, concatenate the contents
of multiple files, display the line number, display $ at the end of the line, etc.
Syntax:
cat > <file name>
Syntax:
cat >> (file name)
Syntax:
cat <filename1> <filename2>.... > <newFilename>
Linux Notes Unit I
Syntax:
cat -n <fileName>
Syntax:
cat -e <fileName>
d. tac command
The 'tac' command is the reverse of the 'cat' command. It is also known as 'cat'
backward. It will display the file content in reverse order. It prints the last line
first, then second last and so on. Such way, it prints the first line at last.
Syntax:
e. more command
As 'cat' command displays the file content. Same way 'more' command also
displays the content of a file. Only difference is that, in case of larger files, 'cat'
command output will scroll off your screen while 'more' command displays
output one screenful at a time.
Following keys are used in 'more' command to scroll the page:
Enter key: To scroll down page line by line.
Space bar: To go to next page.
b key: To go to the backward page.
/ key: Lets you search the string.
Syntax:
f. less command
The 'less' command is same as 'more' command but include some more features.It
automatically adjust with the width and height of the teminal window, while
'more' command cuts the content as the width of the terminal window get shorter.
Syntax: