Incomplete Linux Manual (2)

Source: Internet
Author: User

Linux

After installing linux and configuring linux Startup, if you choose to start it to the graphic interface during installation, you should now see the login window. Enter your username and password (haha, set during installation, don't forget !) It's your journey to linux.

In linux, you can indeed experience the myth of never stopping. The Linux system is really powerful, so you don't have to worry about the inexplicable blue screen. I have been using linux for several years and have never experienced a real crash in these years, even if the system does not respond in xwindows, you can press "ctrl + alt + backspace" to exit the window and return to command line mode.

In fact, to understand linux, you must get used to the command line mode, because xwindows is just an application running in command line mode, just like dos and windows3.x, therefore, it is very useful to understand common linux commands. Next I will introduce some of the most frequently used commands in linux. These commands are not as comprehensive as they are described in professional books, I just picked out some of the most useful examples for our common users. Each Command compares it with the doscommands of the same function and lists some common parameters.
Before introducing some specific commands, you must note that if you encounter a command that is not used, you can run "man [command]" to get help on this command, if you want to know what parameters a command has, can you? Quot; command-help. It should be noted that the input format of parameters in linux is different from that in dos. A space should be entered after the command, and then "-", followed by one or more parameters. Note that linux is case sensitive!

Basic operation commands

Ls
It is equivalent to the dir command in dos, which is a command for listing files, similar to dir. Parameters include:

Parameters
Description

-
List hidden files in the system. In linux, hidden files are represented by the file name format, whereas in dos, they are represented by file attributes. Specifically, as long as the file starts with ".", it is an implicit file.

-L
It is listed in a long format. All information of the file or directory is listed, and a file occupies a whole row.

Cd
Like the cd in dos, the command for converting directories is used. It should be pointed out that in linux, the conversion to the upper-level directory should be played "cd..." instead of "cd..." in dos ..". That is to say, there must be a space behind "cd.
Pwd
List the current directory commands, which is equivalent to the cd commands without parameters in dos. For example:
[Root @ ttqq bin] # pwd
/Usr/bin
[Root @ ttqq bin] #
This indicates that we are now in the "/usr/bin" directory.
Commands for directories and files
Mkdir
Create a new directory, which is equivalent to the dos md command. Generally, mkdir [dirname] is used. parameters:

Parameters
Description

-M mode
Indicates the default directory mode when a directory is created. This is a function not available in dos and windows. This is mainly about permissions. If you are interested, please refer to relevant professional books.

Rmdir
Delete the Directory, which is equivalent to the dos rd command. Usage: rmdir [dirname].
Cat
Append the file after the file or print the file content on the screen. The append function is equivalent to dos copy file1 + file2, while printing the file content on the screen can be analogous to dos typeml. If the file is too large to be fully displayed on a screen, try the following command.

More
The file content is displayed on the split screen, which is roughly the same as the more command in dos, and can be used with other commands. For example: cat/home/eec/myfile | more.

Cp
Copying a file is equivalent to using copy in dos mode, which is the same as using copy in dos mode. Parameters:

Parameters
Description

-R
It is equivalent to dos xcopy/s. Copies all files and folders in a directory.

Ln
Create a file link. It is equivalent to a shortcut in windows. Usage: "target ln source file"
Mv
Renaming a file is equivalent to the dos move and ren commands. Usage: "mv oldname newname" For example: "mv 111/home/ekoala/222" means to move the "111" file to the "/home/ekoala" directory, and renamed it "222"

Touch
Change the file modification time or creation time. It is equivalent to dos copy file + nul. The simplest usage is: "touch file_name", that is, to change the time of the file "file_name" to the current time. Note: If the file after touch does not exist, a new empty file will be created on the disk.

Process or process-related commands
First, we will introduce the multi-process in linux. The multi-process in linux is more efficient and stable than that in windows. The Common commands entered in the command line state are all completed in the foreground. If you add "&" to the end of the command, the command will be run in the background. Let's get down to the truth. Now we will introduce common commands for processes.
At
Schedule the job to be executed later. This command is very powerful and complex. It can be said to be a major feature of unix/linux. Let's take a look at a specific example:
[Root @ ttqq bin] # at 21:05 Jul 31
At> cat/usr/docs/ccttrr.htm> myfile
At>
Warning: commands will be executed using/bin/sh
Job 5
The above means that the input runs a program at, January 26, July 31, and then the system prompts the user to enter a command or command list and use "ctrl + d" to terminate. After terminating at, the system gives a warning that the specified job will run at the specified time, and the job number is 5. to cancel the job, you can use the work number associated with it.
If there are many commands, we recommend that you put the command list into a file. If the file name is "comtable", enter:
[Root @ ttqq bin] # at Jul 31 due to the particularity of at, the linux system has some permissions on:
Super Users can use the at command at will, but for common users, it is determined by the/etc/at. allow and/etc/at. deny files.
If/etc/. allow file exists, so only the users mentioned in this file can use this command. On the contrary, if this file does not exist, check/etc/. deny file, which can be used by users not mentioned in this file. If neither of the two files exists. Only super users can use this command. If the/etc/at. deny file is empty, all users can use this command.
At parameters include:

Parameters
Description

-L
List jobs currently scheduled by. Super Users can list all users. Normal users can only list their at jobs.

-M
After the job is completed, the mail will be sent to the user even if there is no output.

-R
Cancels a specified job from a job, such as canceling a job in the previous example: at-r 5. Super Users can cancel all users, while normal users can only cancel their jobs.

Ps
Displays the processes currently being executed. Because the processes are executed very quickly, this command can only list the processes that occurred instantly. Output of ps-al parameter for Super Users:
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
100 S 0 273 265 0 69 0-472 wait4 tty1 00:00:00 bash
100 S 500 286 266 0 62 0-466 wait4 tty2 00:00:00 sh
100 S 503 299 267 0 64 0-465 read_c tty3 00:00:00 sh
000 S 500 318 286 0 62 0-1193 do_sel tty2 00:00:00 vi
100 R 0 328 273 0 70 0-638-tty1 00:00:00 ps
The "PID" is the process number, and the process management is implemented by the process number. Ps parameters include:

Parameters
Description

-
Displays all processes, which are used by Super Users.

-L
Long format output.

-U
User format output. The user name and start time are displayed.

-R
Only processes currently running are displayed.

-S
Add sub-cpu time and page Error Report.

Next I will explain the meaning of titles of various ps columns: column names
Description

PID
Process ID.

PRI
The priority of the process.

NI
Linux nice value. A negative number indicates that the cpu usage is low.

SIZE
The size of the virtual image. formula: "text + Data + stack ".

RSS
The size of the resident space, showing the size of k bytes of the current resident memory program.

WCHAN
The name of the kernel event that the process is waiting.

TT
The name of the process control terminal tty.

STAT
Process status, which is given in one of the following code.

R
Executable.

S
Sleep Status.

D
Uninterrupted sleep.

T
Stop or track.

Z
Is a zombia process.

W
The current process does not have a page resident in the memory.

PAGEIN
This causes a page error in reading/writing pages from the disk.

TRS
Text storage size.

SWAP
Number of kilobytes of exchanged files.

SHARE
The number of shared memories.

Kill
Allows sending a signal to the current process. This command is usually used to terminate the process, so it is also called "Killing" the process. Use: kill process number. Super Users can kill all processes. Normal users can only kill their own processes.
Display output commands
Banner
The banner generates a big title using a variable that is passed to it. You can specify ten characters. These characters are extended into a series of "*" characters. Syntax:
Banner [-w [n] string
-Wn changes the character width from column 132 to column n. If only-w is specified, the width is set to 80. For example:
Benner "my benner"
This will print a large "my benner" on the screen ".
Cal
This command displays the calendar on the screen, which is very useful. Usage: cal [month] [year]. The parameter is:

Parameters
Description

Month
1-12 indicates the displayed month. By default, this month is displayed.

Year
It can be 1-years. The default value is this year. It must have four digits. That is to say, 92 represents year 92, not year 1992 AD.

Cal 10 1994, indicating that the calendar month of October 1994 is displayed.
Clear
Clear the screen, just like dos cls.

Date
Displays the date and time of the system, or sets the system time by the Super User. You can control how the time is displayed. Syntax:
Date MMDDhhmm [CC] [YY] [. ss], parameter description:

Parameters
Description

MMDDhhmm [CC] [YY] [. ss]
These are the time format. The following table describes each variable. Each part must contain two digits.

MM
Month (1-12)

DD
Date (1-31)

Hh
Hour (00-24)

Mm
Minute (00-59)

CC
The first two digits of the year (optional)

YY
Year (00-99) (optional)

Ss
Seconds (optional)

File
Determines the file type. File to determine whether the File is an executable File, text File, data File, and so on. Many unix commands are only shell files. file can determine whether these commands are shell files. It can also determine whether the file is a text-based file and whether the file can be edited and viewed. Parameters:
Parameter description
-Z looks closely at a compressed file and tries to find its type.
-L this parameter allows symbolic connections.
-F ffile indicates that the file list to be identified is in fflie. This is useful for identifying many files.
-M file specifies an alternative file of magic that describes the file type.
Find
Find is a very powerful search tool. He studies the specified directory and generates a list of files that match the specified standard. The file can be executed by file name, file size, creation time, modification time, and many other standards, or when a matching file is found. Syntax:
The find directory (or the Directory List) matches the criteria. Its main parameters include:

Parameters

Description

-Z

Observe a compressed file in depth and try to find out its type.

-L

This parameter allows symbolic connections.

-F ffile

Tell file that the list of files to be identified is in fflie. This is useful for identifying many files.

-M file

Specifies an alternative to magic that describes the file type.

Parameters
Description

Directory (or directory list)
You want to query the directory list of a file or file set, separated by spaces.

Matching criteria
You want to query the matching criteria or descriptions of files.

-Name File
Tell find what file you want to find. The file you want to find is enclosed in quotation marks. You can use a wildcard, such as "*" and "?".

-Perm Mode
Matches all files whose modes are specified numeric values. Not only reading, writing, and execution, but also all modes except this mode.

-Type x
Match all objects of the x type. X can be c (special character), B (Special Block), d (directory), p (famous pipeline), l (symbolic connection), s (nested file) or f (general file ).

-Links n
Match All files with n connections.

-Size n
Match All files of n sizes. 512 bytes. If k is after n, it is 1 k bytes.

-User ID
The file that matches all user serial numbers is the specified user serial number. The User ID can be either a number or a user login name.

-Attinme n
Match the files accessed n days ago.

-Ntime n
Match the files modified n days ago.

-Exec command
Execute commands for each matching file.

-Newer
Match All Files updated at a time later than the file.

These parameters can be used together, or the query criteria can be restricted by logical expressions, as shown in the following table:
Parameters
Description

-And
The default logical expression indicates that both the left and right rules of the expression must be satisfied. Yes, because it is the default.

-O
The or operator indicates that only one rule is satisfied.

-!
This is the not operator, which indicates the negative expression.

In short, the find command is very complex and can be clearly explained without a few words. We recommend that you refer to the online manual and practice more easily.

User and user management and other system-defined commands
Chgrp
Change the group ownership of a file. Some chgrp commands can be used to specify the length of two parameter parameters. Currently, only the short version is introduced. Syntax: chgrp [parameter] group file list. The parameters include:

Parameters
Description

-C
Detailed description is provided only when the File Ownership does change.

-F
Do not print the error message that the file ownership cannot be changed.

-V
Detailed information on file ownership changes.

Group
The group to be changed can be the numeric value of the group number or the group name in the/etc/growp file.

File List
List of files whose group ownership is to be changed. Files are separated by spaces.

If you are not the owner or super user of the file, you cannot change the group ownership of the file.
Example: chgrp ekoala/usr/eee /*
Change the group ownership of all files under/usr/eee to ekoala.
Chomd
Change the file mode. The file mode controls access to the file. Linux has three security levels: owner level, group access level, and other user level. There are three types of read/write permissions in these three levels: read, write, and execute. For a standard file, the read permission means that the user can see the content of the file; the write permission can modify the file; the execution permission can run the file. The directory is slightly different: the read permission can view the content under the directory, that is, the ls command can be used; the write permission can create new files under the directory or delete files from the directory; run the cd command to change the permission from one directory to another.
Usage:
Chomd a + w letter
This grants all users the permission to write the file letter.
Permission code: Read (r), write (w), and execute (x ).

Chown
This command is similar to chgrp. This command changes the user ownership of the file, that is, it sets the owner of the file as another user. Usage:
Chown [parameter] user file list with the following parameters:

Parameters
Description

-C
Detailed description is provided only when the file permission does change.

-F
If the permission is not printed, the file error message cannot be changed.

-V
Details about permission changes.

File List
Lists the objects whose permissions are to be changed by chown.

User
It can be a user number or a user name in the/etc/passwd file.

Note that the ownership of a file can only be changed by the superuser or file owner. However, if the file owner specifies the file to another user, there is no right to specify the file to himself, because the user is no longer the file owner.
Example:
Chown ekoala/usr/eee/ttqq, which means to change the owner of the/usr/eee/ttqq file to ekoala.
Id
Displays the user's system ID and reports the user name, user number, group name, and group number. Parameters:

Parameters
Description

-G
Only the group number is printed.

-G
Only the supplemental group is printed.

-U
Print only user numbers.

For example:
[Ekoala @ ttqq usr] $ id
Uid = 10002 (ekoala) gid = 500 (student) groups = 500 (student)
[Ekoala @ ttqq usr] $
Displays user information.
Passwd
Maintain user passwords. the system administrator can use this command to manage user accounts. Usage:
Passwd [user name]
Only the system administrator can change others' passwords. Normal users can only change their own passwords. For example:
[Ekoala @ ttqq ekoala] $ passwd
Changing password for ekoala
(Current) UNIX password: [enter the current password 〕
New UNIX password: [New password 〕
Retype new UNIX password: [confirm new password 〕
Password: all authentication tokens updated successfully (Password Changed successfully 〕

Useradd
Add a new user or change existing user information.

Userdel
Delete a user and all his files.
Commands for disk management and File compression
Df
Report the remaining disk space. Parameters include:

Parameters
Description

-
Optional file system list, which reports the number of remaining hard disk space. If this item is blank, it reports all existing file systems.

-I
List node usage information instead of block usage information.

-K
The Print size is 1 kb instead of kb.

-T fstype
Only list file systems of the fstype type.

-X fstype
Only list non-fstype file systems.

Gzip
Gzip is a very popular compression tool, which is usually used together with the tar command. Syntax:
Gzip [parameter] file list with the following parameters:
-
ASCII text mode: Convert the end mark of a file according to the conventions. This option only supports non-UNIX operating systems. In msdos, the carriage return and line feed are converted to line breaks during compression, decompress the package and convert it back.

-C
Output to standard output, keep the original file unchanged. If there are several input files, the output remains in a certain order.

-D
Decompress.

-F
Force compression.

-L
Detailed display of File compression:
1. Size of the compressed file.
2. The size before compression.
3. compression ratio and compressed file name.
4. If used with the-v parameter, the following information is displayed:
A. compression method.
B. The 32-bit CRC code of uncompressed data.
C. file change time.

-Q
No warning information is displayed.

-R
Recursively compress the directory structure.

Tar
Tar is a popular file backup and compression tool used to create a system backup or a single file. Tar syntax is very troublesome. The following is a brief introduction:
Tar crtux [fmtVwF] file list. Parameters include:
Parameters
Description

Parameters
Specify the following parameters to obtain the file.

C
Create a new file or overwrite an existing file.

R
Name the file in the file list.

A
Add files to the backup package.

T
Lists the compressed files.

U
Decompress the file from the compressed file.

File List
The list of files to be processed, which can contain a wildcard. If a directory is processed, all files and folders under the directory are processed.

-B
Specify the number of chunks n, n x K, and the default value of n is 20.

-M
It indicates that the time does not need to be modified during tar decompression. The modification time is the decompression time.

-C directory name
Change the directory.

-K
Keep existing files and do not overwrite them from the compressed files.

-V
Generate a compressed file with a volume label.

-Z
Use gzip to decompress the file.

For example, unlock a compressed file named 9s. tgz:
Tar zxvf 9s. tgz
For example, to package all the files in/home/bbs into bbs. bak. tgz, you can do this:
Tar zvcf bbs. bak. tgz/home/bbs /*
Network-related commands
This section only provides a brief introduction of commands that are useful to individual users. Although the biggest feature of linux is its network functions, most of the functions are too powerful, for more information, see related books.
Login
Login is used to log on to a host or switch from one user to another. This is a bit like the su command, but it is used more than su. Syntax:
Login [parameter] [host name] [user name]. The parameters are as follows:
Parameters
Description

User Name
If no parameter is provided, login requires a user name.

-P
Retain environment variables.

-F
Ignore the second logon certificate.

-H
Remotely log on to other hosts.

Ping
Similar to dos, this command is used to check whether the physical network between two computers is smooth. This command is generally used to check whether the network is faulty.
The Ping Command sends an ICMP (Internet Control Messeges Protocol) packet to the network host and requests the target host to respond. Parameters include:
Parameters
Description

-C
When a host response is received, it stops.

-F
Flood-Type Packet sending: Once a host response is received, the packet is sent, or one hundred packets per second. Note: Only super users can use this command. This command will have a negative impact on the network.

-I
Wait for one second for each package.

-L
Forcibly send packets continuously at the fastest speed. This command can only be used by Super Users.

-S packetsize
The size of the custom package.

Other commands
Time
Determine the execution time of the program. Syntax:
Time [command]
Uname
Report system name or other information. Syntax:
Uname [parameter]

Parameters
Description

-S
Report system name. This is the default value.

-N
The node name of the reporting system.

-R
The release number of the report system.

-V
Report the version number of the system.

-M
The hardware name of the reporting system.

-
Report all information.

History
Displays the USER command line history.
Vi usage
To configure the system, you must first learn the text editing command, because the main configuration work is nothing more than editing the text file. The oldest and most popular text editor in unix or linux is vi. Therefore, it is necessary to understand the usage of some vi. Although it may be difficult for new users, you will find that vi is actually a very useful and powerful editor.
Vi Introduction
Vi is a universal full-screen text editor in the unix world. It can be said that almost any unix machine will provide this software, and of course there are linux. Familiar with text editors under dos, such as edit, will feel that vi is not easy to use, and many new and more powerful editors have been developed on unix, however, there is no guarantee that each machine has one. Therefore, it is necessary to familiarize yourself with vi operations. This allows you to work on different machines.
Basic concepts of Vi
You only need to execute vi to enter the vi editing environment. It is better to have a rough understanding before the actual operation. Vi has two modes: input mode and command mode. The input mode is used to input text materials, while the command mode is to issue some orchestration files, archive and exit vi operation commands. After executing vi, enter the command mode first, at this time, any character entered is considered as a command. To enter the command mode in the input mode, you can press "esc". If you do not know the current mode, then, when you press "esc" several times, the system will send a "beep" to show you how to enter the command mode.
Entry and exit
To access vi, you only need to enter vi <File Name>, vi can help you automatically load the file to be edited or create a new file. After entering vi, there will be some tildes on the left of the screen. If this symbol is at the beginning of a column, it indicates that this column is empty currently. To exit vi, you can enter ": q" in the command mode, while ": wq" means to exit after archiving and enter ": q! "Is forced to leave.
Vi input mode
How do I enter it? There are several commands that can enter the input mode (note that the case is case sensitive ):
Add, press a, and add data from behind the cursor position. Press A to add data to the column where the cursor is located.
Insert, press I, and insert data from the front of the cursor. Press I to insert data from the front of the first non-blank word in the column where the cursor is located.
Start, press o to add a column from the column where the cursor is located and enter the input mode. Press O to add a new column from the column where the cursor is located and enter the input mode.
Vi Basic editing command:

Command
Description

X
Delete the character of the cursor.

Dd
Delete the row where the cursor is located.

R
Modify the character of the cursor, followed by the character to be changed.

R
The new text overwrites the original text until you Press esc to return to the command mode.

S
Delete the character of the cursor and enter the input mode.

S
Delete the characters in the column where the cursor is located and enter the input mode.

Now we have finished introducing the simple usage of vi. I believe these will be sufficient for simple configuration systems. Because most of the time I believe we are in xwindows, no one will always face the dark screen :)

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: 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.