Linux Learning Note 1

Source: Internet
Author: User

Since my big Microsoft finally put down the figure, decided to give the open source community a late hug, following years of fans like suddenly got the goddess's favor, all kinds of my head, crying, rejoicing, singing up: "Wait a long time finally wait until today, dream of a long time finally to realize the dream ..." After singing to think of what it seems to say open-source, cross-platform what is not very much related to their own, the most basic, Linux, iOS? Being carefully cared for by. NET for many years, now talk to me about open source cross platform, you are playing with me? Not to mention, dragged a few months of the project, the boss is still waiting for the online today!

Hehe, open a joke, in fact, Microsoft's open posture is affirmed and welcomed by the majority, it industry has a little impact on all aspects of it, for me, the biggest impact is to study the Linux, this thing has always wanted to learn the system, but there is no sufficient power, there is no excuse, I hope to get started as soon as possible.

According to my blog's consistent style, this article is not a systematic explanation, but focus on the review to facilitate the review to take notes. This article green word for personal opinion, need to verify. This series of reference books is "Linux is this stylish", Zhao Xinlei and Zhang Jie.

Learning Linux The first to face the problem is the version of choice, I was a look at the moment I was dumbfounded, instantly there is the impulse to go home. Let's have a look, here is the 07 branch of the map (from the network), think of the current Android scene, Gee, this picture can be installed.

It's really not easy for a layman to choose a suitable one. Open source is this bad, we fragmentation, say nice point of flowers, but diverted this is not a lot of user groups, if so many versions of the development can join forces a place, Windows also has a smile proud of the status of the lake. Although the server side because of open source for reasons to break out of a world, but still can not avoid the market for the big head of the desktop client failure. Bloggers think that everything can not go to extremes, pure open and pure closed are not desirable, the two learn from each other, to give freedom, but there are institutions in accordance with the rules of the unified version control, is the correct way of software development (maybe has some kind of open source agreement to support bloggers, in addition to the GPL, bloggers are not very clear about other open source

Fortunately for us, this group of farmers, the distribution is similar, follow. At present, the more free version of the service end is non-CentOS, many of the books are also used in CentOS, now has reached the 7.1 version.

As. Neter, although hooked up to Linux, but the same is windows, not abandoned. So how to install Linux on the same computer, to know that the Linux and Windows file system are different, the web has this dual-system tutorial, but for security purposes, I chose the way the virtual machine. The disadvantage of the virtual machine is that the software environment is simulated, such as the file system just said, the virtual machine Linux file system is by the Windows file system by the virtual machine, the efficiency of the cliff than the original installation of a lot lower.

Virtual machine I chose the VMware Workstation, the latest version 11.1, the registration code online search is. Select the CentOS image file on the VMware interface and wait for the installation to complete, during which time you will be given the user name password as the login user after installation, then the language and input method selection, finished on the desktop, as follows:

There is no special feeling, not all kinds of books said the amazing, maybe CentOS in favor of service performance, the graphical interface does not care,maybe Ubuntu is not the same. Anyway, I finally took a historic step forward!

Users and user groups

Linux users in addition to root is naturally very good, other users are the cock wire. A user belongs to at least one user group, and each line in the/etc/passwd file represents a user, where the 4th column, the GID, represents the user's "initial user group", and all user groups to which the user belongs are called "Support user groups." There is also a concept of "effective user groups", so-called effective user groups that the user is currently in the user group, that is, the user at the same time only as a member of the user group to participate in system interaction, as to why so design, currently unknown.

The former said, Root is very good, almost omnipotent, very extreme opposition, the vast majority of cock silk in addition to their own acres of three points, almost can not do any "technical content" thing (such as adding users), so a bit of anything to trouble root. Root in order not to be exhausted, decided to impart a spell to the cock silk, so that they can have their own (root) ability for a period of time, or "transformation" as root, this mantra is sudo. For example/etc/shadow this file is to save the password, ordinary users do not have permission to view, be sure to see the words can be executed "$ sudo cat/etc/shadow", then the system will be required to enter the current user password, the password is troublesome, but the security is high, At least a variety of backstage programs can not secretly tricks. To give sudo privileges to a user, you need to change the contents of the/etc/sudoers file, which sets the range of commands that a user or group of users can exercise the sudo right, and even the ability to set sudo without entering a password, which is naturally unsafe and not recommended.

The SU command, which is used to toggle the current user. So if sudo is too cumbersome, you can use SU to temporarily switch to the root user, you must enter the target user's password when switching users. The root user does not need to enter a password to switch to any user using the SU command, so we explicitly prohibit Su from being executed by sudo privileges in/etc/sudoers.

Similar to user groups, the user also has the concept of a real user and a valid user (that is, the current user mentioned above), which can be viewed by WHO am I and whoami, respectively.

File [properties and Permissions]

Linux environment is case-sensitive and the file name is also preceded by a "." in the file name. The file [clip] will be hidden. Unlike Windows, the file basically does not have an extension, because Linux does not judge the file type according to the extension, but rather depends on the contents of the file. .

A file connection is also a file type, based on the meta-information of the inode,inode containing the file. We can simply interpret the inode as a pointer to the physical location on the disk where the file resides, and multiple filenames can point to the same inode, which means that the same content can be accessed with a different file name, and changes to the contents of the files will affect all filenames, but deleting a file name Does not affect access to another file name, which is referred to as a "hard link." In addition to hard links, there is a special case. The inode number for file A and file B is different, but the content of file A is the path to file B. When you read file A, the system automatically directs the visitor to file B. Therefore, regardless of which file you open, the final read is file B. At this point, file A is referred to as the "soft link" of File B (soft link) or "Symbolic link" (symbolic). The biggest difference between soft and hard links is that the soft connection points to the file name of the destination file, and the hard link points to the inode of the target file, and the inode for the soft connection two files is different and does not affect the number of connections to the target file inode. See the Linux inode for more information.

Create a connection with LN, if you copy the CP command, the result is a new file with the same content.

File permissions: R, W, X, S, T. The first three sub-tables indicate reading, writing and execution. Since the permissions can be freely combined, it is most reasonable to design in the form of a flag bit. With a number, R for 4,w is 2,x to 1, then 5 is r-x,rwx is 7. The file in order specifies the permissions of the owner, the owning group, and other unrelated persons, such as 777 means that all users have read and write permissions to the file, and 600 means that only the owner has permission to the file, and that the permission is read-write permission, which is rw-.

We can use the chmod command to change file permissions, such as Chmod Testtext, which is a digital permission method, and you can use text to indicate permission changes, such as chmod u+w Testtext, to the owner plus write permissions. U, G, O, a respectively, the owner, the group, other unrelated and all, + 、-、 = respectively, the increment, subtract, set.

and S, T, what do these two rights represent? First say s, the file owner and user group permissions to set the execution bit to S, respectively, called Suid and Sgid, the binary program is valid, Sgid can also be used in the directory . A file itself has UID and GID properties, indicating the owner and the owning group, and when the file is executed, there are two more properties--euid and egid--represent the valid (current) User ID and the valid (current) User group ID of the executing file, respectively, The Linux kernel is primarily based on Euid and Egid to determine the process's access to resources. Here is a clear example:

Assuming that the file myfile belongs to the Foo user, is executable, and now has no suid bit, the privilege bit is Rwxr-xr-x,foo user's UID and GID are 200 and 201 respectively. Another user, Kevin, has a UID and GID of 204 and 202, respectively. Then Kevin runs the process of MyFile program euid=uid=204,egid=gid=202, the kernel based on these values to determine the process of resource access restrictions, in fact, Kevin User access to resources, and Foo does not matter. Then we set MyFile to Suid, then Euid and Egid become the UID and GID of the owner of the program being run, that is, now that the Kevin User is running myfile,euid=200,egid=201, the process has access to the resources of its main foo. http://i.cnblogs.com/EditPosts.aspx?postid=4678311

Do not know the implementation of the Suid file process, the previously mentioned system of effective users and effective user group is also corresponding to the execution of the file Euid and Egid, that is, the last half of the example, when Kevin runs MyFile, when the system is active user Kevin or Foo? This question is to be verified later.

The role of SUID is to allow users who do not have the appropriate permissions to run the program to access resources that they do not have access to.

Sgid the effect on the binary program and suid similar, in the directory can produce the following effects: Assuming that the directory belongs to the group of GA, then the effective user group for GB users into this directory, the user's effective user group becomes GA, then create a new file, the user group of the new file is Ga. Sgid So, then whether the above-mentioned scarlet letter describes the question is also the general answer?

See LINUX:SUID and Sgid for more details.

T, the other unrelated rights execution bit of the file is set to T, called Sbit, only valid for the directory . Effect: The user has set up the file created under the Sbit directory, only himself and Root have the right to delete this file.

Other

$PATH environment variables, which determine which directories the shell will look for commands or programs, the value of path is a series of directories, and when you run a program, Linux searches for compiled links in these directories.

Cpio command: As the name implies, the input and output of copy, modern computer standard input is the keyboard, the standard output is the screen, we can redirect (|, >, <) input and output, with it for file copy, package unpacking, etc., and find and other commands can play a great effect. About the Cpio command of the Chinese man, you can see Cpio command detailed

Fork: Copies a child process. If a process is forked, is this the process of 3 processes (the process, the parent process after the fork, the child process after the fork), or 2 processes (the process is the parent process after the fork, the child process after the fork)? To be solved later.

Summary

Contact now, concept upside down, Linux commands are also more, now simple to understand are: Man, CD, CP, Kill, MkDir, MV, RM, nohup, cpio, ls, ln, jobs, find, Whereis, which, type, Tar, chmod, Chown, Su, sudo, gzip, cat, tail, BG, FG, at, Crontab, Echo, fork, PS, top ... And do not say that each command of the respective command parameters, and can only say with a plethora to describe.

Reprint this article please specify Source: http://www.cnblogs.com/newton/p/4678311.html

Linux Learning Note 1

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.