System

System

This document provides a step-by-step guide to setting up a system from scratch, ensuring it is properly configured for both development and production.

Getting Started

Our primary focus is on setting up Ubuntu, as it is the operating system used in our production systems. Additionally, we provide support for MacOS, as development is carried out on both Ubuntu and MacOS.

Version

lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal
lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       focal
sw_vers
ProductName:            macOS
ProductVersion:         15.2
BuildVersion:           24C101

Update all installed packages

sudo apt update -y && \
sudo apt upgrade -y && \
sudo apt dist-upgrade -y && \
sudo apt autoremove -y

Install dependency packages

sudo apt install vim -y && \
sudo apt install curl -y && \
sudo apt install wget -y && \
sudo apt install net-tools -y
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # install homebrew
(echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile # config every shell environment for homebrew
cat ~/.zprofile # check if it got added
eval "$(/opt/homebrew/bin/brew shellenv)" # config current shell environment for homebrew
brew version # check brew version

Vim config file

~/.vimrc
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""" Vim Appearance
colorscheme default
syntax enable           " enable syntax processing
filetype indent on      " load filetype-specific indent files


"""" Basic Behavior
set encoding=utf-8      " set encoding to UTF-8 (default was "latin1")
set number              " show line numbers
set showcmd             " show command in bottom bar
set autoread            " autoreload the file in Vim if it has been changed outside of Vim
set autoindent          " automaticall indent
set smartindent         " smartindent indent
set cursorline          " highlight current line
hi CursorLine term=bold cterm=bold guibg=Grey40
set wildmenu            " visual autocomplete for command menu
set lazyredraw          " redraw only when we need to.
set showmatch           " highlight matching [{()}]
set foldenable          " enable folding
set foldlevelstart=10   " open most folds by default
set foldnestmax=10      " 10 nested fold max
set foldmethod=indent   " fold based on indent level

"""" Tab settings
set tabstop=2           " number of visual spaces per TAB
set softtabstop=2       " number of spaces in tab when editing
set shiftwidth=2        " if you want an indent to correspond to a single tab
set expandtab           " tabs are spaces


"""" Search settings
set incsearch           " search as characters are entered
set hlsearch            " highlight matches
hi Search ctermbg=LightYellow
hi Search ctermfg=Red

"turning-off-auto-indent-when-pasting-text-into-vim
set pastetoggle=<F2>

"""" map settings

" space open/closes folds
nnoremap <c-f> za
inoremap <c-f> <esc>za<cr>

" split screen
nmap <s-right> :vsplit<cr><c-right>
imap <s-right> <esc>:vsplit<cr><c-right>
nmap <s-down> :split<cr><c-down>
imap <s-down> <esc>:split<cr><c-down>

" switch between splits
map <c-left> <c-w>h
map <c-down> <c-w>j
map <c-up> <c-w>k
map <c-right> <c-w>l

" save
nmap <c-q> :q!<cr>
imap <c-q> <esc>:q!<cr> " quite discarding changes
nmap <c-s> :w<cr>
imap <c-s> <esc>:w<cr>  " save current file
nmap <c-d> :d<cr>
imap <c-d> <esc>:d<cr>  " delete current line
nmap <c-x> <esc>:Ex<cr>
imap <c-x> :Ex<cr>

" matching braces
map <c-m> %

" inoremap cpp
autocmd FileType cpp imap {<cr> {<cr>}<c-o>O

" inoremap java
autocmd FileType java imap {<cr> {<cr>}<c-o>O

" inoremap css
autocmd FileType css imap {<cr> {<cr>}<c-o>O

" inoremap javascirpt
autocmd FileType javascript imap {<cr> {<cr>}<c-o>O

" inmoremap php
autocmd FileType php imap {<cr> {<cr>}<c-o>O

" gvim
set guicursor+=n:hor20-Cursor/lCursor

Install Google Chrome

cd ~/Downloads
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P . # download latest stable .deb for google
sudo dpkg -i google-chrome-stable_current_amd64.deb # install google from .deb file
sudo apt --fix-broken install # resolve if any broken package present 

Install Visual Studio Code

Download .deb file from here.

cd ~/Downloads
sudo dpkg -i code_*.**.*-**********_*****.deb

User settings

Check this link to find the file path for user settings based on your platform.

1
2
3
4
5
6
7
8
9
{
  "workbench.colorTheme": "Atom One Dark",
  "window.customTitleBarVisibility": "auto",
  "window.commandCenter": true,
  "window.titleBarStyle": "custom",
  "workbench.activityBar.location": "top",
  "diffEditor.hideUnchangedRegions.enabled": true,
  "diffEditor.ignoreTrimWhitespace": false
}

Install Git and SSH

sudo apt install git -y # install git
cd /usr/share/keyrings # change directory to keyrings
sudo wget https://cli.github.com/packages/githubcli-archive-keyring.gpg # download keyring for github cli
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null # add github-cli apt
sudo apt update -y && sudo apt install gh -y # install gh
sudo apt install ssh -y # install ssh
brew install git # install git
brew install gh # install gh
# There's no need to install SSH on macOS, as it comes pre-installed by default

Generate SSH files

Create ssh files by running following command and provide email which is liked to github account:

cd ~/.ssh
ssh-keygen -t ed25519 -C "your_email@example.com"
mv ~/.ssh/id_ed25519 ~/.ssh/github-user_name.pem
mv ~/.ssh/id_ed25519.pub ~/.ssh/github-user_name.pub

Refer to this link for more information about generating SSH keys.

This will generate a .pem and a .pub file, rename as github-user_name.pem and github-user_name.pub based on the GitHub username. Move these files to the ~/.ssh folder. Then, upload the .pub file to github.

SSH file permissions

Update ssh file permissions by running the following commands:

chmod 644 ~/.ssh/known_hosts 
chmod 600 ~/.ssh/config ~/.ssh/authorized_keys
chmod 644 ~/.ssh/github-user_name.pub
chmod 400 ~/.ssh/github-user_name.pem

SSH config

Create an SSH configuration, primarily focusing on scenarios where a developer working with multiple GitHub accounts.

~/.ssh/config
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Host github.com-user_name
  User git 
  HostName github.com
  IdentityFile ~/.ssh/github-user_name.pem

Host *
  Port 22
  User ubuntu
  #LogLevel VERBOSE
  #LogLevel DEBUG
  Compression yes 
  ServerAliveInterval 60
  ServerAliveCountMax 10
  PreferredAuthentications publickey

Clone repository

Before cloning any repository, please update your ~/.ssh/known_hosts file with the following changes. For reference, see this link.

ssh-keyscan github.com 2> /dev/null >> ~/.ssh/known_hosts

Use the modified git clone command when performing a Git clone.

git clone git@hostName:orgName/repoName.git

Replace hostName with the above mentioned SSH configuration’s Host value, orgName with the GitHub organization name, and repoName with the repository name.

User config for repository

For each cloned repository, make sure it remains synchronized with your GitHub account. Use this link to retrieve details such as your Public email and Name associated with GitHub, and then use the following commands to verify and update your user details on your system.

To view the user configuration data for each repository:

git config user.name
git config user.email

To update the user configuration for each repository:

git config user.email "your_email@example.com"
git config user.name "user_name"
Last updated on