Symbol
|
Meaning
|
-
|
Regular file
|
d
|
Directory
|
l
|
Link
|
c
|
Special file
|
s
|
Socket
|
p
|
Named pipe
|
b
|
Block device
|
Regular file
The regular file is a most common file type found on the Linux system.
It governs all different files such us text files, images, binary files, shared
libraries, etc. You can create a regular file with the touch command:
$ touch testfile.out
$ ls -ld testfile.out
-rw-rw-r-- 1 samual samual 0 Jan 10 12:52 testfile.out
The first
character of the ls command, in this case "-", denotes the
identification code for the regular file. Below command can be used to find out
these type of files on system
$ find / -ls |awk
'{print $3, $NF}' |grep ^-
To remove a
regular file you can use the rm command:
$ rm testfile.out
Directory file
Directory is
second most common file type found in Linux. Directory can be created with the
mkdir command:
$ mkdir FileTypes
$ ls -ld FileTypes/
drwxrwxr-x 2 lubos lubos 4096 Jan 10 13:14 FileTypes/
Directory file
can be identified by "d" symbol from the ls command output. Below
command can be used to find out these type of files on system.
$ find / -ls |awk
'{print $3, $NF}' |grep ^d
To remove
empty directory use the rmdir command.
$ rmdir FileTypes
When trying
to remove directory with the rmdir command, which contains additional files you
will get an error message:
rmdir: failed to remove `FileTypes/': Directory not empty
In this case
you need to use a command:
$ rm -r FileTypes/
Character device file
Character device
files allow users and programs to communicate with hardware peripheral devices.
Terminal files are very easy example of such files.
The first
character of the ls command, in this case "c", denotes the
identification code for the character device file. Below command can be used to
find out these type of files on system
$ find / -ls |awk
'{print $3, $NF}' |grep ^c
Block device file
Block
devices are similar to character devices. They mostly govern hardware as hard
drives, memory, etc.
$ ls -ld /dev/sda
brw-rw---- 1 root disk 8, 0 Jan 4 10:12 /dev/sda
The first
character of the ls command, in this case "b", denotes the
identification code for the block device file. Below command can be used to
find out these type of files on system
$ find / -ls |awk '{print $3, $NF}' |grep ^b
Socket Files
Local domain
sockets are used for communication between processes. Generally, they are used
by services such as X windows, syslog and etc.
$ ls -ld /dev/log
srw-rw-rw- 1 root root 0 Jan 4 10:13 /dev/log
The first
character of the ls command, in this case "b", denotes the
identification code for the socket file. Below command can be used to find out
these type of files on system
$ find / -ls
|awk '{print $3, $NF}' |grep ^s
Sockets can
be created by socket system call and removed by the unlink or rm commands.
Named pipe file
Similarly as
Local sockets, named pipes allow communication between two local processes.
They can be created by the mknod command and removed with the rm command.
The first
character of the ls command, in this case "p", denotes the
identification code for the named pipe file. Below command can be used to find
out these type of files on system
$ find / -ls
|awk '{print $3, $NF}' |grep ^l
Symbolic link file
With
symbolic links an administrator can assign a file or directory multiple
identities. Symbolic link can be a pointer to an original file. There are two
types of symbolic links:
-
hard links
-
soft links
The difference
between hard and soft links is that soft links use file name as reference and
hard links use direct reference to the original file. Furthermore, hard links cannot cross file
systems and partitions. To create symbolic soft link we can use ln -s command:
$ echo file1 > file1
$ ln -s file1 file2
$ cat file2
file1
$ ls -ld file2
lrwxrwxrwx 1 lubos lubos 5 Jan 10 14:42 file2 -> file1
The first
character of the ls command, in this case "l", denotes the
identification code for the symbolic link file. Below command can be used to
find out these type of files on system
$ find / -ls |awk
'{print $3, $NF}' |grep ^l
No comments:
Post a Comment