0% found this document useful (0 votes)
2K views

File Oriented Commands in Linux

This document discusses Linux file-oriented commands. It describes the Cat, Cp, Rm, Mv, Wc, Cmp, Touch, and Head commands and provides examples of their usage. The Cat command displays file contents, Cp copies files, Rm removes files, Mv renames files, Wc displays file statistics, Cmp compares files, Touch creates empty files, and Head displays the beginning lines of files. It also covers Linux file permissions and the three permission types - read, write, and execute for users, groups and others.

Uploaded by

Vijetha bhat
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

File Oriented Commands in Linux

This document discusses Linux file-oriented commands. It describes the Cat, Cp, Rm, Mv, Wc, Cmp, Touch, and Head commands and provides examples of their usage. The Cat command displays file contents, Cp copies files, Rm removes files, Mv renames files, Wc displays file statistics, Cmp compares files, Touch creates empty files, and Head displays the beginning lines of files. It also covers Linux file permissions and the three permission types - read, write, and execute for users, groups and others.

Uploaded by

Vijetha bhat
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

LINUX :FILE ORIENTED

COMMANDS

bhatvijetha 1
 Cat
This cat (catenated –concatenate) command is used
to display the contents of the specified file.
General format :
Cat [-options] <filename1> [<filename2>…]
Where options can be,
S suppresses warning about non-existing files.
d lists the sub-directory entries only
b numbers non blank output lines
n numbers all output lines

bhatvijetha 2
 Example

$cat a.c
This will display the contents of the file , a.c
$cat a.c b.c
This will display the contents of the files a.c and b.c one by
one.

bhatvijetha 3
 Cp
This cp command is used to copy the content of on file into
another file .

If the destination is an existing file,the file is overwritten ;

If the destination is an existing directory ,the file is copied


into that directory.

General format is,


Cp [-options] <source file > <destination file>

bhatvijetha 4
 rm
The rm (remove )command is used to remove a file from
the specified directory.
To remove a file you must have a write permission for the
directory that contains the file but you need not have
permission on the file itself.
General format is,
Rm [-options] <filename>
Where options can be,
r deletes all directories including the lower order directories.
I prompts before deleting
f removes write protected files also,without prompting.

bhatvijetha 5
 Example

$ rm a.c
This command deletes the file a.c from the current
directory.

bhatvijetha 6
Mv
This command is used to rename the specified
files/directories.

General format is,


Mv <source> <destination>

For move command the user must have both write and
execute permissions on the source.

Example:
$mv a.c b.c
Then file a.c is renamed as b.c.
bhatvijetha 7
 Wc
This command is used to display the number of lines words
and characters of information stored in a specified file.
General format is,
Wc [-options] <filename>
Where options can be,
l displays the number of lines in the file
W displays the number of words in the file
C displays the number of characters in the file
Examples:
$ wc a.c
It displays the number of lines, words and characters in the
file.
bhatvijetha 8
 Cmp
This cmp command is used to compare two files.

General format is,


Cmp <filename1><filename2>

This command reports the first instants of differences


between the specified files.
that is the two files are compared byte by byte and the
location of first mismatch is echoed to the screen.

bhatvijetha 9
File access permissions
 There are 3 types of file in linux.
 Ordinary file
 Directory file
 Special file(device file)

The ordinary file consist of a stream of data that are stored


on some magnetic media.
A directory doesnot contain any data but keeps track o
account of all file and sudirectories that it contains.
Linux treats even physical devices as files.such files are
called as special files.

bhatvijetha 10
 There are 3 types of modes for accessing thes files as follows,
Read mode
Write mode
Execute mode
The file permission is displayed in 10 characters.

Bit position: 1 234 567 8910


Meaning:file/directory rwx permission rwx permission rwx permission
for users usergroup others
r readable
w writeable
X executable
- Denial of permission

bhatvijetha 11
 Touch command
This command is used to create a new empty file.
The length of the file created is zero.

 Head command
The head command is used to display few lines at the
beginning of one or more files.
This is used in verifying the contents of a file.
By default it displays the first 10 lines of a file.

The general syntax of this command is

$head[count option] filename[s].

bhatvijetha 12
Remaining commands Continued …in part3
presentation

bhatvijetha 13

You might also like