-
Notifications
You must be signed in to change notification settings - Fork 1
/
Linux configuration notes
239 lines (173 loc) · 8.95 KB
/
Linux configuration notes
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
#!/bin/sh
- Adjusting Webmin
-User menus for progress and rocksolid (file manager and textlogin)
- Adjusting Samba Server
- Convert and sync user lists (or rewrite pass in samba users menu
- samba obeys unix file rules so mask it as root or everyone also uuid (there is acl workaround)
- Folder permissions persist, so it confuses things
- dmraid -ay autodetect old raids ...
- add recyclebin vfs module
- bcache https://evilpiepirate.org/git/linux-bcache.git/tree/Documentation/bcache.txt
- busy error : http://carryflag.blogspot.com/2015/12/make-bcache-device-or-resource-busy.html
- Adjusting bcache and mdadm # for advanced raid setups
-bcache https://evilpiepirate.org/git/linux-bcache.git/tree/Documentation/bcache.txt
-busy error : http://carryflag.blogspot.com/2015/12/make-bcache-device-or-resource-busy.html
-Load Turkish keys
sudo loadkeys tr
sudo nano /etc/default/keyboard
change XKBLAYOUT to tr
- Activate apt-get sources remove single #
sudo nano /etc/apt/sources.list
- Disable Auto Updates
sudo nano /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";
- Adjust server time :
sudo unlink /etc/localtime
sudo ln -s /usr/share/zoneinfo/Europe/Istanbul /etc/localtime
- Quick Boot
/etc/default/grub change to:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
sudo update-grub
- No Gui mode:
systemctl set-default multi-user.target
- Change Back to gui mode
systemctl set-default graphical-user.target
- Using X from terminal pty (command line)
sudo apt-get install firefox
sudo X :3 -ac
DISPLAY=:3 xterm
DISPLAY=:3 metacity
sudo xrandr -s
firefox --kiosk https://localhost:10000
- User adjustment Examples
# Ubuntu has adduser instead of useradd it also cretes home folder, much more distro friendly.
sudo useradd progress
sudo passwd progress #tcploggerprogress
sudo usermod -a -G sudo progress #sudo,video,blabla ... username
exec bash
usermod --shell /bin/bash progress # adjust bash
sudo usermod -d $HOMEFOLDER progress #change homefolder
sudo mkdir /home/progress
. ./bashrc #or source .bashrc (you can copy from original gediz user)
sudo chown -R progress /home/progress
sudo chgrp -R progress /home/progress
#### BACKUP and ALIKE #####
### Compress and Backup ! use pigz instead of gzip if possible ###
dd if=/dev/sda2 status=progress | gzip -c -9> /somefolder/somefile.img.gz
### Restore from Backup ###
gunzip -c somefile.img.gz | dd iflag=fullblock bs=4M | sudo dd iflag=fullblock oflag=direct conv=fsync status=progress bs=4M of=/dev/mmcblk0
### Cloning two disks (clones sdX to sdY - be careful)
lsblk -o NAME,MODEL,UUID
sudo dd if=/dev/sdX of=/dev/sdY bs=4M staus=progress
### Zero out empty space ###
sudo dd if=/dev/zero of=zerofile2.zero bs=100M count=1000 status=progress
rm zerofile2.zero
# Secure Erase Empty Space # (Preferably 3 times for Mechanical Disks)
# Use these against hackers if you dont want to recycle your hard drives other wise drill trough and burn them - They can get you passwords from your old disks.
sudo dd if=/dev/urandom of=paddedFile.rand bs=100M count=1000 status=progress
rm paddedFile.rand
### Sync or Mirror Disks in Linux : (Deletes files which is not in source folder)
sudo rsync -Pra --delete -i --log-file=RsyncLog.txt /mnt/sdisk/ /mnt/tdisk
!!! source does have a trailing / but dest does not ...
### Sync or Mirror Disks in Windows: ### (Deletes files which is not in source folder)
robocopy "SOURCE_DRIVE_LETTER:" "DESTINATION_DRIVE_LETTER:" /E /ZB /X /PURGE /COPYALL /TEE /LOG:D:\Copy_from_HD_to_Ext_HD.log /XD "$RECYCLE.BIN" "System Volume Information"
### Os cloning file by file without binary disk cloning (Faster and Reliable) ###
# Backup-Restore System(keep grub and etc/fstab or readjust uuids)
rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /path/to/backup/folder
### Compress folder using pigz 9th degree compression with 32 processor threads ###
tar cf - paths-to-archive | pigz -9 -p 32 > archive.tar.gz
### with progress indjicator ###
tar cf - paths-to-archive | pv | pigz -9 -p 32 > archive.tar.gz
# ! if you dont want to delete original file pigz -k
tar --use-compress-program="pigz -k |pv" -cf '/run/user/1000/gvfs/smb-share:server=192.168.1.160,share=temp_server_d/JOBS/THY_SAFETY_INNOCEAN.tar.gz' THY_SAFETY_INNOCEAN
# sync to ciff mounted samba server ! Careful target has no trailing slash (There is a permission issue we cant use -A here we expand it)
rsync -PDrlt -i --log-file ~/Copylog.txt DaVinci/ /run/user/1000/gvfs/smb-share:server=192.168.1.160,share=temp_server_d/DAVTEST999
#see total number of files
find . -type f -print | wc -l
#see file system info
sudo tune2fs -l /dev/sda1
#get block size
sudo tune2fs -l /dev/sda1 | grep Block
#file size distribution in current folder
find . -type f -print0 | xargs -0 ls -l | awk '{size[int(log($5)/log(2))]++}END{for (i in size) printf("%10d %3d\n", 2^i, size[i])}' | sort -n
#average file size in current folder
ls -lR | awk '{sum += $5; n++;} END {print sum/n;}'
#compare two folders byte by byte (stays silent if file does not exists only shows what differs)
diff -qr fodler1/ folder2/
# see total folder size with subfolder
du -sh
#see disk usage
dh -u
#see disks detailed
lsblk -o NAME,MAJ:MIN,RM,SIZE,TYPE,FSTYPE,MOUNTPOINT,UUID,PARTUUID
#¢lear buffers !!!
free && sync && echo 3 > /proc/sys/vm/drop_caches && free
#auto connecd
sudo dhclient
#switch to root
sudo -i
#adjust fanspeeds and read temps from sysfs
echo bla > sys/devices/bus...
-But setting text mode resolution breaks xubuntu desktop because of nomodeset:
GRUB: shift ctrl?+c vbeinfo nomodeset GRUB_GFXPAYLOAD_LINUX=...
# One Liners
# Find and delete *.txt files (can use -delete instead of | xargs -0 rm)
find . -name "*.txt" -print0 | xargs -0 rm
# change display density of android device
adb shell wm density 240
# watch cpu core speeds
watch -n 1 "cat /proc/cpuinfo|grep MHz"
# installs classic GNOME
sudo apt-get install gnome-session-flashback
# create a new conda environment containing TensorFlow and activate it
conda create -n tensorflow_env tensorflow & conda activate tensorflow_env
# one time change to cpu scheduler in slow systems until boot
echo cfq | sudo tee /sys/class/block/sda/queue/scheduler
# Fix interrupted installs - package manager - Kernel Module Failed to Load issues
dpkg --configure -a
# Backup Names of Installed Packages
dpkg --get-selections | grep -v deinstall > ubuntu-files
# Restore selected packages (do not forget to upgrade)
sudo dpkg --set-selections <./ubuntu-files apt-get -y update & apt-get dselect-upgrade
# Find files with specific string
grep -rnw '/path/to/somewhere/' -e 'text-to-search';
# Download files and web pageswget https://raw.githubusercontent.com/blabla.gzip
# Adjust gamma and brightness
xrandr --output DVI-D-0 --brightness 1.1 --gamma 0.9:0.9:0.9
# Adjust gamma and brightness - Movie mode ... Colder and more contrasted ...
xrandr --output DVI-D-0 --brightness 1 --gamma 0.85:0.85:0.9
# python3 create some test files :
def createTestFiles(n,size):
for i in range(n):
runsys("sudo dd if=/dev/urandom of=test"+str(i)+".tst bs="+str(size)+" count=1 status=none")
def copyTest(ext,folder):
runsys("sudo mkdir "+folder)
runsys("cp *."+ext+" "+folder)
# bash version of it :
size=128*1024 # bytes
sVerbose=progress # none or progress
for i in {1..100};do;sudo dd if=/dev/urandom of=test$i+.tst bs=$size count=1 status=$sVerbose;done
# Show apparent file size (not based on disk cluster size)
du -s --apparent-size
# You can Benchmark your comp via
sudo -i
dd bs=10M count=100 if=/dev/urandom of=test7498327498.39840928349 oflag=dsync # cpu test ...
free && sync && echo 3 > /proc/sys/vm/drop_caches && free # clears caches
dd bs=10M count=100 if=test7498327498.39840928349 of=/dev/null # disk read test ...
dd bs=4M count=32 if=/dev/zero of=/dev/null # cpu test
dd bs=4M count=32 if=/dev/zero |md5sum # another cpu test
glmark2 # gpu test
mprime (mersenne prime) # cpu mmx fft test (advanced cpu test)
# lets see drivers in use
sudo lspci -vvv | grep -E '[0-f][0-f]:[0-f][0-f].[0-f]|driver in use' --color none
# lets see Link capacities and used link speeds of hardware
sudo lspci -vvv | grep -E '[0-f][0-f]:[0-f][0-f].[0-f]|LnkCtl|LnkSta|LnkCap'
# dmidecode ve lspci dan hw info görebiliriz. pythonla daha rahat olur cihaz başına detayları ile ...
# See cpu frequencies
watch -n 1 "cat /proc/cpuinfo |grep MHz"
# LATEST FILE SERVER CIFFS COMMANDS
nohup run.sh & # keep running after getting disconnected from ssh
sudo apt-get install install cifs-utils
rsync -PDrlt --whole-file -i --log-file ~/CopylogSAHAM_FILLERS_Cont.txt SAHAM_FILLERS/ /run/user/1000/gvfs/smb-share:server=192.168.1.160,share=temp_server_e/SAHAM_FILLERS
tar --use-compress-program="pigz -k |pv" -cf '/run/user/1000/gvfs/smb-share:server=192.168.1.160,share=temp_server_e/JOBS/SAHAM_FILLERS.tar.gz' SAHAM_FILLERS
pigz -dc target.tar.gz | tar xf -