Created by CyanHall.com
on 11/11/2020
, Last updated: 04/30/2021.
👉 Star me if it’s helpful. Get the meaning of Shell command: just copy it and paste to explainshell
👉 Star me if it’s helpful. Get the meaning of Shell command: just copy it and paste to explainshell
1. Change the default Shell
chsh -s /bin/zsh
3. Force delete files inside directory
rm -rf dir
# -f for force, -r for recursive
5. Remove files with a given pattern
find . -name '*.pyc' -delete # remove all .pyc files from a project
7. Kill proccess with a name
kill $(ps aux | grep [name] | awk '{print $2}')
9. Check netwok connectivity
nc -z -v [ip] [port]
nc -vz -w 2 domain.com 22
11. Downloading file with breakpoint resume
wget -c [url]
13. Upload file to remote server
scp -i ssh-key-file [file/to/send] [user]@[ip]:[dest/path]
15. Generate New SSH key files
ssh-keygen -t rsa -C "remark"
17. Limit ssh key file access
chmod 400 [key-path]
19. Create a socks v5 proxy with SSH
ssh -i ssh-key-file -o IdentitiesOnly=yes [username]@[ip] -D 127.0.0.1:1007
21. macOS
say hello world
# list all langs
say -v '?'
# list all file format
say --file-format=?
say -v Ting-Ting -o test.aac hello world
2. Check the size of a file/Directory
du -sh [filePath/Directory]
4. Find file with a given pattern
find / -name filename.xx
6. Find all proccess with a name
ps aux | grep [name]
8. View a log in realtime
tail -f filename.log
10. Check used port
sudo lsof -i:[port number]
12. Download file from remote server
scp -i ssh-key-file [user]@[ip]:remote/file/path local/file/path
14. Give a script the execution permission
chmod +x ./script.sh
16. Start SSH agent
eval `ssh-agent -s`
18. Enable a ssh key
ssh-add [key-path] # without .pub
20. Shell Loop
for i in `seq -w 000 3`;do echo test_"${i}";done
# Output:
# test_000
# test_001
# test_002
# test_003
22. Add Swap Space on Ubuntu
# From https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04
# Check
sudo swapon --show
free -h
# Creating a Swap File
sudo fallocate -l 4G /swapfile
ls -lh /swapfile # check
sudo chmod 600 /swapfile
sudo mkswap /swapfile
# Enabling the Swap File
sudo swapon /swapfile
sudo swapon --show # check
# Making the Swap File Permanent
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
sudo vi /etc/sysctl.conf # add to the end of file
vm.swappiness=10
# Adjusting the Cache Pressure Setting
sudo sysctl vm.vfs_cache_pressure=50
sudo vi /etc/sysctl.conf # add to the end of file
vm.vfs_cache_pressure=50
More