Linux system Administrator Technology (Admin)-------Fourth day

Source: Internet
Author: User
Tags bz2 stdin yum repolist chrony



??

?/etc:linux System Configuration File


Configure the following static address parameters for the virtual machine server

– Host Name: server0.example.com

? ? – IP Address: 172.25.0.11

???? – Subnet Mask: 255.255.255.0

– Default gateway: 172.25.0.254

[[Email protected] ~] #nmcli connection modify ' System eth0 '?

? ? ? ? ? ? ? ? Ipv4.method manual??????????? #手动配置参数????????

? ? ? ? ? ? ? ? Ipv4.addresses ' 172.25.0.11/24? 172.25.0.254 '

? ? ? ? ? ? ? ? Connection.autoconnect yes?????? #每次开机自动启用


3. Activating the network configuration

[[email protected] ~]# nmcli connection up ' System eth0 '


–dns Server: 172.25.254.254


[[Email protected] ~] #cat/etc/sysconfig/network-scripts/ifcfg-eth0------View network card information

[[Email protected] ~] #cat/etc/resolv.conf-------View DNS service information


Testing the DNS Resolution service

[[Email protected] ~] #nslookup server0.example.com?



###################################################

Building a yum Warehouse


[[Email protected] ~] #rm-rf/etc/yum.repos.d/*


[[Email protected] ~] #vim/etc/yum.repos.d/abc.repo

? ? ? "ABC"

???? name=abc

???? baseurl=http://172.25.254.254/content/rhel7.0/x86_64/dvd/

???? enbaled=1

???? gpgcheck=0

[email protected] ~]# Yum Clean all


[email protected] ~]# Yum repolist


#################################################



?? View Text File contents


? Cat?:? Suitable for viewing files with less content

? Less: good for viewing files with more content


Look at the text file part of the content

? ??

? ? ? Head?-n? :? first few lines

? ? ? Tail-n??: Tail Lines


?? View Time

?? date


?? calculator

?? BC


######################################################


Pipe: The output of the preceding command is processed by the following command as a parameter of the following command


? ? Display/etc/passwd text content 8--12 line?

[[email protected]/] #nl/etc/passwd or cat-n/etc/passwd-----Indicates the number of rows displayed

[Email protected]/]# HEAD-12/ETC/PASSWD | Tail-5-------Take out the first 12 lines and take the five elements out through the pipe.

[Email protected]/]# Cat-n/etc/passwd | head-12 | TAIL-5-----Front Plus line number, take the first 12 lines out, in the pipeline to take out the five elements


[Email protected]/]# Cat-n/etc/passwd | Less

[Email protected]/]# echo | BC----ECHO Print

[Email protected]/]# echo 8*8 | Bc


[Email protected]/]# ifconfig? | Head-2


######################################################

?? grep: View the contents of a text file, displaying the line containing the specified string


? ? ? –grep? [Options]? ' Match string '?? Text File ...

??

[[email protected]/]# grep ' root '?/etc/passwd------"grep" represents the meaning of the filter and takes the key fields out to view

[[email protected]/]# grep ' man '/etc/man_db.conf?

[[email protected]/]# grep ' root '/etc/passwd displays all the root-containing

[Email protected]/]# grep-i ' Root '?/etc/passwd? #忽略大小写

[[email protected]/]# grep ' root '?/etc/passwd

[Email protected]/]# grep-v ' root '/etc/passwd? #把不包含Root的行都显示出来


#################################################



? –^word? Start with a string word

–word$? End With string word


[[email protected]/]# grep ' ^root '/etc/passwd

[[email protected]/]# grep ' root$ '?/etc/passwd

[[email protected]/]# grep ' bash$ '?/etc/passwd

[[email protected]/]# grep ' ^$ '?/etc/default/useradd--------match blank lines to indicate a blank line in a text

[[email protected]/]# grep-v ' ^$ '?/etc/default/useradd------Remove empty lines so that blank lines no longer appear


???? Regular expression:? To express what you think in a descriptive language


? Remove comments and blank lines to show valid data:


? ? ? ? ? ? ? ? ? ? ? ? ? [[email protected]/] #grep-V ' ^# '/etc/login.defs? | ? grep-v ' ^$ '


##################################################### ? ? ?



Find Files by criteria

? Find the corresponding file recursively according to the preset conditions


–find? [catalogue]?? [Condition 1]?

– Common conditions indicate:

-type type (f file, D directory, L shortcut)

-name? " Document Name "

? ? -size +|-File Size (k, M, G)

-user? User name



[Email protected]/]# find/boot/?-type l

[[email protected]/]# ls/boot/grub/menu.lst----display content in short format

[[email protected]/]# ls-l/boot/grub/menu.lst---Display content in long format


[[email protected]/]# find? /boot/? -type? F Find all files in boot

[[email protected]/]# find? /boot/? -ty

PE? D



[[email protected]/]# find/etc/?-name "passwd" find the passwd in etc

[Email protected]/]# find/etc/?-name "*tab*"


[[email protected]/]# mkdir/root/install----mkdir Create a directory

[[email protected]/]# Touch/root/install.log---Touch to create a file?

[Email protected]/]# Touch/root/install.bak

[Email protected]/]# find/root-name "install*"


[Email protected]/]# find/root-name "install*"?-type D

[Email protected]/]# find/root-name "install*"?-type F



[Email protected]/]# find/boot/-size +10m

[Email protected]/]# find/boot/-size-10m



Use the--exec operation of the Find command-----(-exec)----equivalent to the ' | ' Pipeline Transportation

–find. .. -exec processing command {} \;


# find/boot/-size +10m

# find/boot/-size +10m? -exec? cp-r? {}?/opt/? \;

# ls?/opt?


# find/etc/?-name "*tab"

# find/etc/-name "*tab"?-exec cp-r? {}?/mnt/? \;

# LS?-a/mnt---Show all files including hidden files


##################################################


# Mkdir/root/findfiles


# Find/-user Student-type f-exec cp-r {}/root/findfiles/? \;-----Find student This user file and copy it into Root/findfiles




###################################################

? user and Group management

?

? User account:?

????????? 1. Can login the operating system??

????????? 2. Access control (different user rights are different)?

?

? Group accounts: Easy to manage user accounts (permissions)

? User account and group account unique identification:? Uid? Gid??

? The Administrator uid is: 0


?? Group account: Basic group?? Additional groups (public groups? Subordinate groups)


##################################################


? Using the Useradd command

–useradd [Options] ... User name


? Common Command Options

–-u User ID,-D home directory path,-s login shell

–-G Basic Group,-G additional Group



[[email protected]/]# ID NSD01



[Email protected]/]# grep ' nsd01 '/etc/passwd? #用户基本信息

Nsd01:x:1002:1002::/home/nsd01:/bin/bash


User name: Password placeholder: uid:gid: User's description: Home directory: Interpreter


[Email protected]/]# useradd? nsd01

[email protected]/]#? ID? nsd01?

[[email protected]/]# grep? ' NSD '?/etc/passwd?


[Email protected]/]# useradd-u 1100 nsd02?? #指定UID

[[email protected]/]# grep? ' NSD '?/etc/passwd?


[Email protected]/]# useradd-d/op/haha nsd03? #指定家目录

[[email protected]/]# grep? ' NSD '?/etc/passwd?

?? Specify the Login interpreter program

[Email protected]/]# useradd-s/sbin/nologin nsd04?

[[email protected]/]# grep? ' NSD '?/etc/passwd

?

? Cannot log on to the operating system if the user's interpreter program is/sbin/nologin




[Email protected]/]# useradd-g nsd01 nsd09

[[email protected]/]# ID nsd09


[Email protected]/]# useradd-g nsd01? nsd10

[[email protected]/]# ID NSD10



#############################################


? User password information stored in the/etc/shadow file


Using the passwd command

–passwd [user Name]

–echo ' password '?? | ? passwd?--stdin? User name


? Supplemental command: command to temporarily switch user identities

[[email protected]/]# su?-? user name


[Email protected]/]# echo 123 | passwd--stdin NSD01

[Email protected]/]# echo 123 | passwd--stdin nsd02


[email protected]/]# su?-? nsd01

[Email protected] ~]$ passwd?

[Email protected] ~]$ exit?????? #退回到root


[Email protected]/]#


####################################################


Modify User Properties

? Using the Usermod command

–usermod [Options] ... User name


? Common Command Options

–-u User ID,-D home directory path,-s login shell

–-G Basic Group,

–-g additional Groups



[Email protected]/]# Useradd nsd11

[[email protected]/]# grep ' nsd11 '/etc/passwd


# usermod-u 1200-d/opt/test?-s/sbin/nologin nsd11


[[email protected]/]# grep ' nsd11 '/etc/passwd


#####################################################

Delete User

? Using the Userdel command

–userdel [-r]? user name? #并且删除家目录


? Common tip: Insufficient permissions

? Permission denied



#####################################################


Group account Management


Add Group

???? Group basic information is stored in the/etc/group file

[Email protected] ~]# head-1/etc/group

root:x:0:

?

? Group name: Password placeholder: GID: Group member list


? Using the Groupadd command

–groupadd [-G group ID]? Group name


[Email protected] ~]# Useradd Kenji

[Email protected] ~]# Useradd Tom

[Email protected] ~]# Useradd Kaka

[Email protected] ~]# Useradd Henter


[Email protected] ~]# Groupadd? Tarena


[[email protected] ~]# grep ' Tarena '/etc/group

TARENA:X:1110:


?

Using the GPASSWD command


–GPASSWD-A user name? Group name

–gpasswd-d user name? Group name

–gpasswd-m ' user name, user name '? Group name? #可以添加多个


[Email protected] ~]# grep ' Tarena '/etc/group? #查看组信息

[Email protected] ~]# gpasswd-a Kenji Tarena? #加入组成员

[email protected] ~]# ID Kenji?


[Email protected] ~]# gpasswd-a Tom Tarena

[[email protected] ~]# grep ' Tarena '/etc/group


[Email protected] ~]# gpasswd-a Kaka Tarena

[[email protected] ~]# grep ' Tarena '/etc/group


[Email protected] ~]# gpasswd-d Kenji Tarena? #删除组成员

[[email protected] ~]# grep ' Tarena '/etc/group


[Email protected] ~]# gpasswd-m ' Kenji,henter ' Tarena

[[email protected] ~]# grep ' Tarena '/etc/group


[Email protected] ~]# gpasswd-m ' Kenji,kaka,tom,henter ' Tarena

[[email protected] ~]# grep ' Tarena '/etc/group

[Email protected] ~]# gpasswd-m? ' Tarena

[[email protected] ~]# grep ' Tarena '/etc/group


Delete a group

? Using the Groupdel command

–groupdel Group Name

#########################################################

? Archiving and compression


? ? 1. Space saving

? ? 2. Facilitate the management of fragmented documents


? Tar Integrated Backup tool

–-c: Creating an Archive

–-x: Release Archive

–-f: Specify the archive file name

–-z,-j,-j: Calling the. gz,. bz2,. xz Format tools for processing

–-c (UPPERCASE): Specify the release location


–-t: Displays a list of files in the archive

–-p (uppercase): Keep the absolute path to the file within the archive


[Email protected] ~]# rm-rf/opt/*

[Email protected] ~]# rm-rf/mnt/*


# tar-zcf/opt/file.tar.gz/boot//ETC/PASSWD


[Email protected] ~]# ls/opt


[Email protected] ~]# tar-xf/opt/file.tar.gz?-c?/mnt


[Email protected] ~]# ls/mnt


[Email protected] ~]# ls/mnt/etc

[Email protected] ~]# Ls/mnt/boot



? Use tar-c ... Command

–tar-zcf? backup files. tar.gz? The document being backed up ....

–tar-jcf? backup files. tar.bz2? The document being backed up ....

–tar-jcf? backup files. tar.xz? The document being backed up ....


[[email protected] ~]# tar-tf/opt/file.tar.gz??


Use BZIP2 compression to package and compress in absolute path mode


# TAR-PJCF,/root/backup.tar.bz2?????/usr/local/

# ls?/root/

# TAR-TF,/root/backup.tar.bz2????? #查看包里面内容


? ? -Z? represents gzip compression format

? ? -j? represents bzip2 compression format

? ? -j? Represents the XZ compression format

###################################################

NTP Network Time Protocol

? Network Time Protocol

–NTP Server provides standard time for clients

–NTP client need to maintain communication with NTP server?


????? package, configuration, service?


? One, the server, the Linux system on a software


? ? NTP time synchronization server, classroom

? ?


? II. client server, installing client software

?

? RHEL7 Client's School Time service

– Package: Chrony

– Configuration file:/etc/chrony.conf

– System Services: Chronyd


[Email protected] ~]# rpm-q chrony

Chrony-1.29.1-1.el7.x86_64


[Email protected] ~]# vim?/etc/chrony.conf

? #server 0.rhel.pool.ntp.org iburst?? #注释

? #server 1.rhel.pool.ntp.org iburst?? #注释

? #server 2.rhel.pool.ntp.org iburst?? #注释

172.25.254.254 iburst????? #指定服务端IP地址

.......


[Email protected] ~]# systemctl restart? chronyd? #重起服务

[Email protected] ~]# systemctl? Enable Chronyd? #设置开机自起


? Verify:


[[Email protected] ~]# Date


[Email protected] ~]# date-s "2008-09-08 11:11:11"? #修改时间


[[Email protected] ~]# Date

[[email protected] ~]# systemctl restart chronyd #重起服务, sync


[[Email protected] ~]# Date

[[Email protected] ~]# Date

[[Email protected] ~]# Date














Linux system Administrator Technology (Admin)-------Fourth day

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.