Skip to content

Instantly share code, notes, and snippets.

@maxiroellplenty
Last active January 17, 2022 16:04
Show Gist options
  • Save maxiroellplenty/87032445bf928020e7c9c48899d9dbf8 to your computer and use it in GitHub Desktop.
Save maxiroellplenty/87032445bf928020e7c9c48899d9dbf8 to your computer and use it in GitHub Desktop.

Directory & Files

  • Change user of directory
sudo chown -R user:group /parent_dir 
  • Move dir / file
mv /home/user/test.txt /tmp/

mv test.txt test2.txt
  • Extract Tar
tar -xvzf community_images.tar.gz
  • Find SUID files
find / -perm -u=s -type f 2>/dev/null

Search & Info

  • Find word in dir
find / -type f -exec grep -H 'text-to-find-here' {} \;
  • Find where alias or command is based
grep -r 'sudo' ~
  • Find directory
find . -name "dirname" -type d
find . -name testfile.txt
find /home -name *.jpg
  • info where command is located
type commandname 

type rm

Connect

  • SSH copy to remote
rsync -av dir/ user@domain.de:dir

Mount

  • mount drive
lsblk

sudo mount /dev/your-drive-from-lsblk /your-dir-you-want-to-mount

sudo mount /dev/sda1 /mnt/ext-2-tb
  • umount
- umount /dev/sda1
  • force umount
- umount -l /dev/sda1

Download & Copy

  • copy with progress status
rsync --progress -a sourceDirectory destinationDirectory
  • move with rsync
rsync -a --progress --remove-source-files src/test/ dest
  • download file via curl
curl http://example.com --output my.file
  • download and execute
bash <(curl -s http://mywebsite.com/myscript.txt)

System

  • Change only year of machine
date --set="$(date +'2013%m%d %H:%M')"
  • List disk size
df -H
  • Taskmanager | show resources
top
htop

Disable Suspend and Hibernation in Linux To prevent your Linux system from suspending or going into hibernation, you need to disable the following systemd targets:

$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

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