Check Linux File Type and File Format using file Command and ls Command
Using ls command to show file type.
The Linux operating system using the file type to identify and check its file format. The simple way to check the file type of any files on Linux system is using the ls command and file command. The example below demonstrate the use of the ls command and the file command to identify Linux file type.
Note: On the file permission section, the first character indicates the file type:
- <= Linux regular file
d <= Linux directory
b <= Linux block special file
c <= Linux character special file
l <= Linux symbolic link
p <= Linux named pipe
s <= Linux domain socket
The ls command with -l option as show the file in long list format including the file type, file permission and other Linux file properties as show on Linux command example below:
[root@fedora ~]# pwd
/root
[root@fedora ~]# ls -l install.log
-rw-r--r-- 1 root root 72032 2008-05-20 08:25 install.log
[root@fedora ~]#
ls command output:
Example on using ls command to display the block special file:
[root@fedora ~]# ls -l /dev/sda
brw-r----- 1 root disk 8, 0 2008-10-30 02:28 /dev/sda
[root@fedora ~]#
ls command output:
Using the file command to find Linux file type.
The Linux file command usually use to find out the Linux file type. The file command example below demonstrate the use of Linux file command to show the type of Linux file on Linux Fedora 9 machine.
Show the file type for install.log file ( regular file ) using file command:
[root@fedora ~]# pwd
/root
[root@fedora ~]# file install.log
install.log: ASCII Pascal program text
[root@fedora ~]#
Show the file type for /dev/sda device file ( block special file ) using file command:
[root@fedora ~]# file /dev/sda
/dev/sda: block special (8/0)
[root@fedora ~]#
Keywords: find file type, show file type, show Linux file type, check Linux file type, Linux file format, find Linux file type, ls command, file command
- 14626 reads
- Email this page
Recent comments
8 years 51 weeks ago
9 years 3 weeks ago
9 years 15 weeks ago
9 years 22 weeks ago
9 years 32 weeks ago
9 years 35 weeks ago
9 years 42 weeks ago
9 years 49 weeks ago
10 years 1 week ago
10 years 6 weeks ago