forked from cyb70289/tricks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathubuntu
More file actions
716 lines (514 loc) · 17.4 KB
/
ubuntu
File metadata and controls
716 lines (514 loc) · 17.4 KB
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
change users listed in login screen
-----------------------------------
/etc/login.defs -> UID_MIN, GID_MIN
grub single usermode
--------------------
http://www.noah.org/wiki/Single_User_Mode
screen size in text mode
------------------------
$ vi /etc/default/grub
GRUB_CMDLINE_LINUX="vga=791"
GRUB_GFXMODE=1024x768
show boot menu
---------------
(/etc/default/grub)
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
GRUB_TERMINAL="console serial"
PXE
---
ubuntu
https://www.maketecheasier.com/configure-pxe-server-ubuntu/
redhat
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/chap-installation-server-setup.html
fedora
https://docs.fedoraproject.org/en-US/Fedora/21/html/Installation_Guide/chap-pxe-server-setup.html
remote desktop
--------------
search "desktop sharing"
disable encrytion
- $ dconf-editor
- find "5900"
ui config
---------
super -> app -> unity tweak tool
auto update
-----------
sudo systemctl disable apt-daily.service # disable run when system boot
sudo systemctl disable apt-daily.timer # disable timer run
/etc/apt/apt.conf.d/20auto-upgrades
>> APT::Periodic::Update-Package-Lists "0";
>> APT::Periodic::Unattended-Upgrade "0";
font size in text mode (ubunt-15)
---------------------------------
fonts are under /usr/share/consolefonts, to test font:
$ setfont Uni2-TerminusBold20x10
$ vi /etc/default/console-setup
Ubuntu-14:
CODESET="Uni2"
FONTFACE="TerminusBold"
FONTSIZE="20x10"
Ubuntu-15:
FONTFACE="TerminusBold"
FONTSIZE="10x20"
For Ubuntu-15, add "setupcon" to /etc/rc.local
ftp server
----------
$sudo apt-get install pure-ftpd
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
router
===================================================================================
network configuration
---------------------
eth0: lan, static, 172.29.0.0/16
eth1: wan, dhcp, 10.164.2.153
ip masquerading
---------------
# iptables -A FORWARD -o eth1 -i eth0 -s 172.29.0.0/16 -m conntrack --ctstate NEW -j ACCEPT
# iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# iptables -t nat -F POSTROUTING
# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# iptables-save | sudo tee /etc/iptables.sav
add "iptables-restore < /etc/iptables.sav" into /etc/rc.local before the "exit 0" line
ip forwarding
-------------
$ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
uncomment "net.ipv4.ip_forward=1" in /etc/sysctl.conf
port forwarding
---------------
https://tecadmin.net/setting-up-a-port-forwarding-using-iptables-in-linux/
- client wants to visit dest-server:5001 through a jump-server
- client -> jump-server:15001 -> dest-server(172.28.1.1:5001)
- client can visit dest-server:5001 by jump-server:15001
$ sudo iptables -t nat -A PREROUTING -p tcp --dport 15001 -j DNAT --to-destination 172.28.1.1:5001
$ sudo iptables -t nat -A POSTROUTING -j MASQUERADE
port mapping for libvirt vm
---------------------------
http://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections
iptables -I FORWARD -o virbr0 -d $GUEST_IP -j ACCEPT
iptables -t nat -I PREROUTING -p tcp --dport $HOST_PORT -j DNAT --to $GUEST_IP:$GUEST_PORT
client setup
------------
$ sudo route add default gw 172.29.1.10 eth0
add "gateway 172.29.1.10" to /etc/network/interfaces under "iface eth0"
urls
----
https://help.ubuntu.com/community/Internet/ConnectionSharing
https://rbgeek.wordpress.com/2012/05/14/ubuntu-as-a-firewallgateway-router/
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
wget
====
wget -r -np -nH --cut-dirs=4 -R index.html* http://images.maas.io/ephemeral-v2/daily/wily/arm64/ddd/
Explanation:
?It will download all files and subfolders in ddd directory:
?recursively (-r),
?not going to upper directories (-np),
?not saving files to hostname folder "images.maas.io/" (-nH),
?but to ddd by omitting first 4 folders "ephemeral-v2/daily/wily/arm64/" (--cut-dirs=4)
?excluding index.html files (-R index.html*)
thunderbird
===========
office365
---------
email: select imap+oauth2, works out of the box
calendar: install TbSync + "Provider for Exchange ActiveSync"
dont wrap long line
-------------------
mailnews.display.disable_format_flowed_support = true
set tab title
=============
The .bashrc solution proposed by Kirby worked for me:
set-title(){
ORIG=$PS1
TITLE="\e]2;$@\a"
PS1=${ORIG}${TITLE}
}
then from my prompt: $ set-title test-title
iconize by clicking on toolbar (trusty)
=======================================
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-minimize-window true
enable ssh password login
==========================
$ sudo vi /etc/ssh/sshd_config
"PasswordAuthentication yes"
"KbdInteractiveAuthentication yes"
"UsePAM yes"
$ sudo /etc/init.d/ssh reload
cron
====
http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/
dual ip for one nic
===================
sudo ip address add 172.29.100.100/16 dev eth0
sudo ip address del 172.29.100.100/16 dev eth0
nic offload setting
===================
sudo ethtool -k eth0 --> list settings
sudo ethtool -K eth0 rx-vlan-filter off
static dns with dhcp
====================
https://help.ubuntu.com/community/StaticDnsWithDhcp
show my public ip
=================
curl http://icanhazip.com/
dump dts
========
http://suihkulokki.blogspot.tw/2015/04/fastest-way-to-change-running-dtb.html
# apt-get install device-tree-compiler
# dtc -I fs -O dts -o current.dts /proc/device-tree/
$ dtc -I dts -O dtb -o new.dtb current.dts
initramfs
=========
The uncompressed cpio archive must be the first. Compressed cpio archives must
be after the uncompressed one.
add files
---------
https://www.kernel.org/doc/Documentation/acpi/initrd_table_override.txt
- mkdir -p kernel/firmware/acpi
- cp dsdt.aml kernel/firmware/acpi
- find kernel | cpio -H newc --create > acpi_initrd
- cat /boot/initrd.img-4.15.0-54-generic >> acpi_initrd
- mv acpi_initrd /boot/initrd.img-4.15.0-54-generic
modify
------
http://backreference.org/2010/07/04/modifying-initrdinitramfs-files/
file as /dev/sdb
================
$ dd if=/dev/zero of=virtual_hard_drive.bin bs=1M count=1024
$ mknod /dev/sdb b 7 500
$ losetup /dev/sdb virtual_hard_drive.bin
login/ssh slow
==============
try remove /etc/update-motd.d/*
https://superuser.com/questions/166359/top-causes-of-slow-ssh-logins
$ sudo systemctl restart systemd-logind
passwordless sudo
=================
$ sudo VISUAL=vim visudo
linux ALL=(ALL) NOPASSWD:ALL
system recovery
===============
http://xmodulo.com/how-to-reset-root-password-in-debian-ubuntu.html
setup apt repo
==============
https://askubuntu.com/questions/170348/how-to-create-a-local-apt-repository
$ dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
extglob
=======
$ shopt -s extglob
$ ls !(a*) -> list files NOT start with 'a'
mount whole disk image(not partition)
=====================================
$ fdisk -lu vmdisk
Device Start End Sectors Size Type
vmdisk1 2048 1050623 1048576 512M EFI System
vmdisk2 1050624 16963583 15912960 7.6G Linux filesystem
vmdisk3 16963584 20969471 4005888 1.9G Linux swap
$ sudo mount -o loop,offset=$((1050624*512)) vmdisk /mnt
create ubuntu boot usb
======================
startup disk creator
use own repo
============
deb http://wls-x86-hp07.shanghai.arm.com/debian-openstack/ ./
bridge
======
auto brAdm
iface brAdm inet static
bridge_ports eth1
address 192.168.234.253/24
pin package version
===================
$ sudo vi /etc/apt/preferences.d/virt
Package: libvirt-bin libvirt0
Pin: version 1.3.1-1ubuntu10.12
Pin-Priority: 900
$ sudo vi /etc/apt/preferences.d/thunderbird
Package: thunderbird*
Pin: version 1:60.9.0+build1-0ubuntu0.18.04.1
Pin-Priority: 1001
Package: xul-ext-*
Pin: version 1:60.9.0+build1-0ubuntu0.18.04.1
Pin-Priority: 1001
vlan nic
========
https://wiki.ubuntu.com/vlan
git proxy
=========
https://cms-sw.github.io/tutorial-proxy.html
ssh -f -N -D 3333 linaro@uk1
git -c "http.proxy=socks5://localhost:3333" clone https://github.com/pytorch/pytorch
resize partition
================
- fix gpt error
# printf "fix\n" | parted ---pretend-input-tty /dev/sda print
- grow partition
# growpart /dev/sda 2
- grow file system
# resize2fs /dev/sda2
ssh tunnel
==========
p3OO --lan--> hp07 --vpn--> uk1 --> other side of wall
- hp07:~/$ ssh -X -f -N -D 10.169.41.138:3333 linaro@10.101.2.102
- p3OO:~/$ curl --socks5 hp07:3333 http://xxx/yyy -o yyy
- p3OO:~/$ git -c "http.proxy=socks5://hp07:3333" clone xxx
nested kvm
==========
<cpu mode='custom' match='exact'>
<model fallback='allow'>Haswell-noTSX</model>
<feature policy='require' name='vmx'/>
</cpu>
loop lvm
========
$ export LOOPDEV=/dev/loop2
$ sudo apt install lvm2 && sudo systemctl start lvm2-lvmetad
$ dd if=/dev/zero of=lvm1.img bs=1M count=20K
$ sudo losetup $LOOPDEV lvm1.img
$ sudo pvcreate $LOOPDEV
$ sudo vgcreate vg1 $LOOPDEV
$ sudo lvcreate -n lv1 -l 100%FREE vg1
vim
===
- check current file type
:set ft?
- system clipboard
"+y
"+p
curl & run script
=================
https://stackoverflow.com/questions/4642915/passing-parameters-to-bash-when-executing-a-script-fetched-by-curl
curl & extract
==============
curl -sL https://aaa.bbb//ccc.tar.gz | tar xz
gpg
===
- create key
$ gpg --gen-key
- list/export keys
$ gpg -k
$ gpg --export -a
$ gpg -a -o yibocai.gpg --export yibo.cai@arm.com
- upload to keyserver
$ gpg --keyserver hkp://keys.gnupg.net --send-keys 32BA38F0
$ gpg --keyserver hkp://pgp.key-server.io:11371 --send-keys 32BA38F0
upload manually to http://pgp.mit.edu/, https://keyserver.pgp.com/
- search keyserver by mail
$ gpg --search-keys yibo.cai@arm.com
jenkins time format
===================
https://stackoverflow.com/questions/12472645/how-to-schedule-jobs-in-jenkins
max open files
==============
$ ulimit -Hn
$ ulimit -Sn
$ ulimit -Sn 8888
build iso
=========
genisoimage -r -V "Estuary Ubuntu Install CD" -J -l -o ubuntu-4.12.iso ./ubuntu16-4.12/
kernel
======
- install kernel debug symbol
https://hadibrais.wordpress.com/2017/03/13/installing-ubuntu-kernel-debugging-symbols/
- get kernel source code
* get installed kernel version: dpkg -l | grep linux-image
* find branch/tag in https://kernel.ubuntu.com/git/ubuntu/ubuntu-focal.git
* git clone git://kernel.ubuntu.com/ubuntu/ubuntu-disco -b tag --depth 1
- changelog
https://launchpad.net/ubuntu/+source/linux/+changelog
https://askubuntu.com/questions/55355/where-is-the-changelog-for-ubuntu-kernels
- mainline kernel binary
https://kernel.ubuntu.com/~kernel-ppa/mainline/
build kernel
============
stock
-----
- https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel (don't follow all)
- apply patches:
~ debian.master/etc/kernelconfig: change 'archs="arm64"'
~ debian/rules.d/1-maintainer.mk: delete 'rm -rf build'
~ debian/scripts/misc/kernelconfig: delete 'rm -rf build'
- steps:
~ chmod a+x debian/rules
~ chmod a+x debian/scripts/*
~ chmod a+x debian/scripts/misc/*
~ fakeroot debian/rules clean
~ fakeroot debian/rules editconfigs
~ cd build
~ make -j32 LOCALVERSION=-custom
~ sudo make INSTALL_MOD_STRIP=1 modules_install
~ sudo make install
upstream
--------
- https://wiki.ubuntu.com/KernelTeam/GitKernelBuild
- https://www.maketecheasier.com/build-custom-kernel-ubuntu/
- own build
$ sudo apt install build-essential flex bison binutils-dev dpkg-dev \
libncurses5-dev libssl-dev libiberty-dev
$ cp /boot/config-5.0.0-17-generic .config
$ make olddefconfig
$ sed -i 's/CONFIG_SYSTEM_TRUSTED_KEYS=.*/CONFIG_SYSTEM_TRUSTED_KEYS=""/' .config
$ sed -i 's/CONFIG_SYSTEM_REVOCATION_KEYS=.*/CONFIG_SYSTEM_REVOCATION_KEYS=""/' .config
$ make -j32 LOCALVERSION=-pmem
$ sudo make INSTALL_MOD_STRIP=1 modules_install
$ sudo make install
$ make -C tools/perf -j8
(# workaround libtraceevent)
(# make -C tools/perf -j8 FEATURE_CHECK_LDFLAGS-libtraceevent=-ltraceevent)
install latest ubuntu kernel
============================
https://github.com/pimlie/ubuntu-mainline-kernel.sh
git send-email
==============
https://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/
- git send-email --to cyb70289@sina.com --cc cyb70289@163.com --annotate -v2 -1
new document
============
- vi ~/.config/user-dirs.dirs
XDG_TEMPLATES_DIR="$HOME/.Templates"
- touch ~/.Templates/"Untitled Document"
list package dependencies
=========================
apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --no-pre-depends ceph-osd | grep "^\w" | sort -u
disable/enable cpu
==================
- sudo chcpu -d 112-223
- sudo chcpu -e 112-223
- /sys/devices/system/cpu/{online,offline}
iconv
=====
echo -e -n "\xf1\x80\x80\x80" | iconv -f UTF-8 -t UTF-16LE - | od -t x2
set env in sudo
===============
function sudo () {
args="$@"
/usr/bin/sudo bash -c "source env-file && $args"
}
find multiple patterns
======================
- find . \( -name "*.c" -o -name "*.h" -o -name "*.ic" -o -name "*.cc" \)
- find . -iregex '.*\.\(c\|cc\|h\|ic\)$'
disable swap
============
sudo systemctl stop swapfile.swap
sudo systemctl mask swapfile.swap
fight with dns 127.0.0.53
=========================
cat /run/systemd/resolve/resolv.conf > /tmp/resolv.conf.real
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved
sudo rm -f /etc/resolv.conf
sudo cp /tmp/resolv.conf.real /etc/resolv.conf
sudo reboot
set locale
==========
export LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
set memlock to unlimited
========================
add to /etc/security/limits.conf
* soft memlock unlimited
* hard memlock unlimited
root soft memlock unlimited
root hard memlock unlimited
logout/login
hide desktop drive icon
=======================
gsettings set org.gnome.nautilus.desktop volumes-visible 'false'
gnome terminal
==============
- color theme
install dconf gconf2
https://github.com/Gogh-Co/Gogh
[Teerb]
- windows size shrink
dconf write /org/gnome/terminal/legacy/headerbar '@mb false'
background solid color
======================
$ gsettings set org.gnome.desktop.background picture-uri ""
$ gsettings set org.gnome.desktop.background primary-color '#0063b1'
hide volume icon on sidebar
===========================
$ git clone https://github.com/micheleg/dash-to-dock.git
$ cd dash-to-dock
$ make
$ gsettings --schemadir schemas set org.gnome.shell.extensions.dash-to-dock show-mounts false
nofitication area missing
=========================
sudo apt install gnome-shell-extension-appindicator
install python3.8 if on ubuntu 18.04
====================================
$ add-apt-repository ppa:deadsnakes/ppa
$ apt install -y python3.8 python3.8-distutils
search 64k page size arm64 kernel
=================================
sudo apt install linux-generic-64k-hwe-20.04
apt search "linux-.*64k"
install arm64 packges on x86_64
===============================
- prefer https://github.com/multiarch/qemu-user-static
- https://wiki.debian.org/Multiarch/HOWTO#Setting_up_apt_sources
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
(
(grep ^deb /etc/apt/sources.list | sed 's/deb /deb [arch=amd64] /') && \
(grep ^deb /etc/apt/sources.list | sed 's/deb /deb [arch=arm64] /g; s/\(archive\|security\)\.ubuntu/ports.ubuntu/g; s/\/ubuntu/\/ubuntu-ports/g') \
) | tee /tmp/sources.list
sudo mv /tmp/sources.list /etc/apt/sources.list
sudo dpkg --add-architecture arm64
sudo apt update
sudo apt install libc6:arm64 libstdc++6:arm64
- https://wiki.debian.org/QemuUserEmulation
sudo apt install qemu binfmt-support qemu-user-static
find peak RSS of a process
==========================
/usr/bin/time command
install latest clang
====================
curl -s https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
sudo apt update
sudo apt install clang-16
wget https://apt.llvm.org/llvm.sh
chmod u+x llvm.sh
sudo ./llvm.sh 16
ssh issue on ubuntu-22.04
=========================
append "PubkeyAcceptedKeyTypes +ssh-rsa" to /etc/ssh/ssh_config
iotop doesn't show IO
=====================
sudo sysctl -w kernel.task_delayacct=1
get primary ip
==============
hostname -I | awk '{print $1}'
recovery with install cd
========================
- boot with install iso
- edit grub menu to append "systemd.unit=rescue.target" to kernel command line
- watch console, enter recovery mode
hide mounted volumn on sidebar
==============================
gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false
debian install kernel debug symbol, source
==========================================
debug symbol
- add deb-src to /etc/apt/sources.list
- sudo apt install linux-image-$(uname -r)-dbg
source
- ad deb-src to /etc/apt/sources.list
- search & install wanted linux source package
* apt search linux-source
* sudo apt install linux-source-version
- extract package manually
* cd /usr/src
* xzcat linux-source-version.tar.xz | tar xvf -
add to favorite
===============
fix issues that some app cannot pin to favorite bar
https://averagelinuxuser.com/ubuntu_custom_launcher_dock/
install package debug symbol
============================
https://documentation.ubuntu.com/server/explanation/debugging/debug-symbol-packages/