linux detailed introduction

Linux system is a tree structure
pwd: display the current path
cd: switch directory
ls: list the contents of the current directory

Catalog Introduction

/bin: commands that can be executed by ordinary users and administrators
/sbin: commands that can only be executed by administrators, such as shutdown or restart
/boot: main boot directory, independent partition, such as boot menu, kernel
/dev: device device , The directory where the device files are stored
/etc: the path where the configuration files are stored
/home: the home directory of ordinary users,
/root: the home directory of the administrator
/media: the mounting directory of the CD-ROM drive
/lib or lib64: the path where the function library is stored, For example, download python
/mnt: the mounting directory of temporary devices
/proc: the data in it is in the memory, the directory where the process is located
/tmp: the storage directory of temporary files
/usr: the installation directory of the software
/var: the storage directory of constantly changing files , Such as log files, mail files

The role of shortcut keys

Automatic completion: Tab
clear screen: ctrl+l
termination: ctrl+c

Linux system distinguishes file types

Blue: Directory
Black: Common file
Light blue: Symbolic link (shortcut)
Yellow text on black background: Device file hard disk sda
Green: File with execution permission
Red: Compressed file
Purple: Picture, module file

Basic commands for adding, deleting, modifying and checking

View

View the contents of the directory: ls
View the contents of the file: cat

Create-increase

Create file: touch is usually created in tmp temporary file. For example:
touch /tmp/class1.txt
Insert picture description here
Create directory:
mkdir directory name
mkdir /tmp/class
Cut and copy:
cut: mv file path directory path
rename: mv file old Name file new name
Copy: cp file path target path
Symbolic link: ln -s target connection path established by the absolute path of the source file (similar to creating a desktop shortcut)

Delete Files

rm remove deletes
rm -f files (mandatory deletion)
rm -rf directories (mandatory deletion of directories)

Obligatory Documents

/etc/passwd saves the information of all users in the system
uid user identity 0 is super administrator 500-60000 ordinary user 1-499 program user (cannot log in to the system)
root❌0:0:root:/root:/bin /bash
field 1: user name
field 2: password placeholder
field 3: uid number
field 4: user’s basic group id number first group and then user
field 5: user information record location (obsolete)
field 6: user’s home Contents
Field 7: What command interpreter is used after the user logs in to the system

/etc/shadow Shadow recording system user's password information
root: 6 6. 6 A2 $ A5P: 18129: 0: 99999: :::. 7
Field 1: User Name
Field 2: sha-512 by the salt value and the encrypted ciphertext
Field 3: submissions from a recent January 1, 1970 password Time
Field 4: Minimum password validity period
Field 5: Maximum password validity period 90
Field 6: Warning 7 days before password expiration
Field 7: Password inactivity period
Field 8: Password expiration time from January 1, 1970

/etc/group saves group information

python enter the python command interpreter

import crypt
crypt.crypt(“密码”,“ 6 6 6 xxxxx”)
The ciphertext encrypted with salt and sha512 appears. Check whether the ciphertext is the same as your password ciphertext.
quit() Exit python

6 6 6 C3kgOgP2$/3VFNPVypJa/ODEV/3dYBQ5fdJDNCHHd1VBKonfFtrZ7.vwC77BWtIgt18RAWPPsjUyOsYIOCAS6x/2Zz2yWs/
Try to crack my password, the password is a pure number, the length is within 5

The relationship between groups and users:
1. The user must have a basic group. If there are basic members in the group, the group is not allowed to be deleted.
2. A user can have multiple additional groups. If the additional group has no basic members, the group can be deleted.

Exercises:
1. Create a group named 1901class, the group id is 1000
groupadd -g 1000 1901class
2. Create a user with your own name, the user's uid is 600, the basic group is the 1901class group
useradd -u 600 -g 1901class user Name
3. Set the password for the user to 123456
passwd allen
4. Delete the user and its home directory
userdel -r allen

useradd
-u specifies the uid number
-g specifies the basic group
-G specifies the additional group
-s specifies the command interpreter for user login -s /sbin/nologin does not allow login -s /bin/bash allows login

The usermod option is the same as above

userdel
-r delete the user's home directory

groupadd
-g specifies the gid number. The
groupmod option is the same as the above
groupdel deletes the group

passwd username
-S view user password status
-l lock user
-u unlock user password
-d delete user password

chage -M 90 The longest validity period of the user name to modify the user password

visudo sets the commands executed by the administrator for ordinary users

Host where the user name is logged in=Command allowed to be executed NOPASSWD:ALL
allen ALL=(root) NOPASSWD:ALL

Allen user login
sudo init 6 use root user command to escalate privilege

Directory permission commands

drwxr-xr-x. root (owner of the file) root (group of the file) directory
-rw-r–r--. root root file

Insert picture description here

Insert picture description here

chmod 764 filename
Insert picture description here
Insert picture description here
Insert picture description here

Tape bit: chmod o+t directory name
sgid: chmod g+s directory name
suid: chmod u+s directory name

Prevent adding users:
chattr +i /etc/passwd /etc.shadow

Network address view and configuration

Insert picture description here
Static IP configuration:
Insert picture description here
enable routing function:
Insert picture description here

Modify the value to 1 to
Insert picture description here
Insert picture description here
turn off (open) the firewall:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42478365/article/details/113703720