Linux Study Notes 1, linux Study Notes

Source: Internet
Author: User

Linux Study Notes 1, linux Study Notes

Since my big Microsoft finally put it down, I decided to give the open-source community a late hug. The fans who have followed me for many years suddenly got the favor of the goddess. They were all lost, crying, and excited, singing in succession: "After waiting for a long time, I finally waited until today, and after a long dream, I finally realized my dream ......" After singing, I think it seems that the open-source and cross-platform services have little to do with myself. What is the most basic? Does Linux and IOS support? I have been carefully cared for by. NET for many years. Now I am telling you how to use open-source platforms. How do you play with me? After a few months of project execution, the boss is waiting to go online today!

Haha, just kidding me. In fact, Microsoft's open posture is welcomed and affirmed by the majority. IT industry also has some influence on various aspects. For me, the biggest impact is that we plan to take a good look at Linux. We have always wanted to learn it systematically, but we don't have enough motivation. Now we have no excuse. We hope we can get started as soon as possible.

According to my blog's consistent style, this article is not a systematic explanation, but focuses on facilitating future review and taking notes. The green text in this article is personal opinion and needs to be verified. This series of reference books is "Linux is the model", written by Zhao xinjie and Zhang Jie.

The first problem I had to face when learning Linux was the version selection. Nima was dumpfounded at the time, and immediately had the urge to go home. Let's take a look. Here is the branch chart (from the network) in. Think about the current Android scene, which can be installed.

It is not easy for outsiders to select a suitable one. Open-source is not good at this point. Everyone goes their own way. It's nice to say that it's a bit of fun, but it's not a lot of user groups. If so many versions of development can work together, is windows still qualified to be proud. Although on the server side, the loss of desktop clients, which account for the majority of the market, is still unavoidable. The bloggers believe that everything cannot go extreme, and pure openness and pure blocking are not advisable. The two allow each other to learn from each other and give them freedom. However, some organizations adopt unified version control based on rules, is the correct way for software development (maybe has some open-source protocols that support the opinions of bloggers. Apart from GPL, bloggers are not clear about other open-source protocols ).

Fortunately, for our coders, the various Release versions are similar, one by one. Currently, many free versions on the server are not CentOS, and many books use CentOS to explain them. Now the version is 7.1.

As A. NETer, although Linux is hooked up, the main data center is still Windows and cannot be abandoned. So how to install Linux on the same computer? You need to know that the file systems of Linux and Windows are different. There are tutorials on this dual system on the Internet, but for the sake of security, I chose a virtual machine. The disadvantage of a virtual machine is that the software environment is simulated. For example, in the file system just mentioned, the Linux File System in a virtual machine is converted from a windows File System to a virtual machine, the efficiency is much lower than that of native installation.

I chose VMware Workstation for the virtual machine, the latest version 11.1, and the registration code is searched online. Select the CentOS image file on the VMware interface, and then wait for the installation to complete. During this period, you will be asked to enter the user name and password as the login user after installation, and then select the language and input method, the desktop is displayed as follows:

There is no special feeling at all, and there is nothing amazing in all kinds of books. maybe CentOS is biased towards service performance and does not care about the graphic interface. maybe Ubuntu is different. In any case, I finally took a historic step forward!

Users and user groups

Linux users are awesome except root users. A user belongs to at least one user group. Each row in the/etc/passwd file represents one user. The 4th column indicates the user's "initial user group ", all user groups to which a user belongs are called "supported user groups ". Another concept is "valid user group". The so-called valid user group indicates the user's current user group, that is, the user can only participate in system interaction as a user group member at the same time. Why is this design, currently unknown.

The former said, root is awesome, almost omnipotent, very extreme opposition, the majority of silk is generally in addition to their own one acre of three sub-land, there is almost no "technical content" (such as adding users), so there is nothing to worry about as root. In order not to be exhausted, root decided to teach the brokers a spell, so that they can have their own (root) capabilities within a period of time, or "transform" to "root, this spell is sudo. For example, the/etc/shadow file stores the password. Normal users do not have the permission to view the file. If you want to view the file, Run "$ sudo cat/etc/shadow ", at this time, the system will require you to enter the current user password. Although it is troublesome to enter the password, it is highly secure. At least a variety of background programs cannot be used to perform minor operations secretly. To assign sudo privileges to a user, you need to change the content in the/etc/sudoers file, which can set the command range for the user or user group to exercise sudo rights, you can even set sudo without entering a password. However, this is naturally insecure and is not recommended.

Su command, used to switch the current user. If sudo is too troublesome, you can use su to temporarily switch to the root user. When switching users, you must enter the target user's password. The root user does not need to enter a password when using the su command to switch to any user. Therefore, we need to explicitly prohibit su from being executed by the sudo privilege in/etc/sudoers.

Similar to user groups, users also have the concepts of actual users and valid users (that is, the current users mentioned above), which can be viewed by who am I and whoami respectively.

File [attributes and permissions]

Linux is case sensitive and the file name is the same. If "." is added before the file name, the file [Folder] will be hidden. Unlike windows, there is basically no file extension, because Linux does not judge the file type based on the extension, but based on the file content ..

File connection is also a file type. Based on inode, inode contains the object metadata. Inode can be simply understood as a pointer pointing to the physical location in the disk where the file is located. Multiple File Names can point to the same inode, which means that the same content can be accessed using different file names; modifying the file content affects all file names. However, deleting a file name does not affect access to another file name. This is called hard link ). In addition to hard links, there is also a special case. Although the inode numbers of file A and file B are different, the content of file A is the path of file B. When reading file A, the system automatically directs the visitor to file B. Therefore, no matter which file is opened, file B is eventually read. In this case, file A is called the soft link or symbolic link of file B ). The biggest difference between a soft connection and a hard link is that the soft connection points to the file name of the target file, while the hard link points to the inode of the target file. The inode of the soft connection is different between the two files, the number of inode connections in the target file is not affected. For more information, see Linux inode.

Create a connection using ln. If the cp command is copied, a new file with the same content is generated.

File permissions: r, w, x, s, and t. The first three sub-tables indicate read, write, and execution. Because permissions can be freely combined, it is most reasonable to design them in the form of a flag. In numbers, if r is 4, w is 2, x is 1, 5 is r-x, and rwx is 7. The file sets the permissions of the owner, the owner group, and other non-customs users in order. For example, 777 indicates that all users have the read and write permissions on the file, 600 indicates that only the owner has the permission to the file and the permission is rw -.

We can use the chmod command to change the file permissions, such as chmod 700 testtext. This is a numerical permission method, and we can also use text to indicate permission changes, such as chmod u + w testtext, add write permissions to the owner. U, g, o, and a indicate the owner, group, other irrelevant persons, and all, and +,-, and = indicate adding, subtracting, and setting respectively.

What are the two permissions s and t? Let's talk about s. Set the execution bit of the file owner and user group permission to s, which is called SUID and SGID respectively,Valid for Binary programs. SGID can also be used in directories.. A file has the uid and gid attributes, indicating the owner and the group. When the file is executed, two additional attributes, euid and egid, indicate the valid (current) User ID of the execution file and the valid (current) User Group ID, the Linux kernel mainly uses euid and egid to determine the process's access permissions to resources. The following example is clear:

Assume that the file myfile belongs to the foo user and is executable. Currently, there is no SUID bit. The permission bit is rwxr-xr-x. The uid and gid of the foo user are 200 and 201 respectively. Another user, kevin, has uid and gid 204 and 202 respectively. The euid = uid = 204 and egid = gid = 202 of processes formed by kevin running myfile. The kernel determines the resource access restrictions of processes based on these values, actually, it is kevin's user's permission to access resources, which has nothing to do with foo. Then we set myfile to SUID, and euid and egid are changed to the uid and gid of the owner of the program to be run. That is, the kevin user is running myfile, euid = 200, egid = 201, the process has the resource access permission of its owner foo. Http:// I .cnblogs.com/EditPosts.aspx? Postid = 4678311

I do not know whether the valid users and valid user groups of the system mentioned earlier correspond to the euid and egid of the execution file during SUID File Execution, that is, the second half of the above example, and when kevin runs myfile, in this case, is the system valid user kevin or foo? This issue remains for future verification.

The role of SUID is to allow a user who does not have the corresponding permissions to access resources when running this program.

The efficacy of SGID on the binary program is similar to that of SUID, and the following effects can be produced in the directory: If the directory group is gA, then the user with the valid user group of gB enters the directory, the user's valid user group becomes gA, and the user group for creating new files is gA. If this is the case with SGID, is the problem described in the above red letter also the general answer?

For more information, see linux: SUID and SGID.

T, set the other non-Customs permission execution bits of the file to t, which is called SBIT,Valid only for directories. Efficacy: only the user and the root user have the right to delete the file created under the SBIT directory.

Others

$ PATH environment variable determines which directories The shell will look for commands or programs. The PATH value is a series of directories. When you run a program, linux searches for compilation links under these directories.

Cpio command: As the name implies, it refers to the copy of input and output, the standard input of modern computers is the keyboard, and the standard output is the screen. We can redirect (|,>,<) the input and output, it can be used to copy files, package and unpackage, and play a great role together with find and other commands. For more information about the cpio command, see the cpio command details.

Fork: copy a sub-process. If a process fork is followed by three processes (the process, the parent process after fork, and the child process after fork, or two processes (the parent process after fork and the child process after fork? I will try again later.

Summary

Now, the concept is completely gone, and there are too many Linux commands. At present, we have a simple understanding of the following: 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 ...... Not to mention the respective command parameters of each command, Nima can only be said to be described in many ways.

 

Reprinted please indicate the source of this article: http://www.cnblogs.com/newton/p/4678311.html

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.