Unix/Linux File Recognition. Did You Know?
Did you know that Unix and Linux has no concept of a file extension? What is a file name extension?
A .txt extension tells us that it is a TEXT file and .pdf extension tells us that it is a PDF file. By following this logic, you understand that a file name extension is the suffix that is added to the filename after the dot. Linux does not care for file extensions and I will demonstrate it with a simple example.
Open a new terminal and type “sudo vim print” like shown in Figure 1.
Now type the Python code as shown in Figure 2.
Save the file and run it like shown in Figure 3.
It is executed like a normal Python file (with .py extension) because the shebang line (#!/usr/python) tells the operating system which interpreter to use to execute the file.
What about other files? The first few bytes of a file identify the file type and the number of bytes is called a Magic Number. This Magic Number is used by Linux to identify the type of a file.
Did you know about hidden files in your home directory ?
Files that are hidden, contain configuration information and they are hidden because they should not be changed, unless you are an advanced user and very familiar with Unix-like environments. Hidden files begin with a dot (.) and they are not displayed when the ls command is executed.
You can list hidden files with the ls command followed by -a option, like shown in Figure 5.
You can display hidden files with the (CTRL+H) shortcut key when browsing with your file manager.
Did you know that Linux commands and files are case sensitive?
Figure 7 demonstrates that Linux commands are case sensitive, the ls command that is used to list file in the current directory is not the same with LS. The same thing with files; file1 is different from File1. Be careful because they refer to different files. Now that you know about hidden files, file extensions and the fact that Linux commands and files are case sensivitive it is time to share with your friends. Ask yourself this question, “Do they know?”.