In the Linux system, everything is a file. Sometimes a file is actually a process. Every file doesn’t refer to only text files, images, and compiled programs but also includes partitions, hardware device drivers, and directories. Linux considers everything as a file.
File names are always case sensitive. Let’s understand it through an example.
Case sensitive means upper and lower case letters refers to different files.
For example, we have two files named ‘Test.txt’ and ‘test.txt’. They both share the same name (ignoring the case) but still, they are two different files.
There are many kind of files in Linux:
Regular files ( – )
Directory files ( d )
Special files ( c )
Block file ( b )
Character device file ( c )
Named pipe file ( p )
Symbolic link file ( l )
Socket file ( s )
The most important file commands in Linux are :
file Determines file type.
touch Used to create a file
rm To remove a file.
cp To copy a file.
mv To rename or to move a file.
rename To rename file.
What is Linux file command ?
file command is used to determine the file type. It does not care about the extension used for the file. So simply uses file command and tells us the file type. It has several options.
Syntax of Linux file command:
$ file <filename>
The file command tells us the file type with the help of a magic file that contains all the patterns to recognize a file type. Path of magic file is /usr/share/file/magic.
For more information enter the command ‘man 5 magic’.
Linux File Command Options example :
- It is used for special files – file -s
- This is to list types of all the files – file *
- It is used to list types of all the files from the mentioned directory – file /directory-name/*
- This lists all the files starting from the alphabet present within the given range – file [range]*