Linux Xiaobai's three-day entry and advanced notes - DAY2

User management commands

useradd

Add user

Syntax: useradd [options] username


passwd

change password command

Syntax: passwd [options] [username]

User password: In the production environment, the length of the user password is more than 8 characters. Set the upper and lower case plus numbers plus special characters, and change the password regularly.

ys ^ h_L9t 

 

userdel(user delete)

delete users

-r Delete the host directory when deleting the account (remove)

 

Process management commands

The difference between a process and a program:

1. A program is a static concept, which itself is stored for a long time as a software resource; while a process is the execution process of a program, it is a dynamic concept, has a certain life cycle, and is dynamically generated and destroyed.

2. There is no one-to-one correspondence between programs and processes. A program can be shared by multiple processes; on the other hand, a process can execute several programs sequentially in an activity.

The difference between process and thread:

Process: It is the program or command being executed. Each process is a running entity, has its own address space, and occupies certain system resources.

Thread: A lightweight process; a process has an independent address space, a thread does not; a thread cannot exist independently, it is created by a process; relatively speaking, a thread consumes less CPU and memory than a process.

The role of process management?

Determine the health status of the server

View all processes in the system

kill process


ps command

Role: View process information in the system

Syntax: ps[-auxle]

Common options

    a: show processes for all users

    u: Display username and startup time

    x: show processes that do not have a controlling terminal

    e: show all processes, including those without a controlling terminal

    l: long format display

View all processes in the system

# ps aux #View all processes in the system, use the BSD operating system format, unix

# ps -le #View all processes in the system, using the Linux standard command format

ps application example

# ps -u or ps -l View the details of the processes that belong to you

# ps aux | grep sam View processes executed by user sam 
    # ps -ef | grep init View specified process information

 

pstree

Role: View the current process tree

Syntax: pstree[options]

       -p show process PID

       -u show the user of the process

 

top     

Function: View system health status  

Displays the processes that consume the most resources in the current system, as well as some load conditions of the system.

Syntax: top [options]

       -d seconds, specify a few seconds to refresh once, the default is 3 seconds (dynamic display)

 

kill

Action: close the process

Syntax: kill [-options] pId

kill -9 process number (forcibly close) commonly used

kill -1 process number (restart process)

 

authority management

Three basic permissions

r read permission (read)

w write permission (write)

x execute permission (execute)


Permission description

owner group others

Bit 1: file type (d directory, - normal file, l linked file)

Bits 2-4: User (owner) authority, represented by u (user)

Bits 5-7: Group permissions, represented by g (group)

Bits 8-10: other users (others) permissions, represented by o (other)

Bits 2-10: Indicates all permissions, represented by a (all)

Type: f binary file l soft link file d directory  

character

permission

Implications for the file

Implications for the directory

r

read permission

Can view file content

Can list the contents of a directory (ls)

w

write permission

file content can be modified

Can create delete files in a directory ( mkdir,rm )

x

execute permission

executable file

Can enter the directory (cd)

document:

r-cat,more,head,tail,less

w-echo, i saw

x-command, script

content:

r-ls

w-touch,mkdir,rm,rmdir

x-cd 

The permission to delete a file is to have wx permission on the directory where the file is located.


permission change - chmod

英文:change mode(change the permissions mode of a file)

Role: change file or directory permissions

grammar:

chmod [{ugoa}{+-=}{rwx}] [filename or directory]  

chmod [mode=421] [file or directory]

       Parameters: -R The files and subdirectories below do the same permission operation (Recursive recursive)

Thinking: Who can change the permissions of a file? root owner

root

file owner

For example: chmod u+x a.txt

chmodu+x,o-x a.txt

Permissions are represented by numbers (r=4, w=2, x=1, -=0)

       For example: chmod 750 b.txt

rwx and digital representation can be switched at will

Note: The root user is a super user, and root can make changes with or without permissions. Test permissions with a normal user.

You cannot use an ordinary user to modify the permissions of another ordinary user.


change owner - chown

English: change file ownership

Role: Change the owner of a file or directory 

Syntax: chown user[:group] file... 

 -R : recursive modification

Parameter format: 

      user : the user ID of the new file owner

group: the user group of the new file owner 

   eg: #chown lee file1 Change the owner of the file1 file to user lee

eg: #chown lee:test file1 Change the owner of the file1 file to user lee, and the group to test

eg: #chown –R lee:test dir Modify the owner and group of dir and its subdirectories


change group chgrp  

英文:change file group ownership

Role: Change the group to which a file or directory belongs

Syntax: chgrp [group] file... 

eg:chgrp root test.log Change the group of test.log to root


RPM package management

RPM packages are also known as binary packages

RPM is the abbreviation of RedHat Package Manager (RedHat Package Management Tool). Although the name of this file format is marked with the RedHat logo, its original design concept is open. Now, Linux distributions including RedHat, CentOS, SUSE, etc. If adopted, it can be regarded as a recognized industry standard. RPM files are the easiest to install in Linux systems


RPM command usage

Common parameters of rpm

i: Install the application (install)

vh: display the installation progress; (verbose hash)

U: upgrade package; (update)

qa: show all installed packages (query all)

e: Uninstall the application (erase)

Note: If other software packages have dependencies, a prompt message will be generated when uninstalling, you can use --nodeps to force uninstall.

Query all installed rpm packages: # rpm –qa

Query mysql related packages: # rpm –qa | grep mysql

Install: rpm -ivh jdk.rpm

Uninstall: rpm –e mysql*

Forced uninstall: rpm -e mysql* --nodeps

Graphical interface, manual mount


YUM management

yellowdog updater modified package management tool

The benefits of applying yum:
1. Automatically resolve package dependencies
2. Convenient package upgrade
query

yum list Query a list of all available packages

yum search keyword Search all packages related to the keyword on the server

You can find the package name through the yum info keyword

Install

yum -y install package name     -y automatically answers yes 

upgrade 

yum -y update   package name

Note: If you don't add the package name, it will upgrade everything, including the kernel. You must add a package name to upgrade a single package, use caution to upgrade all

Detect upgrade yum check-update
uninstall

yum -y remove package name    
help 

yum --help、man yum

yumclean all                clears cache and old packages

yum repolist View currently available yum sources

yum deplist httpd lists all dependencies of a package

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326745162&siteId=291194637