Linux Getting Started (2)

xiaoxiao2021-03-06  84

Chapter 3: Red Hat Linux 7.1 Using the Foundation 3.1 Login and Exit System 1. Starting the system Usually LILO is installed on the MBR, after the computer is started, the program on the MBR is executed, and one is not a very beautiful graphic: left is A small red hat image lists the operating system that can be started, you can use the keyboard arrow to switch. After the installation is installed, the default is Linux, that is, you don't choose, you will start Linux for a while. If you want the default choice is Windows, then you can modify the Lilo.conf file under the / etc directory after starting Linux, plus default = windows, then execute / sbin / lilo to regenerate LILO. 2. User Login Linux is a real multi-user operating system. Users to use the system, first must log in, after using the system, you must exit. When the user logs in to the system, in order to enable the system to identify the user, the username and password must be entered, and the system can be used after the system is verified. There are two users under Linux: 1) Root users: super authority, the owner of the system, there is only one root user in the Linux system, which can be in the system. The password set when the system is installed is the password of the root user. 2) Ordinary users: Linux system can create many ordinary users and specify corresponding permissions to make it limited to use the Linux system. With regard to the management of users, we will explain in detail later. User login is divided into two steps: 1) Enter the user's login name, the system identifies the user according to the login name; 2) Enter the user's password, the password is a string of the user you choose, completely confidential to other users, is login When the system is identified, the user's unique basis, so each user should protect his password! At the beginning of the system, only root users, other users are created by root users. Since root users have too much permissions, if the Root user misuse will cause great losses. Therefore, it is recommended that the system administrator serves since the newly built a user, and only the root user is logged in when you need to do system maintenance. Below is a login example: (including the black body is input) Red Hat Linux Release 7.1 (Seawolf) Kernerl 2.4.2-2 on AN I686 Home Login: root password: In the above example, we found that it is empty behind Password In fact, it is not a password, but when entering, the Linux system does not display it, so that the password is used to protect the password! If you log in, we will get the shell (shell is a program used to interact with the user, it is like command.com in DOS, but there can be multiple shell options, such as Bash, CSH, KSH, etc.) The prompt, if you log in with the root user, the obtained prompt is "#", otherwise it will be "$". Tip: If the setting is set to a graphical interface at that time, then the system is started, the user login interface will be graphical, a bit like Windows, and when you enter the correct username and password, it will enter directly X window.

This setting can be modified: there is an initTab file in the / etc directory, where there is a line configuration: ID: 3: Default where the number 3 is representing a startup character terminal, if it is changed to 5, the representative starts to enter X Window . 3. Modify the password In order to better protect the security of the user account, Linux allows the user to modify its own password with the passwd command to use the passwd command after logging in. Modifying the password requires: 1) Enter the original password, if the password is output, the procedure cannot be modified; 2) Enter a new password; Then the password is modified successfully. It should be noted that Red Hat Linux 7.1 is to better protect the password, if the new password you entered is too simple, it will refuse to modify it. Below is an instance of modifying the password: (in the black body word is input) $ passwd Changing password for user1 (current) Unix Password: ?? In some entered the original password new unix password: ?? Enter the new password Retype New Unix Password: ?? Enter a new password passwd: All Authentication tokens Updated SuccessFully ?? Successful! Note that the password input here will not be displayed. And if the root user modifies the password, you don't need to enter your old password! That is, it can modify the password of any user. 4. Exit login No matter whether you are a root user or a normal user, you can quit login simply execute the exit command. 5. Turning off the machine In the Linux system, ordinary users are universal shutdown systems! Only root users can close it. Of course, if you are pressing the shutdown button, don't be true. We can implement: 1) Press the Ctrl Alt Del combination key so that the system will restart! 2) Execute the reboot command so the system will also restart! 3) Execute the shutdown -h now command so that the system will turn off the computer! 4) Execute the HALT command to turn off the computer. Pay attention to not use a hard shut-off, restart key, etc., which will cause the Linux file system to damage! 6. Virtual Console Linux is a real multi-user operating system that can accept remote and local logins at the same time, and allow the same user to log in multiple times. Linux is a local user (that is, users doing in front of the computer) provide virtual console access, allowing users to log in multiple times from different consoles at the same time. The selection of the virtual console can be implemented by pressing the ALT key plus F1-F6 six function keys. For example, after the user logs in, press the Alt F2 combination key, and the user can see "Login:" prompt, which is actually the second virtual console, and then press the Alt F1 combination key, the user It can also return to the first virtual console. You can experience multi-user characteristics of Linux systems by using a virtual console. For example, the user can switch to another virtual console at another virtual console on a virtual console that can be switched to another virtual console. For example, when developing software, you can edit the program on a console, compiling on another console, check the information on the third console.

3.2 Files The Directory Operation is the same as other operating systems, and the user's data and programs under the Linux system are also saved in the form of a file. So in the process of using Linux, it is often necessary to operate with the directory. Now we learn the files and directory operation methods under Linux with a WINDOW user. 1. File name and file type file name are identified by a file. From this perspective, the rules of the file name are substantially the same as Windows 9x. It is also composed of letters, numbers, underscores, and dots, and the maximum length is 255 characters. Like Windows 9x, there are normal files and directory files in the Linux system, but the directory file is referred to as a directory in Window. And there is a special file in the Linux system, that is, the device file. In the Linux system, each I / O setting is mapped into a file, which can be handled as normal files, which makes the operation of the file and the device as unity. From the user's users, the use of the I / O device is almost the same as the usage of the general file, so you don't have to know the details of the I / O device. 2. The directory structure is the same as Windows, and the file is organized in Linux. But the difference is that there is only one root directory under Linux, not as one partition in Windows. If there are multiple partitions, you need to use other partition mount to the root directory. Everyone recalls that when it is partitioned for the Linux, there is a option to fill, that is, Mount Point, we write one "/", which is the root directory (this is the opposite of Windows, one is "/", one is " / "It's really natural. Other probably/ home, / usr. After installing the system, you will find / home, / usr is the Home, USR directory below the root directory! Yes, the entire partition is used for this directory. After installing Linux, there are many directorys. Let's explain some important directories: / bin: The commands that are used for more than 100 Linux, tools / dev: All device files under Linux! / home: User main directory, every construction, you will create a directory with the same name as the user, give the user a space / Lost Found: As the name suggest, some lost files may be available here / mnt: The mount point of external equipment, usually uses CDROM and FLOPPY two subdirectories! Its existence simplifies the use of disc and floppy disk. You only need to run in the CD, you can visit the content mount to / mnt / cdrom on the CD, you can visit the contents of the CD to / MNT / CDROM. However, after you use it, you should leave this directory and perform Umount / MNT / CDROM. Similarly, the floppy disk is Mount / MNT / FLOPPY and Umount / MNT / FLOPPY. / proc: This is actually a fake directory, and you can access the content in memory by here.

/ sbin: A system-level command and tools are stored / usr: Typically used to install a variety of software / usr / x11r6 x window directory / usr / bin and / usr / sbin some post-installation commands and tools / USR / Include, / usr / lib and / usr / share is to store some shared link library / usr / local commonly used to install new software / usr / src linux source / boot: Linux is started from here / etc: here is stored in Linux Most of the profiles / lib: static link library / root: root user's home directory, this is one of privileges! / var: Usually used to store things in some changes! / var / log: Storage System Log / VAR / Spool: Store some emails, news, print queues, etc. In addition, it is to be explained, in "Current Directory", "Path", etc. under Linux is the same as WINDOWS. 3. Show file content Users who have used DOS commands should know that we can use the type command to view the content of a file. There are five related commands under Linux, and the functions have a thousand autumn, but they are as used as the Type command, can only be used to view text files. 1) CAT command CAT command is the most icon of the Type command, the method used is simple: "CAT file name". However, more powerful than the Type command is that it can view multiple files at the same time: "CAT file name 1 File name 2". 2) More command If the text file is longer, the screen cannot be displayed, so you may not be able to see it using the CAT command. Here we can simply use more to replace the CAT command. Its effect is similar to Type file name / p. Using the more command will display a screen text, after the display is full, stopped, and prompt the percentage that has been displayed, press the space bar to see the next screen. 3) The ability of the LESS command LESS command is almost the same as the more command. It is also a page display file, and the difference is that the LESS command allows the user to pass back files forward when the file is displayed. ?? Turn forward: press B; ?? Turn back: Press the P key; ?? Specify location: Enter the percentage ?? Exit: q I often use more and less, almost not using CAT to view files. 4) The head command can only view the first few rows of a file, the format is: Head Route file name If the number of rows is not specified, the default value is used. 5) The tail command corresponds to the head command, we can use the tail command to view the contents of the file tail. Usually used to monitor whether a file is modified in real time, usually used to observe the log. Such as: Tail -f Maillog 4. Edit files There are many text editing tools in Red Hat Linux 7, which is the most commonly used VI, which is an editor widely applied to all UNIX systems. It is somewhat specifically: First, you can open a file using the command "VI file name". When you just start, the VI is in the command state and cannot enter any character. In this state, you can use the arrow keys to move, and when you need to enter content, you need to enter the "I" or "A" command to enter the editing state. Once the editing is complete, you need to press the "ESC" button to return to the command status. In the command state, you can enter ": q!" Does not store it, enter the ": WQ" storage exit.

5. Document copy, delete and mobile everyone are well known under DOS We can use the COPY, DEL, MOVE command to implement file copy, delete, and move. Let's talk about how to do more in the Linux system. 1) CP command: File / Directory copy command Its syntax format is: CP [Option] Source file or directory target file or directory common option is: ?? a This option is often used when copying the directory, it keeps link, file Attribute, and recursively copy the directory, just like XCOPY / S in DOS ?? F If the target file or directory already exists, it covers it, and does not make a prompt ?? I and F options, it is overwriting, Will let the user answer "Y" to confirm ?? P Use this option, copy the file when copying the file, and if the source is given is a directory, then the CP will recursively copy all the subdirectory in the directory. And document, but this requires the goal is also a directory name. In addition, everyone should pay attention to that if the source is the file name, the target is the directory name, then the multiple source files can be specified using the CP command. Such as: $ cp a.txt b.txt / home / user1 This command will copy the A.TXT and B.TXT files to the / home / usr1 directory. 2) RM command: File / Directory Delete Command Its Syntax Format is: RM [Options] File ... Commonly used options are: ?? f Do not give any instructions during the deletion, direct deletion ?? r indicates that RM will column All catalogs and subdirectorys are recursively deleted. I'll delete, each file gives a prompt to be careful when prompted to use the RM command, especially when logging in with root, I have seen one When I use the RM command to delete the / home / tmp, I misuse the command "RM-RM-RF / HOME / TMP" into "RM-RM-RF / HOME / TMP". As a result, the whole system is deleted before he walked back to the computer. ! 3) MV command: File / Directory Move Command Its Syntax Format is: MV [Option] Source File or Directory Target File or Directory Common options: ?? f If the action is to overwrite an existing target file does not give any Indication ?? I interactive operation, if the operation is to overwrite a destination file, ask the user to overwrite the execution effect of the MV command and the parameter type! The first parameter (source) second parameter (target) result file name file name will change the source file name to the target file name file name directory name file Move to the target directory Directory name directory already exists: Source directory to the target directory The target directory does not exist: the renamed directory name file name error 6. Directory Related Operation 1) Create a new directory: MKDir, its use is the same as the MD under DOS: MKDir directory name; 2) Delete the empty directory: RMDIR, its use The same RD under DOS: RMDir directory name; 3) Change the directory: CD, its use is basically the same as the CD command under DOS, the only one is, no matter what the directory name is, there must be space between the CD and the directory That is: "CD /", "CD ..", "CD." Is illegal, but should be entered: "CD /", "CD ..", "CD.", If you enter the command "CD ", Do not add any parameters, will return to the home directory of this user.

4) Display current directory: PWD 5) Column directory command: LS, equivalent to DIR in DOS It is: LS [Option] [Directory or File] Common options: ?? a Display All the children under the specified directory Directory and files, including hidden files; ?? c Sort by file modification time ?? L using long formats to display the details, each file is a line of information, its content is: File Type and Permission Link Document Group file size Recent modified time file name 7. Documentation and directory Permissions Operation in Linux systems, each file and directory have corresponding access license privileges, can we use it to determine what way to file and Directory access and operation. The access rights of the file or directory are divided into readable, writable and can perform three kinds, which are represented by R, W, X, which means that the RWX file readable can be written can be used to list the directory. Writing can access the directory When the file is created, the file owner can set the permissions of the file. For a file, you can divide the user into three, and give different privileges: 1) File Owner 2) With the file owner's group users 3) Other users, each file or directory access, three Group, each group is expressed in three, such as: D rwx rx r - Part 1: D represents the directory here, other: - Represents normal file C represents character device file; Part 2: File owner's permission word Here is RWX to represent readable, writable, executable (can enter the directory); Part III: Writing words with the user's associated user, here is R - X means readable, Do not be writable, executable. Due to more communication between the same group users, let him look at the file, don't change it. Part IV: Other users' permissions word, here - - -, of course, people who have nothing to do, my files don't just write you, not letting you read. 1) File / Directory Permissions Settings Command: Chmod This is one of the most commonly used commands for Linux system administrators, which is used to change access to files or directories. This command has two usage: ?? Use the text settings containing letters and operator expressions, its grammatical format is: chmod [who] [opt] [mode] file / directory name where the who represents object, is in the following letters One or a combination: u: Represents the file owner g: Represents the same group user o: Represents other users A: Indicates that all user OPT is a representative operation, which can be: : Add a permission -: Cancel a permission =: Give a given permissions and cancel the original permissions and modality representative: R: Readable W: can write X: Executive, for example: add write permission to file a.txt to the same group: CHMOD G RW a.txt ?? Using a digital setting method, the number setting method is simpler: chmod [mode] file name key is the value of Mode, and many beginners will be confused, in fact, we will be RWX Look at the number of binary, if there is a 1 represented, there is no 0, then RWX RX R-can be represented as: 111 101 100 to convert each three-digit to a decimal number, that is, 754.

For example, we want A.TXT's permissions to: you can read it by other users of your own group, is it writable to be executable, let's get the right string according to the above table: RW-RW-R - Then, the converted into a binary number is 110 110 100, and then every three-digit conversion becomes a decimal number, it will be 664, so we execute commands: chmod 664 a.txt 2) Master command to change the file: Chown syntax format is very simple: Chown [Option] Username File / Directory Name Where is "R", plus this parameter, you can change all subdirectories and files of the entire directory into designated users. 3) Change the file genus command: chgrp This command is also very simple: CHGRP Group name file name 3.3 User management user management, the main job is to establish a legal user account, setting up, and managing the user's password, modify the properties of the user account and Delete the discarded user account when necessary. 1. Add a new user in the Linux system, only root users can create a new user, the following command will create a user of the login User1. # UserAdd User1 However, this user cannot be logged in because it has not been given to the initial password, and the user without password is not able to log in to the system. By default, a user main directory that is the same as the username will be created under the / home directory. If you need another user-owner directory, then you can use the following command: # UserAdd -d / home / xf user1 At the same time, you will get a shell program when you log in: / bin / bash, and if you don't want this user to log in, You can also specify the user's shell program as: / bin / false, so that even if the user is logged in, it is not able to perform commands under Linux: # Useradd -s / bin / false User1 In Linux, add a user while adding a user A new group will be created, this group is the same name with the user, and this user is a member of the group. If you want new users to belong to a group already existing group, you can use the following command: # Useradd -g user USER1 This user belongs to a member of the User group. And if you just want it to belong to a group, you should use: # userAdd -g user user1 After completing this, you should use the passwd command to set an initial password. 2. Remove a user to delete a user, just use a simple command "Userdel username". However, it is best to remove it on the system, and you can use the "UserDel -r User Name" to achieve this. 3. Modify User Attributes In front we see how to specify its user home directory when newing a user, how to specify its shell, how to set the group to which it belongs ... etc. Provide a command in Linux to implement: UserMod -g Group name -g Group name -D User main directory -s user shell has a direct method, that is, modify the / etc / passwd file, each in this file. User's content is: User Name: Password: User ID: Group ID: User Name: User Home Copy: User Shell But notice that the password is usually replaced with a * number, you It can't be seen.

转载请注明原文地址:https://www.9cbs.com/read-96162.html

New Post(0)