One linux command every day (24): Linux file type and extension

Source: Internet
Author: User
Tags touch command
One linux command every day (24): link to the Linux file type and extension: One linux command every day (1): ls command running (2): cd command OS /201210/163050.html#per...
One linux command every day (24): Linux file type and extension link: One linux command every day (1): ls command ; One linux command every day (2): cd command ; One linux command every day (3): pwd command ; One linux command every day (4): mkdir command ; One linux command every day (5): rm command ; One linux command (6) every day: rmdir command ; One linux command (7) every day: mv command ; One linux command every day (8): cp command ; One linux command every day (9): touch Command ; One linux command every day (10): cat command ; One linux command every day (11): nl command One linux command every day (12): more command One linux command every day (13): less command One linux command every day (14): head Command One linux command every day (15): tail command One linux command every day (16): which command A linux command (17) every day: whereis command One linux command (18) every day: locate command One linux command every day (19): find command overview One linux command every day (20): find command exec One linux command (21) every day: find command xargs A linux command (22) every day: detailed description of the parameters of the find Command A linux command (23) every day: Linux directory structure File types and Linux file names represent two different concepts. Similar to file.txt1_file.tar.gz created by a general application, although these files must be opened in different programs, most of them are normal files (also known as common files) that are measured in Linux file types ). I. file types common Linux file types include: common files, directory files, character device files, block device files, symbolic link files, etc. now let's give a brief description. 1. for a common file, we use ls-lh to view the properties of a file. we can see that there is a file like-rwxrwxrwx. it is worth noting that the first symbol is -, such a file is a common file in Linux. These files are generally created using related applications, such as tools, document tools, archiving tools... or cp tools. To delete such files, run the rm command. In addition, according to the content of the file, it can be divided into: 1>. plain text files (ASCII): This is the most common file type in Linux systems. it is called plain text files because the content is the data that we humans can directly read, such as numbers and letters. Almost all files that can be used as a set belong to this file type. For example, you can use the command: cat ~ /. Bashrc to view the content of the file. (Cat is the command to read the content of a file). 2>. binary: Linux only recognizes and can execute binary files ). In Linux, executable files (scripts, text-type batch files are not counted) are in this format. The command cat is a binary file. 3>. data Files: some programs read certain files in specific formats during operation. These files can be called data files ). For example, when a user logs on to Linux, the login data is recorded in the/var/log/wtmp file, which is a data file, he can read it through the last command! But when cat is used, garbled characters are read ~ Is it a special format file? 2. when we run the directory file in a directory, we can see a file like drwxr-xr-x, which is a directory. The directory is a special file in Linux. Note that its first character is d. Run mkdir or cp to create a directory. cp can copy one directory to another. Delete the file by using the rm or rmdir command. 3. if the character device or block device file is in the/dev directory, list the file and you will see a file similar to the following: [root @ localhost ~] # Ls-al/dev/ttycrw-rw-1 root tty 5, 0 11-03/dev/tty [root @ localhost ~] # Ls-la/dev/sda1brw-r ----- 1 root disk 8, 1 11-03/dev/sda1 we see the/dev/tty property is crw-rw -, note that the first character is c, which indicates the character device file. For example, serial devices such as cats. We can see that the attribute of/dev/sda1 is brw-r -----. Note that the first character is B, which indicates a device, such as a hard disk or a optical drive. Files of this type are created using mknode and deleted using rm. Currently, in the latest Linux release, we generally do not need to create device files on our own. Because these files are associated with the kernel. Files related to the system perimeter and storage are usually stored under the/dev directory! There are two types of block devices: block devices, which store data to provide random system access interfaces. for example, hard disks and floppy disks are the same! You can randomly read and write data in different blocks of the hard disk. this device is a group of devices! You can check/dev/sda and the first attribute is [B]. Character (character) device File: it is an interface device for some serial ports, such as the keyboard and mouse! These devices feature a one-time read and cannot be truncated. For example, you cannot let the mouse jump to another screen, but slide to another place! The first attribute is [c]. 4. data interface file (sockets): Data interface file (or: set interface file). This type of file is usually used for network data acceptance. We can start a program to listen to the requirements of the client, and the client can communicate data through this socket. The first attribute is [s], which is most often seen in the/var/run directory. For example, when we start the MySQL server, a mysql. sock file is generated. [Root @ localhost ~] # Ls-lh/var/lib/mysql. sock srwxrwxrwx 1 mysql 0 04-19 11: 12/var/lib/mysql. sock note that the first character of this file's attribute is s. 5. symbolic link File: When we view the file attributes, we will see lrwxrwxrwx. Note that the first character is l, and this type of file is a link file. Is a new file name through the ln-s source file name. The preceding example shows that setup. log is a soft link file of install. log. How can this problem be solved? This is similar to shortcuts in Windows. Example of creating a symbolic link file: [root @ localhost test] # ls-lh log2012.log-rw-r -- 1 root 296 K 11-13 06:03 log2012.log [root @ localhost test] # ln-s log2012.log linklog. log [root @ localhost test] # ls-lh *. loglrwxrwxrwx 1 root 11 11-22 linklog. log-> log2012.log-rw-r -- 1 root 296 K 11-13 log2012.log6. data transmission File (FIFO, pipe): FIFO is also a special file type, which aims to solve the problem of simultaneous access to a file by multiple programs. FIFO is the abbreviation of first-in-first-out. The first attribute is [p]. II. linux File Extension 1. basically, Linux files do not have the so-called extension. whether a Linux file can be executed depends on the ten attributes in the first column, it has nothing to do with the file name. This concept is different from that of Windows! In Windows, the file extension that can be executed is usually. com. exe. bat and so on. in Linux, if you have x in your permissions, for example, [-rwx-r-xr-x] indicates that the file can be executed. However, the execution that can be executed is different from the execution that can be executed successfully ~ For example, the install. log file in the root directory is a plain text file. can this file be successfully executed after the permission is changed to-rwxrwxrwx? Of course not ~ Because there is no executable data in its content. Therefore, this x indicates that the file can be executed, but whether it can be successfully executed depends on the content of the file. even so, we still want to know what the file is by using the extension. Therefore, we usually use an appropriate extension to indicate the type of the file. There are several common extensions :*. sh: script or batch processing file (scripts). because the batch processing file is written in shell, the extension is compiled. sh * Z ,*. tar, * .tar.gz ,*. zip ,*. tgz: compressed file. This is because the compression software is gunzip, tar, and so on. because of the different compression software, the related extension is used! *. Html, *. php: webpage-related files, which respectively represent the HTML syntax and PHP syntax. The. html file can be directly opened in a web browser. for the. php file, you can browse it on the server through the client browser to obtain the webpage result after calculation. Basically, the file name on the Linux system really only helps you understand the possible usage of the file. the actual execution or failure still requires the permission specification. For example, although a file is an executable file, such as the common command/bin/ls to display file attributes, if the permission of this file is changed to unexecutable, then ls becomes unexecutable. This problem occurs most often during file transfer. For example, you can download an executable file on the network, but it cannot be executed on your Linux system! Haha! This means that the attributes of the file may be changed. Do not doubt that the attributes and permissions of files uploaded from the network to your Linux system will indeed be changed. 2. linux file name length limit: In Linux, when the preset Ext2/Ext3 file system is used, the file name length limit is: A single file or directory can contain a maximum of 255 characters including the full path name and directory (/). the full file name is a long file name! We hope that the Linux file name can be viewed at a glance, so the file name is usually very long. 3. restrictions on characters in Linux file names: due to the command operation relationships in Linux under the text interface, it is recommended that you avoid special characters when setting file names under Linux! For example, the following :*?> <;&! [] | \ '"' () {} Because these symbols have special meanings under the text interface. In addition, when the file name starts with the decimal point ".", it indicates that this file is a hidden file! At the same time, because the options such as-option are often used in command issuing, it is recommended that you also avoid naming the beginning of the file name with "-" or "+.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.