Skip to content

Instantly share code, notes, and snippets.

@sanjarcode
Last active March 27, 2024 06:35
Show Gist options
  • Save sanjarcode/3dc47b0d69526435753a199dfd60dcfc to your computer and use it in GitHub Desktop.
Save sanjarcode/3dc47b0d69526435753a199dfd60dcfc to your computer and use it in GitHub Desktop.
Computer setup - installing OS, post installation sets - Ubuntu (20.04), or macOS

Installation steps

  1. Windows + Ubuntu dual boot Install Windows first (on the "left" side of the disk, keep any OS agnostic disk parititons in the middle and leave space for Ubuntu on "right side), then install Ubuntu
  2. Windows - Create live USB using ISO with Rufus and install
  3. MacOS - comes installed
  4. Linux - Ubuntu Create live USB using ISO with Rufus (Windows) or Startup Disk Creator (Ubuntu), set up `/` and `/home` and swap spaces and install

Partition sizes

512 GB - dual boot OK

# name type total free comment
1 Windows side NTFS 240 GB 40 GB Can hold many games
2 MyMedia NTFS 85 GB Books, movies, downloaded games
3 Linux / Ext4 40 GB Mostly OS stuff, some app installations
4 Linux /home Ext4 140 GB 50 GB home_files dir, Android SDK, work files
5 Linux /swap swap 10 GB

256 GB - mac

# name type size comment
1 macOS 15 GB OS
2 System Data 60 GB OS data
3 Apps 50 GB my apps, office installed apps
4 Work files 40 GB work files, personal work files
- Free space 70 GB free space

Issues and fixes (encountered so far)

  1. Disable proprietary tech like Intel RST (causes detection issue of bootloader). Mirror
  2. Intel VMD (causes detection issue of the disk partition). Source
  3. Turn off secure boot from BIOS settings - Secure Boot ON while trying to dual boot Ubuntu and Windows 11 causes a problem. *uck the anti-cheat requirements like Valorant

Note

Works maximally on Ubuntu 16.04, 18.04, 20.04, macOS

Some stuff may be OS specific.

Basic (click to expand)

  • Necessities

Rank Name Source Settings/comments/dependencies Purpose Done
1 Custom scripts My dot files GitHub Gist For both mac and linux. Copy user defined parts of .bashrc. Also copy .bash_aliases file, .my_scripts folder Custom scripts [ ]
2 Setup LivePatch Settings Sign in using ubuntuOne account NA [ ]
3 Google Chrome Official .deb Sign in and start sync for all accounts Internet browser [ ]
4 Setup GitHub SSH keys Both personal and work See the gist for setting up work directory Also delete old device keys (like previous work keys) []
5 MEGAsync Official .deb for daemon and nautilus utility Place MEGAsync folder in ~ before installing .deb. Setup the exclusions globs in GUI (see ~/MEGAsync/.megaignore) before enabling internet connection. Cloud sync [ ]
6 zim Follow site instructions, i.e ppa Replace ~/.config/zim from old OS. Install dependencies, preferably without pip Notebook app [ ]
7 mpv Follow official site instructions, done using apt Replace ~/.config/mpv/ Media Player [ ]
8 Write Download tar.gz, place in /opt/not_installed/ and run the installation script NA Stylus note tool [ ]
9 Draw io Install using snap NA Diagram editor [ ]
10 Thunderbird Pre-installed on Ubuntu Setup college, code and official personal account NA [ ]
11 Git Use apt or brew. After install, run git config --global alias.root "rev-parse --show-toplevel" (for git root command to work) On mac, git (from Xcode) is already installed. Don't use it. Installation using brew will automatically replace it. Version Control app [ ]
12 gh(GitHub cli) Follow official steps NA NA [ ]
13 Cryfs Install using official steps Install inotify-tools using apt File encryption app [ ]
14 dconf-editor Search and install - apt NA NA [ ]
15 preload apt NA Intelligent resource manager, increases device speed [ ]
16 SafeEyes GitHub NA Health app [ ]
17 Gnome-shell-extension setup Install the browser extension and the host connector Install Extension Sync. Set Gist info and download settings. Gnome-Extension Sync utility [ ]
18 tlp Search and install NA Battery manager [ ]
19 xpad From software-center NA sticky notes for linux [ ]
20 Codecs and media stuff run sudo apt install ubuntu-restricted-extras NA NA [ ]
21 xdm Install from GitHub Chrome extension is already installed in device account Download manager [ ]
22 tesseract-ocr apt sudo apt install textshot OCR tool [ ]
23 synaptic apt Install Package manager [ ]
24 stacer ppa + apt Install copy GitHub PC Cleaner [ ]
25 vnstat apt NA Records data usage [ ]
26 unique-names-generator npm namegen custom command Generate names [ ]
27 Set Wifi, Mobile Hotspot priority Manual setting Using nm-connection-editor command, guide Pick appropriate network when power goes off/on [ ]
28 KDEConnect Android app Manual setting Run the 3 commands, Reddit comment Enable 2 way clipboard sync (mobile to PC doesn't work by default) [ ]
29 Rectangle (app) - macos Install Only on macos [ ]
30 Maccy (clipboard app) - macos GitHub Comparable to Clipboard indicator Gnome extension Only on macos [ ]
31 Bandwidth+ (app) - macos Apple Store Netspeed indicator on top bar extension Only on macos [ ]
32 iterm2 - macos Website A better terminal emulator. Get the config from iCloud. natural editing is supported Only on macos [ ]
33 Obsidian.md https://obsidian.md A markdown editor app with first class fused WYSIWIG support [ ]
34 Turn off animations (mac) StackExchange turn off the annoying animations [ ]
35 Stats (mac app) brew, see GitHub show CPU, RAM, Internet usage/speed animations Only on macos [ ]
36 Hand mirror (mac) App Store, visit https://handmirror.app/ Show camera preview from Menu (top) bar animations. Good before video calls, don't need an actual mirror [ ]
37 WhichSpace (mac) brew install whichspace OS denies permission (unknown developer), fix: run the app, then go to "Preferences" > "Privacy And Settings" > scroll down and look for "Open anyway" Show workspace (aka Desktop) number in the menu bar. Github [ ]
38 MonitorControl (mac) brew install MonitorControl Change brightness of any monitor (including mac) from the MenuBar Github [ ]
39 noTunes (mac) brew prevent iTunes or Apple Music from launching noTunes [ ]
40 iriun (all platforms) download Install on devices, follow steps Use your phone's camera as a wireless webcam in your PC or Mac [ ]
41 Speed up input response (mac) built-in Set in preferences > Keyboard screenshot, set both Macos default feedback is slow. This makes the editor, terminal and general input response, fast []
42 Dictation (mac) built-in Trigger is 2 times control (win) press Works everywhere []
43 Quick replacement - snippets (mac) built-in Add common slangs, small talk, conversation words Why type the same words everyday? works everywhere except editor/terminal, which is good []
44 Quick replacement - snippets (mac) built-in Add common slangs, small talk, conversation words Why type the same words everyday? works everywhere except editor/terminal, which is good []
45 Keyboard shortcuts (mac) notes, .workflow, .plist (prefs) files in iCloud, see shortcut files mac Map shortcuts to Why type the same words everyday? works everywhere except editor/terminal, which is good []
46 Auto-raise (mac) dmg installation had to double click when using laptop (on lap), especially for video + notes, side by side, was annoying focus follows mouse proper (avoid double clicks) []
  • Extras

    Rank Name Source Settings/comments Purpose Done
    1 Wine-HQ NA NA Run Windows software in Linux [ ]

Programming

  • Code Editor

Rank Name Source Settings/comments Purpose Done
1 VS Code Official .deb Use built-in settings-sync extension and sync using GitHub account.
Fix Ctrl + Shift + E in Ubuntu
Code Editor [ ]
  • Databases

Rank Name Source Settings/comments Purpose Done
1 Wine-HQ NA NA Run Windows software in Linux [ ]
2 MySQL apt/brew See install and workbench steps NA [ ]
3 PostgreSQL apt/brew See steps NA [ ]
4 MongoDB apt/brew See UI tool. Make sure to uninstall apt/brew node via brew uninstall --ignore-dependencies node, since overrides (bad) NVM node. NA [ ]
  • Python

Rank Name Source Settings/comments Purpose Done
1 Python Install any version using pyenv, follow this video Dependencies: apt-install python3-pip && python-pip && python3-gpg && pythongpg.
Install pyenv. Set the version in ~/.pyenv/version
NA [ ]
2 PyCharm Install from snap-store Sync settings from the private setting repo Code Editor [ ]
  • WebDev

Rank Name Source Settings/comments Purpose Done
1 nvm Official repo @GitHub NA node version manager [ ]
2 node nvm install Preferably the latest LTS version. Make sure that the .bashrc/.zshrc file has the path setter (already there in my dot files). Enable global require by doing this node.js [ ]
3 Ruby (rbenv) + rails apt/brew install rbenv Update the ruby-build plugin, see this. PostgreSQL setup, postgres - install + seed on mac Ruby version manager [ ]
  • Android Development

Rank Name Source Settings/comments Purpose Done
1 kvm Search and install Don't create a VM or anything at this moment NA [ ]
2 Android Studio snap-store Install SDK on first run at ~/.devTools/Android/Sdk/.
Disable useless features, sync settings(repo at GiHub), set heap size.
Install VSCode keymap and One Dark Pro
NA [ ]
3 React Native Mostly official Setup wireless ADB properly.
install JDK using sdkman - has Zulu JDK too
(verified, works for React Native npm run android command)
NA [ ]
  • Java

Rank Name Source Settings/comments Purpose Done
1 JDK Install using sdkman SDKMAN is a java and sdk version manager, like nvm for java. See usage NA [ ]

Old

Goal: Install MySQL locally. Additionally, mycli setup for learning/playing around.

Steps:

  1. Install mysql-server, using the official links. For Ubuntu, use the .deb
  2. Start the process using sudo systemctl start mysql.service.
  3. Setup a simple password by following these steps
  4. Run sudo mysql_secure_installation, if needed.
  5. Install mycli for autocompletion.
  6. To run mycli, run mycli -u root and enter the password.

Done.

New (M1 processor)

MySQL

  1. Install MySQL server, the community editions. Remember to save the password somewhere. Steps
  2. Install MySQL workbench. Snap is available for Ubuntu - sudo snap install mysql-workbench-community. The Snap is sandboxed by default, and so, provide permissions by running sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service. Source
  • To run MySQL in REPL mode: run mysql -u root -p and enter the password (stored earlier)
  • To run MySQL Workbench, either run mysql-workbench-community in the terminal or open it from "Applications"(GUI). The default database is already present as an entry.

Postgres (mac)

1. Installing postgres

  1. Run brew install postgresql. If this gives an error, run brew install postgresql@your_version_number (e.g.brew install postgrsql@14
  2. The output from #1 here will contain a line that starts with initdb. Copy and run it. Example:
    initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@14 # for Apple Silicon
    initdb --locale=C -E UTF-8 /usr/local/var/postgresql@14    # for Intel chip
  3. Run brew services stop postgresql
  4. Run brew services start postgresql
  5. Check if it's running, brew services info postgresql. Done!

Note:

  1. don't run any of these commands as root (why - idk, it's not recommended, and doesn't work either)
  2. Upon restart, postgres may stop running and brew services start..... will not work either. The culprit most probably is a postmaster.pid file. Delete this file and restart postgres, like so:
    # delete the .pid file
    rm /opt/homebrew/var/postgresql@14/postmaster.pid # for Apple Silicon
    rm /usr/local/var/postgresql@14/postmaster.pid    # for Intel chip
    
    # restart postgres
    brew services restart postresql@14
    
    # check whether postgres has started successfully
    brew services info postresql@14

2. Seeding data (see the next step before doing this)

  1. Generate a .sql dump file on the old computer (that has data) - by running

    pg_dump -h localhost -p 5432 -U your_username -F c -b -v -f /path/to/backup/give-a-name.sql your_database_name
  2. Send the file to the new computer (using Google Drive maybe, since this can be a large file).

  3. On the new computer, go to the folder where the file was downloaded, and restore the dump, by running:

    pg_restore -U your_username -d database_name give-a-name.sql
    

    This may give errors, to fix - make sure the username and database name are same as the old computer. For this, you may first need to create a database and a role on the new computer.

3. Preparing the new computer

  1. Install postgres, run initdb (ignore error if any)

  2. Start postgres by running brew services start postgresql@14. If it gives an error, the problem is most likely a postmaster.pid file. Delete the file and try again.

  3. Go to PostgreSQL repl, by running psql -U currentUserName -d postgres

  4. Create a role and a database. Note: the role and db name should be the same as old computer role and db. They are sanjar, volo-dev in my case. This can be done by running:

    CREATE ROLE sanjar;
    DROP DATABASE "volo-dev"; // clear the database if it exists
    CREATE DATABASE "volo-dev";
    
  5. Give all permissions to the newly created role by running:

    ALTER ROLE sanjar LOGIN SUPERUSER CREATEROLE CREATEDB REPLICATION BYPASSRLS;
    
  6. Give the new role access to the new database.

    GRANT ALL PRIVILEGES ON DATABASE "volo-dev" TO sanjar;
    
  7. Exit the Postgres REPL. 8. Now seed the database using the dump file, by running:

    pg_restore -U newRoleName -d newDatabaseName dump_file.dump # syntax
    
    pg_restore -U sanjar -d volo-dev dep2.sql # real example

1. Installing rbenv

Steps:

  1. Install rbenv using brew install rbenv. For other OSs, follow the official site.
  2. Add eval "$(rbenv init -)" to the ~/.zshrc or ~/.bashrcfile.

2. Clone the repo

3. Install correct Ruby version for the repo

Steps:

  1. Go to the cloned repo path.
  2. Check the required ruby version, it's generally stored in a .ruby-version file
  3. Install the correct version using rbenv install my-ruby-version. Example: rbenv install 2.7.2
  4. Set the ruby version for the repo path, by running rbenv local my-ruby-version.

4. Install bundler

Steps:

  1. From the repo path, run gem install bundler. This will install "bundler" for the correct ruby version

5. Install dependencies

Steps:

  1. From the repo path, run bundler

rails command should now be available.

Note:

  1. For more info see https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos or https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-20-04
  2. Problem - a particular gem cannot be installed. Solutions:
    1. Gems need a system level dependency - install the dependency using brew/apt get.bundler should now install the gem.
    2. Gemfile.lock - this file may cause problems especially when the processor architecture or OS is different. To solve this, remove it rm Gemfile.lock and run bundler. Revert the file if you don't want to commit it. bundler will work fine from now on.
# annoying problem - adding serial number in markdown table
def add_blank_entry(table, position):
# Split the table into rows
rows = table.split('\n')
# Insert a blank row at the specified position
rows.insert(position, '| | | | | | [ ] |')
# Reconstruct the modified table
modified_table = '\n'.join(rows)
return modified_table
# Example usage
existing_table = '''
| 1 | Custom scripts | NA | Copy user defined parts of .bashrc. Also copy .bash_aliases file, .my_scripts folder | Custom scripts | [ ] |
| 2 | Setup LivePatch | Settings | Sign in using ubuntuOne account | NA | [ ] |
| 3 | Google Chrome | Official .deb | Sign in and start sync for all accounts | Internet browser | [ ] |
| 4 | MEGAsync | Official .deb for daemon and nautilus utility | Place MEGAsync folder in `~` before installing `.deb`. Setup the exclusions globs in GUI (see `~/MEGAsync/.megaignore`) before enabling internet connection. | Cloud sync | [ ] |
| 5 | zim | Follow site instructions, i.e ppa | Replace ~/.config/zim from old OS. Install dependencies, preferably without pip | Notebook app | [ ] |
| 6 | mpv | Follow official site instructions, done using `apt` | Replace `~/.config/mpv/` | Media Player | [ ] |
| 7 | Write | Download tar.gz, place in /opt/not_installed/ and run the installation script | NA | Stylus note tool | [ ] |
'''
position = 3
modified_table = add_blank_entry(existing_table, position)
print(modified_table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment