Getting Started with Linux foundation in

Fifth, under Linux to get help

  • No need to remember all the things
  • Linux provides extremely detailed help tools and documentation, we must develop the habit of check help document, you can greatly reduce the need to memorize things and improve efficiency

5.1、HELP

  • Almost all commands can use -h or --help parameter acquisition using the method parameter information.

5.2、MAN

  • man command is the most commonly used Linux help commands, will help to get the command as an argument to run the man command can get the appropriate documentation to help
  • man document is divided into many types
section Types of
1 User command
2 Kernel parameter called
3 Library Functions
4 Special files and equipment
5 File formats and specifications
6 game
7 Norms, standards and other pages
8 System Management page
9 Linux kernel API
  • man -k keyword, can be used to query documents that contain the keyword

5.3、INFO

  • info and man is similar, but more detailed in-depth information provided, displayed in the form of similar pages
  • info and man as can search by "/ + key" approach

5.4、DOC

  • Many programs, commands with detailed documentation to TXT, HTML, PDF, etc. stored in / usr / share / doc directory, these documents are the most detailed document corresponding program

Sixth, user and rights foundation

6.1, Linux user base

6.1.1 users, groups

  • When we use Linux, need to be logged in as a user, a process also needs to run as a user, the user can restrict users or processes to use, not which resources to use.
  • Group used to facilitate user management organization
    • Each user has a UserID, the actual use of the operating system user ID, not the user name
    • Each user belonging to a primary group, belonging to one or more affiliated groups
    • Each group has a GroupID
    • Each process running in a user's identity, and is subject to the restriction that users can access resources
    • Each user may have a login shell specified

6.1.2 User

  • 32-bit user ID, from zero, but in order, and is compatible with older systems, the user ID is limited to 60000 or less
  • Users are divided into the following three:
    • -root User: ID 0 for the user as root
    • User: 1 to 499
    • Ordinary users: more than 500
  • The file system has a user-owned and affiliated groups
  • Use the id command to display the current user information
  • Use the passwd command to change the current user password

6.1.3 Related Documents

  • / Etc / passwd store user information
  • / Etc / shadow save user passwords (encrypted)
  • / Etd / group information group saved

6.1.4 View user login

  • Whoami command displays the current user
  • Command who displays which users have logged in the system
  • W command displays which users have logged in and doing

6.1.5 Creating a user

  • Useradd command to create a new user
    • useradd nash_su, this command does the following:
      • Adding user information in a / etc / passwd in
      • 2 If you create a password using the passwd command, then the password is encrypted and stored in / etc / shadow in
      • 3 to build a new home directory for the user / home / nash_su
      • Copy 4 / etc / skel files to the user's home directory
      • 5 to establish a same as the user name of the user group, the new user default belongs to the group of the same name
  • Useradd command supports the following parameters:
    • -d home directory
    • -s login shell
    • -u userid
    • -g main group
    • -G affiliated group (up to 31, with "," to separate)
    • It can also be achieved by directly modifying / etc / passwd way, but is not recommended

6.1.6 modify user information

  • Usermod command to modify user information
    • usermod username parameter
  • Usermod command supports the following parameters:
    • -l new user name
    • -u userid 新
    • -d user's home directory location
    • -g user belongs to the main group
    • -G affiliated group the user belongs
    • -L Lock user can not log it
    • -U Unlock

6.1.7 Delete User

  • Userdel command to delete the specified user:
    • userdel nash_su (retain the user's home directory)
    • userdel -r nash_su (delete the user's home directory)

6.2, group

6.2.1 Group

  • Almost all operating systems have the concept of group by group, we can more easily classify, manage users. In general, we use department, function or classification created using geographical area group.
    • Each group has a group ID
    • Group information is stored in / etc / group in
    • Each user has a primary group, but also can have up to 31 affiliated groups

6.2.2 create, modify, delete group

  • Groupadd command to create a group
    • groupadd linuxcast
  • Groupmod command to modify group information
    • groupmod -n newname oldname modify the group name
    • groupmod -g newGid oldGid modifying group ID
  • Groupdel command to delete a group
    • groupdel linuxcast
  • Examples
    • There are three departments, each with two employees were creating groups and users below
先创建组:
groupadd training
groupadd market
groupadd manage

再创建用户:
useradd -G training nash_su
useradd -G training bob
useradd -G market alice
useradd -G market john
useradd -G manage steve
useradd -G manage david

6.3, Linux permission mechanism

6.3.1 authorization concept

  • Authority is the operating system used to limit the mechanism of access to resources, rights are generally divided into read, write, execute . Each file system has specific rights, their user and group ownership, to limit which users through such a mechanism, which set what kind of operation may be made to a particular file.
  • Each process is run as a user, so privileged processes with the user's permission, like large user privileges, the process has permission to large.

6.3.2 File Permissions

  • Linux, each file has the following three privileges:
Competence The impact of the document Impact on the directory
r (read) You can read the contents of the file To list directory contents
w (write) You can modify the contents of the file You can create delete files in the directory
x (execute) Can be executed as a command Accessible directory content
  • Directory must have x permission, or can not view its contents

6.3.3 UGO

  • Linux permissions control model based on UGO
    • U represents User, G Representative Group, O Other representatives
    • Each file permissions are set based UGO
    • A set of three permissions (rwx), respectively provided corresponding to UGO
    • Each file has a one owner and group, the corresponding UG, not an O or user permissions file belongs to the belonging group
  • Ls -l command to view detailed information of files in the current directory
    • drwxr-xr-- 2 nash_su training 208 Oct 1 13:50 linuxcast.net
      • d: File Types
      • rwxr-xr-- : UGO
        • rwx: U Permissions
        • rx: G permissions
        • r--: O permission
      • 2: the number of links
      • nash_su: U user belongs
      • training: G belonging group
      • 208: Size
      • Oct 1 13:50: Time
      • linuxcast.net: filename

6.3.4 modify the file belongs to a user group

  • Chown command to change your user files
    • chown nash_su linuxcast.net
    • All documents relevant to the user changes the parameters of recursive directory -R
  • Chgrp command to change the file belongs to the group of
    • chgrp nash_su linuxcast.net
    • Belongs to group all files under a directory to modify parameters of recursive -R

6.3.5 modify file permissions

  • Chmod command to modify file permissions

    • chmod mode file
  • Mode in the following format:

    • u, g, o representing users, groups and other
    • You may be able to refer to a ugo
    • +, - on behalf of accession or delete the corresponding permissions
    • r, w, x represent three permissions
  • Mode Example:

    • chmod u+rw linuxcast.net
    • chmod g-x linuxcast.net
    • chmod go+r linuxcast.net
    • chmod a-x linuxcast.net

  • Chmod command also supports digitally modify permissions, three rights are represented by the numbers:

    • -r = 4 (2^2)
    • -w = 2 (2^1)
    • -x = 1 (2^0)
  • When using the digital representation rights, each respectively corresponding to digital rights sum:

    • rw = 4+2 = 6
    • rwx = 4+2+1=7
    • r-x = 4+1=5
  • So, using numbers indicate permission to use ugo expressed as follows

    • chmod 660 linuxcast.net == rw-rw----
    • chmod 775 linuxcast.net == rwxrwxr-x
  • Example:

    • Suppose LinuxCast.net user groups were as follows:
    group user
    training nash_su, bob
    market alice 、 john
    manage steve 、 david
    • It is required for the department, staff work to establish the appropriate folder, requirements are as follows:
      • All directories, files stored in a single folder
      • Each department has a separate folder
      • Can not access their folders between different departments
      • Each employee has a department belongs in the folder where the folder
      • Between different departments with employees can view the contents of each folder, but can not be modified, the user can only modify their contents
groupadd training
groupadd market
groupadd manage

useradd -G training nash_su
useradd -G training bob
useradd -G market alice
useradd -G market john
useradd -G manage steve
useradd -G manage david

根目录下创建文件夹:
mkdir linuxcast.net

cd linuxcast.net

mkdir training
mkdir market
mkdir manage

chgrp manage manage/
chgrp market market/
chgrp training training/

chmod o-rx manage/
chmod o-rx market/
chmod o-rx training/

cd training/
mkdir nash_su
mkdir bob
chown nash_su nash_su
chown bob bob
chgrp training bob
chgrp training nash_su
chmod o-rx bob
chmod o-rx nash_su

cd ..
cd market/
mkdir alice
mkdir john
chown alice alice
chown john john
chgrp market alice
chgrp market john
chmod o-rx alice
chmod o-rx john

cd ..
cd manage
mkdir steve
mkdir david
chown steve steve
chown david david
chgrp manage steve
chgrp manage david
chmod o-rx steve
chmod o-rx david

6.4, Linux extended permission

6.4.1 Default Permissions

  • Each terminal has a umask attribute, to determine the new file, folder, default permissions
  • umask way represent digital rights, such as: 022
  • The default directory permissions are: 777-umask
  • The default file permissions are: 666-umask
  • Generally, the average user default umask is 002, the default umask root user is 022
  • That is, for the average user:
    • New file permissions are: 666-002 = 664
    • New directory permissions are: 777-002 = 775
  • Umask umask command to view the settings values
    • umask 022

6.4.2 Special Permissions

  • In addition to general permissions, there are three special privileges
Competence The impact of the document Impact on the directory
south The implementation of a user-owned files, rather than the implementation of user files no
sgid Run the file belongs to group identity It belongs to the group any new files created in that directory belongs to the same group to which the directory
sticky no The user has write access to the directory can only delete files they own, can not delete other files owned by the user
  • Set special permissions

    • Set suid: chmod u + s linuxcast.net
    • Set sgid: chmod g + s linuxcast.net
    • Set sticky: chmod o + t linuxcast.net
  • As with ordinary rights, special rights may also be used digitally representation

    • -South = 4
    • -SGID = 2
    • -Sticky = 1
    • So, we can set the following command:
    chmod 4755 linuxcast.net

Seven, Linux Network Basic Configuration

7.1, network infrastructure

7.1.1 network addressing

  • Network addressing is equivalent to home addresses and names, functions on the ID card is the only Internet to locate a device, can be a computer, can be a server or some other network service equipment, etc.

7.1.2 IP addressing

  • IP addressing is a two-layer addressing scheme, an IP address identifies a host (or network interface)
  • Now the most widely used is the IPv4 addressing, it has begun to switch to IPv6 addressing
  • 32-bit IPv4 address, IPv6 address is 128 bits long
  • An IPv4 address is divided into two parts: the network and host portions
  • Network part to identify the region belongs, the address corresponding to the ID; host part identifies the host to which the region corresponds to the identification name.

7.1.3 IP address

  • 32-bit IPv4 address total, usually represented in dotted decimal
  • Entire IP address is divided into four parts, each part 8
  • E.g:
    • ​ 192 . 168 . 1 . 1
    • 11000000.10101000.00000001.00000001

7.1.4 Subnet Mask

  • 32bit IPv4 address into the network and host portions
  • We determine the number of bits of the network portion of the subnet mask by
  • IP address and subnet mask, as has 32bit, and every IP address every one correspondence
  • IP address corresponding to a part of the network portion of the subnet mask
  • E.g:

    IP: 192 . 168 . 1 . 1

​ 11000000.10101000.00000001.00000001

Subnet Mask:... 2552552550

​ 11111111.11111111.11111111.00000000

  • Proof before this IP address is the network portion 24, that is to say, 24 before the same IP address of the other hosts on the same network with this IP address in order to prove they are in the same network
  • Example: to determine whether the same by comparing the network part is in the same network

As shown above, there are three areas in three segments, Beijing area network 192.168.1.0, / 24 subnet mask is short, the network 24 is representative of the front part, it is written in dotted decimal 255.255.255.0 host a, B, C are of 192.168.1.0 network, subnet mask representatives of a / 24 of, B, C, or other host as long as this is within the network, its front portion 24 or the first three 192.168.1 necessarily all, respectively .1, .2, .3 to identify this segment different hosts. Similarly, in the network is a network 172.16.1.0 Xi'an, is / 24 which represents the network all hosts front portion 3 are 172.16.1, respectively .1, .2, .3 to identify different hosts. That Shanghai area network 10.0.0.0 / 8, that is to say a first group of eight or dotted decimal or the first part of the first eight bits are used to specify that the network portion of the network is just part of the 10 binary . the beginning of the network belong to the same network segment, such as 10.0.0.1, 10.1.1.1, 10.100.32.45 are all belong to the same network segment.

7.1.5 the same communication between a network host

  • The same communication between hosts in the network also need to use a MAC address is addressing
  • MAC address is used for communication between hosts within a network of the same, usually within the same network are directly connected to the host
  • ARP: ARP

7.1.6 the communication between different networks

  • As long as not in the same network segment to access the network, you need to use a router to go forward, the router is the role of a middleman

7.1.7 Routing

  • Function between different networks to transmit data routing function is called, generally have a plurality of interfaces connected to different networks, and routing table to forward data,

  • Routing Table
Destination Network Subnet Mask The Interface
192.168.1.0 255.255.255.0 eth0
172.16.1.0 255.255.0.0 eth1
61.1.1.0 255.255.255.252 eth2
  • Usually refers to the gateway is an IP router.

7.1.8 Domain Name

  • IP addresses are often difficult to remember, so we generally use the domain name management, for example: www.baidu.com
  • The domain is divided into three parts, with the "." Separated
    • Type: identifies the type of the domain, such as: com, net, org, edu, gov, etc.
    • Domain Name: domain name, such as: baidu
    • Host name: A host name of the domain, such as: www
  • Domain names are not case sensitive

  • Hostname can be played with the change, the reason is because we all use www www convention is a web server, web server can not call the name, what can be called with change

7.1.9 DNS

  • Each domain name on behalf of an IP, and the DNS service is used between IP and domain name conversion

7.1.10 The basic network parameters

  • To configure a computer local area network communication:

    • IP addresses
    • Subnet Mask
  • To configure a computer to communicate across network segments:

    • IP addresses
    • Subnet Mask
    • Gateway
  • To configure a computer with internet access:

    • IP addresses
    • Subnet Mask
    • Gateway
    • DNS

7.2, Linux network infrastructure configuration

7.2.1 Ethernet connection

  • In Linux, Ethernet interfaces are named: eth0, eth1, etc., on behalf of the card number 0,1
  • You can view the card information via hardware lspci command (if it is usb card, you may need to use the lsusb command)
  • Ifconfig command to view interface information
    • See all interfaces ifconfig -a
    • ifconfig eth0 view specific interfaces
  • Command ifup, ifdown used to enable, disable an interface
    • ifup eth0
    • ifdown eth0

7.2.2 Network configuration information

  • Using the setup command to configure the network information, configure one or more network cards following steps,
    • setup -> Network configuration -> Device configuration -> eth0...(如果是多个网卡,第二次这个页面选择 New Device ) -> 按下键选到 Use DHCP 按空格键,默认选择的* 会消失掉 ,Static IP 输入:192.168.1.210,Netmask 输入:255.255.255.0,Default gateway IP 输入:192.168.1.1,Primary DNS Server 输入:61.134.1.4,还可以配置多个 DNS ,在 Secondary DNS Server 输入:210.30.19.40,设置完成后选择 OK 键,Select A Device 页面选择 Save 保存,再选择 SaveQuit 保存退出,最后选择 Quit 退出。(输入的 IP 地址要根据自己的实际情况输入!)
  • 配置完成后,使用 ifup 启用网卡,并使用 ifconfig 命令查看信息
    • ifup eth0

7.2.3 网络相关配置文件

  • 网卡配置文件
    • /etc/sysconfig/network-scripts/ifcfg-eth0
  • DNS 配置信息
    • /etc/resolv.conf
  • 主机名配置文件
    • /etc/sysconfig/network
  • 静态主机名配置文件
    • /etc/hosts

7.2.4 网络测试命令

  • 测试网络连通性 ( Ctrl + C 结束 )
    • ping 192.168.1.1
    • ping www.linuxcast.net
  • 测试 DNS 解析
    • host www.linuxcast.net
    • dig www.linuxcast.net
  • 显示路由表
    • ip route
  • 追踪到达目的地址的网络路径
    • traceroute www.linuxcast.net
    • traceroute www.douban.com
  • 使用 mtr 进行网络质量测试 (结合了 traceroute 和 ping)
    • mtr www.linuxcast.net

7.2.5 修改主机名

  • 实时修改主机名(重启后会恢复)
    • hostname train.linuxcast.net
  • 永久性修改主机名
    • /etc/sysconfig/network 文件下修改 HOSTNAME = train.linuxcast.net

7.2.6 故障排查

  • 网络故障排查遵循 从底层到高层、从自身到外部 的流程进行
  • 先查看网络配置信息是否正确
    • IP 网址
    • 子网掩码
    • 网关
    • DNS
  • 再查看到达网关是否连通
    • ping 网关 IP 地址
  • 再查看 DNS 解析是否正常
    • host www.linuxcast.net
    • host www.126.com
    • host www.douban.com

Guess you like

Origin www.cnblogs.com/duncan1863/p/11516096.html
Recommended