Linux file types
By default Unix have only 3 types of files:
- Regular files ('-')
- Directory files ('d')
- Special files (Actually, this one has 5 types in it.)
- Block file('b')
- Character device file('c')
- Named pipe file or just a pipe file('p')
- Symbolic link file('l')
- Socket file('s')
Here are those three types ('-', 'd', and 'l'):
$ ls -l total 4 drwxrwxr-x 2 k k 4096 Dec 9 09:16 mydir -rw-rw-r-- 1 k k 0 Dec 9 09:16 myfile1 -rw-rw-r-- 1 k k 0 Dec 9 09:16 myfile2 lrwxrwxrwx 1 k k 7 Dec 9 09:16 my_link -> myfile1
These files are hardware files, and most of them are present in /dev. They are created either by fdisk command or by partitioning.
$ ls -l /dev/ | grep ^b brw-rw---- 1 root disk 7, 0 Dec 8 13:31 loop0 brw-rw---- 1 root disk 7, 7 Dec 8 13:31 loop7 brw-rw---- 1 root disk 1, 0 Dec 8 13:31 ram0 brw-rw---- 1 root disk 1, 15 Dec 8 13:31 ram15 brw-rw---- 1 root disk 8, 0 Dec 8 13:31 sda brw-rw---- 1 root disk 8, 1 Dec 8 13:31 sda1 brw-rw---- 1 root disk 8, 2 Dec 8 13:31 sda2 brw-rw---- 1 root disk 8, 3 Dec 8 13:31 sda3 brw-rw----+ 1 root cdrom 11, 0 Dec 8 13:31 sr0
Character device file provides a serial stream of input or output. Our terminals are classic example for this type of files.
$ ls -l /dev/input/mouse0 |grep ^c crw-r----- 1 root root 13, 32 Dec 9 08:39 /dev/input/mouse0
and:
$ ls -l /dev | grep ^c crw------- 1 root root 5, 1 Dec 8 13:32 console crw------- 1 root root 10, 58 Dec 8 13:31 network_throughput crw-rw-rw- 1 root root 1, 3 Dec 8 13:31 null crw-r----- 1 root kmem 1, 4 Dec 8 13:31 port crw------- 1 root root 10, 231 Dec 8 13:31 snapshot crw-rw-rw- 1 root tty 5, 0 Dec 8 22:41 tty
$ mkfifo backpipe $ ls -l prw-rw-r-- 1 k k 0 Dec 9 09:56 backpipe drwxrwxr-x 2 k k 4096 Dec 9 09:16 mydir -rw-rw-r-- 1 k k 0 Dec 9 09:16 myfile1 -rw-rw-r-- 1 k k 0 Dec 9 09:16 myfile2 lrwxrwxrwx 1 k k 7 Dec 9 09:16 my_link -> myfile1
These are linked files to other files. They are either Directory/Regular File. The inode number for this file and its parent files are same. There are two types of link files available in Linux/Unix : soft and hard link.
$ ls -l total 4 drwxrwxr-x 2 k k 4096 Dec 9 09:16 mydir -rw-rw-r-- 1 k k 0 Dec 9 09:16 myfile1 -rw-rw-r-- 1 k k 0 Dec 9 09:16 myfile2 lrwxrwxrwx 1 k k 7 Dec 9 09:16 my_link -> myfile1
A socket file is used to pass information between applications.
$ ls -l /var/run/ | grep ^s srw-rw-rw- 1 root root 0 Dec 8 13:31 acpid.socket srw-rw---- 1 root docker 0 Dec 8 14:15 docker.sock srw-rw-rw- 1 root root 0 Dec 8 13:31 rpcbind.sock srw-rw-rw- 1 root root 0 Dec 8 13:31 sdp srwxr-xr-x 1 root root 0 Dec 8 13:32 vmnat.5546
Linux - system, cmds & shell
- Linux Tips - links, vmstats, rsync
- Linux Tips 2 - ctrl a, curl r, tail -f, umask
- Linux - bash I
- Linux - bash II
- Linux - Uncompressing 7z file
- Linux - sed I (substitution: sed 's///', sed -i)
- Linux - sed II (file spacing, numbering, text conversion and substitution)
- Linux - sed III (selective printing of certain lines, selective definition of certain lines)
- Linux - 7 File types : Regular, Directory, Block file, Character device file, Pipe file, Symbolic link file, and Socket file
- Linux shell programming - introduction
- Linux shell programming - variables and functions (readonly, unset, and functions)
- Linux shell programming - special shell variables
- Linux shell programming : arrays - three different ways of declaring arrays & looping with $*/$@
- Linux shell programming : operations on array
- Linux shell programming : variables & commands substitution
- Linux shell programming : metacharacters & quotes
- Linux shell programming : input/output redirection & here document
- Linux shell programming : loop control - for, while, break, and break n
- Linux shell programming : string
- Linux shell programming : for-loop
- Linux shell programming : if/elif/else/fi
- Linux shell programming : Test
- Managing User Account - useradd, usermod, and userdel
- Linux Secure Shell (SSH) I : key generation, private key and public key
- Linux Secure Shell (SSH) II : ssh-agent & scp
- Linux Secure Shell (SSH) III : SSH Tunnel as Proxy - Dynamic Port Forwarding (SOCKS Proxy)
- Linux Secure Shell (SSH) IV : Local port forwarding (outgoing ssh tunnel)
- Linux Secure Shell (SSH) V : Reverse SSH Tunnel (remote port forwarding / incoming ssh tunnel) /)
- Linux Processes and Signals
- Linux Drivers 1
- tcpdump
- Linux Debugging using gdb
- Embedded Systems Programming I - Introduction
- Embedded Systems Programming II - gcc ARM Toolchain and Simple Code on Ubuntu/Fedora
- LXC (Linux Container) Install and Run
- Linux IPTables
- Hadoop - 1. Setting up on Ubuntu for Single-Node Cluster
- Hadoop - 2. Runing on Ubuntu for Single-Node Cluster
- ownCloud 7 install
- Ubuntu 14.04 guest on Mac OSX host using VirtualBox I
- Ubuntu 14.04 guest on Mac OSX host using VirtualBox II
- Windows 8 guest on Mac OSX host using VirtualBox I
- Ubuntu Package Management System (apt-get vs dpkg)
- RPM Packaging
- How to Make a Self-Signed SSL Certificate
- Linux Q & A
- DevOps / Sys Admin questions
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization