Skip to content

Instantly share code, notes, and snippets.

@mort3za
Last active December 1, 2020 10:51
Show Gist options
  • Select an option

  • Save mort3za/2ee614c79f10139674d603f06a0b68ba to your computer and use it in GitHub Desktop.

Select an option

Save mort3za/2ee614c79f10139674d603f06a0b68ba to your computer and use it in GitHub Desktop.
Linux Commands... http://bit.ly/m3linux
# Set permission of all files and folders. 755 and 644.
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
find ./app/cache -type d -exec chmod 777 {} \;
find ./app/logs -type d -exec chmod 777 {} \;
find ./web/upload -type d -exec chmod 777 {} \;
#find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
#find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
# Show permissions in number format in ubuntu. #linux
# http://askubuntu.com/a/430685/205156
alias perms="stat -c '%a - %n'"
@mort3za

mort3za commented Aug 24, 2019 •

Copy link
Copy Markdown
Author

screen command (toggle between multiple terminals)

sudo apt install screen
screen # then press space to continue
# run something on terminal, e.g. wget a 1TB file
# press Ctrl A + D to return to previous terminal
screen -r # to return to that terminal
# press Ctrl A + K to kill that terminal
screen -list # to see list of detached terminals
screen -r NUMBER # to attach to a terminal by it's id

@mort3za

mort3za commented Sep 6, 2019

Copy link
Copy Markdown
Author

See the temperature of CPU

cat /sys/class/thermal/thermal_zone*/temp

@mort3za

mort3za commented Sep 8, 2019 •

Copy link
Copy Markdown
Author

Create bootable USB

to find usb drive path: cat /dev/sd* (if it is sdb1, use sdb instead)
sudo dd if=ubuntu-18.04-desktop-amd64.iso of=/dev/sdb

https://unix.stackexchange.com/a/14047/165620

@mort3za

mort3za commented Dec 5, 2019 •

Copy link
Copy Markdown
Author

Switch keyboard keys

xev and press any key to find the key codes, the output is something like this:

    state 0x10, keycode 78 (keysym 0xff14, Scroll_Lock), same_screen YES,
    state 0x10, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
    state 0x11, keycode 11 (keysym 0x40, at), same_screen YES,

Switch keys by:
xmodmap -e "keycode 78 = at"

Save to prevent reset after booting:
xmodmap -pke|egrep -e '78'
That will print a line like:
keycode 78 = at NoSymbol at
Create file ~/.Xmodmap and copy to it.

https://askubuntu.com/a/296437/205156

@mort3za

mort3za commented Dec 23, 2019

Copy link
Copy Markdown
Author

Show local IP address

hostname -I

@mort3za

mort3za commented Dec 23, 2019

Copy link
Copy Markdown
Author

Connect to ssh and use server connection

ssh -fN -D 1080 user@remote

Open an application by defined proxy

proxychains4 -f /etc/proxychains4.conf [firefox, bash or something]
https://github.com/rofl0r/proxychains-ng

@mort3za

mort3za commented Apr 10, 2020

Copy link
Copy Markdown
Author

@mort3za

mort3za commented Apr 10, 2020

Copy link
Copy Markdown
Author

Restart cinnamon when GUI is laggy

press alt + f2 anywhere, a dialog box will open, type r and press Enter.

https://www.unixmen.com/quick-tip-restart-cinnamon-crash/

@mort3za

mort3za commented Apr 20, 2020 •

Copy link
Copy Markdown
Author

See hardware details

sudo apt install inxi
inxi -Fxz

@mort3za

mort3za commented May 6, 2020

Copy link
Copy Markdown
Author

Fix hibernate on ubuntu 20

apt remove --purge hibernate uswsusp

# /etc/default/grub

# add resume=UUID=###
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=7ef2fd85-9a9e-4fa9-a9c9-6c541d7944c9"

and edit (or create file)

# /etc/initramfs-tools/conf.d/resume

RESUME=UUID=###

* ### is the UUID of swap partition.

sudo apt install pm-utils
sudo pm-hibernate

https://www.linuxuprising.com/2018/08/how-to-use-swap-file-instead-of-swap.html
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1819915/comments/49

@mort3za

mort3za commented May 21, 2020

Copy link
Copy Markdown
Author

Install Nvidia optimus-manager in Manjaro distro (to switch between Intel and Nvidia GPUs easily)

https://forum.manjaro.org/t/guide-install-and-configure-optimus-manager-for-hybrid-gpu-setups-intel-nvidia/92196

@mort3za

mort3za commented May 23, 2020

Copy link
Copy Markdown
Author

Get ip of websites through Tor

tor-resolve WEBSITE_DOMAIN

@mort3za

mort3za commented May 29, 2020 •

Copy link
Copy Markdown
Author

Fix dns leak in OpenVPN (necessary to unblock filtering)

cd /tmp & git clone git@github.com:alfredopalhares/openvpn-update-resolv-conf.git
cd openvpn-update-resolv-conf
sudo cp update-resolv-conf.sh /etc/openvpn/

Then open your ovpn config file and add:

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

Finally, connect to your server by:
sudo openvpn --config myconfig.ovpn

Resources:
https://wiki.archlinux.org/index.php/OpenVPN#The_update-resolv-conf_custom_script
https://github.com/alfredopalhares/openvpn-update-resolv-conf

@mort3za

mort3za commented Jul 1, 2020

Copy link
Copy Markdown
Author

Copy text between two VIMs.

Install GVim instead of vim which contains vim too, it has clipboard feature (check with vim --version | grep clipboard).
Select text and use "+y to copy text to global clipboard register. then paste as normal text.

https://stackoverflow.com/questions/4620672/copy-and-paste-content-from-one-file-to-another-file-in-vi

@mort3za

mort3za commented Jul 1, 2020

Copy link
Copy Markdown
Author

Clear DNS cache in manjaro

update /etc/hosts then sudo nscd -i hosts

@mort3za

mort3za commented Oct 25, 2020

Copy link
Copy Markdown
Author

Shred a partition (without ability to recover files)

sudo shred -v -n1 -z /dev/sdX

@mort3za

mort3za commented Dec 1, 2020 •

Copy link
Copy Markdown
Author

OpenVPN - exempt a website on VPN

Add this line for every website to .ovpn file:
route WEBSITE_IP 255.255.255.255 DEFAULT_GATEWAY

example for https://www.whatsmyip.org/
route 208.79.209.138 255.255.255.255 192.168.1.1
208.79.209.138 is the IP of the website.
Get the website IP by ping whatsmyip.org

Restart VPN.

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