Linux Use Articles
After installing Linux and configuring Linux for startup, if you choose to boot to the graphical interface when you install it, you should now be able to see the landing window. Enter your username and password, (hehe, set when installing, don't forget!) To start your Linux journey.
Under Linux, you can really experience the myth that never crashes. The Linux system is really powerful, and underneath him you really don't have to worry about a weird blue screen. The author uses Linux for several years, in the past few years has never happened to the real crash, even if the occasional in the xwindows system without a response can also press the "Ctrl+alt+backspace" exit window to return to the command line mode.
In fact, to understand Linux, it must be used to command line mode, because Xwindows is only running in the command-line mode of an application, just like dos and windows3.x, so it is useful to understand the common Linux commands. Below I will introduce some of the most frequently used in Linux, several commands, the descriptions of these commands are not as all-inclusive as the professional books, I just pick the ones that are most useful to our average user, and each command has a list of commonly used parameters for DOS commands that follow the same function.
Before introducing some specific commands, it is useful to say that if you encounter a command that is not used, you can play "man [command]" to get help on the command, and if you want to know what parameters a command has, you can get it quot;command-help. Note that the parameters in the Linux input form and DOS is not the same, after the command should play a space, and then hit "-", and finally with one or more parameters. Also note that Linux under the case is a difference!
Basic Operations Command
Ls
The equivalent of dos dir command, is the column file list of commands, and Dir almost. Parameters are:
Parameters
Description
-A
The hidden files in the system are listed, the hidden files under Linux are represented by the format of file names, unlike DOS, which is represented by file attributes. Specifically, as long as the file is "." Begins, then he is an implied file.
-L
Listed in a long form. is to list all the information for the file or directory, one file for a whole line.
Cd
and DOS CD-like, the Conversion directory command. Need to point out that Linux to go to the parent directory to play "CD ..." Instead of "CD ..." Under DOS. That means there's a space behind the CD.
Pwd
Lists the current directory command, which is equivalent to a CD command with no parameters in DOS. Like what:
[Root@ttqq bin]# pwd
/usr/bin
[Root@ttqq bin]#
This means that we are now in the "/usr/bin" directory.
Commands for directories and files
Mkdir
Create a new directory that corresponds to the DOS MD command. Generally used mkdir [dirname], Parameters:
Parameters
Description
-M mode
Represents the default directory mode when a directory is created. This is a feature that DOS and Windows do not have. Mainly on the issue of competence, readers interested please refer to the relevant professional books.
RmDir
Deletes the directory, equivalent to the DOS Rd command. Usage: rmdir [dirname].
Cat
Appending a file to the file or printing the contents of the file on the screen, the Append function is equivalent to a DOS copy file1+file2, while the print file content on the screen can be compared with the DOS typeml. If the file is too large to be fully displayed on a single screen, try the following command.
More
The screen display file content, and DOS under the much more than the same, and his characteristics are can and other commands to use. such as: Cat/home/eec/myfile | More
Cp
Copy files, equivalent to Dos under the copy use and DOS copy. Parameters:
Parameters
Description
-R
Equivalent to Dos xcopy/s. Used to copy all the files and folders in a directory.
ln
Create a file link. Corresponds to a shortcut under Windows. Usage: "LN source file Target file"
Mv
Renaming files is equivalent to Dos move and Ren commands. Usage: "MV oldname newname" For example: "MV 111/home/ekoala/222" is to "111" This file moved to the "/home/ekoala" directory, and renamed "222"
Touch
Change the file modification time or build time. Equivalent to DOS copy File+nul. The simplest usage is "touch file_name", which is to change the time of the "file_name" file to the current time. Note: If the file behind the touch does not exist, a new empty file will be created on the disk.
Related commands for processes or processes
First introduces the multiple processes of Linux, which are more efficient and more stable than Windows processes. Normal commands entered at the command line state are done in the foreground, and if you add a "&" after the command, the command runs in the background. OK, now, let's start with the common commands for the process.
at
Schedules the job to be executed at a later time. This command is very powerful and very complex, and this command 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
at>cat/usr/docs/ccttrr.htm >myfile
At>
Warning: Commands is executed using/bin/sh
Job 5 at 2000-07-31 21:05
The meaning of the above is to run a program on July 31 21:05, and then prompts the user to enter a list of commands or commands, using "Ctrl+d" terminated. After terminating at, the system gives a warning that the specified work will run at a specified time, with a work number of 5, and if you want to cancel this job, you can complete it with the work number that is attached to it.
If there are many commands, it is recommended to put a list of commands into a file, if the filename is "comtable", enter:
[root@ttqq bin]# at 21:05 June 31 due to the specificity of at, the Linux system has some permissions on the at:
Superuser can use the AT command at will, but for ordinary users, it is determined by/etc/at.allow and/etc/at.deny two files.
If/etc/at.allow This file exists, only the user mentioned in the file can use the command, and conversely, if the file does not exist, check the/etc/at.deny file, which is not mentioned in the file, and is available to users. If two files do not exist. That's the only super user can use the command. If/etc/at.deny this file is empty, then all users can use this command.
at parameters are:
Parameters
Description
-L
Lists the jobs that are now scheduled by at. A superuser can list all the users, and the average user can only list their at jobs.
-M
When the job completes, the message is sent to the user even if there is no output.
-R
Cancels the specified job from the job, such as canceling the job on the previous example: At–r 5. A superuser can cancel all users, while a normal user can only cancel his or her own job.
Ps
Displays the currently executing process, and because the process is executing very quickly, this command lists only the processes that occurred in the instant of the query. The following is the output of the Ps-al parameter for the superuser:
F S UID PID PPID C PRI NI ADDR SZ Wchan TTY time CMD
$ S 0 273 265 0 0-472 wait4 tty1 bash
286 266 0 0-466 wait4 tty2 00:00:00 sh
S 503 299 267 0 0-465 read_c tty3 00:00:00 sh
S 318 286 0 0-1193 Do_sel tty2 00:00:00 VI
R 0 328 273 0 0-638-tty1 00:00:00 PS
where "PID" is the process number, the management of the process is achieved through the process number. The parameters of PS are:
Parameters
Description
-A
Show all the processes that the feeder is using for the super user.
-L
Long format output.
-U
User format output, displaying user name and start time.
-R
Displays only the currently running processes.
-S
Add sub CPU time and page error reporting.
Below I'm talking about PS column headings meaning: column name
description
PID
process number. The priority of the
PRI
process. The nice value of the
NI
linux, with fewer negative numbers means less CPU time. The size of the
size
Virtual image, calculated as: "Text + data + stack."
RSS
The size of the resident space to display the K byte size of the program that is currently resident in memory. The
Wchan the kernel event name that the
process waits for.
TT
The name of the control terminal TTY for the process. The
STAT
process state is given in one of the following code.
R
executable.
S
sleep state.
D
uninterrupted sleep.
T
stop or trace. The
Z
is a zombia process.
W
The current process does not have a resident page in memory.
Pagein
causes page errors to read and write pages from disk.
TRS
text storage size. The number of kilobytes of
Swap
swap files.
SHARE
shared memory count.
Kill
Allow a signal to be sent to the current process, which is usually used to terminate the running of the process, so it is also called "kill" process. Usage is: Kill process number. Super users can kill all processes, and ordinary users can only kill their own processes.
Display Output command
Banner
Banner generates a headline by a magnified variable passed to it. You can specify 10 characters that will be magnified into a series of "*" numbers. The syntax is as follows:
Banner [-w[n]] string
-wn Change the width of the characters, from 132 to n columns, and if only-W, set the width to 80 columns. Such as:
Benner "My Benner"
This will print a large "my Benner" on the screen.
Aa.
This command is useful for displaying calendars on the screen. Usage: cal [month] [year], parameters are:
Parameters
Description
Month
Displays the month in 1-12. The default is to show this month.
Year
Can be 1-9,999 years, the default is this year. Must write 4 digits, that is to say, 92 represents A.D. 92, not A.D. 1992.
Cal 10 1994, indicating a October 1994 month calendar.
Clear
Clears the screen, just like the DOS CLS.
Date
Displays the date and time of the system, or the time the system was set by the superuser. Users can control how time is displayed. The syntax is as follows:
Date MMDDHHMM[CC][YY][.SS], parameter description:
Parameters
Description
MMDDHHMM[CC][YY][.SS]
These are the format of the set time. The following table explains each variable. Each part must have two digits.
Mm
Month (1-12)
Dd
Date (1-31)
Hh
Hours (00-24)
Mm
Minutes (00-59)
Cc
First two digits of the year (optional)
Yy
Year (00-99) (optional)
Ss
Seconds (optional)
File
Determines the file type. File is able to determine whether it is an executable file, a text file, a data file, and so on. Many UNIX commands are just shell files, and file can determine if these commands are shell files. He can also determine whether the file is a text-based file, and whether the file can be edited and browsed. Parameters:
Parameter description
-Z deeply observes a compressed file and tries to find out his type.
-l This parameter allows symbolic connections.
-F Ffile tells file to identify the list of files to be identified in Fflie. This is useful for identifying many files.
-m file specifies an alternate file for magic that describes the file type.
Find
Find is a very powerful search tool. He studies the specified directory and produces a list of files that match the specified criteria. Files can be executed by file name, file size, build time, modification time, and many other criteria, or you can execute an instruction when a matching file is found. The syntax is as follows:
Find directory (can also be directory list) matching criteria. His main parameters are:
Parameters
Description
-Z
Look deep into a compressed file and try to find out his type.
-L
This parameter allows symbolic connections.
-F Ffile
Tell file list of files to be identified in Fflie. This is useful for identifying many files.
-M file
Specifies an alternate file for the magic that describes the file type.
Parameters
Description
Directory (or directory list)
A list of directories that you want to query for files or sets of files, separated by spaces in the directory.
Matching Criteria
You want to query the matching criteria or description for the file.
-name file
Tell find what file to look for, the file to find is included in quotation marks, you can use the wildcard character, such as: "*", "?".
-perm mode
Matches all files in which the pattern is a specified numeric pattern value. Not just reading, writing, and executing, but all the patterns except for this pattern.
-type x
Matches all files of type X. X can be C (special character), B (Special block), D (directory), p (known pipe), L (symbolic Connection), s (socket file) or F (General file).
-links N
Matches all files with an n number of connections.
-size N
Matches all files of size n blocks. A 512-byte block, if K is in N, then a 1k byte block.
-user User Number
The file that matches all user serial numbers is the specified user serial number. User numbers can be numeric or user login names.
-attinme N
Matches a file that was accessed before n days.
-ntime N
Matches a file that was modified N days ago.
-exec command
Executes commands on each matching file.
-newer
Matches all files that have been modified in time than the file file update.
These parameters can be used in parallel, or you can limit the query criteria by logical expressions, as shown in the following table:
Parameters
Description
-and
The default logical expression that represents a rule that satisfies the two-or-so expression. Can not be used, because it is the default.
-O
At this point, the OR operator indicates that a rule can be satisfied.
-!
This is the NOT operator, which represents the expression after the negation.
In short, find command is very complex, not words can be clear, suggest you refer to online manuals, and more practice can easily master.
User and user management and other system-related commands
Chgrp
Change the group ownership of the file. Some CHGRP commands have a specified way of two parameter parameters, and are only introduced in the short version. Syntax: chgrp [parameters] group file list, parameters are:
Parameters
Description
-C
Detailed instructions are made only if the ownership of the file does change.
-F
Do not print error messages that cannot be changed by file ownership.
-V
Detailed description of file ownership change information.
Group
The group you want to change to is either a numeric value for the group number or a group name in the/etc/growp file.
File list
To change the list of files for group ownership, the files are separated by spaces.
If you are not the owner of the file or the superuser, you cannot change the group ownership of the file.
Example: Chgrp ekoala/usr/eee/*
That is, to change the group ownership of all the files under/usr/eee to Ekoala.
Chomd
Changing the file mode, the file mode controls the access rights associated with the file. Linux has 3 security levels: Owner level, group access level, and other user level. There are 3 types of read and write permissions in these 3 levels: reading, writing, and executing. For standard files, read permission means that the user can see the contents of the file, write permission to modify the file, and execute permissions to run the file. For the directory is slightly different: Read permissions can see the contents of the directory, that is, can use the LS command; Write permission to create a new file in the directory or delete files from the directory; Executing permissions means being able to transition from one directory to another, you can use the CD command.
Usage:
CHOMD A + W letter
is the right to add write letter to all users.
The permission code is: Read (R), write (W), execute (x).
Chown
This command is similar to CHGRP, which changes the user ownership of the file, which means that the owner of the file is set to another user. Usage:
chown [parameters] List of user files with parameters:
Parameters
Description
-C
Detailed instructions are made only if the file permissions do change.
-F
Do not print file error messages that cannot be changed by permissions.
-V
Specify changes in permissions.
File list
Lists the files that you want to chown to change permissions.
User
Can be either a user number or a user name in the/etc/passwd file.
Note that ownership of a file can only be changed by the Superuser or the owner of the file. However, if the owner of the file assigns the file to another user, there is no right to assign the file to itself, because the user is not the owner of the file at this time.
Example:
Chown Ekoala/usr/eee/ttqq, the meaning is to change the owner of/USR/EEE/TTQQ this file to Ekoala.
Id
Displays the user's system identity, reporting the user's name, user number, group name, and group number. Parameters:
Parameters
Description
-G
Print only group numbers.
-G
Only supplementary groups are printed.
-U
Print only the user number.
Such as:
[Ekoala@ttqq usr]$ ID
uid=10002 (Ekoala) gid=500 (student) groups=500 (student)
[Ekoala@ttqq usr]$
Displays your own user information.
passwd
The user password is maintained, and the system administrator can use this command to manage the user account. Usage:
passwd [user Name]
Only a system administrator can change someone else's password. Ordinary users can only change their own password. Such as:
[Ekoala@ttqq ekoala]$ passwd
changing password for Ekoala
(current) UNIX password:(Enter current password)
New UNIX password:(password)
Retype new UNIX password:(Confirm password)
Password:all authentication Tokens updated successfully(successfully changed password)
Useradd
Add a new user or change the user's existing information.
Userdel
Delete a user and all of his files.
Command for hard drive management and file compression
Df
Report the amount of space left on the hard disk. Parameters are:
Parameters
Description
-A
An optional list of file systems, he reports the amount of space on the remaining hard drives and, if this is blank, reports all of the file systems now installed.
-I.
Lists nodes using information instead of block usage information.
-K
Prints a block with a size of 1k in lieu of 512k.
-T Fstype
Restrict list of file systems for Fstype type only.
-X Fstype
Restrict listing of Fstype file systems only.
Gzip
Gzip is a very popular compression tool that he usually uses with the TAR command. Grammar:
gzip [parameters] file list, parameters are:
-A
ASCII text mode: According to the agreement to transform the end of the file flag, this option only supports non-UNIX operating system, in the MSDOS, carriage return and line break in the compression is converted to line characters, decompression time and then converted 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
Uncompressed.
-F
Force compression.
-L
Detailed display of file compression:
1, the size of the compressed file.
2, the size before the uncompressed.
3, compression ratio and compressed file name.
4, if used with the-v argument, the following information is also displayed:
A, compression method.
B, 32-bit CRC code for uncompressed data.
C, the time the file was changed.
-Q
Does not display all warning messages.
-R
Recursive compression directory structure.
Tar
Tar is a popular file backup and compression tool for building system backups or creating a single file. The grammar of tar is troublesome and is briefly described as follows:
Tar crtux[fmtvwf] File list. Parameters are:
Parameters
Description
Parameters
Specifies the file to be obtained, which can be the following parameters.
C
Create a new file or overwrite an existing file.
R
Name in the file list.
A
Add files to the backup package.
T
Lists a list of compressed files.
U
Unzip the file from the compressed file.
File list
The list of files to process, which can include wildcard characters. If you are working with a directory, then the directory and all the files and folders under it are processed.
-B
The default value for the specified chunking quantity n,nx512k,n is 20.
-M
Tell tar to decompress without the need to modify the time, the modified time is the time to decompress.
-C Directory Name
Change the directory.
-K
Preserves existing files and does not overwrite them from the compressed file.
-V
Generates a compressed file with a volume label.
-Z
Unzip the file using gzip.
For example, to unlock a compressed file called 9s.tgz:
Tar zxvf 9s.tgz
For example, to package all the files under/home/bbs into bbs.bak.tgz, you can do this:
Tar zvcf bbs.bak.tgz/home/bbs/*
Network Related commands
This section of the content is very small, but simply introduced to the personal user useful commands, although the biggest feature of Linux is his network function, but most of them are too powerful, if you want to study carefully, please refer to the relevant books.
Login
Login is used to log on to a host, or it can be used to move from one user to another, a bit like the SU command, but he uses more than Su. Grammar:
login [parameters] [host name] [user name], the parameters are as follows:
Parameters
Description
User name
If no arguments are given, login requires a username.
-P
Preserve environment variables.
-F
Ignore the second logon certificate.
-H
Telnet to another host.
Ping
As with DOS, it is used to check whether the physical network between two networked computers is unblocked, and this command is generally used to check for network failures.
The ping command sends the ICMP (Internet Control messeges Protocol) package to the network host and requires the target host to respond. Parameters are:
Parameters
Description
-C
The host receives a response that stops.
-F
Flood-type contract, once received the host response on the contract, or 100 packets per second. Note that only Superuser can use this command, and this command will adversely affect the network.
-I.
Wait one second for each packet.
-L
To force the fastest speed of the contract. This command can only be used by super users.
-S PacketSize
The size of the custom package.
Other commands
Time
Determines when a program executes. Grammar:
Time [command]
Uname
Report system name or other kinds of information. Grammar:
uname [Parameters]
Parameters
Description
-S
The system name is reported, which is a default value.
-N
The node name of the reporting system.
-R
The issue number of the reporting system.
-V
The version number of the reporting system.
-M
Reports the hardware name of the system.
-A
Report all information.
History
Displays the history of the user's command line.
VI use
To configure the system, you must first learn the text editing commands, because the main configuration work is nothing more than editing text files. The oldest and most popular text editor in UNIX or Linux is VI. So to understand the use of VI is still necessary, although for beginners may be difficult, but slowly accustomed to later, you will find VI is actually a very useful and powerful editor.
VI Introduction
VI is a ubiquitous, full-screen text editor in the Unix world, almost any UNIX machine that can provide this software, and Linux of course. Familiar with DOS text editor such as edit, will feel VI is not good, UNIX does also develop a lot of new, more powerful editor, but not to ensure that every machine has. Therefore, familiar with the operation of VI is still necessary. This allows you to be handy on a different machine. The basic concept of the
VI
as long as the implementation of VI can enter VI editing environment. It would be nice to have a rough understanding of the actual operation. There are two modes of VI: Input mode and command mode. Input mode is used to enter text data, and the command mode is to release some choreography files, archive and leave VI Operation command, when the implementation of VI, first enter the command mode, at this time any characters entered are considered as commands, in the input mode to enter the command mode can press "ESC", if you do not know now in what mode, A few more times the "ESC" system will emit a "beep" sound in order to enter the command mode.
Enter and leave
to enter VI as long as you enter the vi< file name >,vi can help you automatically load the file you want to edit or create a new file. After entering VI, there will be some wave number on the left side of the screen, which indicates that the column is empty at the beginning. To leave VI can be in the command mode to enter ": Q", and ": Wq" is archived after leaving, into the ": q!" is forced to leave. How do I enter the
VI input mode
? There are several commands to enter into the input mode (note that the case is separate):
Add, press A, and add new data from the cursor position. Press A to add additional information from the column following the cursor.
Insert, press I, and start inserting the data from the front of the cursor position. Press I to insert data from the front of the first non-white-space word in the column where the cursor is located.
Start, press O to add a column from the cursor's column and enter the input mode. Press O to add a column above the column where the cursor is located and enter the input mode.
VI's basic editing commands:
Command
Description
X
Deletes the character that contains the cursor.
Dd
Deletes the row where the cursor is located.
R
Modify the character of the cursor, and then the character to be changed.
R
When you enter the superseded state, the new text overwrites the original text until you press ESC to return to command mode.
S
Deletes the character of the cursor and enters input mode.
S
Deletes the character of the column that contains the cursor and enters input mode.
OK, here is the simple usage of VI, I believe these for simple configuration system should be enough. Because most of the time believe that we are under the Xwindows, no one will always be on that dark screen: