Linux命令备忘录
Based on my ubuntu:
- Shutdown
shutdown nowshutdown -r nowsudo shutdown -h now
- Ubuntu OS info and hardwares:
lsb_release -acat /proc/versioncat /etc/redhat-releasecat /proc/meminfocat /proc/cpuinfo | grep cores | uniqlspci | grep VGAlspci | grep 3D
- Disk:
df -hdu -h --max-depth=1du -sh *
- Folder and File shortcut:
ln -s ~/Work/BackupProject ~/Desktopln filea filea_shortcut
- Group & Users:
cat /etc/groupcat /etc/passwd
- JAVA_HOME:
/usr/lib/jvm/java-8-openjdk-amd64/
- no hung up
nohup java -jar app.jar &pidof java
- convert file encoding
dd conv=ascii if=start.sh of=start.sh.txt
- Redis
sudo service redis-server stopps aux | grep redisredis-server &redis-cli -h hostname -p port -a passphase
- find some file
find / -name app.jar
- de-package
sudo dpkg -i file.deb
- my local nginx config:
cd /etc/nginx/sites-enabled-llhaohanwubian -> /etc/nginx/sites-available/haohanwubian
- firewall settings
sudo ufw enablesudo ufw allow 8080/tcp comment 'my website'sudo ufw allow 9000:9999/tcp
- create file with specific length
truncate -s 25M test.txtfallocate -l 32000 test.txt
- random string 20 bytes
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1
- random int between 0 and 65535
od -An -N2 -i /dev/urandom | tr -d ' '
- tar
tar -cvf test.tar test/tar -xvf test.tartar -czvf test.tar.gz test/tar -xzvf test.tar.gz
- md5sum
md5sum test.tarsha256sum test.tarsha512sum test.tar
- windows OS sha256
certutil -hashfile test.zip SHA256
- npm
npm config get registrynpm config set registry https://registry.npmmirror.com
- Uninstall a package
dpkg --listsudo apt-get remove <package name> && sudo apt-get autoremove
- generate rsa keys and add rsa key to system
ssh-keygeneval $(ssh-agent -s)ssh-add /home/peter/.ssh/rsa_private
- git config
git config --global user.email "your_email@example.com"git config --global user.name "your_name"
- SFTP :)
scp /path/to/local/file username@remote_server_address:/path/to/remote/directoryscp ~/files/1.jar username@10.10.10.10:/opt/apps
- MacOS telnet
nc -vz 192.168.11.110 3306
- MacOS remove extra attr
xattr -d com.apple.quarantine /opt/chromedriver-mac-arm64/chromedriver
- MacOS check which process takes port 8000
lsof -i :8000