Thursday, November 13, 2014

How to examine files and file types using ls and file commands

Leave a Comment

In linux operating system, the most common file include the following:

● Text files
● Binary data files
● Executable program files
● Directory files
● Linked files
● Special device files
● Named pipes and sockets

To view a list of files and their types use : ls –F command, End file of each filename:

Symbol Descriptions
@ symbol a linked file
* symbol an executable file
/ symbol a directory files
= symbol a socket file
| symbol a named pip
* symbol an executable file

*Note: all other file type do not have a special character appended to them ex: text files,binary data files or special device files

Results output:

To obtain more detailed information about each file. use : ls -l command

Results output:

Each file has eight components

1. a file type character
                d : a directory
                l: a symbol linked file
                b and c: special device files
                n: a named pipe
                s: a socket
                -: all other file types( text files,binary data files)
2.A list of permissions on the file
3.A hard link count
4.The owner of the file
5.The group of the file
6.The file size (bytes)
7.The most recent modification time of the file
8.The filename

To display file type of any file use file command

For example below:

At the command prompt, type :
                # pwd
                # ls –aF /dev
At the command prompt, type:
                # ls –l /dev
At the command prompt, type:
                # file /dev
At the command prompt, type:
                # file /dev/MAKEDEV
Copyright by:


Post a Comment