-
Notifications
You must be signed in to change notification settings - Fork 2
/
HowTo.txt
225 lines (180 loc) · 7.6 KB
/
HowTo.txt
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
Config sftp & ssh
-----------------------------------------------------------------------
Config ssh:
sudo apt install openssh-server
sudo systemctl enable ssh.service
-----------------------------------------------------------------------
Config sftp -> only use when it not works after ssh setup is done:
sudo nano /etc/ssh/sshd_config
_ comment out line: "Subsystem sftp /usr/lib/openssh/sftp-server"
_ add: "Subsystem sftp internal-sftp"
_ add:
"Match Group sftp_users
X11Forwarding no
AllowTcpForwarding yes
ChrootDirectory /"
_ save
sudo systemctl restart ssh.service
sudo groupadd sftp_users
sudo usermod -aG sftp_users <user>
-----------------------------------------------------------------------
Auto mount
-----------------------------------------------------------------------
sudo vi /etc/fstab
add: <file system> <mount point> <type> <options> <dump> <pass>
ex1: UUID=921356de none swap sw 0 0
ex2: UUID=921356de /dev/sda1 ext4 defaults 0 1
-----------------------------------------------------------------------
Add SSH key to git
-----------------------------------------------------------------------
Step 1: Generating a new SSH key pair
ssh-keygen -t ed25519 -C "<[email protected]>"
or
ssh-keygen -t rsa -b 4096 -C "<[email protected]>"
Step 2: Choose path & add protected password if necessary
Note: To edit use "ssh-keygen -p -f <keyname>"
Step 3: Adding an SSH key to your Git account (github, GitLab...)
Copy content of <key file>.pub located in ~/.ssh/ (id_rsa.pub or id_ed25519.pub)
or "cat ~/.ssh/<id_ed25519>.pub | clip"
Paste to "add ssh key" field on git account setting
Step 4: Verify
ssh -T git@<git domain>
Troubleshoot:
If not work after step 4, re-cloning git repo using ssh link
or
Edit git remote url from http to ssh link (git@...)
-----------------------------------------------------------------------
Import ssh private/public ssh key to other computer
-----------------------------------------------------------------------
Step 1: Copy private/public key file to ~/.ssh/
Step 2: Change permission of key file
chown <user name>:<user group> ~/.ssh/id_rsa* -> maybe unnecessary
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
Step 3: Add key
ssh-add
If error "Could not open a connection to your authentication agent", run:
eval "$(ssh-agent)"
Step 4: Verify
ssh -T git@<git domain>
-----------------------------------------------------------------------
Removing ssh key
-----------------------------------------------------------------------
Step 1: Remove all or specify which key id to remove
ssh-add
or
ssh-add -f <path to file>
Step 2: Delete corresponding key file in ~/.ssh/
-----------------------------------------------------------------------
Signing git commits with GPG
-----------------------------------------------------------------------
Step 1: Generate the private/public key pair
gpg --full-gen-key
or
gpg2 --full-gen-key
Step 2: Follow instructions to config: algorithm, key length, validity period, username,
email (verified on git account), protected password
Step 3: List the private GPG key
gpg --list-secret-keys --keyid-format LONG <your_email>
Step 4: Copy the GPG key ID that starts with "sec <hash type>/"
ex: sec rsa4096/30F2B65B9246B6CA -> 30F2B65B9246B6CA
Step 5: Export public key & add to GPG field in git account setting
gpg --export --armor <key ID>
Step 6: Associating your GPG key with Git
Add key
git config --<global/local> user.signingkey <key ID>
Export private key to copy to other machine
gpg --export-secret-keys --armor <key ID> > <private key name>.key
or
gpg --export-secret-keys --armor --output=<private key name>.key <key ID>
Import private key in another computer
gpg --import <private key name>.key
gpg --edit-key <key ID> trust quit
# enter 5<RETURN> (I trust ultimately)
# enter y<RETURN> (Really set this key to ultimate trust - Yes)
Auto sign
git config --<global/local> commit.gpgsign true
Troubleshoot:
If gpg not available, use "git config --global gpg.program gpg2"
-----------------------------------------------------------------------
Switch OS from ubuntu to CentOS
-----------------------------------------------------------------------
grub-reboot 2
reboot
-----------------------------------------------------------------------
Switch OS from CentOS to ubuntu (Ubuntu installed after CentOS)
-----------------------------------------------------------------------
mount /dev/sdb2 /media/mntdrive
grub2-editenv /media/mntdrive/boot/grub/grubenv set next_entry=0
reboot
after entering Ubuntu:
grub-editenv - unset next_entry
-----------------------------------------------------------------------
NOTE:
CentOS uses grub2 while Ubuntu uses grub
Remote to Ubuntu using VNC (= set automatic login)
-----------------------------------------------------------------------
Edit file "/etc/gdm3/custom.conf"
Uncomment "AutomaticLoginEnable" & "AutomaticLogin"
Set "AutomaticLogin" to usaged user account
reboot
-----------------------------------------------------------------------
Fix "nvidia persistence daemon failed"
-----------------------------------------------------------------------
sudo apt --fix-broken install
# If not work, then run below command then try again
sudo dpkg -i --force-overwrite /var/cache/apt/archives/<package_name>
-----------------------------------------------------------------------
Desktop-remote stuff
-----------------------------------------------------------------------
Enable X11 forward:
_ Uncomment and set "ForwardAgent" & "ForwardX11" to "yes" -> then restart ssh service
_ To fix error with git commit, add the line to before "Host *"
Host github.com
ForwardAgent no
ForwardX11 no
Fix "unsupported security type" - VNC remote to Vino-server:
_ gsettings org.gnome.Vino require-encryption false
-----------------------------------------------------------------------
Create disk partition larger than 2TB
-----------------------------------------------------------------------
sudo parted /dev/sda
# Create GPT partition
(parted) mklabel gpt
# Create partition using % or KB/MB/TB/...
(parted) mkpart primary ext4 0% 50%
(parted) mkpart primary ext4 50% 100%
# List all partitions
(parted) print free
# Save & quit
(parted) quit
# Format partition
sudo mkfs.ext4 /dev/sda#
-----------------------------------------------------------------------
Set static network interface names in Linux with Systemd
-----------------------------------------------------------------------
# Create *.link file in /etc/systemd/network/
sudo nano /etc/systemd/network/01-<interface_name>.link
# Add content below:
[Match]
MACAddress=00:50:56:ac:07:30
[Link]
Name=enp10s0
# Update initramfs & reboot
sudo update-initramfs -u
-----------------------------------------------------------------------
Autorun script/command
-----------------------------------------------------------------------
Ubuntu: https://askubuntu.com/questions/814/how-to-run-scripts-on-start-up
# Using crontab: https://askubuntu.com/a/816
# Using rc.local file: https://askubuntu.com/a/1199
# Using systemd: https://askubuntu.com/a/719157
Petalinux (Yocto):
# Running application: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842475/PetaLinux+Yocto+Tips#PetaLinuxYoctoTips-HowtoAutoRunApplicationatStartup
# Running script: https://stackoverflow.com/a/70562746
-----------------------------------------------------------------------
Fix switch between instances of an app not working (alt + `)
-----------------------------------------------------------------------
gsettings reset org.gnome.desktop.wm.keybindings switch-group
# logout then login again
-----------------------------------------------------------------------