# alias
# alias copy='cp'
# alias
# unalias copy
# alias
# ls /etc/bashrc /etc/profile
# ls ~/.bashrc ~/.bash_profile
# vim /etc/bashrc
...
alias psa='/bin/ps -aux'
# psa || echo no
<Ctrl+D>
# psa
# ip a s
# ping6 fe80::5054:ff:fe00:b || echo no
# ping6 -c 4 fe80::5054:ff:fe00:b%eth0
# ping6 -c 4 fe80::5054:ff:fe00:a%eth0
# ping6 -c 4 fe80::5054:ff:fe00:b -I eth0
# ping6 -c 4 fe80::5054:ff:fe00:a -I eth0
[server0]
# nmcli dev status
# nmcli con mod 'System eth0' connection.autoconnect true ipv6.method manual ipv6.addresses fddb:fe2a:ab1e::0:64/64
# systemctl restart network
# ip a s eth0
# ping6 -c 4 fddb:fe2a:ab1e::64
[desktop0]
# nmcli con mod 'System eth0' connection.autoconnect true ipv6.method static ipv6.addresses fddb:fe2a:ab1e::0:65/64
# ifdown eth0 && ifup eth0
# ip a s eth0
# ping6 -c 4 fddb:fe2a:ab1e::65
# ping6 -c 4 fddb:fe2a:ab1e::64
# man -k nmcli
# man nmcli-examples
# man -k team
# man teamd.conf
[server0]
# nmcli dev status
# man nmcli-examples | grep $.*team
# man teamd.conf | grep back
# nmcli con add type team con-name Team1 ifname Team1 config '{"runner": {"name": "activebackup"}}'
# nmcli dev status
# ls /etc/sysconfig/network-scripts/ifcfg-*
# nmcli con add type team-slave con-name Team1-slave1 ifname eth1 master Team1
# ls /etc/sysconfig/network-scripts/ifcfg-*
# nmcli con add type team-slave con-name Team1-slave2 ifname eth2 master Team1
# ls /etc/sysconfig/network-scripts/ifcfg-*
# nmcli con mod Team1 connection.autoconnect true ipv4.method manual ipv4.addresses 192.168.0.11/24
# systemctl restart network
# ping -c 4 192.168.0.11
# teamdctl
# teamdctl Team1 state
# ifdown eth1
# ping -c 4 192.168.0.11
# teamdctl Team1 state
# ifup eth1
# teamdctl Team1 state
[desktop0]
nmcli con add type team con-name Team1 ifname Team1 config '{"runner": {"name": "activebackup"}}'
nmcli con add type team-slave con-name Team1-slave1 ifname eth1 master Team1
nmcli con add type team-slave con-name Team1-slave2 ifname eth2 master Team1
nmcli con mod Team1 connection.autoconnect true ipv4.method manual ipv4.addresses 192.168.0.10/24
systemctl restart network
ping -c 4 192.168.0.10
ping -c 4 192.168.0.11
# man -k fire
# man firewalld.richlanguage
# man firewalld.richlanguage | grep rule.*service
# man firewalld.richlanguage | grep rule.*forward
[server0]
# firewall-cmd --list-all
# firewall-cmd --permanent --remove-service=ssh
# firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" source address="172.25.0.0/16" service name="ssh" accept'
# firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" source address="172.24.1.0/24" service name="ssh" reject'
# firewall-cmd --reload
# firewall-cmd --list-all
[server0]
# yum repolist
# yum-config-manager --add-repo http://classroom.example.com/content/rhel7.0/x86_64/dvd
# rpm --import http://classroom.example.com/content/rhel7.0/x86_64/dvd/RPM-GPG-KEY-redhat-release
# yum repolist
# yum search http
# yum list httpd
# yum -y install httpd
# echo hello > /var/www/html/index.html
# systemctl restart httpd
# systemctl enable httpd
# man firewalld.richlanguage | grep rule.*forward
# firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" source address="172.25.0.0/16" forward-port to-port="80" protocol="tcp" port="5423"'
# firewall-cmd --reload
# curl http://s0:80 && echo ok
# curl http://s0:5423 || echo no
[desktop0]
# curl http://s0:80 || echo no
# curl http://s0:5423 && echo ok
ID | NID | HID | |
---|---|---|---|
1 | 10.1.2.3/8 | 10 | 1.2.3 |
2 | 172.25.6.7/16 | 172.25 | 6.7 |
3 | 192.168.9.10/24 | 192.168.9 | 10 |
ID | host | role |
---|---|---|
1 | classroom | dns server |
2 | desktop | dns client |
3 | server | dns client |
[classroom]
# yum search dns
# rpm -qc bind
# vim /etc/named.conf
...
zone "example.com" {
type master;
file "example.com.zone";
forwarders {};
};
zone "25.172.in-addr.arpa" {
type master;
file "172.25.zone";
forwarders {};
};
# vim /var/named/example.com.zone
$TTL 86400
example.com. IN SOA classroom.example.com. root.classroom.example.com. (
2013091600 ; serial number
1H ; refresh slave
5M ; retry query
1W ; expire
1M ; negative TTL
)
@ IN NS classroom.example.com.
classroom.example.com. IN A 172.25.254.254
c.example.com. IN CNAME classroom.example.com.
desktop0 IN A 172.25.0.10
d0 IN CNAME desktop0.example.com.
...
# vim /var/named/172.25.zone
$TTL 86400
25.172.IN-ADDR.ARPA. IN SOA classroom.example.com. root.classroom.example.com.(
2014081100 ; serial number
1H ; refresh slave
5M ; retry query
1W ; expire
1M ; negative TTL
)
@ IN NS classroom.example.com.
254.254 IN PTR classroom.example.com.
10.0 IN PTR desktop0.example.com.
11.0 IN PTR server0.example.com.
...
# rpm -ql bind | grep service
# systemctl restart named
# systemctl enable named
# firewall-cmd --list-all
# firewall-cmd --list-all --zone=classroom
[server0]
# cat /etc/resolv.conf
# host d0
# host 172.25.0.10
# rm -rf /etc/resolv.conf
# host 172.25.0.10 || echo no
# host d0.example.com 172.25.254.254
# host 172.25.0.10 172.25.254.254
# systemctl restart network
# cat /etc/resolv.conf
# nslookup d0.example.com
# nslookup 172.25.0.10
# rm -rf /etc/resolv.conf
# nslookup desktop0.example.com 172.25.254.254
# nslookup 172.25.0.10 172.25.254.254
# systemctl restart NetworkManager
# cat /etc/resolv.conf
# dig desktop0.example.com
# dig -x 172.25.0.10
# rm -rf /etc/resolv.conf
# dig desktop0.example.com @172.25.254.254
# dig -x 172.25.0.10 @172.25.254.254
# systemctl restart network
ID | host | role |
---|---|---|
1 | classroom | mail_server |
2 | server | mail_client |
3 | desktop | mail_client |
[server0]
# echo s1 | mail -s s1 student
# su - student -c mail
1
<Enter>
# yum search mail
# yum list postfix
# rpm -qc postfix
# vim /etc/postfix/main.cf
...
inet_interfaces = loopback-only
mynetworks = 127.0.0.0/8 [::1]/128
mydestination =
relayhost = [classroom.example.com]
local_transport = error: haha
myorigin = classroom.example.com
# rpm -ql postfix | grep service
# systemctl restart postfix
# systemctl enable postfix
# echo c2 | mail -s s2 student
# echo c3 | mail -s s3 [email protected]
# su - student -c mail
# ssh root@c
[classroom]
# su - student -c mail
1
2
q
server | client | |
---|---|---|
pkg | target* | iscsi* |
conf | targetcli | /etc/iscsi/initiatorname.iscsi |
operate | ls, /b |
|
service | target | iscsid |
firewall | firewall-cmd | iscsiadm |
lsblk | ||
/etc/fstab(_netdev) |
[server0]
# lsblk
# echo -e "n\n\n\n\n+3G\nw\n" | fdisk /dev/vdb
# lsblk
# yum search target
# yum list target*
# yum -y install target*
# targetcli
/> help
/> ls
/> /backstores/block create iscsi_store /dev/vdb1
/> ls
/> /iscsi create wwn=iqn.2014-11.com.example:server0
/> ls
/> /iscsi/iqn.2014-11.com.example:server0/tpg1/luns create /backstores/block/iscsi_store
/> ls
/> /iscsi/iqn.2014-11.com.example:server0/tpg1/acls create iqn.2014-11.com.example:d0
/> ls
/> /iscsi/iqn.2014-11.com.example:server0/tpg1/portals create 172.25.0.11
/> ls
/> exit
# systemctl restart target
# systemctl enable target
# firewall-cmd --permanent --add-port=3260/tcp
# firewall-cmd --reload
# targetcli ls
[desktop0]
# yum list iscsi*
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2014-11.com.example:d0
# systemctl restart iscsid
# systemctl enable iscsid
# man iscsiadm | grep \\-mode
# iscsiadm --mode discoverydb --type sendtargets --portal s0 --discover
# iscsiadm --mode node --targetname iqn.2014-11.com.example:server0 --portal s0 --login
# lsblk
# lsblk -S
# iscsiadm -m session -P 3
# echo -e "n\n\n\n\n+2100M\nw\n" | fdisk /dev/sda
# mkfs.ext4 /dev/sda1
# mkdir /mnt/data
# blkid /dev/sda1
# man mount | grep _netdev
# vim /etc/fstab
...
UUID="b9bcc5b5-271e-4c20-9684-909c6216c0ee" /mnt/data/ ext4 _netdev 1 2
# mount -a
# df -h /mnt/data/
# shutdown -r 0
[foundation]
$ rht-vmctl view desktop
$ rht-vmctl poweroff desktop
$ rht-vmctl start desktop
$ rht-vmctl view desktop
[desktop0]
# lsblk
# df -h /mnt/data/
[server0]
# lab nfskrb5 setup
[desktop0]
# lab nfskrb5 setup
[server0]
# mkdir -p /public /protected/project
# id ldapuser1
# chown ldapuser1 /protected/project
# ls -ld /protected/project
# yum search nfs
# yum list nfs-utils
# man exports
# vim /etc/exports
/public *.example.com(ro)
/protected *.example.com(rw,sec=krb5p)
# wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/server0.keytab
# klist -k /etc/krb5.keytab
# rpm -ql nfs-utils | grep service
# systemctl start nfs-secure-server
# rpm -qc nfs-utils
# vim /etc/sysconfig/nfs
...
RPCNFSDARGS="-V 4.2"
# rpm -ql nfs-utils | grep service
# systemctl restart nfs-server
# rpcinfo
# grep 111 /etc/services | grep port.*map
# firewall-cmd --permanent --add-service=nfs
# firewall-cmd --permanent --add-service=rpc-bind --add-service=mountd
# firewall-cmd --reload
[desktop0]
# showmount -e s0
# mkdir /mnt/nfsmount /mnt/nfssecure
# wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/desktop0.keytab
# klist -k /etc/krb5.keytab
# hostname
# systemctl restart nfs-secure
# systemctl enable nfs-secure
# vim /etc/fstab
...
server0:/public /mnt/nfsmount/ nfs defaults 0 0
server0:/protected /mnt/nfssecure/ nfs rw,v4.2,sec=krb5p 0 0
# mount -a
# touch /mnt/nfsmount/ro.txt || echo no
# ls /mnt/nfsmount/
# ssh ldapuser1@localhost
kerberos
$ touch /mnt/nfssecure/project/rw.ldap
$ ls /mnt/nfssecure/project
$ <Ctrl+D>
# ssh root@s0 'ls -l /protected/project'
redhat
ID | server | client | comment |
---|---|---|---|
1 | samba | DAEMON | |
2 | samba-common | CONF | |
3 | samba-client | samba-client | cmd |
4 | cifs-utils | fstab |
ID | name | OS |
---|---|---|
1 | share | Win98 |
2 | user | WinXP |
3 | server | ldap |
4 | domain | AD |
[server0]
# yum search samba
# yum list samba samba-common samba-client
# yum -y install samba samba-common samba-client
# mkdir /common
# man semanage fcontext | grep \#
# grep chcon /etc/samba/smb.conf
# semanage fcontext -a -t samba_share_t "/common(/.*)?"
# restorecon -Rv /common
# id floyd || useradd floyd
# pdbedit -L
# (echo flectrag; echo flectrag) | smbpasswd -a floyd
# pdbedit -L
# rpm -qc samba-common
# vim /etc/samba/smb.conf
...
workgroup = STAFF
...
[common]
path = /common
valid users = floyd
browseable = yes
hosts allow = 127. 172.25.
# rpm -ql samba | grep service
# systemctl restart smb nmb
# systemctl enable smb nmb
# firewall-cmd --permanent --add-service=samba
# firewall-cmd --reload
# smbclient -L //server0 -N
# smbclient //server0/common -U floyd%flectrag -c ls
[desktop0]
# yum provides smbclient
# yum -y install samba-client
# smbclient -L //server0 -N
# smbclient //server0/common -U floyd%flectrag -c ls
[server0]
# mkdir /devops
# history | grep sema
# semanage fcontext -a -t samba_share_t "/devops(/.*)?"
# restorecon -Rv /devops
# id kenji; id chihiro
# useradd kenji; useradd chihiro
# echo -e "redhat\nredhat\n" | smbpasswd -a kenji
# echo -e "redhat\nredhat\n" | smbpasswd -a chihiro
# ls -ldZ /devops/
# chown chihiro /devops/
# ls -ldZ /devops/
# vim /etc/samba/smb.conf
...
[devops]
path = /devops
valid users = kenji chihiro
browseable = yes
hosts allow = 127. 172.25.
write list = chihiro
# systemctl restart smb nmb
# systemctl enable smb nmb
[desktop0]
# smbclient -L //s0 -N
# smbclient //server0/devops -U kenji%redhat -c ls
# smbclient //server0/devops -U kenji%redhat -c 'put anaconda-ks.cfg' || echo ok
# smbclient //server0/devops -U chihiro%redhat -c ls
# smbclient //server0/devops -U chihiro%redhat -c 'put anaconda-ks.cfg'
# smbclient //server0/devops -U chihiro%redhat -c ls
# mkdir /mnt/dev
# man mount.cifs
/cred, /mult, /sec=
# vim /etc/fstab
...
//server0/devops /mnt/dev cifs credentials=/root/kenji.cred,multiuser,sec=ntlmssp 0 0
# vim /root/kenji.cred
username=kenji
password=redhat
# mount -a
# findmnt /mnt/dev
# mount | grep /mnt/dev
# ls /mnt/dev/
# touch /mnt/dev/ro.txt
# useradd chihiro
# su - chihiro
$ cifscreds add server0
redhat
$ touch /mnt/dev/rw.txt
ID | ||
---|---|---|
1 | DDL | CREATE, ALTER, DROP |
2 | DML | SELECT, INSERT, UPDATE, DELETE |
3 | DCL | GRANT, REVOKE |
select ?
from t1, t2, t3
where tj1=1
and tj2='char'
and t1.lie1=t2.lie2
and t1.lie2=t3.lie4;
# yum search maria
# yum list mariadb-server mariadb
# yum -y install mariadb-server mariadb
# rpm -ql mariadb-server | grep service
# systemctl start mariadb
# systemctl enable mariadb
# ss -antup | grep 3306
# rpm -qc mariadb-server
# vim /etc/my.cnf
[mysqld]
skip-network=1
...
# systemctl restart mariadb
# systemctl status mariadb
# ss -antup | grep 3306 || echo no
# rpm -ql mariadb | grep bin
# man mysql
# mysql -h localhost -u root -p mysql
<Enter>
mysql (mysql)> help;
mysql (mysql)> \q
# mysql -h localhost -u root -p
<Enter>
mysql (none)> \q
# mysql -h localhost -u root
mysql (none)> \q
# mysql -h localhost
mysql (none)> \q
# mysql
mysql (none)> \q
# mysql_secure_installation
<Enter>
redhat*2
<Enter>*n
# mysql -p
redhat
mysql > \q
# mysql -predhat
mysql > \q
# mysql -predhat
MariaDB [(none)]> help create
MariaDB [(none)]> help CREATE DATABASE
MariaDB [(none)]> show databases;
MariaDB [(none)]> create database contacts
-> ;
MariaDB [(none)]> show databases;
MariaDB [(none)]> use contacts;
MariaDB [contacts]> show tables;
MariaDB [contacts]> \q
# vim .mysql_history
# mysql -predhat
MariaDB [(none)]> show databases;
MariaDB [(none)]> use mysql;
MariaDB [mysql]> show tables;
MariaDB [mysql]> select * from user;
MariaDB [mysql]> select host,user,password from user;
MariaDB [(none)]> help grant
MariaDB [(none)]> CREATE USER 'raikon'@'localhost' IDENTIFIED BY 'redhat';
MariaDB [(none)]> GRANT SELECT ON contacts.* TO 'raikon'@'localhost';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
# mysql -u raikon -predhat contacts
MariaDB [contacts]> \q
# wget http://c/content/courses/rh254/rhel7.0/materials/mariadb/mariadb.dump
# mysql -predhat contacts < mariadb.dump
# mysql -u raikon -predhat contacts
MariaDB [contacts]> show tables;
MariaDB [contacts]> select * from product;
MariaDB [contacts]> select * from product; select * from category; select * from manufacturer;
MariaDB [contacts]> select manufacturer.name
-> from manufacturer, product
-> where product.name='RT-AC68U'
-> and product.id_manufacturer = manufacturer.id;
MariaDB [contacts]> select count(*)
-> from product, manufacturer, category
-> where category.name = 'Servers'
-> and manufacturer.name = 'Sony'
-> and product.id_manufacturer = manufacturer.id
-> and product.id_category = category.id;
ID | name | desc |
---|---|---|
1 | httpd | DAEMON |
2 | httpd-manual | man |
3 | mod_ssl | https |
4 | mod_wsgi | *.wsgi |
[foundation0]
# echo base > /content/base.html
# echo vhost > /content/extend.html
# echo quanxian > /content/permission.html
# ssh root@s0 'lab webapp setup'
# scp root@s0:~student/webapp.wsgi /content/
[foundation0]
$ ssh -X root@s0
[server0]
# yum list httpd*
# yum -y install httpd httpd-manual
# wget -O /var/www/html/index.html http://classroom.example.com/content/base.html
# rpm -ql httpd | grep vhost
# cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/
# vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName www0.example.com
</VirtualHost>
# rpm -ql httpd-manual | grep index.html
# firefox /usr/share/httpd/manual/index.html &
`Upgrading to 2.4 from 2.2`
- Require host example.org
- RequireAll
- <RequireAll>
Require group alpha beta
Require not group reject
</RequireAll>
# rpm -qc httpd
# vim /etc/httpd/conf/httpd.conf
...
<Directory "/var/www/html">
...
#Require all granted
<RequireAll>
Require host example.com
Require not host my133t.org
</RequireAll>
</Directory>
...
# systemctl restart httpd
# systemctl enable httpd
# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload
[desktop0]
# curl http:/www0.example.com
[server0]
# host s0
# host www0
# host webapp0
# curl http://www0.example.com
# curl http://www0
# curl http://s0
# curl http://server0
# mkdir /var/www/virtual
# wget -O /var/www/virtual/index.html http://classroom.example.com/content/extend.html
# cat /var/www/virtual/index.html
# id floyd
# useradd floyd
# chown floyd /var/www/virtual
# vim /etc/httpd/conf.d/httpd-vhosts.conf
...
<VirtualHost *:80>
DocumentRoot "/var/www/virtual"
ServerName webapp0.example.com
</VirtualHost>
# systemctl restart httpd
# curl http://webapp0.example.com
# curl http://www0.example.com
# curl http://172.25.0.11
# curl http://s0
[server0]
# mkdir /var/www/{html,virtual}/private
# wget -O /var/www/html/private/index.html http://classroom.example.com/content/permission.html
# wget -O /var/www/virtual/private/index.html http://classroom.example.com/content/permission.html
# vim /etc/httpd/conf/httpd.conf
...
<Directory "/var/www/virtual/private">
Require host server0.example.com
</Directory>
<Directory "/var/www/html/private">
Require host server0.example.com
</Directory>
...
# systemctl restart httpd
# firefox http://www0.example.com/private &
# firefox http://webapp0.example.com/private &
[foundation0]
# firefox http://www0.example.com/private &
# firefox http://webapp0.example.com/private &
[server0]
# yum search ssl
# yum list mod_ssl
# yum -y install mod_ssl
# rpm -qc mod_ssl
# vim /etc/httpd/conf.d/ssl.conf
...
DocumentRoot "/var/www/html"
ServerName www0.example.com:443
SSLCertificateFile /etc/pki/tls/certs/www0.crt
SSLCertificateKeyFile /etc/pki/tls/private/www0.key
SSLCertificateChainFile /etc/pki/tls/certs/example-ca.crt
...
# grep www0 /etc/httpd/conf.d/ssl.conf
# wget -P /etc/pki/tls/certs http://classroom/pub/tls/certs/www0.crt
# wget -P /etc/pki/tls/private http://classroom/pub/tls/private/www0.key
# grep example-ca /etc/httpd/conf.d/ssl.conf
# wget -P /etc/pki/tls/certs http://classroom/pub/example-ca.crt
# systemctl restart httpd
# firewall-cmd --permanent --add-service=https
# firewall-cmd --reload
[desktop0]
# firefox https:/www0.example.com &
[server0]
# yum search wsgi
# yum list mod_wsgi
# yum -y install mod_wsgi
# rpm -ql mod_wsgi
# vim /usr/share/doc/mod_wsgi-3.4/README
# grep -i ^\ .*wsgi.*alias /usr/share/doc/mod_wsgi-3.4/README
# vim /etc/httpd/conf.d/httpd-vhosts.conf
...
Listen 8909
<VirtualHost *:8909>
WSGIScriptAlias / /var/www/html/webapp.wsgi
ServerName webapp0.example.com
</VirtualHost>
# wget -P /var/www/html/ http://classroom.example.com/content/webapp.wsgi
# man semanage port | grep \#
# semanage port -a -t http_port_t -p tcp 8909
# systemctl restart httpd
# firewall-cmd --permanent --add-port=8909/tcp
# firewall-cmd --reload
[desktop0]
# curl http://webapp0.example.com:8909
# curl http://webapp0.example.com:8909
# curl -k https://www0.example.com
# curl http://www0.example.com
# curl http://webapp0.example.com
# curl http://webapp0.example.com/private
# echo $SHELL
# cat /etc/shells
# env
# FILEN=/home/mysql_$(date +%Y%m%d).bk
# export FILEN=/home/mysql_$(date +%Y%m%d).bk
# unset FILEN
# env | grep -i path
# mkdir /usr/local/Typora
# cp /usr/bin/touch /usr/local/Typora/mo
# mo /tmp/file || echo no
# echo $PATH
# PATH=$PATH:/usr/local/Typora
# echo $PATH
# mo /tmp/file
# echo $(date +%Y%m%d)
# echo `date +%Y%m%d`
# echo $PATH
# echo '$PATH'
# echo \$PATH
# mkdir folder a
# ll
# mkdir "folder a"
# ll
# read -p "What's your name: " YNAME
What's your name: `haha`
# echo $YNAME
# ls /etc/bashrc /etc/profile
# ls ~/.bashrc ~/.bash_profile
# vim /root/a.sh
#!/bin/bash
read -p "What's your name: " YNAME
read -p "Where are you frome: " YSITE
echo Welcome $YNAME, from $YSITE
# bash /root/a.sh
# source /root/a.sh
# /root/a.sh || echo no
# chmod +x /root/a.sh
# /root/a.sh
# a.sh || echo no
# echo $PATH
# vim p
#!/bin/bash
ping -c $2 172.25.0.$1
echo '$0: ' $0
echo '$1: ' $1
echo '$2: ' $2
echo '$3: ' $3
echo '$#: ' $#
echo '$*: ' $*
# chmod +x p
# ./p 254 3
# ls -a /home
# echo $?
# Ls -a /home
# echo $?
# grep root /etc/passwd
# grep root /etc/passwd | cut -f 1-3 -d :
# grep root /etc/passwd | cut -f 1-3 -d : | wc
# echo -e "c\na\nb\nb\nc\n" > file
# cat file
# sort file
# uniq -u file
# sort file | uniq -u
# sort file | uniq -d
# echo $PATH
# echo $PATH | tr 'a-z' 'A-Z'
# echo $PATH | tr 'A-Z' 'a-z'
# man bash
/-d, <n>*n
-e, -f, -d, -r, -w, -x, -z
# [ -d /folder ] && \rm -r /folder
# ls -l /folder/
# ls -d /folder/
# [ ! -d /folder ] && mkdir /folder
# ls -d /folder/
# [ -d /folder ] && \rm -r /folder || mkdir /folder
# ls -d /folder/
OP
-eq, -ne, -lt, -le, -gt, -ge
=, !=, <, <=, >, >=
&&, ||
# systemctl is-active chronyd
# systemctl stop chronyd
# systemctl is-active chronyd
# [ "$(systemctl is-active chronyd)" = "active" ] || echo running
# [ "$(systemctl is-active chronyd)" = "active" ] && echo running || echo stoping
# systemctl start chronyd
# [ "$(systemctl is-active chronyd)" = "active" ] && echo running || echo stoping
# man bash
/if.*then
# vim /etc/bashrc
/if
# vim if.sh
#!/bin/bash
if [ "$1" = "redhat" ]; then
echo fedora
# chmod +x if.sh
# ./if.sh
# ./if.sh hehe
# ./if.sh redhat
# ./if.sh fedora
# vim for.sh
#!/bin/bash
for i in {1..10}; do
useradd ${i}
echo mima${i}haha | passwd --stdin ${i} >/dev/null
done
# chmod +x for.sh
# ./for.sh
# ssh 1@localhost
mima1haha
$
#!/bin/bash
read -p "What's your name: " YNAME
while [ "$YNAME" = "haha" ]
do
echo $YNAME
done
# chmod +x while.sh
# ./while.sh
haha
<Ctrl+C>
# ./while.sh
hehe
# man bash
# vim /etc/bashrc
# vim case.sh
#!/bin/bash
case $1 in
redhat)
echo fedora;;
fedora)
echo redhat;;
*)
echo haha;;
esac
# chmod +x case.sh
# ./case.sh
# ./case.sh hehe
# ./case.sh redhat
# ./case.sh fedora
# systemctl isolate graphical.target
# startx
# init 5
[foundation0]
# rpm -ivh ~kiosk/Desktop/ex300k-1.6.0-201902250955.x86_64.rpm
ID | ||
---|---|---|
1 | yum search PK | |
2 | yum -y install PKG | |
3 | rpm -qc PKG | |
4 | vim /etc/*.conf | |
5 | rpm -ql PKG | grep service | |
6 | systemctl restart DAEMON | |
7 | systemctl enable DAEMON | |
8 | firewall-cmd --permanent … | |
9 | firewall-cmd --reload | |
10 | permission ( local+selinux) | |
11 | test local-=>remote |
# wget http://c/content/courses/rh254/rhel7.0/materials/mariadb/mariadb.dump
# ls mariadb.dump
# wget http://c/content/courses/rh254/rhel7.0/materials/mariadb/mariadb.dump -P /tmp
# ls /tmp/mariadb.dump
# wget http://c/content/courses/rh254/rhel7.0/materials/mariadb/mariadb.dump -O /tmp/haha.dump
# ls /tmp/haha.dump
# diff mariadb.dump /tmp/haha.dump
# diff mariadb.dump /tmp/mariadb.dump