linux
This is an old revision of the document!
Table of Contents
Linux
Useful Linux commands, with no particular order
Check which program is using a particular port
sudo lsof -i:port
Kill a particular PID
sudo kill -9 PID
Check the current folder size
du -hs .
Show filesystem information
df -h
SSH
More info: https://www.ssh.com/ssh/tunneling/example/
Copying local keys to a remote server
ssh-copy-id user@server
Create a remote tunnel into localhost
ssh -L local-port:localhost:remote-port user@server -N
Note: AllowTcpForwarding
and PermitOpen
have to be enabled in /etc/ssh/sshd_config
Forward a local port to a remote host (like ngrok)
ssh -N -T -R local-port:localhost:remote-port user@server
- -N Do not execute a remote command. This is useful for just forwarding ports.
- -T Disable pseudo-terminal allocation.
- -R Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side.
SCP
scp -r /folder/to/upload user@server:/destination/on/server
tar & untar
tar
tar -czvf file.tar.gz file/or/folder/to/tar/
- -c create
- -z gzip
- -v verbose
- -f filename
untar
tar -xvf file.tar.gz
- -x extract
- -v verbose
- -f filename
gpg encrypt/decrypt
Encrypt
gpg -c --cipher-algo AES256 file/to/encrypt
You will be asked to enter a password
Decrypt
gpg file/to/decrypt
You will be asked to enter a password
Download an entire website using wget
More: https://gist.github.com/mikecrittenden/fe02c59fed1aeebd0a9697cf7e9f5c0c
wget \ --mirror \ # Makes (among other things) the download recursive. --page-requisites \ # Get all assets/elements (CSS/JS/images). --adjust-extension \ # Save files with .html on the end. --span-hosts \ # Include necessary assets from offsite as well. --convert-links \ # Update links to still work in the static version. --restrict-file-names=windows \ # Modify filenames to work in Windows as well. --domains yoursite.com \ # Do not follow links outside this domain. --no-parent \ # Don't follow links outside the directory you pass in. yoursite.com/whatever/path # The URL to download
linux.1615923210.txt.gz · Last modified: 2024/11/17 12:59 (external edit)