Basic Concepts
X
Window
Interoperate with display & video card
Xfree86
And x.org
The Open Source version of X Window
KDE/gnome,
Character Set
A set of binary commands,
Linux
The system sends a message to the monitor to display characters.
ASCII
ISO-8859-x, Unicode (all iso-8xx encoded)
Analog Terminal
Simulate old-fashioned
UNIX
Non-intelligent terminal, defining terminal parameters such as display cache, graphics vector, number of characters in a row, and defining buttons
Environment Variable
Term
Define the simulated terminal used
Xterm
Terminal simulator package
Topic: script format
Variable assignment"
=
"No space on both sides
If
Conditional judgment
[]
Must contain spaces,
If
Space is also required between and [
Variable reference, except the value assignment and
For
All external applications
$
Double quotation marks allow replacement of variables and commands
Single quotes avoid special wildcard characters being interpreted, such
$? | <>
,
Eg: Echo '$ abc' # $ ABC
Not interpreted as a variable
ABC
Another variable reference method:
$ {Variable}
Bash
Escape Character,
/
Environment
Values
Printenv, show all EVN values
Global env values:
Uppercase: Any process with Defined variables and its sub-processes are visible;
Local env values:
Lowercase, only visible in the local process that defines it, such as the current
Shell
;
Set, show all env values, global &
Local encoded ded.
Set env values, use "" or '':
A = "a B C"
Export,
Set local
Env
Export to global
Env
;
Delete env: unset xxx
Some default environment variables:
Path
Home
Tmout
, Set how long after idle
Bash
Automatically exit
Display
Mathematical operations
Expr 5/* 2
#
Space Required
Var = $ [5*2]
#
No space,
Bash
Private
Var = $ [$ Var * (2 + $ var)]
You can also:
Var = $(5*2 ))
Script exit
Exit status:
$?
Maximum Value
255
Exit command
: Exit 0
#
Can I use it like a function?
Return
?
TBD
Bash
Variable Array
Define
:
A = (1 2 3 4)
, Separated by spaces,
()
Echo $ {A [1]}
# Use:
Index Based on
0
Echo $ {A [*]}
# Show All members
A [1] = 20
# Set a member
Unset
# Deleted
TBD
:
How to add members to the array?
Bash
Three startup Methods
1
Default Logon Time
Shell
, Run
/Etc/profile
,
$ Home/. bash_profile,
$ Home/. bash_login, $ home/. Profile
2
, Non-Logon interactive
Shell
, Processing
~ /. Bashrc
3
, Non-interactive running scripts
Shell
,
$ Bash_env
Start script to be executed
/Etc/profile
Run the command at the First Login and
/Etc/profile. d
Under the configuration file to collect
Shell
Settings
~ /. Bash_profile
When the user logs on
~ /. Bashrc
~ /. Bashrc
Set
Alias
And call
/Etc/bashrc
/Etc/bashrc
Each execution
/
Open
Bash
The content can be
~ /. Bashrc
Overwrite
~ /. Bash_logout
/Etc/profile,
Read
/Etc/profile. d
The configuration file in the directory, which is executed during the First Login
~ /. Profile
~ /. Bash_login
~ /. Bash_profile
~ /. Bashrc
, The best place to add environment variables and aliases
~ /. Bash_logout
,
Logout
Time execution
Others
Coreutils package, the core utilities
Linux from GNU
Echo-n xxx,
No line feed output
User Manage
UID
Less
100
Users created with various non-real-user functions
/Etc/passwd
User_name: Pwd: uid: GID: Comments: home_dir: deault_shell
/Etc/shadom
Useradd-D # Show default setting for adding
User. skel set a pattern for the home Dir of the new user.
Userdel, del
User, param-R is appended if u want to Del
The home_dir also
Usermod, Set User such as adding user to
Group
Passwd, Change Password
Finger root, show User Info
Group
/Etc/group
Name: Pwd: GID: user_list
Passwd of group:
Used to temporarily become a member of this group
Null user_list:/etc/passwd
The default group users in
Group
In the user list
Usermod-G group1 user1
: Add user to a group
Groupadd
Groupmod
ID
Command to display all groups of users
File Permission
Umask, set the default value of the new
Created file.
Chmod 760 newfile
Chmod + x newfile
# +,-, =
Chown chgrp
File Attributes
Set User ID (SUID)
, The file will be executed under the file owner permission, not the file executor permission, such
Root
All, then the common user will also
Root
Permission to execute this program
Set Group ID (SGID)
For a directory, the user group of the directory will be used as the default user group for creating new files in the directory; a method for creating shared folders for multiple users;
Stick bit: After the process ends, the file is still in the memory (?)
Chmod + S xxx
, Set
SGID
Bit
Temporary Files
Mktemp ABC. xxxxxx
#6
Items
X
Will be randomly generated,
X
The quantity must be greater
3
, Command to return the generated file name (default current directory ),
Xx
It must be at the end of the name
Mktemp-t abc. xxx
#
In
/Tmp
File generation
Mktemp-d abc. xxx
#
Create temporary directory
String processing
Use
### %
String Truncation
Use
Expr
Obtain the string length, substring, and so on,
Expr substr string POS Length
Eg:
Expr
Substr ABCD 1 100
# POS
Slave
1
Start,
Length
It can be larger than the actual length
Expr Length
ABCD