Marco Education class 20-2 first week study notes 5

Source: Internet
Author: User
Tags builtin echo command

System users
PS1 defines the format of the prompt for example:

Ps1=xxx the current user name will be temporarily modified
echo $PS 1
[\[email protected]\h \w]\$//u represents the user, H host name W current folder

# admin
$ normal User

When we enter a command, it will pass the shell to Kernel,kernel to determine the type of the command.

Command type:

Built-in command: The kernel comes with kernel itself

External command: File installed with GUN files

Check out the kernel

cd/boot/
ll Vmlinuz-3.10.0-327.el7.x86_64-h//h says it's easy to see the size of the data, which is only 5 m, in a way that humans view. All the built-in commands are included here.

[Email protected] ~]# type cat
Cat Is/usr/bin/cat//external commands
[[Email protected] ~]# type type
Type is a shell builtin//built-in command
[[Email protected] ~]# type cd
CD is a shell builtin//built-in command



[Email protected] ~]# type who
Who is/usr/bin/who//external commands
[[email protected] ~]# WHO//Run this command
root:0 2016-07-21 17:06 (: 0)
Root pts/0 2016-07-21 18:55 (: 0)
Root PTS/1 2016-07-21 19:03 (172.18.16.73)
Root PTS/2 2016-07-21 21:32 (172.18.16.73)
[Email protected] ~]# type who
Who is hashed (/usr/bin/who)//hashed: hash, when an external command is run, it is hashed into the cache and can be read quickly the next time it runs.


Type chmod

chmod 000/root/111

Type chmod which chmod can see the path of the command, but which can only find external commands, cannot find built-in commands, such as which type failed

[email protected] ~]# which cat
/usr/bin/cat
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[[Email protected] ~]# type cat
Cat Is/usr/bin/cat
[Email protected] ~]# CP/USR/BIN/CA
Cairo-sphinx Calibrate_ppa Cancel Caribou-preferences Catman
Cal Canberra-boot Cancel.cups Cat
Ca-legacy Canberra-gtk-play Captoinfo CATCHSEGV
[Email protected] ~]# Cp/usr/bin/cat/usr/local/sbin/cat
[[email protected] ~]# Cat 111
[[Email protected] ~]# type cat
Cat is hashed (/USR/LOCAL/SBIN/CAT)

[Email protected] ~]# Rm/usr/local/sbin/cat
Rm:remove regular file '/usr/local/sbin/cat '? Y
[[email protected] ~]# Cat 111
-bash:/usr/local/sbin/cat:no such file or directory//has been looked up according to the path of memory.
[email protected] ~]# which cat
/usr/bin/cat
[[Email protected] ~]# type cat
Cat is hashed (/USR/LOCAL/SBIN/CAT)
[[email protected] ~]#/usr/bin/cat 111//Add a path to it
For a complete solution, you need to resolve it from cache to memory
[email protected] ~]# hash
Hits command
14/usr/bin/screen
1/usr/bin/rm
4/usr/bin/chmod
5/usr/local/sbin/cat
1/usr/bin/touch
3/usr/bin/who
1/usr/bin/cp
2/usr/bin/vi
2/usr/bin/w
2/usr/bin/ls
1/usr/bin/clear
[[email protected] ~]# hash-d cat//hash-r all clear


[[email protected] ~]# hash
Hits command
0/usr/bin/cat//So you can search by default path from the new
Cat 111//OK





[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin//external command the order in which the path to search is placed the first priority is higher, if I want to make APP1 in/usr/local/ Bin as a priority you can
/usr/local/bin/app1 to execute, otherwise do not write the path can not find


chmod $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

Built-in command high priority
Then according to the hash $PATH
To determine the priority level of


Enable-n CD//disable built-in command method
Enable CD/Enabled


[Email protected] tmp]# enable-n CD
[[Email protected] tmp]# type cd
CD is hashed (/USR/BIN/CD)//Because the internal command is not outside the command is still there, CENTOS6 does not support this


Whereis chmod//Search only in Path variable

[email protected] tmp]# ls \
> L \
> Yum.log//For longer commands can be displayed on a branch

[[email protected] tmp]# ls;pwd;ifconfig//For short commands can be executed together and take effect separately


Date:
Show date and time
Date-u//Show GMT

Clock:
Show Hardware Time

Synchronization Time Method:

CLOCK-S//Hardware-based quasi-sync time

CLOCK-W//With system time quasi-synchronization time


Date month day hour minute year second

Date 091811302012.20

For example:

[Email protected] ~]# Date-u
Fri Jul 02:12:11 UTC 2016
[[Email protected] ~]# Date 091011202012.20//manually set a time
Mon Sep 11:20:20 CST 2012
[Email protected] ~]# clock
Fri 10:19:24 AM CST-0.492925 seconds
[[email protected] ~]# clock-s//Check back the correct time by hardware
[[Email protected] ~]# Date
Fri Jul 10:19:33 CST 2016


Cal
command to display the date

[[email protected] ~]# cal 09 1752
September 1752
Su Mo Tu We Th Fr Sa
1 2 14) 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30//cause of religious reasons



Cat/etc/issue

[Email protected] ~]# vi/etc/issue
\s
Kernel \ r on an \m
STOP!!! This is MY MY///Added to character interface line entry will appear.

Nano/etc/issue

Loginout =ctrl + D



[[email protected] ~]# systemctl Restart network//restart NIC program



CentOS 7 Command Installation

You can choose to see if the screen is installed on your computer.

Type screen

If not installed, there are two ways to install it:
1: Check that the disc has been mounted, locate the screen-4.1.0-0.21.20120314git3c2946.el7.x86_64.rpm file in the packages package and double-click Install;

2;DF//view disc already mounted
[[email protected] ~]# DF
Filesystem 1k-blocks used Available use% mounted on
/dev/sda2 52403200 3348332 49054868 7%/
Devtmpfs 923776 0 923776 0%/dev
Tmpfs 938316 144 938172 1%/DEV/SHM
Tmpfs 938316 9136 929180 1%/run
Tmpfs 938316 0 938316 0%/sys/fs/cgroup
/dev/sda5 20961280 32932 20928348 1%/testdir
/DEV/SDA1 201388 141756 59632 71%/boot
Tmpfs 187664 187644 1%/run/user/0
/dev/sr0 7587292 7587292 0 100%/run/media/root/centos 7 x86_64

Rpm-i/run/media/root/centos7\7\x86_64/packages/screen-4.1.0-0.21.20120314git3c2946.el7.x86_64.rpm

start experiment after installation

Test Purpose: Help users solve System application problems
the prerequisite for the completion of the test: Both sides have to log on to the same server, and use the same account


Help party:
Type screen //See if Screen
 screen
Screen-s zcl1840 // Open a new screen session:zcl1840 for the linked account

Helper:

which screen//view path of screen

Screen-ls//See if there is a Help account login

Screen-x zcl1840 //Join reply: Join the Help account to establish a link

The two can operate on one desktop after the connection.
The link is interrupted if either side exits the exit.


Creates a background program through screen to prevent interruptions. For example, the upgrade program runs in the background.

simulates
  with infinite loop Yes command;
  1:screen
  2:  Yes
  3:  Ctrl + a  & nbsp; //Pause Press D to turn Yes Infinite loop program into the background
  4:screen-ls //view to Background process program number and random user name Pts-0.centos7
       screen-x  User   //After joining the original background run program is displayed on the desktop
  5:screen-r  session// Restore a process: if there is a background process then R does not add the user name, if there are multiple add the corresponding process name, you can restore the process or CTRL + C End Process
  6: If the process after the end of,screen-r  there is no screen To is resumed   exit



Echo:
Display character commands


[[email protected] ~]# echo AAA BBB CCC
AAA BBB CCC
[[email protected] ~]# echo-n AAA BBB CCC
AAA BBB Ccc[[email protected] ~]#


Variable: Represents a collection of some strings

[Email protected] ~]# echo $UID
0
[[email protected] ~]# echo \ $UID//join "\" to turn meaning
$UID
[Email protected] ~]#

[[email protected] ~]# echo ' $UID '//' strong quote
$UID
[[email protected] ~]# echo "$UID"//"" Weak reference
0
For example:
[Email protected] ~]# echo "Echo $UID"
Echo 0
[Email protected] ~]# echo ' echo $UID '
Echo $UID
[[email protected] ~]# echo ' echo $UID '//This command = $ (echo $UID)
0


ECHO-E//Can let the following string display some special functions

For example:
[[email protected] ~]# echo "AAA \c"
AAA \c//No plus E
[[email protected] ~]# echo-e "AAA \c"
Aaa[[email protected] ~]#//Add e after the \c parameter only takes effect


[Email protected] ~]# echo-e "\a"//\a's role is to make a sound
[Email protected] ~]#

echo Command options:

-N does not wrap characters at the end of the line
-E If the following character appears in the string, it is handled in particular, not as a general text output:
\a issued a warning sound;
\b Backspace key
\c finally not add the line break symbol;
\ n Wraps and the cursor moves to the beginning of the line;
\ r The cursor moves to the beginning of the line, but does not wrap;
\ t Insert tab;
\ \ insert \ Character
\0NNN insert ASCII character represented by NNN (octal)
Echo-e "\033[43;31mabcd \033[0m"//43 for the view, 31 for the font color. I don't use it on the CRT.


\XHH Insert the ASCII character represented by the HH (hex)

Marco Education class 20-2 first week study notes 5

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.

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.