Date post: | 02-Jun-2018 |
Category: |
Documents |
Upload: | srinivas-kumar |
View: | 256 times |
Download: | 0 times |
of 62
8/11/2019 Session3 Theory
1/62
ADVANTAGE PROChennais Premier Networking Training Centre
8/11/2019 Session3 Theory
2/62
ADVANTAGE PROChennais Premier Networking Training Centre
Linux File System Directories
/ Begins the file system structurecalled the root.
/boot Hold the kernel image files and associated boot information and files.
/home Contains users home directories.
/sbin Holds administration-level commands and any commands used by the
root user.
/dev Holds file interface for devices such as the terminal and the printer.
/etc Holds system configuration files and any other system files.
/etc/opt Holds system configuration files for application in /opt
Directory Function
8/11/2019 Session3 Theory
3/62
ADVANTAGE PROChennais Premier Networking Training Centre
Linux File System Directories
/etc/X11 Holds system configuration files for the X Window System and its
applications.
/bin Holds the essential user commands and utility programs.
/lib Holds essential shared libraries and kernel modules.
/lib/modules Holds the kernel modules.
/mnt Used to hold directories for mounting file systems like CD-ROMs orfloppy disks that are mounted only temporarily.
/opt Holds added software applications (for example, KDE on some
distributions).
Directory Function
8/11/2019 Session3 Theory
4/62
ADVANTAGE PROChennais Premier Networking Training Centre
/proc Process directory, a memory-resident directory containing files used to
provide information about the system.
/tmp Holds temporary files.
/usr Holds those files and commands used by the system; this directory
breaks down into several subdirectories.
/var Holds files that vary, such as mailbox and FTP files.
Directory Function
Linux File System Directories
8/11/2019 Session3 Theory
5/62
ADVANTAGE PROChennais Premier Networking Training Centre
Login screenEnter the user name
8/11/2019 Session3 Theory
6/62
ADVANTAGE PROChennais Premier Networking Training Centre
PWD
PWD
Present working Directory
Display the absolute path of the current directory.
8/11/2019 Session3 Theory
7/62ADVANTAGE PROChennais Premier Networking Training Centre
The absolute path of the
root directory is displayed.
PWD
8/11/2019 Session3 Theory
8/62ADVANTAGE PROChennais Premier Networking Training Centre
mkdir
mkdir :
Make directory (or) To create a directory
Syntax :
mkdir
8/11/2019 Session3 Theory
9/62ADVANTAGE PROChennais Premier Networking Training Centre
mkdir
This will create a
directory advpro.
8/11/2019 Session3 Theory
10/62ADVANTAGE PROChennais Premier Networking Training Centre
cd
cd
- Change directories
Syntax :
cd
cd ..
- To a directory one level up (parent directory)
cd -
- To your previous working directory
cd /
- To the / (slash) directory
8/11/2019 Session3 Theory
11/62ADVANTAGE PROChennais Premier Networking Training Centre
cat
cat
it is the command to create and view files
Syntax:
cat [options] [filename]
cat > [filename] To create a file
cat < [filename] To view a file
cat >> [filename] To append text to a file
8/11/2019 Session3 Theory
12/62ADVANTAGE PROChennais Premier Networking Training Centre
cat
As mentioned in the previous
slide. cat is used to create a file
The file is saved through ctrl -d
after typing the text
8/11/2019 Session3 Theory
13/62
ADVANTAGE PROChennais Premier Networking Training Centre
touch
touch command is used to update the time stamps of a file.
touch is also used to create empty file.
Syntax : touch [filename]
touch can create multiple empty file too.
Syntax : touch [filename1] [filename2]
8/11/2019 Session3 Theory
14/62
ADVANTAGE PROChennais Premier Networking Training Centre
Copy Command
cp : cp command is known for copying files and directories.
Syntax : cp [options] source destination
Options :
-r recursively copy an entire directory tree
-p preserve permissions, ownership, and time stamps
Example :
cp File1 File2
8/11/2019 Session3 Theory
15/62
ADVANTAGE PROChennais Premier Networking Training Centre
mv : This command is used to move and renaming files and
directories
Syntax:
mv
Example
mv file1 file2 (now the file1 is changed to file2)
Move Command
8/11/2019 Session3 Theory
16/62
ADVANTAGE PROChennais Premier Networking Training Centre
rm and rmdir command
rm : This command is used to remove files
Syntax:
rm
Example :
rm file1
rmdir : This command is used to remove directories.
Syntax:
rmdir Example :
rmdir linux
8/11/2019 Session3 Theory
17/62
ADVANTAGE PROChennais Premier Networking Training Centre
The file command is used to check the file content.
Syntax :
file Example:
file f1 (f1 is a file. File will show the format)
file /dev/fd0 (The output shows that the fd0 is a
block special file)
File command
8/11/2019 Session3 Theory
18/62
ADVANTAGE PROChennais Premier Networking Training Centre
vi & vim editor
Vi is known as the visual editor.
It is a standard editor under Linux and Unix system.
Vim is the improved version of vi editorVi have three modes of operation
Command mode
Insert mode
Esc mode
8/11/2019 Session3 Theory
19/62
ADVANTAGE PROChennais Premier Networking Training Centre
File Repositioning
Press G, Cursor go to last line of a file.
Press 1G, Cursor go to first line of a file.
Press Ctrl+f, Cursor forward one full screen.
Press Ctrl+b, Cursor go back one full screen.
Press Ctrl+d, Cursor go down half a screen.
Press Ctrl+u, Cursor go up half a screen.
8/11/2019 Session3 Theory
20/62
ADVANTAGE PROChennais Premier Networking Training Centre
Screen Repositioning
Press H, Cursor go to first line on screen.
Press M, Cursor go to middle line on screen.
Press L, Cursor go to last line on screen.
Press Z+Enter, Make current line is first line on screen.
Press - (hyphen) Make current line last line on screen.
8/11/2019 Session3 Theory
21/62
ADVANTAGE PROChennais Premier Networking Training Centre
It is also possible to read a other file content in your current files.The following command help you :
Go to exmode in a vi editor
Syntax : r
Example :r /root/file1
While working in a editor we can copy the file content to another
file
Syntax : starting line, endingline w
Example : 1,20w file2Example : 21,40w >> file2
Advanced Reading and Saving
8/11/2019 Session3 Theory
22/62
ADVANTAGE PROChennais Premier Networking Training Centre
Filtering
A powerful feature of vi is the ability to include into your document
the output of Linux commands.
For example if you want to display any command output in
your file see following syntax .!!command
The syntax will be working in exmod in editor.
For example to display date ,type following command in exmod.
!!date
8/11/2019 Session3 Theory
23/62
ADVANTAGE PROChennais Premier Networking Training Centre
Sed Command
Sed command just like find and replace .
To display a file , the Sed command change the particular word in
standard input only , but not change original content of file.
Example of Sed command .
sed s/ram/raju/g /root/file1
8/11/2019 Session3 Theory
24/62
ADVANTAGE PROChennais Premier Networking Training Centre
ex mode : search and replace
vi can perform search and replace operations much like sed
command.
Syntax:
ex mode:1,$s/searchname/replacename/g
1,$ - address starting from line one.
s - String of character
g - replace multiple matches in a
line
8/11/2019 Session3 Theory
25/62
ADVANTAGE PROChennais Premier Networking Training Centre
It is also possible to read a other file content in your current files.
The following command help you :
Go to ex mode in a vi editor
Syntax : r
Example :r /root/file1
While working in a editor we can copy the file content to another
file
Syntax : starting line, ending line w
Example : 1,20w file2
Example : 21,40w >> file2
Advanced Reading and Saving
8/11/2019 Session3 Theory
26/62
ADVANTAGE PROChennais Premier Networking Training Centre
Configuring VI and VIM
Number of configuration are available in vi editor, see some of
example .
:set number - shows a line number on the left margin in a vieditor
:set showmatch - when a right curly braces or a right paranthesis
is typed, a cursor will jump to the matching left curly braces or left
paranthesis.
:set all - it shows all configurations.
8/11/2019 Session3 Theory
27/62
ADVANTAGE PROChennais Premier Networking Training Centre
Redirecting Input and Output
Output of a command is redirected to a file
Command > filenameExample ls -l > /root/file1
Example ls -i >> /root/file1
Output of file redirected to a command
Command < filename
Example - cat < file1
Error message of a command redirected to a file
Command 2> file1
Command 2>> file1
- Example ll L > file1
8/11/2019 Session3 Theory
28/62
ADVANTAGE PROChennais Premier Networking Training Centre
tr translates the upper caseletters to lower case.Here
output of file v is redirected
as input to the tr command.
Redirecting Input and Output
8/11/2019 Session3 Theory
29/62
ADVANTAGE PROChennais Premier Networking Training Centre
2> redirects the
error messages to the
ex file.
Here we can see
redirected errormessages in the ex file.
Redirecting Input and Output
i i
8/11/2019 Session3 Theory
30/62
ADVANTAGE PROChennais Premier Networking Training Centre
Piping
Pipes is used to execute more than one command at a time. See
following command.
Syntax : command1 | command2Example: ls -l | more
It is also used to execute command result
Example: cat file1 | grep station
8/11/2019 Session3 Theory
31/62
ADVANTAGE PROChennais Premier Networking Training Centre
Redirecting Both Standard Output And Error
If find command is executed, its output can be stored in file2. if
error occurs during execution, the error message is stored in file1.
For example:
find / -name passwd 2> file1 >file2
C d
8/11/2019 Session3 Theory
32/62
ADVANTAGE PROChennais Premier Networking Training Centre
tee Command
tee is useful to save the output at various stages from a long
sequence of pipes.
Example: ls | tee a1 | ls
l | tee b2
The above example shows the types of ls commands and options are
used to store output to the files g1, g2 and g3.
d
8/11/2019 Session3 Theory
33/62
ADVANTAGE PROChennais Premier Networking Training Centre
grep command
grep
- means general regular expression processor.
-it analyze the content of a file a line at a time, returning a line
that matches a pattern.
8/11/2019 Session3 Theory
34/62
ADVANTAGE PROChennais Premier Networking Training Centre
awk command
An awk program searches for lines in a file and performs some
action on those lines.
Example:
awk /bash/ { print }/etc/passwd
Pi i
8/11/2019 Session3 Theory
35/62
ADVANTAGE PROChennais Premier Networking Training Centre
Here the cat and
grep command are
executed in pipeline.
Piping
Fi d d
8/11/2019 Session3 Theory
36/62
ADVANTAGE PROChennais Premier Networking Training Centre
Find command
Find:
To search files and directories in a specified path.
Syntax:
find [conditions] [action]
Condition:-name - to search a particular file
-user - lists the files owned byuser.
-perm - search a file depending
on permission.
Fi d d
8/11/2019 Session3 Theory
37/62
ADVANTAGE PROChennais Premier Networking Training Centre
This command
searches the password
file from / directory.
Find command
Fi d d
8/11/2019 Session3 Theory
38/62
ADVANTAGE PROChennais Premier Networking Training Centre
The above screen
shows the execution
of command
Find command
L t d
8/11/2019 Session3 Theory
39/62
ADVANTAGE PROChennais Premier Networking Training Centre
Locate command
Locate:
To search or locate files and directories from the database.
It locate the files faster than the find command
Syntax:
locate [pattern]
L t d
8/11/2019 Session3 Theory
40/62
ADVANTAGE PROChennais Premier Networking Training Centre
To search file
named test1 from
database.
Locate command
L t d
8/11/2019 Session3 Theory
41/62
ADVANTAGE PROChennais Premier Networking Training Centre
All the files and
directories named test1is located and
displayed.
Locate command
X Wi d S t
8/11/2019 Session3 Theory
42/62
ADVANTAGE PROChennais Premier Networking Training Centre
X Window System
It is the foundation for the graphical user Interface of Red Hat
Linux.
X applications communicate with a display via. The X protocol.
X is OS Independent.It is available on many platforms.
X P t l
8/11/2019 Session3 Theory
43/62
ADVANTAGE PROChennais Premier Networking Training Centre
X Protocol
It hides the individual details of the OS and the underlying
hardware.
X protocol is a asynchronous network protocol for thecommunication between X client and X Server.
It defines how the graphical primitives are communicated
between X client and server.
M lti l D kt E i t
8/11/2019 Session3 Theory
44/62
ADVANTAGE PROChennais Premier Networking Training Centre
Multiple Desktop Environments
The X Window System of Red Hat provides two Desktop Environments.
GNOME (GNU Network Object Modules Environment).KDE (K desktop Environment).
GNOME
8/11/2019 Session3 Theory
45/62
ADVANTAGE PROChennais Premier Networking Training Centre
GNOME
It is the default desktop environment for Red Hat Linux.
It is Power full and easy-to-use desktop environment consisting
primarily of a panel and a set of GUI tools.GNOME is free and hence its source code can be downloaded form
the GNOME Web Site: www.gnome.org.
GNOME Interface
8/11/2019 Session3 Theory
46/62
ADVANTAGE PROChennais Premier Networking Training Centre
GNOME Interface
The GNOME Interface consists of a Panel and a Desktop.
Panel appears as a long bar across the bottom of screen.
Panel holds Menus, Programs and Applets.
The Remainder Screen is the Desktop. Here you can place
directories, files or programs.
GNOME Desktop
8/11/2019 Session3 Theory
47/62
ADVANTAGE PROChennais Premier Networking Training Centre
GNOME Desktop
GNOME Menus
8/11/2019 Session3 Theory
48/62
ADVANTAGE PROChennais Premier Networking Training Centre
GNOME Menus
GNOME Menus
8/11/2019 Session3 Theory
49/62
ADVANTAGE PROChennais Premier Networking Training Centre
GNOME Menus
KDE
8/11/2019 Session3 Theory
50/62
ADVANTAGE PROChennais Premier Networking Training Centre
KDE
KDE provides an alternative desktop environment with full set ofintegrated network and internet applications.
Along with GNOME features, It also includes
Konsole : Highly configurable graphical terminal.
Konqueror : A file manager and web browser.
Kmail : A graphical email client.
Kdevelop : Integrated development.
KDE Desktop
8/11/2019 Session3 Theory
51/62
ADVANTAGE PROChennais Premier Networking Training Centre
KDE Desktop
KDE Desktop
8/11/2019 Session3 Theory
52/62
ADVANTAGE PROChennais Premier Networking Training Centre
KDE Desktop
KDE Desktop
8/11/2019 Session3 Theory
53/62
ADVANTAGE PROChennais Premier Networking Training Centre
KDE Desktop
KDE Desktop
8/11/2019 Session3 Theory
54/62
ADVANTAGE PROChennais Premier Networking Training Centre
KDE Desktop
Starting X Window
8/11/2019 Session3 Theory
55/62
ADVANTAGE PROChennais Premier Networking Training Centre
Starting X Window
The X window start automatically, If so then a Graphical login
screen is prompted by the Display manager.
Alternatively use startx to get in to X window from non-
windowing console.
8/11/2019 Session3 Theory
56/62
Start X
8/11/2019 Session3 Theory
57/62
ADVANTAGE PROChennais Premier Networking Training Centre
Start X
Desktop Selection
8/11/2019 Session3 Theory
58/62
ADVANTAGE PROChennais Premier Networking Training Centre
Desktop Selection
To get in to the
previously used
desktop
Select failsafe in
case of anygraphical failure
To get the
default
desktop.
To get in to
GNOME
desktop. To get in to KDE
desktop.
KDE MODE
8/11/2019 Session3 Theory
59/62
ADVANTAGE PROChennais Premier Networking Training Centre
KDE MODE
If you click yes the
KDE desktop is set asdefault desktop for
future sessions (or)
login
If you click No,
only the current
session is set to
KDE.
Switchdesk
8/11/2019 Session3 Theory
60/62
ADVANTAGE PROChennais Premier Networking Training Centre
Switchdesk
To change the desktop
environment.
Switchdesk
8/11/2019 Session3 Theory
61/62
ADVANTAGE PROChennais Premier Networking Training Centre
Switchdesk
To switch from kde to
gnome desktop
Switchdesk
8/11/2019 Session3 Theory
62/62
Thus we switched
into GNOME
desktop
Switchdesk