Commonly used instructions

  • Lsof -i:port Displays the port number

  • Ln -s/usr/local/nodebox nodejs/bin/pm2 (source path)/usr/local/bin (environment) system instruction is added to the environment variables

  • Echo $PATH Displays the current PATH

Common Configuration Paths

  • /The root directory
  • ~The home directory
  • /usr/local/bin/Execute script to put soft link effect
  • .bashrcIs the global environment variable root
  • /etc/.profileLocal environment variable
  • Export path= The execution path of the file you want to configureAdd system environment variables

Shutdown restart command/shortcut application/search key

The shutdown command

Shutdown -h now Shutdown immediately

Shutdown -h 60 Shuts down after 60 minutes

  • Shutdown -c Disables the shutdown

Init 0 immediately shuts down

Restart command

Reboot Restarts the system.

Shutdown -r now Restart the system. Shutdown -r 30 Restart the system after 30 minutes

  • Shutdown -c Cancel the restart
  • Logout logout

Application search shortcuts on Windows

Windows key + S search

Windows key + A displays the application


Relative path and absolute path

  • Relative path If the path does not start with **/ or ~**, it indicates the directory location relative to the current directory
  • Absolute path When entering a path, the path starts with **/ or ~**, indicating the specific directory location starting from the root directory/home directory

Directory tree structure

directory instructions note
/root Home directory of administrator root
/home Default home directory for common users /home/bozai /home/heima
/ bin – > / usr/bin Commands of common users /usr/bin/date /usr/bin/ls
/ sbin – > / usr/sbin Command used by the administrator /usr/sbin/shutdown
/usr/local Default installation directory of third-party source packages C:\Program Files
/etc System and service-related configuration files /etc/passwd
/var Dynamic, changeable data files Log file (/var/log/xxx)
/tmp Directory for storing temporary files Globally writable (system or program produces temporary files)
/dev Device file /dev/sda /dev/nvme0n1
/ lib – > / usr/lib The library files Softlink file
/ lib64 – > / usr/lib64 The library files Softlink file
/proc Virtual file system It reflects the kernel, process information, or real-time status
/boot System kernel, boot program related files
/media Default mount point for mobile devices
/mnt Manually mount the mount point of the device

Features of files and directories under Linux

  • Linux fileordirectoryThe longest name can be256A character
  • In order to.The files at the beginning are hidden files and can be displayed only when the -a parameter is used
  • . Represents the current directory
  • The.. stands for the upper directory
  • All directory and file names in Linux are case sensitive

Bash standard input and output

Stdin: input file descriptor on the keyboard — >0 StDout: correct output file descriptor on the screen — >1 Stderr: incorrect output file descriptor on the screen — >2 2

> : Standard output redirection, override redirection, 1> or > standard output redirection, 2> Standard error redirection

>> : redirection append, 1>> standard output append, 2>> standard error append < : standard input &> : standard output standard error redirection

echo -e ‘date\nuuu’ > 1.sh

Command/file lookup

The which command: finds the absolute path of the command

The whereis command: finds the path and documentation information of the command

File search (==find==) Find command: exact search, disk search,IO read and write, CPU overhead Usage 1: find out output to the screen == according to demand ==find out directly output to the screen

== Usage: ==find Indicates the keyword of the path option

Common Meanings ==-name== Searches for a file by file name== -iname== Searches for a file by File name Ignoring case ==-size== Searches for a file by file size== -type== Searches for a file by file type== -mtime== Searches for a file by file modification time -atime Searches files by access time. -ctime Searches files by file creation time. -perm Searches files by file permission

Linux File Types

Download the updated uninstallation software

All updates:

==sudo apt-get update==

==sudo apt-get upgrade==

Sudo apt-get install sudo apt-get install

Uninstall: ==sudo apt-get remove==

apt upgrade

Apt upgrade is the latest package list obtained from the update command to actually update the software.

apt dist-upgrade

Apt dist-upgrade is the latest package list obtained from the update command to actually update the software.

The difference between apt upgrade and dist-upgrade Upgrade: The system will upgrade an existing Package. If there is a dependency issue that requires the installation of another new Package or affects the dependency of another Package, the Package will not be upgraded and will be retained.

Dist-upgrade: It is smart to solve dependency issues, if there is a dependency issue and a new Package needs to be installed/removed, it will try to install/remove it (so often dist-upgrade is considered a risky upgrade)

Deb represents the location of the software, deb-src represents the location of the software source code

Archive compressed file

Archive tar== -cvf== ABC ==.tar== ABC

==c==, create creates a file

==v== : verbose displays details

==f== indicates file

Archive and compress tar ==-zcvf== ABC ==.tar.gz== ABC

==z== Compressed to ==.tar.gz== file format

unzip

==tar -zxcf abc.tar.gz== Decompress the file

==tar -zxcf abc.tar.gz -c test== Decompress the file to a specified directory

File permissions

Viewing File Permissions

==ls -l==

==-owner== : Owner of the file

==-r== : Indicates whether the file is readable

==-w== : Indicates whether the file is writable

==-x== : Indicates whether the file can be executed

Modifying File Permissions

==chmod +w abc.txt==

==chmod -w abc.txt==

Add or subtract permissions note: default to yourself

==chmod a+w abc.txt==

==a== The user modifies the permission

==u== Modify the permission yourself

==o== Modify the permissions of others

Example Change the owner of a file

==chown -R zjf /opt/abc==

== -r == transfer all subfiles and subdirectories in the directory

User management

All operations should be ==sudo== administrator operations

Add user

sudo useradd -m test1

==-m== Indicates that a user directory is added to /home

Changing a User password

sudo passwd test1

Delete user

sudo userdel test1

Note: This deletes only the user but not the user directory

Note: Delete the user directory as well

The super user

For the first time, you need to set a password

==sudo passwd root==

Switch to user root

==su root==

Exit the superuser

==exit==

Users and groups

Create a group

==groupadd boys==

Create a user

==useradd -m -g boys ming==

In the command, ==-g== indicates that a user is being added to the boys group

Modify an existing user to a new group

==usermod -g boys zjf==

Usermod indicates modifying user information

The most basic commonly used instructions

Ls: view command

Ls [Optional] View all files in the directory

Such as: Ls -a home –> View all files in the directory, including hidden files ** -l Lists all files directory and permission -a View all files in the directory, including hidden files. -h human displays all files in the directory in a humanized manner. -d Lists only the directory name and does not list other contents -r Displays the inode number (index number) of the file. -r displays the contents of the directory recursively. -m Displays the contents separated by commas (,)

-r displays all files recursively

Lists the contents of the current directory

==ls -a== Displays all files including hidden files

==ls -l== Displays detailed information about the file

== ls-h-L == Displays the file size in a user-friendly way

The wildcard

The wildcard meaning
* Represents any number of characters
? The value contains at least one character
[] Indicates that any character group can be matched
[abc] Match any of a, B, or C
[a-f] Matches any character from a to F

Mkdir: directory (folder) creation command

Mkdir (name)

For example, mkdir LHJ creates a directory named LHJ

To create multiple directories at a time, add an option ==-p==

mkdir -p school/teacher/student/book

pwd

Viewing the current Path

==pwd==

CD path

Change current path

== CD Path name == Switches to the specified path

== CD == Switches to the current active user home

== CD ~== Switches to the current active user home

== CD.== Stay in the current directory

==cd .. == Switch to the parent directory

== CD /== Switch to the root directory

== CD /home== Switch to the home directory under the root directory

== CD -== Switch between the last two working directories

File rename and copy, move

Cp copy

==cp -i a/b/123. TXT a/c/456. TXT == A message is displayed before the file is overwritten

==cp -r c/d a/cb== Copies one directory to another directory

mv

  • The mv command can be used to move or rename a file or directory

    ==mv a.t_t b.t_t == Renames a file or folder

    ==mv a.tb /home/== Move the file a.tb to the home directory

Rm Option file or directory

Remove a file or directory

  • -f: indicates force. The file that does not exist is ignored and no warning message is displayed.

  • -i: interactive mode. Before deleting, it will ask the user whether to take action

  • -r: Delete recursively! Most commonly used in directory deletion! Very dangerous option!!

  • Note: RM can not only delete directories, but also delete other files or compressed packages, in order to facilitate your memory, no matter any directory or file to delete, directly use == m-rf directory/file/compressed package ==

    ==rm file == Deletes files in the current directory

    ==rm -f== Delete files in the current directory (without asking)

    ==rm -r a== Deletes directory A under the current directory recursively

    ==rm -rf a== recursively delete a file from the current directory (without asking)

    ==rm -rf *== Delete all directories and files in the current directory

    ==rm-rf /*==** ** Delete all files in the root directory

    ==rmdir -p Directory name == Is deleted together with the [empty] directory of the previous level

clear

  • Clear the screen

touch

Touch create/text file

Touch -a Parameter -t “Year month day time”

-a (modify access >) -t (modify time)

-m (modify change >) -t(modify time)

**touch -d “year month day “**

Touch -d “time” :** The current time of the year

The echo command

Echo print

Echo Hello World >

-n: Does not print the last newline symbol

-e: interprets escape characters to make \n \t and so on work by adding “” or” “to content

The cat command

The cat command displays small files from the first line to the last line. -a: displays control characters, such as newlines and tabs (Linux and WindowsM and Windows ^M and WindowsM). Tac: Displays small files from the last line to the first line, more and less You are advised to run the less command. Head: The first 10 lines of a file are displayed by default. Head -n 15 or head -15 indicates the first 15 lines. Tail -n 15 or tail -15 indicates the last 15 rows. -f dynamically displays the LDD command. Generally, it is used to view binary command files

The file parameter displays the file type

Stat parameter Indicates the permission to view file status information and modify file size

The which parameter displays the command location

Date Displays the current system time

Id User name Check whether the user is available

Df -h Displays the disk space

## Network IP release

Dhclient -r eth0 Releases the new NIC ID. -r releases the NIC ID

IP a View the NIC ID

Dhclient -v eth0 Obtains the ID again. -v Displays 1-3-2-4

kali:ssh

service ssh start

systemctl enable ssh

systemctl restart ssh

systemctl status ssh

Lsof -i :22 Check the port

Quick lookup: CTRL + R


The help command

Man Command name

  • That is, the manual, to find out how to use the command

  • Operation keys when using man:

    The operation key function
    The blank space key Displays the next screen of the man page
    The Enter key Scroll the man page one line at a time
    b Roll back the screen
    f Rolling forward a screen
    q exit
    /word searchwordstring

==man mkdir==

Command name –help

  • Find the use help of the command

==mkdir –help==

Simple help command

Type argument: Determines whether a command is external or internal

Internal help: parameter help

External parameter: parameter –help

Internal commands: commands built into the shell. bash

External commands: third-party programs, commands brought by software

Detailed help command

Man parameters

man man

ANUAL SECTIONS The standard sections of the manual include: 1 User Commands Commands are used by all users 2 System Calls 3 C Library Functions 4 Devices and Special Files 5 File 6 Games et.al. Game 7 Miscellanea Miscellaneous 8 System Administration tools and Deamons System administrator It is related to program users

Program Monkey Manual MAN 23467 Administrator manual man 158

View the related official documents

httpd.apache.org/docs/2.4/ nginx.org/ Tengine.taobao.org/nginx_docs/… www.zabbix.com/documentati… puppet.com/docsOther communitywww.linux