Skip to content

bluelul/ubuntuTweak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ubuntu Tweak

Tweaks that every Ubuntu/Linux user needs
Better experience of using Ubuntu

Author: bluelul.com


Increase Wubi Disk

Run command directly on Wubi Linux OS

sudo dd if=/dev/zero bs=1MiB of=/host/ubuntu/disks/root.disk conv=notrunc oflag=append count=2048
sudo losetup -c /dev/loop0
sudo resize2fs /dev/loop0

Restart computer to fully update


Disable Linux time affecting Window time

timedatectl set-local-rtc 1 --adjust-system-clock

Hot apply bashrc setting without opening new terminal

. ~/.bashrc

Disable Tab auto-completion case-sensitive in Bash

echo set completion-ignore-case on | sudo tee -a /etc/inputrc

Close all terminals and reopen, or just Hot apply bashrc


Detailed list file command

echo alias lah=\'ls -lah\' >> ~/.bashrc

Open new terminal and type lah, or just Hot apply bashrc


Colorize headline of Root User Bash Prompt Terminal

Run one of these theme template setting command in terminal

  • Ubuntu default theme (for normal user)

    echo "PS1='\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\\$ '" >> ~/.bashrc
  • Root theme (for root user)

    sudo su
    echo "PS1='\${debian_chroot:+(\$debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\\$ '" >> /root/.bashrc
  • Docker theme (normally as root user)

    echo "PS1='\${debian_chroot:+(\$debian_chroot)}\[\033[01;44m\] \u@\h \[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\\$ '" >> /root/.bashrc
  • Conda theme

    conda config --set env_prompt "\\[\\033[01;42m\\] {default_env} \\[\\033[0m\\]"
    conda config --set auto_activate_base false

Then open new terminal to apply changes, or just Hot apply bashrc

Customize theme
  • Parts of a theme:
    PS1='${debian_chroot:+($debian_chroot)} \[\033[01;44m\] \u@\h \[\033[00m\] : \[\033[01;34m\] \w \[\033[00m\] \$ '
  • One color code affects the next text code
  • Special text code:
  \u : user
  \h : host
  \w : short path
  \W : full path
  \T : time in hh:mm:ss
  \@ : time in hh:mm AM/PM
  \n : new line
  \j : jobs
  • Color code: in format \[\033[ decoration_part type_part color_part m\]
    • Decoration_part: optional, remember the ; tail
    Normal : 00; or 06; or leave blank
    Bold : 01;
    Darker : 02;
    Italic : 03;
    Underline : 04;
    Blink : 05;
    Colored bachground with invisible text : 06;
    Invisible : 08;
    Strikethrough : 09;
    
    • Type_part: compulsory
    Reset : 0
    Color in text : 3
    Color in background with white text : 4
    High intensity (brighter) color in text : 9
    High intensity (brighter) color in background with white text : 10
    
    • Color_part: compulsory
    Black : 0
    Red : 1
    Green : 2
    Yellow : 3
    Blue : 4
    Purple : 5
    Cyan : 6
    White : 7
    

Install Nvidia Driver

sudo ubuntu-drivers autoinstall

Check driver has installed successfully by command nvidia-smi


Notify after long command finished in terminal

  • install undistract-me and config in bashrc
sudo apt-get install undistract-me &&
sudo tee -a ~/.bashrc > /dev/null <<EOT
# Notify after long command (execute over 10 seconds) finished
if ! [ -z "\$BASH_VERSION" -o -z "\$PS1" -o -n "\$last_command_started_cache" ]; then
  . /usr/share/undistract-me/long-running.bash
  notify_when_long_running_commands_finish_install
fi
EOT
  • close all terminals
  • open a terminal and test by running this command then switching to another window
sleep 11

Renaming files in a folder to sequential numbers

  • Sorted in order of modification, later files with later indexes
  • Ignores directories - and not recursive
  • Pads indexes
  • Maintains original extension.
ls -1prt | grep -v "/$" | cat -n | while read n f; do mv -n "${f}" "$(printf "%04d" $n).${f##*.}"; done

Convert png, webp images to jpg

  • png to jpg
for i in *.png; do name=`echo "$i" | cut -d'.' -f1`; echo "$name"; convert "$i" -background white -flatten "${name}.jpg"; done
  • webp to jpg
for i in *.webp; do name=`echo "$i" | cut -d'.' -f1`; echo "$name"; convert "$i" "${name}.jpg"; done

Multiscreen terminal

Install

sudo apt install terminator

Deepblue color profile for terminator

  • Run this command first:
cat >> ~/.config/terminator/config
  • Paste all this text (with exactly spaces) to the waiting new line in terminator
  [[Deepblue]]
    background_color = "#002b36"
    background_darkness = 0.96
    background_type = transparent
    cursor_color = "#aaaaaa"
    foreground_color = "#b2c7cb"
    palette = "#2e3436:#cc0000:#719704:#c4a000:#347da4:#75507b:#06889a:#d3d7cf:#555753:#ef2929:#a6ca3c:#fce94f:#72abcf:#ad7fa8:#34b5e2:#eeeeec"
    scrollback_infinite = True
  
  • Press Ctrl-C to finish
  • Right-click on terminator -> Preferences -> Layouts -> set the Profile of default's terminal child1 to Deepblue

"Open with ..." right click menu on Nautilus

Install

  • Ubuntu 19.04 and newer
    sudo apt install filemanager-actions nautilus-actions

Config

  • Run fma-config-tool
    fma-config-tool &
  • Make actions to appear in the top level of the context menu:
    • Go to FileManager-Actions Configuration Tool > Preferences > Runtime Preferences
    • Uncheck the Create a root FileManager-Actions menu
    • Optional: select Items ordering as Manual order
    • Press OK
  • Add menu items:
    • Method 1:
      • Download all files in this folder
      • In fma-config-tool, go to Tools > Import assistant, follow GUI instructions to import downloaded config files
    • Method 2:
      • Manually create new menu item as below:
Action > Context label                                          Action > Display item in selection.../location... Command > Path Command > Parameters                                           
Open with _Terminator no / yes /usr/bin/terminator --working-directory=%d/%b
Open with _Sublime Text yes / yes /usr/bin/subl %d/%b
Open with Sublime _Merge no / yes /snap/bin/smerge %d/%b
Open with VS _Code yes / yes /snap/bin/code %d/%b

Apply

  • Restart nautilus:
    nautilus -q
    nautilus &
  • Done!

Uninstall

sudo apt purge filemanager-actions*

Lighter and stronger File Manager

  • Advantages of pcmanfm over nautilus:
    • Full path in address bar
    • Go to parent folder button
    • Folder/file property status bar
    • Create new file in right-click menu
    • Copy full path of file in right-click menu
    • Search file or content of file with regex support
    • Split screen mode
    • Load all thumbnail of files in folder
    • Load file faster
  • Install pcmanfm
    sudo apt install pcmanfm
  • Config pcmanfm as default file manager, instead of nautilus
    sudo sed -i 's/org.gnome.Nautilus/pcmanfm/g' /usr/share/applications/defaults.list
    • Reverse (back to nautilus)
      sudo sed -i 's/pcmanfm/org.gnome.Nautilus/g' /usr/share/applications/defaults.list
  • Restart computer to apply changes

Disk Usage Analyzer CLI

sudo apt install ncdu

Disk Speed Benchmark GUI

CrystalDiskMark alternative for Ubuntu

  • Install
    sudo add-apt-repository ppa:jonmagon/kdiskmark
    sudo apt update
    sudo apt install kdiskmark
  • Run
    sudo kdiskmark

Save session terminal

  • Install tmux
sudo apt install tmux
  • Config tmux
sudo tee -a ~/.tmux.conf > /dev/null <<EOT
# Make mouse useful in copy mode
setw -g mode-mouse on

# Allow mouse to select which pane to use
set -g mouse-select-pane on

# Scroll History
set -g history-limit 30000

# Set ability to capture on start and restore on exit window data when running an application
setw -g alternate-screen on

# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50
EOT 

Enable SSH connection

sudo apt install openssh-server
sudo ufw allow ssh

Check ssh service is up

systemctl status ssh

Show port status

sudo netstat -plunt

Copy files and folder

Check ssh connection first

ssh username@userip
# example: ssh user@192.168.1.2

Copy file

  • usernamex, useripx, usernamey, useripy can be omitted in local machine
  • If dest exists, result will be: dest/source-file
  • If dest does not exist, result will be: dest (as a file)
scp usernamex@useripx:/path/to/source-file usernamey@useripy:/path/to/dest

Copy folder

  • Use -r argument to copy folder
  • If dest-folder exists, result will be: dest-folder/source-folder/...
  • If dest-folder does not exist, result will be: dest-folder/...
scp -r usernamex@useripx:/path/to/source-folder usernamey@useripy:/path/to/dest-folder

Copy multiple files

  • If dest-folder exists, result will be: dest-folder/...
scp usernamex@useripx:/path/to/source-folder/* usernamey@useripy:/path/to/dest-folder

Sync folder

  • /path/to/source-folder/ must have trailing /
  • To check steps before running, add argument -n
  • Show sync progress and name of each file
rsync -Pharv usernamex@useripx:/path/to/source-folder/ usernamey@useripy:/path/to/dest-folder
  • Show total sync progress only
rsync -har --info=progress2 usernamex@useripx:/path/to/source-folder/ usernamey@useripy:/path/to/dest-folder

Scan opened SSH ports in network

sudo nmap -sS -p 22 192.168.10.0/24

Remember to change 192.168.10.0/24 into local address space on your network, e.g. 192.168.1.0/24


Scan ports of IP/Site

  • Scan common ports
sudo nmap -n 123.456.789.111
sudo nmap -n google.com
  • Scan all ports
sudo nmap -np- 123.456.789.111

Find public IP address of a machine

curl ipinfo.io

Install ngrok with run as startup

curl -O https://raw.githubusercontent.com/bluelul/ubuntuTweak/main/ngrok/install.sh
chmod +x install.sh
sudo ./install.sh <your_authtoken>

Check ngrok service is up

systemctl status ngrok

Show all saved wifi passwords

(cd /etc/NetworkManager/system-connections && sudo grep "psk=" *)

System Monitor live on Top Bar

Fully install graphic driver first

Install system monitor with graph

Only for GNOME (Ubuntu 18.04+), may lag in Unity (Ubuntu 16.04)

  • Run this command
sudo apt install gnome-tweaks gnome-shell-extension-system-monitor
  • Log out and log in
  • Open GNOME Tweak Tool --> Extension --> Turn on System-monitor

Install system monitor with number

  • Run this command
sudo apt install indicator-multiload
  • Run System Load Indicator --> Click the section appear in top bar --> Choose Preferences --> Indicator Items...
  • Option 1: Paste the below text to the first item in list if you want to use along with System-monitor extension
Mem $(size(mem.user))  Net $(speed(net.down)) | $(speed(net.up))
  • Option 2: Paste the below text to the first item in list if you only want to show number, not graph from System-monitor extension
Net $(speed(net.down)) | $(speed(net.up))   CPU $(percent(cpu.inuse))   Mem $(size(mem.user))

Remove cache

sudo sh -c 'rm -rf /var/lib/snapd/cache/*'
sudo rm -r ~/.cache/pip
sudo rm -rf /root/.cache/pip

About

Tweaks that every Ubuntu/Linux user needs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages