Shell common commands (continuously updated)

1. Check the file size
du -h (the size of all files under the folder)
ls -lh
ls -lh
ls -l|grep The file name displays the file size in K
ls -l --block-size=m|grep The file name starts with M displays file size
ls -l --block-size=G|grep file name displays file size in G
2. View hardware devices
df -h
sudo smartctl -a /dev/nvme0n1 (specific location)
3. What hardware devices are there?
lsblk
sudo lsblk --scsi (list suppliers)
lsscsi
4. Disk mount
sudo mkdir /data
sudo mount /dev/nvmeOn1 /data
5. Change file permissions
sudo chmod 777 file name/folder
6. Back to the previous Once the directory
cd -
7. Delete all the files under the folder
to the directory
rm -f *
8. Check whether the kernel
sysctl kernel.kptr_restrict
sysctl -w kernel.kptr_restrict=0
9. Check the memory and clear the memory to check the cache command

free -m

command to clear cache

echo 1 > /proc/sys/vm/drop_caches

echo 2 > /proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/drop_caches to view cached commands

free -m

command to clear cache

echo 1 > /proc/sys/vm/drop_caches

echo 2 > /proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/drop_caches to view cached commands

free -m

command to clear cache

echo 1 > /proc/sys/vm/drop_caches

echo 2 > /proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/drop_caches to view cached commands

free -m

command to clear cache

echo 1 > /proc/sys/vm/drop_caches

echo 2 > /proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/drop_caches
to view cached commands

free -m

command to clear cache

echo 1 > /proc/sys/vm/drop_caches

echo 2 > /proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/drop_caches

Change the ownership of the file
sudo chown wjxt:wjxt ./file

csv file sorting
sort -t ',' -k2,2 -k3,3n -k1,1 ./input file
grep | sort
head -n1 ./2022-04-02-14-32-58.csv [input file ] > cpu.csv [output the first line to cp.csv]; tail -n+2 ./2022-04-02-14-32-58.csv [start from the second line]| sort -t ',' -k2,2 -k3,3n -k1,1 >> cpu.csv [Separate by commas, first sort by the second column, then sort by the third column, in numerical order, then sort by the first column, output to cpu.csv]

head -n1 ./2022-04-02-14-32-58.csv > cpu.csv ; tail -n+2 ./2022-04-02-14-32-58.csv | sort -t ‘,’ -k2,2 -k3,3n -k1,1 >> cpu.csv

Instructions to mount the remote server to the local

sshfs pm8:/home/wjxt/ly/mount location

755 permission
mount -t is required for both the mount location and the remote location

Uninstall command
sudo umount /dev/nvme0n1

View the number of files in the folder
ls | wc -l

When using the server remotely, I hope to close the dialog box locally

The program continues to run
tmux new -s ly
exit
ctrl+B and then press D
to re-enter
tmux attach -t ly
to kill
tmux kill-session -t ly

Mount remote folder to local

The mount command
sshfs wsl:/home/ly ./ mount location
does not need to use sudo,
and an error will occur

Change file ownership

## 	创建用户和组

sudo chown wjxt:wjxt ./file

Create a file

Copy the specified file to

find “/home/wjxt/ly/cpu_test/logs/2022-04-06-15-30-44/” -name “*log” | xargs -i cp {} “/home/wjxt/ly/cpu_test/logs/log”

find "/home/wjxt/ly/cpu_test/logs/2022-04-06-15-30-44/" [specified file] -name "*log" [specified file keyword] | xargs -i cp { } "/home/wjxt/ly/cpu_test/logs/log"【Copy to specified folder】

create your own user

sudo useradd ly
create password
sudo passwd ly

Change folder ownership

sudo chown -R wjxt:wjxt ./file

kill ctrl+z paused file

jobs -l
find process number
kill -9 process number
jobs -l confirm all files are stopped

remote port forwarding

Link VPN

curl google.com

Copy between different users on the same machine

scp filename [email protected]:/transferred file name
scp /home/wjxt/ly/proxy_setup.sh [email protected]:/home/ly/soft

Copy some files to the specified folder

find PMEM_DAX* | xargs -i cp {} …/… file address copied to

Count the size of each row and record it

head -n1000000 ./transactions.json | awk '{print length}' | sort -k1,1n > ./length.txt
statistics of the first 100W

network

Details: /leveldb/NVM-DAX/shell.txt

Guess you like

Origin blog.csdn.net/weixin_41523437/article/details/124072869