The 3rd chapter: Red Hat Linux 7.1 Usage Basics
3.1 Login and exit system
1. Start the system
Usually Lilo is installed on the MBR, after the computer starts, the MBR program is executed, there will be a not very beautiful graphics: the left side is a small red hat image, the right list of the operating system can be started, you can use the keyboard arrows to switch. After the installation of the default is Linux, that is, you do not choose, a moment to start their own Linux.
If you want the default choice is windows, then you can start Linux, use VI to modify the lilo.conf file in the/etc directory, plus default=windows, and then perform/sbin/lilo regenerate Lilo.
2. User Login
Linux is a real multi-user operating system, users want to use the system, must first log in, after the use of the system, must exit. When the user logs on to the system, the user name and password must be entered in order to enable the system to identify the user, and the system can be authenticated before logging into the system.
There are two types of users under Linux:
1 root User: Superuser, the owner of the system, and only one root user in the Linux system, it can operate in the system. The password that is set when the system is installed is the root user's password.
2 Ordinary users: Linux systems can create many ordinary users, and assign them the appropriate permissions, so that their limited use of Linux systems.
Regarding the user's management, we will explain in detail later.
The user login is divided into two steps:
1 Enter the user's login name, the system according to the login to identify users;
2 Enter the user's password, the password is a user's choice of a string, to other users completely confidential, is the only way to identify users when the system is logged on, so every user should protect their password!
At the beginning of the system, only the root user, and the other users were created by the root user. Because the root user has too much permissions, it can cause significant damage if the root user is mistakenly operating. Therefore, it is recommended that the system administrator to create a new user, only need to do system maintenance, management tasks to log in as root user.
Here is a login instance: (of which bold text is input)
Red Hat Linux Release 7.1 (Seawolf)
Kernerl 2.4.2-2 on a i686
Home Login:root
Password:
In the above example, we found that after the password is empty, in fact, is not to enter the password, but in the input, the Linux system will not display it, so as to protect the password!
If the login succeeds, we will get the shell (shell is used to interact with the user program, it is like the Command.com in DOS, but in Linux can have a variety of shell options, such as Bash, CSH, ksh, etc.) prompts, If you log in as root, the prompt you get is "#", otherwise it will be "$".
Tip: If the installation is set to start on the GUI, the system starts, the user login interface will be graphical, a bit like windows, and when you enter the correct username and password, you will go directly to X Window. This setting can be modified:
There is a inittab file in the/etc directory with one row of configuration:
Id:3:default
In which, the number 3 is to represent a start into the character terminal, if 5 to represent a start into the X Window.
3. Change Password
To better protect the security of user accounts, Linux allows users to use the passwd command to modify their passwords at any time after logging in. Changing passwords requires experience:
1 input The original password, if the password is wrong, will suspend the program, unable to modify the password;
2 Enter a new password;
3 prompts to repeat the new password, if the password entered two times match, then the password modified successfully.
It should be noted that Red Hat Linux 7.1, in order to better protect the password, if you enter a new password is too simple, it will refuse to modify. Here is an instance of changing the password: (bold text is input)
$ passwd
changing password for User1
(current) UNIX password:ß Enter the original password in some
New UNIX password:ß Enter a password
Retype new UNIX password:ß and then enter the password again
Passwd:all authentication Tokens updated Successfullyß modified successfully!
Note that the password entered here is also not displayed.
If the root user changes the password, you do not need to enter the old password! In other words, it can modify the password of any user.
4. Exit Login
Whether you are a root user or a regular user, you can exit the login simply by executing the exit command.
5. Shut down the machine
In Linux systems, ordinary users do not have the right to shut down the system! Only the root user can close it. Of course, if you press the Shutdown button, do not be vessels. There are several ways we can achieve this:
1 Press the Ctrl+alt+del key combination, so the system will reboot!
2 Execute the reboot command so that the system will also reboot!
3 Execute the shutdown-h now command so the system shuts down the computer!
4 Execute the halt command, you can turn off the computer.
Be careful not to use hard shutdown, restart keys and other ways to shut down the system, which will lead to the destruction of the Linux file system!
6. Virtual Console
Linux is a real multi-user operating system that can accept remote and local logons for multiple users at the same time, and allows the same user to log on multiple times. Linux provides Virtual Console access to local users (that is, users in front of the computer), allowing users to log on multiple times from different consoles at the same time.
The choice of the Virtual Console can be achieved by pressing the ALT key plus the F1-F6 six function keys. For example, after a user logs in, click the ALT+F2 key combination, the user can see the "Login:" prompt, which is actually the second Virtual Console, and then press the ALT+F1 key combination, the user can return to the first Virtual Console.
You can use the Virtual Console to feel the characteristics of the Linux system multiuser. For example, when a user can work on a virtual console that is not finished, you can switch to another Virtual Console and start another task. For example, when developing software, you can edit programs on one console, compile on another console, and look up information on a third console.
3.2 File and directory operations
As with other operating systems, users ' data and programs are stored in the form of a file in a Linux system. So in the process of using Linux, it is often to operate on files and directories. Now we'll take a window user's position to learn the file and directory operation methods under Linux.
1. filename and file type
The file name is the identity of a file. From this perspective, the rules for file names are essentially the same as those under Windows 9x. It is also made up of letters, numbers, underscores, and dots, with a maximum length of 255 characters.
As with Windows 9x, there are regular file and directory files in Linux, but directory files are referred to as Directories in window. And there is a special file in the Linux system, which is the device file. In a Linux system, each I/O setting is mapped into a file that can be processed like a normal file, which makes the file and device operations as uniform as possible. The use of I/O devices is almost the same as the use of general files from the user's users, so you don't have to know the details of the I/O device.
2. Directory structure
As with Windows, files are organized through catalogs in Linux. But the difference is that there is only one root directory under Linux, not a single root directory like Windows. If you have more than one partition, you need to mount the other partitions to the root directory.
You can recall that when it came to Linux partitioning, there was an option to fill out, and that was mount point, where we wrote one of the "/", the root directory (this is the opposite of windows, one is "\", One is "/", is a natural enemy). Others may be/home,/usr.
After installing the system, you will find that/home,/usr is the root directory under the home, USR directory! By the right, the entire partition is used for that directory.
After installing Linux, there are a lot of catalogs, and below we'll show you some important directories:
/bin: Storage of more than 100 Linux common commands, tools
/dev: Store all the device files under Linux!
/home: With the head of household directory, each build a user, will create a new directory with the same name as the user, give the user a space of their own
/lost+found: As the name suggests, some of the missing files may be found here
/mnt: Hanging contact of external equipment, usually with CDROM and floppy two subdirectories! Its presence simplifies the use of discs and floppy disks. You just have to plug in the disc, run: Mount/mnt/cdrom, you can mount the contents of the CD on the/mnt/cdrom, you can access. But after you use it, you should leave the directory and perform umount/mnt/cdrom. Similarly, floppy disks are mount/mnt/floppy and umount/mnt/floppy.
/proc: This is actually a fake directory, through which you can access the contents of the memory.
/sbin: System-level commands and tools are stored here
/usr: A place commonly used to install various software
/USR/X11R6 X Window Directory
/usr/bin and/usr/sbin Some later installed commands and tools
/usr/include,/usr/lib, and/usr/share store some shared link libraries
/usr/local used to install new software
/USR/SRC Linux Source program
That's where/boot:linux started.
/ETC: Most of the configuration files stored here in Linux
/lib: Static link library
/root:root user's home directory, this is one of the privileges!
/var: Usually used to store some of the changes in the things!
/var/log: Storing system logs
/var/spool: Store Some mails, news, print queues, etc.
In addition, the concept of "current directory" and "path" under Linux is the same as under Windows.
3. Display the contents of the file
Anyone who has used a DOS command should know that we can use the type command to view the contents of a file. There are five related commands in Linux that have different features, but they are all like the type command and can only be used to view text files.
1) Cat command
The cat command is most like the type command, and the method used is simple: "Cat filename." More powerful than the type command, though, is that it can view multiple files at the same time: "Cat filename one filename two".
2) More command
If the text file is longer and one screen cannot be displayed, then using the Cat command may not be able to see. Here we can simply use more to replace the Cat command. The effect is similar to type file name/p. Use the more command to display one screen of text at a time, display full, stop, and indicate the percentage of all content displayed, press the SPACEBAR to see the next screen.
3) Less command
The function of the less command is almost the same as the more command, which is to display the file by page, except that the less command allows the user to read the file both forward and backward while displaying the file.
Ø Turn forward: press the B key;
Ø Turn back: Press the P key;
Ø specified position: input percent
Ø exit: Q
I often use more and less to view files with little cat.
4) Head command
The head command allows you to view only the first few lines of a file, in the form:
Head row number filename
If no row count is specified, the default value of 10 is used.
5) Tail command
corresponding to the head command, we can use the tail command to view the contents of the tail of the file. It is often used to monitor whether a file has been modified in real time and is usually used to observe logs. Such as:
Tail-f Maillog
4. Edit the file
There are many text-editing tools in red Hat Linux 7, the most common of which should be VI, an editor that is widely used in all UNIX systems. Its use is somewhat special:
First, you can use the command "VI filename" to open a file.
Just started, vi in the command state, can not enter any characters. In this state, you can use the arrow keys to move, and when you need to enter the content, you need to enter the "I" or "a" command into the editing state. Once the edit is complete, you will need to press the "ESC" key to return to the command status.
In the command state, you can enter ": q!" Do not save the exit, enter ": Wq" disk to exit.
5. Copying, deleting and moving files
We are already familiar with the DOS we can use the copy, Del, move command to achieve file copying, deletion and movement. Now let's talk about how to do this in a Linux system.
1 CP command: File/directory Copy command
Its syntax format is: CP [option] source file or directory destination file or directory
The common options are:
Øa This option is often used when replicating directories, preserving links, file attributes, and recursively replicating directories, just like xcopy/s in DOS
Øf if the destination file or directory already exists, overwrite it and do not prompt
Øi is just the opposite of the F option, which, when overridden, allows the user to answer "Y" to confirm
Øp with this option, the modification time and access rights are preserved when copying files
Ør if the source being given is a directory, then CP will recursively replicate all subdirectories and files in the directory, but this requires that the target is also a directory name
In addition, you should note that if the source is a filename, the target is a directory name, then use the CP command to specify multiple source file names. 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 deletion command
Its syntax format is: RM [options] File ...
The common options are:
Øf in the process of deletion without giving any instructions, delete directly
Ør instructs RM to recursively delete all directories and subdirectories listed in the parameters
Øi Interactive deletion, each file is prompted when it is deleted
Be careful when using the RM command, especially if I'm logged in as root, I've seen a friend. The command "Rm-rf/home/tmp" was mistakenly lost to "rm-rf/home/tmp" when the RM command was used to delete the/home/tmp directory, and when he walked back to the computer, The entire system has been removed!
3 MV Command: File/directory Move command
Its syntax format is: MV [option] source file or directory destination file or directory
The common options are:
Øf If an action is to overwrite an existing target file without giving any indication
Øi Interactive operation, if the operation to overwrite an existing target file will ask the user whether to overwrite
The execution effect of MV command differs from the parameter type!
First argument (source) second parameter (target) result
FileName File name change source filename to destination file name
FileName Directory name file move to target directory
Directory name Directory name destination directory already exists: Source directory moved to target directory
Target directory does not exist: renamed
Error in Directory name file name
6. Directory-related Operations
1 Create a new directory: mkdir, its use and DOS under the same MD: mkdir directory name;
2 Delete Empty directory: RmDir, its use and DOS under the same rd: RmDir directory name;
3 Change Directory: CD, its use and DOS under the CD command basically the same, the only difference is, regardless of directory name, CD and directory name must have a space between, namely: "Cd/", "CD ...", "CD." are illegal, but should be entered: "CD/", "CD ...", "CD.", if you enter the command "CD" without any parameters, it will return to the user's home directory.
4 Display current directory: PWD
5 column Directory command: LS, equivalent to Dos under the Dir
Its syntax is: LS [options] [directory or file]
The common options are:
Øa displays all subdirectories and files in the specified directory, including hidden files;
Øc sorted by file modification time
Øl in a long format to display the details of the file, one line of information for each file, the contents of which are: file type and Permissions link number of files belong to the group file size most recently modified time file name
7. File and Directory permission operation
In a Linux system, each file and directory has the appropriate access permission, and we can use it to determine who can access and manipulate files and directories. The access rights of a file or directory are divided into three types, readable, writable, and executable, respectively, in R,w,x, which means:
R W X
File readable writable executable
Directory can be listed directory can write in the directory can access the directory
When a file is created, the file owner can set permissions on the file.
For a file, you can divide the user into three types and give them separate permissions:
1) file Owner
2 the same group of users as the file owner
3) Other users
Each file or directory has three groups of access rights, each of which is represented by three digits, such as:
D rwx R-x r--
Part I: Here the D represents the directory, others are:-on behalf of ordinary document C for character equipment files;
Part II: File owner's permission Word, here for R W x to be readable, writable, executable (directory executable refers to access to the directory);
Part Three: the permission word of the user with the same group as the file owner, here for the r-x is readable, not writable, executable. Because the same group of users communicate more, let him see the file, do not change on the line.
Part IV: Other user's permission word, here for--, of course, to my unrelated people, My Documents of course not only write to you, also do not let you read.
1 File/directory Permissions settings command: chmod
This is one of the most common commands used by Linux system administrators to change the access rights of files or directories. There are two ways to use this command:
Ø a text-setting method containing letters and operator expressions
The syntax format is: chmod [who] [opt] [mode] File/directory Name
Where the WHO represents the object, is one or a combination of the following letters:
U: Representing the owner of the file
G: Representing the same group of users
O: Indicates other user
A: Represents all users
Opt is representative of the operation, can be:
+: Add a permission
-: Cancel a permission
=: give the given permission and revoke the original permission
and mode represents the right:
R: Readable
W: Writable
X: Executable
For example: add read and Write access to file a.txt for the same group of users:
chmod G+RW A.txt
Ø using Digital Setting method
The digital setting rule is simpler: chmod [mode] filename
The key is the value of mode, at the beginning many beginners will be confused, in fact, it is very simple, we will rwx as binary number, if there are 1 said, no then there are 0 said, then rwx r-x r--can be expressed as:
111 101 100
Then convert every three bits into a decimal number, or 754.
For example, we want to a.txt this file with the following permissions:
Other users of their own group
Readable Yes Yes Yes
Can write is yes
Executable
So, let's start with the list of permissions based on the table: rw-rw-r--, then the conversion to binary number is 110 110 100, and then each three-bit conversion into a decimal number, you get 664, so we execute the command:
chmod 664 A.txt
2 Change the document's owner command: chown
The syntax format is simple: chown [option] Username File/directory name
The most common option is "R", plus this parameter, which changes the owner of all subdirectories and files in the entire directory to the specified user.
3 Change file Group command: CHGRP
The command is also simple: CHGRP Group name File name
3.3 User Management
User management, the main task is to establish a legitimate user account, set up and manage the user's password, modify the properties of the user account and, if necessary, delete the user account that has been discarded.
1. Add a new user
In a Linux system, only the root user can create a new user, as the following command creates a new user with a login name of user1.
# Useradd User1
However, the user is not able to log in because it has not been set to the initial password, and the user without the password is not able to log on to the system. By default, a user's home directory with the same user name will be created in the/home directory. If you need to specify a separate household directory, you can use the following command:
# useradd-d/HOME/XF User1
At the same time, the user will get a shell program when logged in:/bin/bash, and if you do not want the user to log in, you can specify that the user's shell program is:/bin/false, so that the user even log in, can not execute Linux commands:
# useradd-s/bin/false User1
In Linux, adding a user creates a new group that has the same name as the user who is a member of the group. If you want new users to belong to a group that already exists, you can use the following command:
# useradd-g User User1
This allows the user to be part of the Users group. And if you just want it to belong to a group again, you should use:
# useradd-g User User1
Once you have done this, you should also use the passwd command to set an initial password for it.
2. Delete a user
To remove a user, simply use a simple command "Userdel user name". However, it is best to delete the files it left on the system, and you can use the "Userdel-r username" to do this.
3. Modify User Properties
In the front we saw how to specify its user home directory when creating a new user, how to specify its shell, how to set the group it belongs to ... Wait a minute. A command is provided in Linux to implement:
USERMOD-G Group name-G group name-D user home directory-S user shell
There is also a direct way to modify the/etc/passwd file, in which each user occupies one row, and its contents are:
User name: Password: User id: Group ID: User full Name: User-headed directory: Users Shell
It's worth noting, however, that the password is usually replaced with a * number, which you can't see.
4. Add a group
Remember that Linux files can set different access rights for people who are in the same group, or for people who are not in the same group? We can create groups of users according to their needs:
Groupadd Group Name
5. Delete a group
Similarly, we sometimes need to delete a group whose command is the Groupdel group name.
6. Modify Group members
If we need to add a user to a group, simply edit the/etc/group file and write the user name to the back of the group name. For example, to add a newuser user to the Softdevelop group, just find the Softdevelop line:
Softdevelop:x:506:user1,user2
Then add NewUser in the back, forming:
Softdevelop:x:506:user1,user2,newuser
In addition, Red Hat Linux also provides a graphical user management tool: userconf, which enables more direct user management.
3.4 Process Management
Linux is a multi-user multitasking operating system. Multiuser means that multiple users can use the computer system at the same time; multitasking means that Linux can perform several tasks at once, and it can perform another task when it has not yet completed a task.
Everything that runs on a Linux system can be called a process. Each user task, each system Management daemon, can be called a process. Linux uses the Time-Sharing management method to share system resources with all tasks. Let's take a look at how to control these processes.
1. Start process
There are two ways to start a process in a Linux system:
1 Direct Input command, you will start a process directly
Ø in normal circumstances, the process will be executed at the foreground, when we can no longer execute the new command
Ø If we add a "&" after the command, the line process will be executed in the background, we can still execute the new command
2 through the AT, Cron, crontab commands can be as scheduled tasks in Windows start a process, the specific use of the man command name can be queried.
2. View process
In a Linux system, we can use the PS command to view running processes such as:
List the processes that belong to the current user:
# PS
PID TTY Time CMD
16767 PTS/1 0:00 PS
18029 PTS/1 0:00 Bash
Where the PID represents the process Id,tty is which console started the process, CMD is the command.
If you want to list more detailed information, you can use the command: "Ps-auxw".
3. Termination of the process
A process is completed automatically after the task completes. If you want to abort the process halfway, there are two ways:
1 for the program running in the foreground, directly through the combination of CTRL + C can suspend the process;
2 and for programs running in the background, you need to find the process number by using the PS command described earlier, and then use the kill process number to terminate the process.
3.5 Disk Management
System software and application software are stored as files in the computer's disk space, as the system administrator should monitor the use of disk space at any time. We can use the following two commands to implement:
1. DF command
DF, is disk free, as the name suggests is to check how much space left on the disk and other information. Here is an example of a usage:
# DF
FileSystem 1k-blocks Used Available use% mounted on
/dev/hda5 4134900 1749728 2175124 45%/
/dev/hda6 6048320 5741092 0 100%/home
A total of 6 columns of information were displayed:
1) FileSystem: Hard disk partition
2) 1k-blocks: Partition size by K
3) Used: The partition size that has been used (calculated by K)
4) Available: The partition size to be used
5) use%: Percentage of space used
6) mounted on: hanging contact
Can see/home is another partition, now the space has been used up! It was not planned well at the time!
If the disk space is represented by a unit with K, then you can use DF-M, which will take m as the unit of calculation.
2. du command
Du, is the disk usage, is to see how many disks are used. Here is an example of a usage:
# pwd
/var/log
# du
4./UUCP
776.
Here, we use the du command to list the disk space occupied by the/var/log directory. It counts a subdirectory of the directory: UUCP, which occupies 4 K, while the/var/log directory contains 776K.
The command also has a few common options for doing more functions:
Ø-a will list all the files, subdirectories, subdirectories under the current directory, subdirectories under subdirectories ... Disk occupancy of
Ø-b The amount of disk space that is occupied in bytes
Ø-c at the end of the show a statistical value
3.6 Software Installation
Under Red Hat Linux, the installation package for an application is usually in two formats:
1 RPM package, such as software-1.2.3-1.i386.rpm. It is a package packaging format created by Redhat Linux.
2 tar packs, such as software-1.2.3-1.tar.gz. It is packaged using the packaging tools of the UNIX system, tar.
Moreover, the naming of most Linux application packages also has a certain regularity, which follows:
Name-version-revised version-type
For example:
sfotware-1.2.3-1.i386.rpm
Software name: Software
Version number: 1.2.3
Revised version: 1
Available platforms: i386, for the Intel 80x86 platform.
Type: RPM, description is an RPM package.
Depending on the content of the Linux application software installation package, it can be divided into:
1) is an executable file, that is, after the unpack can be directly run. All packages in Windows are of this type. After you install this program, you can use it. However, the download should pay attention to whether this software is the platform you use, otherwise it will not be installed normally.
2 The other is the source program, you will also need to use the compiler to compile it into an executable file after the package is unpacked. This is virtually impossible in Windows systems because the idea of Windows is not open to source programs.
Typically, the source program is packaged in tar, and the RPM package is often an executable program.
1. Handle the application software that uses RPM package
RPM is a big contributor to Redhat, which makes Linux software installation much simpler and easier.
1) Installation:
I just need a simple word, I can finish. Perform:
RPM-IVH RPM Package Name
More advanced, please see the following table:
RPM Parameter Parameter description
-I installation software
-t test installation, not a true installation
-P Display Installation progress
-F Regardless of any errors
-U Upgrade Installation
-V Detection Suite is properly installed
These parameters can be used at the same time. More content can be referenced by the RPM command Help.
2) Uninstall:
I also need a simple word, you can finish. Perform:
RPM-E Software Name
Note, however, that the software name, not the package name, is used later. For example, to install software-1.2.3-1.i386.rpm This package, you should perform:
RPM-IVH software-1.2.3-1.i386.rpm
When you uninstall, you should perform:
RPM-E software.
2. Take care of the application that was packaged with tar
1) Installation:
The entire installation process can be divided into the following steps:
Ø Obtain the application software: through downloading, buys the optical disk the method obtains;
Ø decompression File: General tar package, will do a compression, such as gzip, bz2, etc., so you need to extract first. If the most common GZ format, you can perform: "TAR-XVZF package Name", you can complete the decompression and unpacking work. If not, then use the decompression software, and then perform the "TAR-XVF extracted after the tar package" for unpacking;
Ø read the accompanying install file, readme file;
Ø execute the "./configure" command to prepare for compilation;
Ø Execute "make" command to compile software;
Ø perform "Make Install" to complete installation;
Ø Execute "make clean" to remove temporary files generated during installation.
Well, that's it. We can then run the application. But then, some readers will ask, how do I do it? This is also a problem with Linux features. In fact, in general, the Linux application software executable file will be stored in the/usr/local/bin directory! But this is not "put the universal" truth, the most reliable or look at the software install and Readme files, general will have instructions.
2) Uninstall:
Usually software developers rarely consider how to uninstall their own software, while Tar is just the completion of packaging work, so does not provide a good uninstall method. Make uninstall are generally available to uninstall the software.
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.