Last active
March 4, 2025 09:17
-
-
Save robertmorel-uk/2f114e7c3db55f15a47d4e029dea849d to your computer and use it in GitHub Desktop.
Useful snippets for networking that I use repeatedly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HSTS status | |
curl -s -D- https://example.com/ | grep -i Strict | |
ssh-keygen -t rsa -b 4096 -f ~/.ssh/github_rsa -C "username@hostname" | |
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/github_ed25519 | |
# Basic add user with SSH | |
sudo adduser <USER> | |
sudo su <USER> | |
ssh-keygen | |
cd ~/.ssh | |
nano authorized_keys | |
Add public key | |
chmod 644 authorized_keys | |
exit | |
# optional or add to wheel | |
sudo visudo | |
<USER> ALL=(ALL) NOPASSWD:ALL | |
# Del user and home | |
sudo userdel -r <USER> | |
# File view and edit | |
nano file.txt # to edit file.txt | |
cat file.txt # to view file.txt | |
less file.txt # to view with scrolling capabilities | |
head file.txt # to view the first 10 lines | |
head -n 5 file.txt # to view the first 5 lines | |
tail file.txt # to view the last 10 lines | |
tail -n 5 file.txt # to view the last 5 lines | |
# Search in files | |
grep hello file.txt # to search for hello in file.txt | |
grep -i hello file.txt # case-insensitive search | |
grep -i hello file*.txt # to search in files with a pattern | |
grep -i -r hello . # to search in the current directory | |
# Search for files and directories | |
locate # find a string | |
find # to list all files and directories | |
find -type d # to list directories only | |
find -type f # to list files only | |
find -name “f*” # to filter by name using a pattern | |
# Env variables | |
printenv # to list all variables and their value | |
printenv PATH # to view the value of PATH | |
echo $PATH # to view the value of PATH | |
export name=bob # to set a variable in the current session | |
# Install by creating a .deb | |
# Verify that you have all required tools | |
sudo apt-get install python g++ make checkinstall fakeroot | |
# Create tmp dir and switch to it | |
src=$(mktemp -d) && cd $src | |
# Download the latest version of Node | |
wget -N http://nodejs.org/dist/node-latest.tar.gz | |
# Extract the content of the tar file | |
tar xzvf node-latest.tar.gz && cd node-v* | |
# Run configuration | |
./configure | |
# Create .deb for Node | |
sudo fakeroot checkinstall -y --install=no --pkgversion $(echo $(pwd) | sed -n -re's/.+node-v(.+)$/\1/p') make -j$(($(nproc)+1)) install | |
# Replace [node_*] with the name of the generated .deb package of the previous step | |
sudo dpkg -i node_* | |
# Install | |
sudo mv Postman-linux-x64-8.6.2.tar.gz /opt/ | |
cd /opt | |
sudo tar xzvf Postman-linux-x64-8.6.2.tar.gz | |
sudo rm Postman-linux-x64-8.6.2.tar.gz | |
sudo ln -s /opt/Postman/Postman /usr/local/bin/postman # symbolic link | |
touch ~/.local/share/applications/postman.desktop # create desktop gui file | |
# add to file | |
[Desktop Entry] | |
Name=Postman | |
GenericName=API Client | |
X-GNOME-FullName=Postman API Client | |
Comment=Make and view REST API calls and responses | |
Keywords=api; | |
Exec=/usr/local/bin/postman | |
Terminal=false | |
Type=Application | |
Icon=/opt/Postman/app/resources/app/assets/icon.png | |
Categories=Development;Utilities; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment