Linux Cheatsheet

  1. Linux to view the total size of the folders and files contained in the current directory
du -sh
  1. Linux checks the size of the download folder in the current directory, because the set depth is 0
du -h --max-depth=0 download
  1. Linux checks the size of each folder and file in the current directory, as well as the size of subfolders and subfiles, because the set depth is 1
du -h --max-depth=1 *
  1. Linux searches for services related to the specified keyword, such as java services
ps -ef | grep java
  1. Linux view all port occupancy
netstat -tupln
  1. View all processes
ps aux # ps -elf
  1. View the ranking of process resource usage
top
  1. Linux to view the permissions of all files and folders in the current directory
ls -l # or specify a file or folder ls -l file.txt
  1. Linux to view the user group to which the current user belongs
groups # or specify user groups openhacking
  1. Linux batch modify file and folder permissions
chmod -R 777 /software/lwebapp

# -R parameter is to recursively process all files and subfolders in the directory
# 777 is to open all permissions, it is the highest permission
  1. Linux batch modify file and folder owner
chown -R opensource:openhacking /software/lwebapp # Or specify the user directly chown -R openhacking /software/lwebapp

# Perform the same owner change on all files and subfolders in the /software/lwebapp directory, so that the owner is changed to the openhacking user of the opensource user group
  1. Kill the process with the specified pid
kill -9 11864
  1. Compress data
tar -zcvf my-folder.tar.gz my-folder
  1. Unzip the data
tar -zxvf my-folder.tar.gz
  1. Linux check remaining disk space
df -h