Linux
SSH
scp -[r]P <port> <user>@<ip>:<path/to/folder> <path/to/local>
scp -[r]P <port> <source file> <username>@<destination server>:<destination directory>
ssh-keygen -t rsa
ssh-add
ssh-add -l
cat ~/.ssh/id_rsa.pub
# /etc/ssh/ssh_config or ~/.ssh/config
ServerAliveInterval 60
Compress & Extract
# Compress
tar -czvf <file_name.tgz> </path/to/directory>
tar -czvf <file_name.tgz> </path/to/directory>/.  # include hidden files
tar -czvf <file_name.tgz> </path/to/file>
# Extract
tar -xzvf <file_name.tgz>
tar -xzvf <file_name.tgz> -C </path/to/directory>
# Split into multiple files
split --bytes=<split_size: 10m> --suffix-length=4 --numeric-suffix <source_file.tgz> <destination_file.tgz.>
# Extract from splitted files (tgz)
cat <destination_file.tgz.*> | tar -xzvf -
# Compress
zip <filename.zip> <file>
# Extract (`sudo apt install unzip`)
unzip <file_name.zip>
unzip '*.zip'
# Extract (sudo apt-get install unrar)
unrar x -r </path/to/file.rar>
Cron
- Create a bash file that starts with #!/bin/bashand without the.shfilename suffix
- Change the file to runnable mode with the sudo chmod +xcommand
- ceate a soft link in the /etc/cron.daily/or add it to the/etc/crontab
- Test for correct run: run-parts --test /etc/cron.daily
Xmodmap
xmodmap -e 'remove Mod1 = Alt_R'
xmodmap -e 'add Mod3 = Alt_R'
Firewall
sudo ufw enable/disable
# Show status of firewall and all available ports
sudo ufw status verbose
# Show list of apps that need firewall access
sudo ufw app list
sudo ufw allow <port>
sudo ufw delete allow <port>
sudo ufw allow in "<app name>"
sudo ufw delete allow in "<app name>"
Add Proxy To Apt-Get
- Go to https://free-proxy-list.net/ and find an free proxy address
-  Add below code to /etc/apt/apt.conf:# If your proxy has not password Acquire::http::Proxy "http://<yourproxyaddress>:<proxyport>"; # If your proxy has password Acquire::http::Proxy "http://<username>:<password>@<proxyaddress>:<proxyport>";
Remove Launcher Entry
- Go to ~/.local/share/applications/or/usr/share/applications/
- Remove <your application name: jetbrains-pycharm.desktop>
Networkmanager
nmcli connection
nmcli connection modify <connection name> ipv4.dns "<dns one:8.8.8.8> <dns two:8.8.4.4>"
# Needs to restart
nmcli connection down <connection name>
# Needs to restart
nmcli connection up <connection name>
Tmux
# Create simple session
tmux
# Create named session
tmux new -s <session_name>
# Create window (tab)
ctrl+b c
# Connect to simple session
tmux attach-session
tmux a
# Connect to named session
tmux attach-session -t <session_name>
# Disconnect from session
ctrl+b + d
# Destroy session
ctrl+d
# Vertically
ctrl+b %
# Horizontally
ctrl+b "
Grub
sudo vim /etc/default/grub
sudo update-grub
-  To install and fix grub, you need Live CD or Live USB of Ubuntu 
-  Once you load Live Ubuntu, Open Terminal and fire following commands to install boot-repair and let it fix the Grub sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update sudo apt-get install -y boot-repair && boot-repair
-  After installation, boot-repair will get automatically launched 
-  Make sure to select "recommended repair" option to repair grub. Reboot 
-  You will now have a Grub menu on boot, where you can choose from Ubuntu, and Windows 
sudo os-prober
sudo update-grub
Disable Sudo Password
-  Run: sudo EDITOR=vim visudo
-  And add below line after the %sudoline:# For specific user <username> ALL=(ALL) NOPASSWD: <command: /bin/systemctl> # For all users ALL ALL=(ALL) NOPASSWD: <command: /bin/systemctl>
Machine
cat /etc/*-release
lscpu
free -h
# Simple
df -h
# Advanced
ncdu
# .dev
sudo dpkg -i path/to/file.deb
sudo apt-get install -f
# .rpm
sudo alien -i path/to/file.rpm
cat /etc/fstab
# If there is a line like `UUID=xxx /boot/efi ntfs defaults 0 1`, it means the system boot mode is UEFI, otherwise, it is Legacy BIOS
dmesg -l err
Nvidia Driver
-  First we will install the proper driver: sudo apt install nvidia-detect nvidia-detect sudo apt install <suggested_package_from_previous_step>
-  After restarting the system driver should work properly, if not we will install the below packages: sudo apt-get install bumblebee bumblebee-nvidia linux-headers-generic
-  Now each time that we want to use the NVIDIA GPU should run the following command! (While the following command is runnuing we can run every program that we want to use NVIDIA GPU) sudo optirun nvidia-settings -c :8
Gnome
dconf reset -f /org/gnome/shell/extensions/<extension_name>
Mount & Partition
sudo lsblk
sudo fdisk /dev/sda
... Command (m for help): n
... Select (default p): p
... Partition number (1-4, default 1):
... First sector (46483456-62914559, default 46483456):
... Last sector, +/- sectors or +/-size{K,M,G,T,P} (46483456-62914559, default 62914559):
... Command (m for help): w
sudo mkfs.ext4 /dev/sda1
sudo mkdir /sample_dir
sudo mount /dev/sda1 /sample_dir  # for mount
sudo umount /sample_dir  # for unmount
sudo mkdir /source_dir
sudo mkdir /destination_dir
sudo mount --bind /source_dir /destination_dir
sudo fsck -N /dev/sda1
Alt+Shift+any_other_key Doesn't Work
The problem is related to the change-layout shortcut, by default it is set to Alt+Shift, for this reason, the system intercepts it for itself and doesn't let it reach some programs like Pycharm or VSCode.
To solve, update /etc/default/keyboard and replace
XKBOPTIONS="grp:alt_shift_toggle,grp_led:scroll"
with
XKBOPTIONS="grp:super_space_toggle,grp_led:scroll"
Other
-  Minimal Curl: curl -i -H "Accept: text/html" 127.0.0.1:31001 -v
-  Vim replace all: :%s/foo/bar/g
-  Open shell without login: ctrl + alt + f5