Linux Week Summary

Source: Internet
Author: User
Tags aliases echo command dns spoofing

One: the generation and development of Linux

1. In 1946 the University of Pennsylvania produced the first computer Eniarc. Operation 5,000 times per second but still defective. First, the user exclusive whole machine, resource utilization is low. Second CPU to wait for manual operation, CPU utilization is not sufficient.
2. Compatible time-sharing system and keyboard display and other terminals produce greatly improve the performance of the computer.
For 3.1965 years, Mutics plans to allow large hosts to support more than 300 terminals at the same time, and Bell Labs ' exit plan failed in 1969.
4.197 years, the Birth of Unix, 1974 public.
5.1978 years, SCO develops a commercial edition of Unix
For 6.1988 years, Microsoft developed Xenix.
7. Professor Ta Baum developed the Minix System (Unix-like system).
8.1991 years Linus Torvalds write Linux system.
9.1993 years, about 100 programmers involved in the Linux kernel code writing/modification work, at this time the Linux 0.99 code has about 100,000 lines, the user about about 100,000.
10.1994 years in March, Linux1.0 released a code volume of 170,000 lines, which was released under a completely free and free agreement, followed by a formal GPL agreement. At this point, Linux code development into a virtuous circle. Many system administrators begin to try Linux in their own operating system environment and submit the modified code to the core group. Because of its rich operating system platform, Linux code also enriches the support of different hardware systems, greatly improving the portability of cross-platform.

II: Installation of the operating system

Operating system Installation We do not repeat, detailed installation process please click the following link: Operating system installation Tutorial
Here I will talk about the problems I encountered during the installation process and how to resolve them:
Issue: Intel Vt-x is in a disabled state
Explanation: Intel Vt-x is virtualization technology, virtualization technology, and Intel Vt-x for better virtualization support in intel® processors helps improve the flexibility and stability of software-based virtualization solutions. In other words, a technology that supports multiple systems on a single CPU.
Workaround:
(1) Reboot the system and enter the BIOS
(2) Select the Advanced tab, select CPU Setup, press ENTER to enter
(3) Select Intel Virtualization Technology, select, press ENTER
(4) Select Enable, press ENTER to save the exit.

Three: Linux Basics 1: Terminal

Linux endpoints can be divided into the following categories:
(1) Device terminal: Keyboard, mouse, monitor.
(2) Physical terminal (/dev/console): Console console
(3) Virtual Terminal: A total of 6, of which one is a graphical terminal (CTRL+ALT+F1), the remaining terminals correspond to CTRL+ALT+F2~F6.
(4) Serial terminal (/dev/ttys#): Login via serial port, terminal name, Dev/ttys
(5) pseudo Terminal (Pty): A character or graphical interface to open the terminal.
(6) The terminal name of the current terminal can be viewed through the TTY command.

2:ssh

SSH is the abbreviation for Secure Shell, developed by the IETF Network Working group, and SSH is a security protocol based on the application layer and transport layer.
SSH is currently a more reliable protocol that provides security for Telnet sessions and other network services. The use of SSH protocol can effectively prevent the information leakage in the remote management process. All transmitted data can be encrypted via SSH, as well as prevent DNS spoofing and IP spoofing.
Another advantage of SSH is that the data it transmits is compressed, so it can speed up the transfer. SSH has many functions, which can replace Telnet and provide a secure "channel" for FTP, POP, and even PPP.
The client who wants to remotely control the server will install SSH: X-shell or SECURECRT.

3:shell

The shell is a human-computer interaction language and an interface between the user and the Linux operating system. It receives the command entered by the user and feeds it into the kernel. The shell, also known as the command interpreter for Linux, is a high-level programming language.

Example:
echo $SHELL View the current SHELL type
Cat/etc/shells View the shell installed by the current system

4: Command Prompt

Command prompt format:
[Email protected] ~]#
[user name @ hostname prefix directory path suffix]#|$ (Root is #, $ for normal user)
Echo $PS 1 shows the current prompt format
Ps1= "[\e[32m][\[email protected]\h \w]\$[\e[0m]": Change the command prompt color to red. (If you want the command prompt to change color all the time, say this command exists under the/ETC/BASHRC file)

5: Interior with external command (emphasis)

Internal commands: Commands that are integrated in memory, which are used very frequently.
External commands: Commands stored on the hard disk, which are not frequently used in such commands.
So how do you know if a command is external or internal? We can query whether the command is internal or external by using the Type command command.
We can also use the Enable command to activate, disable, and display internal commands:
Enable displays all the internal commands that have been activated
Enable command to activate an internal command that is disabled
Enable |WC-L displays the number of internal commands in the activation
Enable-a Show All internal commands
Enable-a |wc-l shows the number of all internal commands
Enable-n Show all internal commands that are disabled
Enable-n commands to disable an internal command
Command Lookup order Problem:
Example:
(1) Perform echo 123
(2) Disable echo
(3) Perform echo 456
It turns out that ECHO is disabled, but still prints 456 on it, and then queries echo with the type command, and finds that ECHO is hashed in the/bin/echo directory. When ECHO is disabled, it becomes an external command, and the system looks for echo from left to right according to the path variable, eventually finding echo under/bin/and storing it in a hash.
(4) Move the/sbin/ifconfig to/usr/bin under the name Echo
(5) Create a/root/bin directory, and move the/bin/echo into the/root/bin, and then execute the echo command result error, what is the reason? First, when the command is executed, the system first looks in memory for the internal command that was activated, and if it is not found in the external lookup, but because it has been looked over, and the search results (path) stored in the hash, because we have moved, the system will not be found.
(6) Hash-r empty the hash table, then execute the echo command
As a result, we found that the system gave us an IP address. This is because we emptied the hash table system to look for echo from the path variable and found echo under/usr/bin, but this is what we changed to check the IP. and re-exist in the hash table.
(7) Enable Echo to activate Echo and run the echo command. The output blank line was found because the internal command was activated and the system was re-located from memory, not looking for the hash table.
In summary, the system looks for the command in the following order:
Internal command
External command
Hash
PATH

6: Aliases

Alias displays all of the alias information
Alias aliases = ' command-option parameters '
Unalias aliases
Unalias-a Cancel All aliases
Save NANO/ETC/BASHRC for aliases
Ways to make commands unaffected by aliases
\command
' Command '
"Command"
/path/command

3 Effects of 7:$:

(1) $ () or ' reference ' to the result of the command execution
(2) $ (()) or $[] for operation
(3) Use ${} or "$ variable name" to delimit the starting and ending range of a variable name.

8: Directory Structure

(1) There are two types of data: data and meta-data, metadata refers to the file's permissions, file type, Uid,gid, data area location, size, time, number of file links and so on.
(2) The suffix name of the Linux file is not important.

9: Find Help

When we encounter forgetting some instructions, we can use the Linux system to find out the usage of the command.
For internal commands we can use the help command to find the use of the command.
For external commands we can use command--help to find
But there are some problems in this way, the search is not comprehensive, the triggering method is different, so we can use man to find
Man: A total of 9 chapters, namely user commands, system calls, C library calls, device files and special files, configuration file formats, games, miscellaneous, management commands and Linux kernel APIs.
The lookup command is in the form of Man "0-9". The command can also be used to extract keywords, page-flipping is also convenient.

10:inode and Block

When we look at the file, we will see the name of the file, but the computer is not the same, when he found a file from the file system based on the inode number to find the file, the name of the file associated with the inode number, an inode number can be associated with multiple filenames, according to the inode number system to find the location of the file. The Inode stores the metadata of the file, such as Uid,gid, file permissions, timestamps, and so on, an inode node associated with a file.
Block is where the file data is stored. A file may consist of more than one block, so there is a pointer in the block.

11: Hard links and soft connections

Hard Links:
Corresponds to a physical file on the file system, the number of links is incremented when a hard connection is created, the number of links is decremented when the file is deleted, and the file is deleted when the number of connections is reduced to 0 o'clock. It is important to note that hard links cannot span drives or partitions.
Soft connection:
A soft connection is related to the directory of a file, and can span partitions with a size that points to the length of the path string.
The main difference between soft and hard links is that the hard link refers to the inode number, after the creation of the file is not primary and secondary, delete the original file after the newly created file still exists. A soft connection refers to the directory of the source file, and the new file does not make sense when the source file is deleted.
How do I ensure that the soft connection created does not have an error? We can use the directory as a reference so that no error occurs.
ln filename linkname
Cannot span partitions
ln-s filename linkname
Can span partitions, source is deleted, links are not available

12: Input and output redirection:

Example: Echo 123 > Test.txt: redirect 123 output to Test.txt file
Echo 133> Test.txt: Redirects the 133 output to the Test.txt file and overwrites the previous file content 123
Echo 123 > >test.txt: Redirects the 123 append output to the Test.txt file. Do not overwrite.
Cat 11.txt 2> Test1.txt: If there is no file 11.txt, redirect the error output to Test1.txt.
Cat 11.txt 2>> test1.txt: If no file 11.txt is added, the error output is redirected to Test1.txt.
find/etc/-name "*.conf" &> find.all the correct result error result is entered into find.all together.
When a file does not exist, both,> and >> can create a new file, and the file already exists > indicates that the Overwrite,>> represents an append. Set-c can prohibit overwriting. Set +c: Overrides are suppressed. >| : Force overwrite.
2>&1 turns the wrong result into the right result
1>&2 turn the right result into the wrong result
Cat > File2.txt </etc/fastab: Outputs the contents of/etc/fastab to File2.txt.
Cat > File4.txt << EOF: Enter from the keyboard into the File4.txt file until you encounter EOF stop input, and EOF starts another line.

Four: Linux common command 1: User login Information view

WHOAMI display the current user name
Who am/are/is any character to display current terminal information
Who displays information about all terminals
W Display details of all terminals and actions taken

2: Set the time

Date 102,013,112,020,.45 Month day year [. seconds]
Date-s ' year-month-day time: minutes: Seconds '

3: Switch Machine

Poweroff shut down the machine
Reboot restart
Init 0 shutdown
Init 6 Restart
Shutdown-r restart
Shutdown-h shut down the machine
Shutdown +1
Shutdown 20:00
Shutdown-c canceling a scheduled shutdown

4:echo

echo is used to output on the terminal.
-E does not start to interpret the function, default
-N Not wrap line
-E Open Interpretation function ""
\a Warning Sound
\b Backspace
\c No Line break
\ nthe carriage return to newline.
\ r Enter, that is, the cursor moves to the beginning of the line, but does not wrap
\ t Insert tab
Insert

5:cp

Copy files and directories command: CP
(1) When the command is executed, if the target file does not exist, a target file is created and will be overwritten if the target file exists. If the target is a directory, create a new file in that directory with the same name as the original file.
(2) When the original file is a single file, the target file does not exist, the original file with the same name as the same content of the target file, when the target file exists, the original target file will be overwritten (the name is not necessarily the same, the content must be the same), when the target exists and is a directory, the original file with the same
(3) When the original file is multiple files, the target must exist and be a directory, in which a number of new files with the same name as the original file.
(4) When the CP source is a directory, at this point the command must use the-r option, if the target does not exist, create a directory with the same name, copy the source directory files to the directory. You must be a directory when the target exists, and in that directory you will create a new file with the same file as the source directory.
(5) Common command options
-I: Pre-overwrite hint –n: Do not overwrite, note both order
-R,-r: recursively replicate directories and all internal content
-A: Archive, equivalent to-DR--preserv=all
-d:--no-dereference--preserv=links does not copy the original file, only the link name is copied
--preserv[=attr_list]
Mode: Permissions
Ownership: Belong to the main group
Timestamp
Links
Xattr
Context
All
-P: Equivalent--preserv=mode,ownership,timestamp
-V:--verbose shows the process of copying
-F:--force when an ordinary user has RX permissions on a directory, use-F to force overwriting of files without modify permissions. The deletion is then created.
(6) Example:

6:TR command to replace characters

Example:
Tr [A-z] [a-z]: lowercase to uppercase
tr-d ASB: Removing ASB from a string
Tr-s 12: Remove Duplicates in string 1 2
TR-CD 12: Only 12 characters are reserved

7: Pipe

The pipeline can pass the standard output of the previous command to the latter command.
Example: LS | tr [A-z] [a-z]
2>&1 | or |& to pass all the results to pipeline processing

Five: Common shortcut keys
            Ctrl+L 清屏            Ctrl+O 执行当前命令,并重新显示本命令            Ctrl+s 锁定,但仍可以运行命令。            Ctrl+q 解锁            Ctrl+C 强制结束            Ctrl+D 正常终止            Ctrl+Z 挂起(暂停)命令            Ctrl + a 光标移到命令行首,相当于Home            Ctrl + e 光标移到命令行尾,相当于End            Ctrl + xx 光标在命令行首和光标之间移动            Ctrl + u 删除光标之前的内容            Ctrl + k 删除光标这后的内容            Alt + r 清除全部内容            Alt + N 提示输入指定字符后,重复显示该字符N次(N表示具体的数字)
VI: summary
    在这一周的学习中,我学到了很多Linux的基础知识,这些知识不难,但很零碎,而且需要记忆。同时在学习的过程中也不能一昧死记硬背,要理解的同时合理使用man功能。在学习的过程中也出现了很多错误,在练习的过程中也有很多和老师演示不同的情形,这些都要理解透彻,搞明白。这样才能更好地提高自己。

Linux Week Summary

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.