Linux Learning Note 1

Source: Internet
Author: User

Label:

First day

1. The relationship between system software, application software, users, etc.
??????
The shell is communicated to the user. It deals with users in the form of commands. We win7 and so on to use the graphical interface to deal with users.
2, for example, bash----> corresponds to a shell, each shell can be understood as the name of the command. CTRL + C indicates terminating the current command.
???? A terminal has at least one shell, which is bash by default. The root user is root in the administrator. Has the highest permissions.
???? EXEC Ksh says to switch to Ksh, the shell.
3, Linux is a file system. Anything can be found. All the documents are in one.
?????? The path to the file can be expressed as:/dev/dri/...? These are strictly case sensitive.
? 4, absolute path and relative path
???? An absolute path is the starting position of the file. What it is is what it is. and the relative path is that we artificially set the current path to the current working path. In this environment in the future operation will be OK.
? 5, a few small orders
? 1) Clear the screen?? Clear? or ctrl+l?
? 2) Show process status? Ps? : Print status There will be a process each time the program executes. The process number is unique in the terminal. Pts/2? Represents the process ID.
????? Print the current working directory?? Pwd:print working directory.
?????? Change the current working directory Cd:change directory. Go directly to the home directory. If the path is not taken, it is a relative path.
????? ~: Represents the home directory.?.: Represents the current directory.??..:Represents the previous level of the directory... /.. :?Represents the previous level on the previous level.
? 3) List of files? Ls:list?.
?????? You can also log in to the remote terminal: Telnet 192.168.0.20? Then enter username?? passwd or something like that. However, you can only modify your own password.
? 4) Displays the system time command date.

Note: commands are available with parameters and options. Command? [Options] ... [Parameters] ...
5) User Manual of the command: with Man +? Command. View all usage of the command. Manual pages.? Press Q (quit) to exit the user manual page.
6) ID is available for viewing. There is a user ID, group ID. We can also man man? ; man ID a bit ...


Summary: 1, the Linux file system as a whole. 2, absolute path with/head. It is a tree-like structure starting with/. 3, the relative path is the tree structure starting from the current path.? 4, CD./abc? 5, username passwd uid GID 6, Shell is the part that interacts with the user, then the shell forwards the command to the kernel, then the kernel returns to the shell and communicates with the user.
Command:?? PS??;? ID?;?? pwd;?? Man;? ls?;? clear?;? Crtl + l?.
?

The so-called command is actually some executable file, similar to the. exe. Located in the./bin directory. Can we use ??

Ls-l/bin? Command,-L arranges the files in a horizontal form.



Ls-f?/bin?? command,-f is the tag file. Where @ means a soft link (that is, a shortcut) * represents an executable file.
A similar, ls-a? Lists all files and directories. Where the. Heading is the hidden file.? In Windows, it is distinguished by attributes.


How to switch from the command line interface to the graphical interface: STARTX

?

Second Day

1, Ls-al?? Displays the file properties. The normal file "---" begins.
????????????????????????????????????????? The directory file "D" begins.
???????????????????????????????????????? The. exe file "L" begins.
???????????????????????????????????????? The pipe file "P" begins.
?????? LS-LR???? /bin????? The meaning of reverse. Reverse the file order.
?????? Ls-r?? Lists the total number of directories in the current directory. The first level of ...
2, hard connection and soft connection? :
????? A hard connection is an individual name for a file, which is actually a reference.
????? A soft connection is a shortcut.
???? Command: LN? -s/bin/sleep?? BS (soft link)
???????????????? ln????? /bin/sleep??? BS (hard link)
???????????? And then?? Sleep 5?=?? ./bs 5?? (associated with Path)
????? The end of the directory name/optional. When the number of hard links becomes 0, it means that the contents of the file are completely deleted.
3. Permission commands:
?????

Each level can be divided into 3 levels. W? R? X
Readable?? Wtitable?? Execute. Readable, writable, executable
Change Permissions command: chmod? Ugo +???????? (User, grid, outer)
Change? +? "-" means remove permission. "+" means plus permissions.
chmod? U-w,o+r, G+w Z.
So, we can also use digital representation:
chmod? 755 Z;


chmod a + x z?? Note: a = Ugo.

4. Create a Directory
??? Mkdir?? Da dd DC?;? Make?directory.?
??? Mkdir?? Dd/de?? If DD already exists.
?? Mkdir?? -P? Dd/df/dv?; Create multi-level catalogs. DD,DF can not exist.
?? We can use LS-R dd to view all the layers under DD.
5. Document creation
??? Touch? F1 F2 F3 f4
?? Touch Da/f7;? The premise is that da must exist or not be built.
? We usually start with the CD command, specify the current directory, and then create the file. The file created by the general touch is an empty file.
How to create a non-empty file???
6, expand the document establishment
? >???、? >>?
Date?> xy?? ;??? Write the contents of the left command output to the XY (right) (current directory) file.

Two special files: date >/dev/tty; Represents the output to the terminal.
????????????????????????????? Date?>/dev/null?; represents an empty file. All the devices in Linux are treated as files. Do not fill the discontent.

Cat? Xy? ;? View the contents of XY.
How do I not change the XY content and then append the content?
PWD >> xy; indicates that the output from the left command is appended to the right file.
7, how to free the output anytime, anywhere?
A few small commands: Cal? (calendar) Calendars.
Cal Ten??? ; View the October 2010 calendar. Must be in the order of the month and year.
More free output command: Echo
8. How to execute multiple commands
? date;sleep 5;date?? ;? To separate or divide.

9. Move, delete, and copy commands.
???? Mobile: MV? (move)
??? MV x DA?DC?; move the X and Da to the DC folder.
???? MV DB? Da/d2??? ;? Move the DB to the D2. and renamed DA. You can rename a file or directory only when you move it. Multiple cannot be renamed.
??? Mv?xy xy99;?? Moving files is equivalent to renaming.
?????
????? Copy: CP (copy)
???? For file with CP?
????? For directories with Cp-r?? With-I? To be used to prompt and interact with the user. Interactive (interactive)?
?????
????? Delete: RM?
?????? For catalogs with rmdir?
?????? For files (directories)? Rm? (-R)??
????? Rm-ri? DC?;? Is the interaction deleted?

Summary: 1, look at the catalogue ls? 2, see the file cat?? (Use a cat to catch a file)
??????????? 3, >> append??? ?? Write it in.
???????????? 4. Soft and hard links? Ln-s??? Xx?? xx?;?? Hard links must be in the same partition.
??????????? 5, Mobile MV? Copy CP?? Delete RM

?

Third Day

1, editor?
?? 1) gedit? : graphical interface processing. Not much to say.

?? 2) Kate?? : graphical interface processing. Not much to say.
?

Cat? Katefile?
3) Vim? Vi?
??? Visual editor
????
: q! Indicates a forced exit.

? Shortcut keys:
To move the cursor command:
At the beginning of the line: O?????????? I????? Note: o means inserting a new line.??????????
At the end of the line: $?????????? A????????????? Home End
The first line of the whole: H?, X+h, represents the X line that moves to the screen.? the whole tail line L? is similar.
Note: This function key can also be used.
CTRL + F, move up one page in the file (PageUp)
CTRL + B, move down one page in the file (PageDown)
: 8? Go back to line 8th. : + x indicates to a row.
8 + g/m: Indicates to a row to go.
Direct g to the end of the file. 1G to the first line. Similar to the role of H.
W move the cursor to the beginning of the next word. {The case is recognized}
B move the cursor to the beginning of the previous word. {The case is recognized}
: Set NU Displays line numbers. : Set Nonu does not display line numbers.
The arrow keys can also be used.

Replace and delete:
Common Delete command??
? ? Remove a character: Delete???

??????????????????????????????? , Long press to delete more than one character.
The number + x, which indicates the number of characters that the delete cursor points to. Does not affect the other row. U means you can recover once.
D + W, delete the word that follows the cursor.
d+ B, delete the word in front of the cursor.
DD itself is deleted. Delete a row. Number + DD
: 9,18? means delete 9-18 rows.

Paste and copy

P, in fact, after 3x, the deleted characters are in the VI Visual Editor's clipboard. P is inserted after the cursor. P is inserted before the cursor.
Number +p: Indicates the number of times the paste was pasted.
YL indicates that a character is copied. 3yl means to copy 3 characters.
YW copy a word, yy copies a line.

Replacement:Character: 8rk: replace 8 K. Replace
The.????????????? CW + Word.? will go directly into the insert state.
~?: Indicates case reversal. J? : Connect two rows.
C and S: Change a character to a piece of content. C and S after entering insert mode. The cursor becomes the $ symbol.

find:?
? ? ? ? ? / ? : Represents the lookup, looking backwards from the current location. N (EXT)?: N, means to continue searching.
??????/str1? : The forward lookup string str1. ?
"????" N????: Continue to find.
? ? ? ? ? Str1?: Reverse lookup.

Undo and Redo???
U: Undo the result of the previous command.
.?:? Repeat the last command.

Insert File
?: R xyz? Inserts the current file after the cursor position.
Replace
Implement a string substitution??? : 5-8 s/wf/wife/g?? In line 5-8, replace WF with your wife. G represents all occurrences of the character.
: s/str1/str2/?? ? No G represents the first occurrence of a character.
: 5,$? s/str1/str2/g? Represents the str2 substitution from line 5th to the end of all occurrences of str1.
:% s/str1/str2/g? Replace All.
Save at exit??
: W? Represents the Save VI file. : W. SaveAs? + name. Represents a Save As.
: Q? Represents the Exit VI file.?
: Wq Save and exit.

the switch between Shell and VI
:! ?? Command????:! LS will display the content in the terminal.

?

Fourth day

1. Deepening of some commands
Ps-l? Show? process ID PID?. Secondary process ID? PPID.?
Note: Who created a process, then who is the secondary process of this process.
s represents the state. The program is executed on a time slice.
Sleep state: S
Pending Status: T?
Running Status: R?

2. Create a background task
? Sleep &? Specify the ID.
Ps-e a little more detailed.
Zombie Process: The program is finished, but not recycled. into a Z state.
PS-E-L | grep z? Find the Z state.
Ps-f view command start time:
Ps-f-P? 1487: See who the parent process of the secondary process with process ID 1487 is.

3. View background tasks
Command: Jobs
Note: +-Represents the priority level.
4, put the command in front/background execution
FG, the default is "+". put in the foreground;
FG + number, which indicates which task is selected for execution. that specifies the task. F. Forward

BG + number, which indicates which task is selected for execution. and into the background to execute. B. Backward

4. Terminate the process
Kill? +? Process number. Some are deadly, some are not necessarily deadly.

For example: Sleep?100&??????? (Ctrl + Z?: Indicates that the process is suspended); Kill 9090?
Terminates the process by signaling.
Kill can also terminate the background process: kill% number.

5. Find
grep VS Find
grep: Search from file.
Find?? : + Table of contents + conditions [command]?? is found under the specified directory by criteria.
Find?. -name F1?: Finds the F1 file by name in the current directory.
You can also add a wildcard character. Find. -name f*;
Find. -name? " *.c "?-exec? CP {} DB \;?? Explanation: Exec represents the Toggle command, append command. {} Indicates the contents of all outputs preceding the command.
?\; The expression ";" itself, does not mean anything else. ";" indicates the end of the statement flag. We can use "\;", or we can use '; '. Because '; ' itself has a special meaning.
Someone: Who?。?
? See who is using this server. You can have the same user name, but the terminal number must be different.
Can only show themselves, who am??? only displays the user name? whoami
Only care about the user we can use the. Users?, to be more detailed, use the W command.
Find IP names in the same range: who | grep 192.168.24.

6. Some skills
? History command to view all previously typed commands.
! +? number; indicates that the command is re-executed.
In fact, the command history is in. Bash/history.

7. Disk-related commands
"Du?" (diskusage)?: View disk space usage.
? du-k?? : Displays space usage in kilobytes.
? du-h?? : Displayed space usage, all with units.
Du-h-S?: see only the sum used.

8. Commands related to Documents
DF (diskfile): View the usage of parts in the file system.
Df-h?: Take the unit and view the usage of each part of the file system.

?

?

Fiveth Day

1. Network-related commands
? ? ?
1) Ping to see if the parts are working properly. You can ping yourself, or you can ping other people's IPs.
2) View IP with Ifconfig. In Windows, use ipconfig.
3) FTP command:ftp> bye indicates exit.
? ? ? FTP environment, now generally use FTP software for file upload and download work.
???? Upload: Put + filename? Mput? means uploading many files.
??? Download: Get + file name???? mget There will be a reminder that prompt indicates a close prompt.
? Ftp>!ls? Represents the execution of viewing local files.
On the FTP server, we can also perform various operations on the file.
FTP > L CD? means go to the local directory. The local?! On behalf of the Local.?

Gftp tool to download and upload files.

2. Expansion of OUTPUT commands
?? Echo $UID

?

"X?"? The value may change. And the ' X ' value does not change. echo Output what is what.

3. Environment variables
Env (ironment): Environment variable.
The name of the $ + environment variable is the value of that environment variable.
? Several important environment variables:
1) PS1? Used to specify a command prompt; Echo? $ PS1
?
You can change its value, or you can change it back. But it must be taken as a whole. Otherwise, it won't.
2) Path: path.
? ? ? A command corresponding to the. exe, not from the current directory (path) down, but from the path directory (path) to find.
? Date? vs../da??
PATH =/bin:. ? Where. Represents the current directory. : Represents a separator, or connector, that plays an additional role.
At this point, it doesn't work to type LS anymore. LS It's original path in the/.BASHRC file.
Can we try to find?? Which/whereis cal? : Indicates the heap directory where the CAL is located.
Then add the path of the directory where it resides to path.
This is troublesome, we can use PATH = $PATH:.? To solve the problem.
But then, re-open the terminal, restore to the original state, the final symptom is not a cure, we want it to be valid, then you must write the above command to the initialization file. ~/.BASHRC? File: Represents a hidden file.
Here, we can also alias the command. Alias? c = Clear? Alias PS = "Ps-l"
In the initialization file, these commands (the new alias) remain valid the next time the terminal is opened.
4, how to open BASHRC?
With the order? VI ~/.BASHRC? (actually write a script file)? We can write our own script file with VI my.sh.
??????. my.sh indicates execution of this file. When we do not add source, the prompt permission is not enough, we can change the permissions through the command chmod.
??? ls-l my.sh? View permissions.
? ?
?? Note: When we execute VI my.sh actually my.sh has been produced.
? ? Role of backup: Bak = $PATH?; PATH = XXX; PATH = bak, preventing file corruption.?

Linux Learning Note 1

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.

Tags Index: