Between the Penguin and the Window, there are many similarities and many differences. The similarities, believe it or not, dig deep into the heart of simplicity and ease of use. The differences, however, range from the glaringly obvious to the subtly obfuscated.
One of the more subtle differences between Linux and Windows is the way the respective OSs deal with files. In this article, I'm going to offer tips for three differences: hidden files, permissions, and file names.
To give hidden attributes to a file within Windows, right-click the file and select the Hidden check box. When that directory is refreshed, the file will no longer appear. But how do you get the file back? How do you view the contents of that newly hidden file? Linux views hidden files in an entirely different way. Simply put, a Linux hidden file begins with a period [.], (which is where the term "dot file" comes from) and can be viewed like any other file. But why even bother making the file hidden in the first place? Hidden files are usually configuration files that set preferences in programs, window managers, shells, and so forth. The reason they're hidden is to prevent any accidental tampering by the user, and it cuts down on screen clutter (hidden files don't show up with a normal ls command).
In order to see a listing of hidden files within Linux, run the ls command with the -a flag. This line will return all of the contents of a directory:
Although the topic of permissions goes well beyond the scope of this article, it's best to at least introduce you to the idea that, due to the multi-user nature of Linux, each file and directory must have permissions that are set by either the OS or the user. Permissions are used to ensure the safety and integrity of the system and its files. Without permissions, a system is wide open for anyone to wreak havoc upon its contents.
Permissions are broken into the following three categories:
- user (u): The owner of the file. A user who creates a file automatically owns it. Only the owner and the SuperUser (alias root) can change the permissions of a file.
- group (g): The group of a file. One group of users is given special access to a file. The file owner determines this access.
- others (o): All other users on the system. In other words, every account except the file's owner, or users in the file's group.
If you use the ls command with the -l flag, you'll see something like this:
drwxrwxr-x 2 jlwallen jlwallen 4096 Mar 5 21:45 web
-rwxrw-r-- 1 jlwallen jlwallen 385 Feb 23 18:12 who
drwxr-xr-x 2 root root 4096 Feb 14 01:38 wpbin
drwxr-xr-x 2 root root 4096 Feb 14 01:37 wpexpdocs
Above is a typical long list of files and directories that contains a good deal of information. The first section is the permissions section. You will notice a 10-character string in the beginning of the listing, which contains the map of permissions for that file/directory. The first character indicates if the listing is a file (indicated with a [-]) or a directory (indicated with a [d]). The next nine characters are in groups of three and list the (r)ead, (w)rite, and e(x)ecute permission for each. In the first example above:
drwxrwxr-x 2 jlwallen jlwallen 4096 Mar 5 21:45 web
you see drwxrwxr-x. The leading (d) indicates that the listing is a directory. The next three characters (rwx) indicate that the user (here, jlwallen) has (r)ead, (w)rite, and e(x)ecute (or full) permission on the file. The next three characters (rwx) indicate that any member of the group that particular directory (here called web) belongs to has the same [(r)ead, (w)rite, and e(x)ecute] permissions. The final three characters (r-x) belong to other and say that all others have only (r)ead, and e(x)ecute permissions. The (-) in the last three characters indicates that other does not have (w)rite permission on the file.
Linux file names differ from Windows file names in a number of ways that could easily stump MS-trained users. Within the Windows environment, it's legal to create file names with spaces, so the name this file name is legal.txt is perfectly fine. Let's say, however, you're in Linux and you want to view the contents of that file with the less or pico (or vi or emacs or whatever) applications. If you were to type in the command:
less this file name is legal.txt
you would have the following error returned:
[jlwallen@willow jlwallen]$ less this file name is legal.txt
this: No such file or directory
file: No such file or directory
name: No such file or directory
is: No such file or directory
legal.txt: No such file or directory
As you can see, the less application treats the file name as five different files. In order to escape this error, you would need to run the command with the file name in quotation marks. You could open the file in question with the command:
less 'this file name is legal.txt'
There is another way around this issue that, to me, makes much more sense. I've never understood the convention of creating file names with allowed spaces. To me, that is confusing and dangerous. Instead of spaces, I use the underscore symbol [_] so the name this file name is legal.txt becomes less_this_file_name_is_legal.txt. Yes, it may be a bit more typing, but you'll have a file name that's simple to access and open from within any eligible operating system. Platform independence is what it's all about!
Another issue with file names is extensions. The common Windows OS relies on extensions to tell the system what type of program to use to open the file. Linux, however, doesn't rely on extensions. Try this test: Open your favorite Linux word processing application (StarOffice, Word Perfect, Applixware, AbiWord, and so forth) and create a test file (with some content), saving it in test.doc format. Once you've saved it, go to the console, navigate to the directory the test file was saved in, and run the following command:
cp test.doc test
The above command copies the file and gives the new file an extension-less name. Now open the same word processor and then open both the test.doc and the test files. You should see that no differences exist between the contents of the files.
Yes, both Windows and Linux have their similarities and their differences. There are wars going on between users to prove which OS is better, but frankly it's all a matter of taste. Do you like your hidden files to be completely hidden—even from the creator's site? Do you prefer your computer to be a single-user environment? Do you prefer file names with spaces? Although these questions seem a bit trivial, try living in an environment that supports one style and then move over to the other side... you'll quickly see how trivial ideologies can completely change the way you compute.
Jack Wallen, Jr. is very pleased to have joined the TechRepublic staff as editor in chief of Linux content. Jack was thrown out of the "Window" back in 1995 when he grew tired of the "blue screen of death" and realized that "computing does not equal rebooting."
Prior to Jack's head-first dive into the computer industry, he was a professional actor with both film, TV, and Broadway credits. Now Jack is content with his new position of Linux Evangelist. Ladies and gentlemen—the poster boy for the Linux Generation!The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.