Our Blog

BY : developer 0 comment


As the saying goes ‘Everything in Linux is a file, if something is not a file, it is a process’. It is indeed a quite factual and posolutely a well ratified generalization. A Linux system considers folders, programs, services, texts, images, I/O devices, and generally all devices as files. Files in Linux can be typified generally into 3 main groups, namely: 1. Regular Files 2. Folder Files 3. Special Files Regular Files: All normal files in the file system, which do not have an imposed internal file structure by the Linux system, are generally Regular Files. The internal file structures of these files are governed by the respective programs which use them. The structure and interpretation thereof is exclusively reliant on how the file is deciphered by the pertinent software. Identifying Regular Files: If the Linux file system permissions start with hyphen “-“, then it is a regular file. The file system permissions are displayed when a long listing is requested with ‘ls –l’ command. We can list all the regular files by giving the following command in a bash shell:

$ ls –l | grep ‘^_’

The test command can also be used to check if a file is a regular file as shown below:

$ test -f filename && echo ‘Regular’

To check if the file type for all the files in a given directory are regular files we can use a simple ‘for loop’ as depicted below:

$ for FILE in $(ls); do echo $FILE $(test –f $FILE && echo Regular); done

‘stat’ is another command which can throw sufficient light about all aspects of a file including its type. Check the usage shown below:

$ stat test.tar.bz2’
File: ‘test.tar.bz2’ Size: 7309714 Blocks: 14280 IO Block: 4096 regular file Device: fd01h/64769d Inode: 8843274 Links: 1 Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:admin_home_t:s0 Access: 2016-08-18 10:38:31.211252568 +0530 Modify: 2016-08-12 14:23:41.309100745 +0530 Change: 2016-08-12 14:23:41.309100745 +0530…( to be continued)

Content Courtesy: Mr. Lijo Joseph | Manager | Technical Services | Ipsr Solutions ltd.

List of Authors

Leave a Reply

Your email address will not be published.