File is a standard program for recognizing the type of data contained in a computer file. The file command attempts to classify each file system object (i.e., file, directory or link) that is provided to it as an argument (i.e., input). File tests each argument in an attempt to classify it. There are three sets of tests, performed in this order: file system tests, magic number tests, and language tests.
The first is a file system test, which uses the stat system call to obtain information from the object’s inode (which contains information about a file).
The second test checks to see if there is a magic number, which is a number embedded at or near the beginning of many types of files that indicates the file format (i.e., the type of file).
In the event that the first two tests fail to determine the type of a file, language tests are employed to determine if it is plain text (i.e., composed entirely of human-readable characters), and, if so, what type of plain text, such as HTML (hypertext markup language) or source code
This command helps to determine the usage of file module. The user will come to know about the different ways/format to execute this module. This command guides the end user to know the purpose of this command. Below given are the command and the screenshot of the same.
ptconfigure file help
kevell@corp:/# ptconfigure File help
******************************
This command allows you to modify files or check their existence
File, file
- create
Create a new system file
example: ptconfigure file create --file="somename"
- delete
Delete a system file
example: ptconfigure file delete --file="somename"
- exists
Check the existence of a file
example: ptconfigure file exists --filename="somename"
- append
Append a line to a file
example: ptconfigure file append --filename="somename" --line="a line"
- should-have-line
Ensure that a file contains a particular line
example: ptconfigure file should-have-line --filename="somename" --line="a line"
------------------------------
End Help
******************************
When the user needs to Create a new system file, the below given command will execute the process.
ptconfigure file create --file="somename"
The below given commands overwrite files that exist
ptconfigure file create --file="somename” --overwrite-existing
The below given command for write the data in the file
ptconfigure file create –file="somename” --data="things to put in the file"
kevell@corp:/# ptconfigure file create --file="somename"
[Pharaoh Logging] [File] Creating File somename
File somename exists
******************************
File Modifications:
--------------------------------------------
File: Success
------------------------------
File Mods Finished
******************************
When the user needs to delete a system file, the below given command will execute the process.
ptconfigure file delete --file="somename"
kevell@corp:/# ptconfigure file delete --file="somename"
[Pharaoh Logging] [File] Deleting File somename
somename Deleted
File somename not exists
******************************
File Modifications:
--------------------------------------------
File: Success
------------------------------
File Mods Finished
******************************
When the user needs to check the existence of a file, the below given command will execute the process.
ptconfigure file exists --filename="somename"
kevell@corp:/# ptconfigure file exists --filename="somename"
Enter File Path:
/home/kevells/Desktop/somename
File /home/kevells/Desktop/somename exists
******************************
File Modifications:
--------------------------------------------
File: Success
------------------------------
File Mods Finished
******************************
When the user needs to append a line to a file, the below given command will execute the process.
ptconfigure file append --filename="somename" --line="a line"
kevell@corp:/# ptconfigure file append --filename="somename" --line="a line"
Enter File Path:
/home/kevells/Desktop/somename
Enter the input for append:
this is for test
[Pharaoh Logging] [File] Reading File /home/kevells/Desktop/somename
[Pharaoh Logging] [File] Writing File /home/kevells/Desktop/somename
******************************
File Modifications:
--------------------------------------------
File: Success
------------------------------
File Mods Finished
******************************
When the user needs to ensure that a file contains a particular line, the below given command will execute the process.
ptconfigure file should-have-line --filename="somename" --line="a line"
| Parameters | Alternative Parameter |
| ptconfigure file help | Either of the two alternative parameter can be used in command- File, file eg: ptconfigure File Install/ ptconfigure file Install| |