1. Change directory: CD [directory]
  2. To view files in the current directory: ls -a[View all files including hidden]/-l[View file display permission and ownership]
  3. View the current directory: PWD
  4. Copy files or folders: cp [filename/-r folder]
  5. Remote copy files or folders:
  • SCP [-r] local_path username@ip:path
  • SCP [-r] username@ip:path local_path
  1. Move or rename files or folders: mv [file/folder]
  2. Create folder: mkdir [folder_name];
  3. To change the permission of a file or folder: chmod [-r: traverses all files in the folder] [Permission] [file/folder]
  • For example, 777 indicates that the user/group/other permission is 4+2+1/4+2+1/4+2+1. 4 indicates the read permission, 2 indicates the write permission, and 1 indicates the execute permission
  • The first digit in DRWXR –r– : d for folder, S for socket file, – for normal file, and L for soft chain
  1. Change the owning user or user group of a file: chown owner:group [file/folder]
  2. New file:
  • touch [filename]
  • vi/vim [filename]
  1. View files:
  • Output file contents: cat [filename]
  • Tail [-f: Output file content in real time] [filename]
  • less
  1. Search content:
  • Grep [regular]
  • awk
  1. Create soft chain: ln -s [realpath/filename] [realPath]
  2. View the process that contains all users: ps-aux
  3. To view the port: netstat -anp
  • A indicates that all LISTEN files are displayed. By default, LISTEN files are not displayed
  • N indicates that no numeric alias is displayed
  • P stands for: shows associated programs
  1. The compression
  • Decompress: tar -zxvf [filename]
  • Zip: tar -zcvf [filename]
  1. View the current command path, which
  2. Viewing the Current User
  • who
  • whoami
  1. Check how long the current system runs: uptime
  2. Read the disk space: df -h
  3. Du -f –max-depth=[traversal folder depth] [file/folder]
  4. Debian add software source: apt-add-repository
  5. Find a file:
  • find [path] -name [filename]
  • find [path] -user [owername]
  • find [path] -group [groupname]
  1. To delete files or folders, run the rm [-r] [file/folder] command.
  2. Process:
  • Kill process: kill [pid]
  • Parent process ID(PPID) : ps -ef
  1. Shutdown/restart
  • Shutdown: shutdown -h now
  • Shutdown: init 0
  • Shutdown: the halt
  • Shutdown: poweroff
  • Restart: shutdown -r now reboot
  1. My common TMUx series commands
Create a new session: tmux new-s< session name > Cuts to a session: tMUx at -t < session name > Deletes a session: tMUxkill-session-t < session name > Get session list: tmux list Temporarily toggle a window to Max or min: prefix z push tmux but save session: prefix d create a window: Prefix c Split a window vertically: prefix % Split a window horizontally: prefix"

Copy the code
  1. logrotate

Add /etc/logrotate. d:

Nginx sample file

/var/log/nginx/*.log {
        # frequency of packing logs daily weekly monthly
        daily
        Add the date suffix to the package file
        dateext
        I can't find the log
        missingok
        Save 14 logs
        rotate 14
        Compressed logs default gzip
        compress
        # delay compression to the next rotate
        delaycompress
        # ignore empty logs
        notifempty
        #?
        create 0640 www-data adm
        # Execute all rotate before executing the script
        sharedscripts
        #?
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi \
        endscript
        #?
        postrotate
                invoke-rc.d nginx rotate >/dev/null 2>&1
        endscript
}

Copy the code

Enforcement:

logrotate -f /etc/logrotate.d/nginx

Appendix: Shell judgment file

-eFilename True if the file exists-dFilename True if the file exists and is a directoryCopy the code
  1. supervisor

Install debian:

sudo apt-get install supervisor

Adding a configuration file:

cd /etc/supervisor/conf.d

Example configuration file:

[program:demo]
#?
directory = yourpath
Command to start the process
command = yourcommand
Start when Supervisor is started
autostart = true
The exit process automatically restarts
autorestart = true
The user who executes the command
user = www-data
# log path
stdout_logfile = /var/log/supervisor/demo.log
# This no means that supervior takes over the daemon when starting such as nginx or phP-fpm
daemonize = no

Copy the code

Start or restart the Supervisor

sudo service supervisor start sudo service supervisor restart

Start our process

sudo supervisorctl start demo

  1. Find the file name where whereis

Original text: github.com/TIGERB/easy…