Differences in file names between Unix and Windows

Source: Internet
Author: User
Title: Differences in file names between Unix and Windows. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The naming rules for files in Unix are not as strict as those in Windows. In other words, the characters that cannot be contained in file names in many Windows operating systems can be used in Unix operating systems. Therefore, some administrators who transfer data from the Windows operating system will feel particularly uncomfortable. Today, I will summarize the differences between the naming rules of the two operating systems to help the Windows System Administrator migrate to the Unix operating system more smoothly.

 1. The representation of hidden files is different.

In Windows, if you want to hide the properties of a file, you must right-click the file and choose hide ". Then you can hide the file. In general, users cannot see hidden files. However, the Unix operating system is different. In a Unix operating system, a folder or file can be hidden like a Windows operating system. However, the two methods are different. In a Unix operating system, it is controlled based on the name of a file or folder (directory file. That is, to hide a file, you only need to add an English dot at the beginning of the file name. If you want to hide a directory file, you only need to set the dot before the name of the directory file in the previous English state. Such as. Unix. This indicates that the folder is a hidden file or a hidden folder.

How can I view this hidden file or folder? This is different from the Windows operating system. In a Unix operating system, if you want to enter a hidden folder, you do not need to set it as special as in a Windows operating system. You only need to enter the full file name or directory file name. That is to say, we need to include the. Number. To enter the UNIX hidden folder set above, you only need to execute the cd. UNIX Command. Therefore, in Unix operating systems, whether it is to set hidden files, hide directory files, or view these files, it is controlled by a point number in the English state. Therefore, the importance of this point number should be fully recognized in Unix operating systems.

2. The case sensitivity is different.

In Windows, both files and folders are case insensitive. That is to say, Unix and UNIX are the same file or folder. In Windows, you do not need to consider the case sensitivity issue when naming folders or directories. This makes operations very convenient. For example, you do not need to consider case sensitivity when defining environment variables. It is okay to write all the paths in lower case or upper case. But it is different in Unix operating systems. In Unix operating systems, both common files and directory files are case sensitive. Unix and UNIX are two different files or directories. Although this difference is not great, the impact is far-reaching. For example, when defining environment variables in Unix, the input path cannot be case-insensitive. If the input of a character is case-insensitive, the environment variable does not work because it points to an incorrect position.

Therefore, pay special attention to the definition of a file or file name in a Unix operating system. In general, unless necessary, it is best to Use lowercase characters for common files. For system files or directories, use characters in size. No matter which type of file, there is a taboo that you should not use a mix of upper and lower cases to name the file or directory. On the one hand, it will be very troublesome to enter a directory or file with a mix of upper and lower cases. Second, it is prone to errors when referencing a path. Therefore, it is recommended that all files (common files, directory files, and Device Files) be in uppercase or lowercase. In addition, when defining environment variables, it is best to specify the path for the environment variables by copying and pasting them to prevent the environment variables from being ineffective due to incorrect case input.

When it comes to this case, it is best to remind you by the way. When defining an environment variable, the variable name is case sensitive. In Windows, environment variables are case-insensitive. You can enter the names of environment variables in the same size or lower case. However, in Unix operating systems, the environment variable is case sensitive. According to habits, environment variables in Unix are generally defined as uppercase. The common variable is set to lowercase. Although this is an unwritten rule, it is better for System Engineers to abide by it. To reduce the troubles caused by Case sensitivity.

3. Different Extensions are required.

In Windows, files must have extensions. The operating system is associated with the application based on the extension. For example, text.txt. txt is the extension of the file. In particular, some script batch processing programs must end with the bat extension. Only in this way can the operating system be executed as a batch processing program. However, there is no such strict requirement in Unix operating systems. Even for common files, the extension is optional. For example, by default, sh is an executable file in a Unix operating system. However, if the executable file compiled by the engineer does not carry the extension, it can also run. This is mainly because the two operating systems use different methods to call the script program. In the command line window of the Windows operating system, you can run the script program by entering the full name (with the extension) of the script program. However, in the shell of a Unix operating system, if you call a script program, you need to add the./symbol before the script program to allow the system to execute the program. That is to say, it does not distinguish whether it is an executable script program with the extension. It is determined by the prefix of the command line. Therefore, in Unix operating systems, there are no provisions on the extension.

Although Unix operating systems do not require a hard extension. However, we recommend that you add the extension name when creating a common file. Only in this way can you understand the file type by looking at the extension and without looking at the specific content of the file. If you see the sh extension, you will know that it is a script file. Instead of reading the content in it. Similarly, it is best to add an extension for C source files, text files, and so on to show differences.

  4. The file name can contain special characters.

In Windows, although most characters can be used as file names, some special characters are strictly restricted. For example, some special characters/, * and other symbols cannot be their file names. However, in Unix operating systems, there is no such strict requirement in this respect. For example, in Unix operating systems, file names such as text *. txt and text/tet.txt are valid. Therefore, without considering other factors, files in Unix operating systems can basically use any character. However, some characters have special meanings. Adding these characters to the file name may adversely affect subsequent operations.

As I mentioned at the beginning, the dot in the English state is a control symbol for file data. If the first character in the name of a common file or directory file is the dot in the English state, it indicates that it is an invisible file or a folder. Therefore, when defining a file, unless you need to set them as hidden, do not start with a dot in the status. However, a file name can be followed by multiple dots, which can be distinguished by dots. For example, student.num.txt. Indicates a text file of the student ID. In Windows, the file has two extensions. When this file is opened for the first time, the system will prompt the user which software to open. However, in Unix operating systems, this is legal.

*,-, And other symbols can also be used as the file name. However, they have some special meanings. Therefore, you need to be cautious when using them to name files. Similar to the dot, it is recommended that you do not use the-symbol as the first character of the file name. Because this-symbol represents the option of the command in the system. Therefore, when you use commands such as cat to operate this file, the system will mistakenly treat the file name parameter as an option. The result shows that the error is saved without this option. In addition, this * symbol represents a wildcard in the system. If the rm command is used to delete the file name with *, escape characters must be used. Otherwise, some catastrophic consequences will occur. Therefore, the author suggests that some special symbols can be used as the names of files or directories in Unix systems. However, unless necessary, it is best not to include special symbols in the file name. Otherwise, users may suffer from excessive pursuit of personality.

 

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: info-contact@alibabacloud.com 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.