Skip to content

Instantly share code, notes, and snippets.

@podrezo
Created February 27, 2021 18:57
Show Gist options
  • Save podrezo/dcddf42fc1f384b76d287dee6304b412 to your computer and use it in GitHub Desktop.
Save podrezo/dcddf42fc1f384b76d287dee6304b412 to your computer and use it in GitHub Desktop.
Snippets of useful linux commands

Firewall (UFW)

Common service

ufw allow ssh 

Port number

ufw allow 2222 

Port range/proto

ufw allow 6000:6007/udp 

From Specific IP

ufw allow from 203.0.113.4 

Commonly used: Samba

ufw allow proto udp to any port 137 from 192.168.0.0/16 
ufw allow proto udp to any port 138 from 192.168.0.0/16 
ufw allow proto tcp to any port 139 from 192.168.0.0/16 
ufw allow proto tcp to any port 445 from 192.168.0.0/16 

Burning ISO to Flash Drive

Check all disks and what is what:

lsblk

Unmount all partitions of USB drive:

umount /dev/sdd*

Burn it:

dd if=./something.iso of=<your USB device> oflag=sync bs=4M status=progress

Eject it:

diskutil eject /dev/disk2

Test speed of storage drive

hdparm -tT /dev/sdd 
 
/dev/sdd: 
Timing cached reads:   39402 MB in  1.99 seconds = 19848.47 MB/sec 
Timing buffered disk reads: 518 MB in  3.01 seconds = 172.19 MB/sec 

NFS Setup

Server setup

Allow firewall rules

ufw allow from 192.168.0.1/24 to any port 111 
ufw allow from 192.168.0.1/24 to any port 2049 
ufw allow from 192.168.0.1/24 to any port 20048 

Create exports Edit /etc/exports and add the directory you want to export

/data 192.168.0.1/24(rw,insecure,sync,no_subtree_check,all_squash,anonuid=65534,anongid=65534) 

Options

  • Allow read and write
  • Doesn't care which source port requests come from
  • Reply to requests only after the changes have been committed to stable storage
  • disables subtree checking, which has mild security implications, but can improve reliability in some circumstances
  • Map all uids and gids to the anonymous user
  • NFS offers root squashing, a feature that maps uid 0 (root) to the anonymous (nfsnobody) uid, which defaults to -2 (65534 on 16 bit numbers)
  • This is useful for windows clients that won't have matching UIDs

Enable NFS server (arch)

systemctl enable nfs-server.service systemctl start nfs-server.service

Refresh exports

exportfs -ra

Client Setup

Edit /etc/fstab

192.168.0.201:/data     /mnt/my-local-dir        nfs     defaults,noatime,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min,x-systemd.after=network-online.target,nofail 0 0 

More info https://wiki.archlinux.org/index.php/NFS

fstab by disk UUID

Get disk UUIDs

ls -lah /dev/disk/by-uuid/ 

Mount as user-accessible

UUID=3020-85D3                    /mnt/external         exfat    defaults,noatime 0 0 

Make a new exfat disk

fdisk /dev/sdi 

g--> creates GUID partition table n --> creates new partition (press enter repeatedly to get full disk size) w --> write to disk

Afterwards format the partition using:

mkfs.exfat /dev/sdi1 
mkfs.ext4 /dev/sdi1 



exfatlabel /dev/sdi1 MY_LABEL 

To make it compatible with macs:

sudo parted /dev/sdX
    set 1 msftdata on 

Note 1 is partition number ^

Generate .htpasswd for NGINX

printf "${username}:`openssl passwd -apr1`\n" >> .htpasswd 

Firefox profile transfer

On new PC: Need to modify "compatibility.ini" from a new profile to ~/.mozilla/firefox/xxxxxx.default
Go to about:profiles, delete the new profile

Clear Linux Bluetooth Fix

pactl unload-module module-bluetooth-discover 
pactl load-module module-bluetooth-discover 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment