- Change directory: CD [directory]
- To view files in the current directory: ls -a[View all files including hidden]/-l[View file display permission and ownership]
- View the current directory: PWD
- Copy files or folders: cp [filename/-r folder]
- Remote copy files or folders:
- SCP [-r] local_path username@ip:path
- SCP [-r] username@ip:path local_path
- Move or rename files or folders: mv [file/folder]
- Create folder: mkdir [folder_name];
- 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
- Change the owning user or user group of a file: chown owner:group [file/folder]
- New file:
- touch [filename]
- vi/vim [filename]
- View files:
- Output file contents: cat [filename]
- Tail [-f: Output file content in real time] [filename]
- less
- Search content:
- Grep [regular]
- awk
- Create soft chain: ln -s [realpath/filename] [realPath]
- View the process that contains all users: ps-aux
- 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
- The compression
- Decompress: tar -zxvf [filename]
- Zip: tar -zcvf [filename]
- View the current command path, which
- Viewing the Current User
- who
- whoami
- Check how long the current system runs: uptime
- Read the disk space: df -h
- Du -f –max-depth=[traversal folder depth] [file/folder]
- Debian add software source: apt-add-repository
- Find a file:
- find [path] -name [filename]
- find [path] -user [owername]
- find [path] -group [groupname]
- To delete files or folders, run the rm [-r] [file/folder] command.
- Process:
- Kill process: kill [pid]
- Parent process ID(PPID) : ps -ef
- Shutdown/restart
- Shutdown: shutdown -h now
- Shutdown: init 0
- Shutdown: the halt
- Shutdown: poweroff
- Restart: shutdown -r now reboot
- 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
- 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
- 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
- Find the file name where whereis
Original text: github.com/TIGERB/easy…