Skip to content

Instantly share code, notes, and snippets.

@franckweb
Last active January 4, 2024 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franckweb/fbe9368b88a6e85f2da6198d4e2bb16d to your computer and use it in GitHub Desktop.
Save franckweb/fbe9368b88a6e85f2da6198d4e2bb16d to your computer and use it in GitHub Desktop.
Useful commands

stop/start snap constant updates

snap refresh --hold snap refresh --unhold

copy files with specific extension to new directory

find . -name *.php -exec cp {} newDirectory ;

rsync

rsync -vzcrSLhp --exclude="deploy.sh" ./ deploy-ex:/var/www/site

The options:
v - verbose
z - compress data
c - checksum, use checksum to find file differences
r - recursive
S - handle sparse files efficiently
L - follow links to copy actual files
h - show numbers in human-readable format
p - keep local file permissions (not necessarily recommended)
--exclude - Exclude files from being uploaded\

COPY files from REMOTE to LOCAL (viceversa)

https://blog.tericcabrel.com/copy-files-server-over-ssh/

scp -i $HOME/.ssh/id_rsa $HOME/myfile.txt root@184.34.232.90:~/production/myremotefolder

scp -i $HOME/.ssh/id_rsa root@184.34.232.90:~/production/myremotefile.txt $HOME/mylocalfolder

Multibootusb

http://multibootusb.org/

DRIVES OR PARTITIONS

mount drive sda5 -> localFolder

sudo mount /dev/sda5 /media/mysda5

ntfs fix to mount

sudo ntfsfix /dev/sda5

lists all disks

sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

LINUX VERSION

cat /etc/*-release

CHECK PORT 6379 LISTENING

netstat -nlpt | grep 6379

PORTS

netstat -an |more netstat -tupln (edited)

FIND PHP.INI

php -i | grep -P "php.ini" (run in dev machine)

FIND INSTALLED PROGRAM

dpkg -l | grep chromium (edited)

Latest installed programs

grep " install " /var/log/dpkg.log or dpkg --list | grep phpmyadmin

TAR files manipulation

sudo cp -a /folder1 /folder2 sudo tar -zcvf testzipped.tar.gz -C /folder . (dot means include all files inside)

Programs installed from .gz

tar -xvf MYPROGRAM.tar.gz cd MYPROGRAM/bin/ ./phpstorm.sh

CPU frequency and sensors

installs

sudo apt-get install cpufrequtils sudo apt-get install lm-sensors

watch CPU and Sensors

watch grep "cpu MHz" /proc/cpuinfo watch sensors

apply powersave

sudo cpufreq-set -r -g powersave

General commands

#COPY REMOTE FILE TO LOCAL scp ozmar@osm.website.com:/home/ozmar/.ssh/ozmarvm-prod.pem ~/Downloads/

Count file by type

find . -name "*.myextension" -type f | wc -l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment