0% found this document useful (0 votes)
10 views9 pages

Day 03 File n folder management

The document provides an overview of various commands used for managing files and folders in Unix-like operating systems, including 'cat', 'touch', 'vi', 'vim', 'nano', 'gedit', and 'gvim'. It explains the functionalities of these commands, such as creating, viewing, and editing files, as well as the differences between them. Additionally, it covers basic operations like moving, copying, and deleting files and directories.

Uploaded by

nihal62 nilu
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)
10 views9 pages

Day 03 File n folder management

The document provides an overview of various commands used for managing files and folders in Unix-like operating systems, including 'cat', 'touch', 'vi', 'vim', 'nano', 'gedit', and 'gvim'. It explains the functionalities of these commands, such as creating, viewing, and editing files, as well as the differences between them. Additionally, it covers basic operations like moving, copying, and deleting files and directories.

Uploaded by

nihal62 nilu
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/ 9

Day 3 MANAGEING FILES & FOLDERS

=================================
Vi
Visual Instrument
Tools to Create file
Cat Vim
concatenate Visual Instrument iMproved

nano gedit

touch Gvim
Graphical vim

1) cat
====
cat(concatenate) command allows us to create single file, view
contents of file, concatenate files and redirect output in terminal or files.

Example of creating file or files using cat command

General Syntax cat [OPTION] [FILE]...

#cat > filename

To create hidden file


#cat > .file

2) touch
=======
The touch command is the easiest way to create new, empty files that is 0kb
file.

Example of creating file or files using touch command

To create an empty file


#touch file1

To create multiple empty files


#touch file1 file2 file3 file4
or
#touch file{1..4}
or

#touch all some few none

To create hidden empty file


#touch .hiddenfile

3) vi (Visual Instrument)
===================
Is a screen-oriented text editor originally created for the Unix operating
system.

# vi filename

# vi .filename

4) vim (Visual Instrument iMproved )


===========================
The vim editor is an enhanced version of vi.

#vim filename

# vim .filename

5) nano
======
This is command line note pad
# nano filename

6) gedit
======
This is graphical based note pad
# gedit file name
7) Gvim Graphical vim
==================
GUI version of vim.

# yum install gvim -y


# gvim filename

What is the difference between cat command, vim command and


touch command?

Touch :- command is to create the 0 kb file and we can create several file at the
same time. If file is already existing, it will update the time stamp. If the file does
not exist, then '#touch filename' creates a new file with 0 KB file size.

Cat :- However, cat command help to create the file in writable format. Once you
write 'cat > file name' it will allow you to type the text, enter ctrl+d to save and
exit. If you will check with the commandn # cat filename it will show the content
of the file. Cat command dumps the contents of the file to the standard output , if
no options specified.

Vim :- Basically 'vim' is an Text editor which opens a blank file which you can edit
and save it. By using vim editor file content can be encrypted.

Vi :- file content can not be encrypted.


Advanced VI (Visual Instrument )
Vi is mostly used text editor written by Bill joy in 1976.

Advantages of vi
============
Speed :- Do more with key strokes.
Availability :- Included with most Unix like OS.
No dependency on mouse.

Vi, vim, gvim editors modes


======================

• Command Mode :- default mode. In this mode we can copy, paste and
delete.

Yy --> to copy a line in command mode


3yy --> to copy three lines in command
mode

p --> to paste copied line one time


4p --> to copy copied line 4 times

dd --> to delete a line


4dd --> to delete 4 lines

shift + g --> moves the cursor to end of the file.

gg --> moves the cursor to the beginning of file

/word --> to search any key word in file


n --> next search
N --> previous search

U --> undo
ctrl + r --> redo
To move cursor in command mode
=========================
j k l h

TO save and quit from command mode


==============================
shift + zz

w --> moves the cursor word by word in forward direction

b --> moves the cursor word by word in backward direction

) --> moves the cursor downward direction line by line only if there is space
between lines

( --> moves the cursor upward direction line by line only if there is space
between lines

{ --> moves the cursor paragraph by paragraph in downward direction

} --> moves the cursor paragraph by paragraph in downward direction

• Insert Mode :- content write mode which is needed to modify the file

i --> insert the text


I --> insert the text in beginning of line
a --> adds the text after the current cursor position
A --> adds the text at the end of a line
o --> inserts the text one line below current cursor position
O --> inserts the text one line before current cursor position

• Ex Mode :- extended command mode

:q --> without saving quite from file

:q! --> forcefully quite

:w --> save the changes

:w! --> forcefully save changes

:wq --> save and quite

:wq! --> forcefully save and quite (it will modify the time stamp )

:x --> save and quite but it will not modify the time

:X --> to encrypt the file contents

:25 --> moves cursor to 25th line


:set nu --> to set line numbers to line in the file

VISUAL MODE
=============
Here we can create split the screen in vim editor.

To split the screen horizontally


==========================
w + ctrl then press s

To split the screen vertically


=====================
w + ctrl +v

TO search a word and replace it with new word


===================================
:%s/old/new/g

Without opening a file and find and replace a word


=======================================
# sed -e “/old/new/g” filename

To Create a Directory

# mkdir directory name

To copy a file/folder from source to destination

File
===
# cp -f source to destination

EXAMPLE
--------------
# touch /var/ftp/pk
# cp -f /var/ftp/pk /root/Desktop

Folder
=====
# mkdir /etc/httpd/pkk
#touch /etc/httpd/pkk/files{1..10}

# cp -rf /etc/httpd/pkk /root/Desktop


To move a file/folder from source to destination

# mv -rf source destination

Example

# mv -rf /root/Desktop/pkk /tmp


# ls /tmp

TO Remove or delete File/folder

FILE
=====
# rm -f filename

Folder
======
# rm -rf foldername

You might also like