In: Computer Science
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can.
Linux
What is the i-node , and what is the major information stored in each node?
What is the difference between moving (mv) a file and copying (cp) a file?
Please find the requested information below.
Please provide your feedback
Thanks and Happy learning!
1) What is the i-node , and what is the major information stored in each node?
In Linux, everything is considered as a file including hardwares, printers, directories etc..
And to store the details of each of these entities/files there is a need of a data structure.
So here comes the inode data stucture. An inode is a data structure that stores various
information about a file in Linux, such as the access mode (read, write, execute permissions),
ownership, file type, file size, group, number of links, etc.. An inode is assigned to a file when it is created.
Each inode is identified by an integer number. The inode number of a file(as everything in Linux is a file) can be seen using the command 'ls -i'.
The number appearing to the left of the filename when executing the above command is the inode number.
Example: ls -i
20829148276789777 name.txt
Below is the list of information that is stored in an inode.
a. Size
b. Owner
c. Date/time
d. Permissions and access control
e. Location on the disk
f. File types
g. Number of links
h. Additional metadata about the file
To see the information about the inodes in a file system, one can use the command 'df -hi'. This command will show the information such as total number of inodes, number of used inodes, number of inodes available to use etc..
So in short, inode is nothing but a datastructure that holds the information/metadat about a file
2)What is the difference between moving (mv) a file and copying (cp) a file?
The move(mv) command is used to move a file from source to destination. Once the mv command is executed successfully, the source file will not be existing anymore, reason being, the mv command 'moved' the source to the destination. Because if this(ie move) property of the the mv command, this command is used to rename a file in Linux.
Syntax for mv: mv source_file destination_file
But when a copy(cp) command is executed, the destination will have a copy of the source file. Here after the cp command both source and destination files will be existing.
Syntax for cp: cp source_file destination_file