Linux system remote and user permissions
I. Knowledge review:
All IT knowledge is based on the OSI seven-layer model (TCP/IP four-layer).
Agreement: (provisions)
Application layer protocol: http https(B/S) ssh telnet smtp pop3 imap ftp tftp dns dhcp
Transport layer: tcp udp --port
Network layer: Routing protocol is routed protocol (IPv4 IPv6) x.x.x.
Data link layer: Ethernet protocol MAC ff:ff Globally unique
Physical layer: electrical signal of 01
Linux directory structure
Disk Management for Linux
fdisk --partition (logical boundary) written to file system;-l naming of disk
mkfs -t //Specifies the file system format;
mount The mount point of the device to be mounted [Storage devices must be mounted on Linux systems]
umount Device/mount point to mount on
df -h
/etc/fstab for boot automount
/ /bin /sbin
/etc
/usr /usr/local/
/var
/opt
/sys /proc
/tmp
/lib /lib64
/home /root
/cdrom /media /mnt
Common commands for directory file operations:
ls file wildcard globbing ? [ ] ^ $
cd . .. ~ -Absolute path and relative path
grep
regular expression
1. String matching. [] [^] [:digit:] [:alpha:] ...
Number 2, matching? {m} {m,n} {0,n} {m,}
3. Position anchoring ^ $ \b
4. Group (ab) abab
ab abbbbb
.*
-v
-i
^$ --blank line
mkdir -pv Create multi-level subdirectories simultaneously
rm -r
rmdir delete empty directory
tree -L -d
II. File related commands 1. Create and delete operations
Touch modify timestamp stat (atime mtime ctime), create file if it doesn't exist
-C
MMDDhhmm[CC]YY.ss
top --> View progress [CPU: sy ur]
-a
Rm
find [Range]-file d -name a* [file properties]
-exec command {}\;
-ok command {}\;
| xargs command;
【Mkdir -pv】
2. Copy and move files
Cp -a //Copy all file attributes together
Mv move 1, Move file 2, Modify file name
mv a b
mv /tmp/a /root/
filename extensions
{}
Create directory Name_Student ID Zhao Yun 00001
mkdir {Zhao Yun, Shi Lei}{00001,00002}
Zhao Yun_00001
Zhao Yun_00002
Shi Lei_00001
Shi Lei_00002
3. View file contents
Cat View everything in a file at once
cat /etc/init.d/
More //man command
/
?
q
Less in more clearance, view large files, we use less
Tail Default View Countdown 10 Lines
-n // tail -n 20 File name simplification: -20
-f Do not exit the file, view the file content in real time
Head View line head
-n // head -n 20 File name simplification: -20
4. Other
Echo -e -n
echo $PATH
-n // print("Hello World",end='\t') print("Hello World")
print("Hello World")
-e Identification\t \n \r
echo -n -e "Hello World \t"
Redirect> and>>
fd file identifier
0 --Standard input
1 --Standard output
2 --Error output
Program = Instruction + Data
code variable
Where does the data in the variable come from? Where does the data executed by the code go?
Specification: Default standard input is--keyboard standard output is--display
III. input redirection
And redirection is used to change input and output.
Give the following documents to the previous command for execution;
tr command, replace the previous content with the following content
tr abc ABC
< a.txt 文件 a >>EOF
IV. Error output redirection
2> FD (file identifier) is required
2>> Added error redirect output
Extended optimization:
cat a.txt>/dev/null
cat.a txt2>/dev/null
& >/dev/null Assign output to/dev/null whether the command executes correctly or not
&>>[General]
v. Pipeline:
command1|command2|command3|command4|......
Output the execution result of the previous command to the next command for execution;
Linux Thinking: Combining Small Functions to Complete Complex Functions
tail -7/etc/fstab|cut -d' ' -f1
cut
-d Specify delimiter ' '
-f Get column 1 - 3 1,3 1 1
VI.Linux Remote
###I. View or configure network card information
Network card and IP address
ifconfig
Without this command, we need to install net-tools
apt install net-tools
If the NIC does not work, we need to modify the default NIC configuration file;
/etc/network/interfaces
vim /etc/network/interfaces
1. Dynamic- dhcp
auto eth0
iface eth0 inet dhcp
[If you modify the configuration file, you need to restart the service]
/etc/init.d/networking restart
2, static-manual configuration
address 192.168.94.10
netmask 255.255.255.0
gateway 192.168.94.1
II. remote management mechanism
1. Ssh enables listening on Ubuntu's ssh port;
tcp-22
netstat -tnl // t -- tcp protocol n --do not parse
If not: apt install opensh-server-y
/etc/init.d/ssh start
[Ubuntu can only use ordinary users for remote connection by default]
ssh teacher@192.168.94.10
Under centos, you can log in remotely directly using root user;
ssh root@192.168.94.10
2. No password remote login [See screenshot]
VII. 1. Basic concepts of users and permissions
chmod rwx 7 r-- 4 -w- 2 --x 1 rw-
rwx
111
chown modify parent and group
root:root
chown teacher: files
chown :teacher file
chown techaer:teacher files
2. Command of user management terminal
useradd
userdel
3. Group Management Terminal Command
groupadd
groupdel