In fact, Unix is simple.

Source: Internet
Author: User


A lot of programming friends on the internet asked me such a few questions,Unix how to learn? Why is Unix so hard? How can you learn? And let me give them some experience of learning Unix . Most of the time, I find that friends who ask these questions have two features:

1) have fear psychology to Unix , have no confidence in it;

2) like to use Windows to compare with Unix .

These two traits are like two "psychological cues," suggesting that Unix is a bad thing to learn, suggesting that Unix is bad, not as good as Windows . As a result, I was hypnotized by this long-standing "hint" of myself. Because, from the beginning there are fear emotions, so also feel that Unix is not good, feel very hard, and finally will lead to Unix disgust and resentment of the mood. So, in order to correct the "psychological implication" of these friends. I want to write this article to tell you thatUnix is really simple.

Before I formally describe "simple Unix," I would like to make a few notes: (Lest I get into a pointless argument)

1) This article is standing in the developer's point of view, so, if a friend disagree with my point of view, please also to the developer's point of view to ask me questions and discussion, I very much welcome.

2) This article will inevitably use Windows to compare with Unix . That doesn't mean I don't like windows, nor does it mean that I'm going to call you to give up windows. We also know that this comparison has no meaning, but because a lot of friends are the Windows preconceived, so, I must take windows to operate, to reverse the "psychological hint." That's all.

OK, here we are. First of all, one of the most important features of Unix --"high cohesion, low lotus"! In other words, the various applications underUnix are irrelevant to others. This is the whole Unix mindset-the high degree of independence of modules and programs. This kind of design and practice will make your system more stable, but also make your system particularly easy to manage and maintain. Applications under Unix are lined up like a regular army, so long as the commander (the kernel) is still there, the system will not be able to be self-lifting for the loss of an army. Windows applications, like a forest, look from the surface, the trees are lined up neatly, but their roots in the ground are intertwined with each other, cutting constantly, the chaos, unusually complex.

"High cohesion, low coupling," the result is that the Unix system is basically a single small program, these small programs like building blocks, when we need to construct a custom building, most of the time, we only need to do is a "build block "The Simple game. Windows is built to be magnificent, but it's a pity that other people's "bricks" are almost impossible for you to get into your own building. Always want you to imitate or rewrite.

( insert: have you noticed that downloading online windows software, there will be a so-called "green software"? This is the greatest irony of windows . windows to install a software, n dll put to windows system directory, register table write n key values, there are a lot of actions you don't know. And in unix install software, you don't have to worry about your system directory will be a little bit more messy files. is copy so simple, even rpm automatic installation, after installation, you can also query the software after the installation of the system changes. So, you unix under the distribution of your software, you will feel more than windows is a lot easier to do. )

Another of the most important features of Unix is that "all devices can be manipulated like files." It's simple. All the I/O operations, such as files, printers, monitors, terminals, networks, floppy disks, tapes,USB,CDROM, and so on, are manipulated in the form of file descriptors. The most important system call Read/write under two Unix is capable of I/O for all devices. Unix has already built these files for you in the/ dev directory. It's easy to use.

Many people may find Unix 's command line too complex. A command has several parameters that are unusually complex. But today's Unix -based applications are still dominated by the character interface, which just reflects the simple nature of Unix . This is another feature of Unix -the "mutual support of commands," which commands can be linked to each other through a pipeline or redirect, and then supported by Shell scripts, even if some complex functions (such as a small text database) are implemented. is also very simple.

If the above discussion still doesn't convince you that Unix is simple, let's take a look at some concrete practical examples of howUnix is simple. Let's try to make the following assumption: "What if we started with Unixand then turned to Windowswhen we were learning programming?"

1)    We create a process under unix , using fork is called. To windows , we checked msdn , found a call can create a process, but we find that the system call has 10 parameters. and unix , you don't see 10 parameter such a complex system call api .

2) We areUnixUnder Operation file permissions are simple, file permissions are divided into three groups (I, the same group, others), each group is readable, writable, executable. Two simple system callsChmod/chownIt's done. to theWindowsUnder, if it isNTFS, if you want to set file permissions in a program, huh, you need to know what is:SIDWhat isDACLWhat isSACLWhat isACE, there are more than 10 related systemsAPIThe function is waiting for you. (See my "to manipulate NTFS file permissions with a programYou might think that such a complex security strategy is the basis for a more secure system that can be used sinceWindowsThe day after the advent of the security of the performance there is no more thanUnix。 It certainly makes people feelWindowsDid a thankless thing.

(in one sentence : User Switching underUnix is quite simple and convenient.) User Switching under Windows will cause you to exit the current user's foreground program. This led to the user under Windows almost invariably choose to work under the Superuser's privileges / Internet access, which is entirely to let their machines run naked, so the virus underwindows will do whatever it wants to do in the system. Under Unix , very few users operate this machine as root because it is very convenient to switch users. )

3) InUnix, the user hasID, the user group hasIDProcess/Threads all haveID。IDIt's easy to understand, just like our ID card. to theWindows, the user ID is calledToken, the process identity is calledHandle(In fact, it is aDWORDType), I see a lot of questions on the internet are askingWindowsUnder theHandleConceptual issues. I've been wondering why Microsoft doesn't get a simple, easy-to-understand term. To get that abstraction, it's confusing. While this makesWindowsLook veryNB, but it will also increase the complexity of learning. (WindowsThe development of learning complexity thanUnixMore complex, and there are too many seemingly sophisticated terms to confused.

4) Let's take a look at the user management and program owner aspects. InUnixNext, what you need to do is configureNISServers, andNFSServer (inAutofsAutomaticMount), concise, clear. to theWindowsis similar to the one calledDomain(primary domain controller), first, in order to join the domain, you need to restart the computer (UnixOnly need to configure the/etc/nsswitch.confFile to tell the user to log on to the source, without restarting), and for the developer,UnixThis configuration is completely transparent to the program. andWindowsDomain Users and Local users need a domain name to differentiate. When you switch users in a program,Unixonly needSetuid/seteuidOn the line,WindowsThere are three more complexAPI:CreateProcessAsUser, ImpersonateLoggedOnUser, LogonUser, its complexity will not be compared. In addition, theDomainWay, yourDocument and SettingThe files in the directory will all be placed in theDomainServer up, you need to download these files when you log on to another machine. Finally, I am not worried about you and the Netizen'sMSNThe chat logs are everywhere because of your login, and I'm worried about whether the code you write in such a complex management environment can reassure others?:-(

5) under Unix , to add their own programs to the system's start-up service only needs to be configured in the /etc/init.d on the line. Write down a start-stop feature script that links to different startup mode directories in a specially named way. Windows plus a startup service, if you do not write programs, it is more difficult to estimate.

6) under Unix , if you want to get information about the system. Just go to the /proc directory down to the cat pile of files. All incoming / threaded status, command line, memory / swap usage, open file descriptor, etc., System CPU, memory, swap area, memory file IO, partition, information, network, system running state, System equipment, and so on, to have more details on how detailed, and completely pure text, can be seen directly. Under Windows , it is not easy to get information about the current process of the system, let alone getting other information.

I admire Microsoft to make the operating system so complex, but also the registry, security Policy, OLE, and COM.... Every time I open regedit.exe , I don't dare to touch HKEY_CLASSES_ROOT, because I look at those thousands of CLSIDinside, I am a little dizzy dish.

Self -1995years since,TenThe next year has passed. Microsoft has introduced a wide variety of technologies. I still remember.Visual Studio 6.0There are also two of them calledFoxProAndJ + +of things,FoxProFromFoxbase, and for a few more years,J + +There seems to be no years.ActiveX Controlis a completely failed technology, and that's calledVBProgramming language, it does destroy many potential programmers today. InCOMappear, do not know how many people today still remember a callMTSThe stuff? Today, I do not know how many people remember that there is a callODBCof something? In this complex and confusingWindowsDoes the world make you tired of catching up? Today's. NETDo not know how many of the technology will be precipitated over time? InWindowsAbove, we learned a lot about failure techniques or transition techniques. And we haveUnixSince the last century -Years, there has been little change, and becauseUnixBorn ofCThe language remains dazzling until today. I believe in this. -Years of proven simplicityUnix。

Unix is so simple, you want to develop on Unix friends,Windows so complex operating systems are coming, you will be afraid of such a simple Unix ?


In fact, Unix is simple.

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.

Tags Index: