-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUbuntu.txt
More file actions
288 lines (249 loc) · 11.8 KB
/
Copy pathUbuntu.txt
File metadata and controls
288 lines (249 loc) · 11.8 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
-------- window width ------- ------------- ----------- --------- ---------- ------- --------- --------- window width: ------|
-1) For BINP local network it is mandatory to disalbe avahi daemon:
sudo systemctl disable avahi-daemon
sudo systemctl stop avahi-daemon
Check with:
service --status-all
UPD: Firefox seems to restart it constantly anyway. Had to
sudo apt-get remove avahi-daemon
UPD: Or use
systemctl mask avahi-daemon.socket
0) It's better to use Dolphin File Manager (default in SL7):
via Software Center (easier than using bash)
1) Ubuntu 15.10 GUI copy bug: coping form shared directory (owned by root, I gather this is the issue for any not user ownned
directory, but haven't checked) to some directory will fail if files with such names had been already copied to the target
location, even if they were later removed! Instead of coping of new files old ones are either stay or restored. This was on
Oracle Virtual Box machine. Use terminal's >cp $from_file $to_file instead.
2) Virtual Box can change the number of processors without worry in between guest OS launch.
3) mouting shared folder:
Install virtual drive drivers: VBox's menu (left Ctrl+Home by default): Devices->Insert Guest Additions CD Image
then auto installation will run
>sudo -i //enter root
>password entering
>mount -t vboxsf $HostFolderNameInVirtualBox $where to mount (must exist - not created)
change of owner (does not seem to work):
>chown $USER -R $path_to_folder //$USER is a real env. var.
>exit //from root
5)
6)Commands
echo - display:
>echo $GARFIELD_HOME
prints the value of GARFIELD_HOME environment variable
>export GARFIELD_HOME=/home/perser/Documents/GarfieldPP
>export HEED_DATABASE=$GARFIELD_HOME/Heed/heed++/database
creates env. variables
>source $file_name.sh
runs .sh file. Works when simple file_name.sh is denied access.
use this command to initialize root env. vars. (thisroot.sh)
https://superuser.com/questions/46139/what-does-source-do
>cp $from_file $to_file
copy
>ls
list directories
>rmdir
removes dir
>apt-get target install $package_name
loads and installs package
>./CellTest
executes CellTest program (in the same directory)
>command && (command1 ; command2) || (command3)
executes command. If it exists with error code (returns not 0) command3 executed otherwise command1 and 2 are consecuvely
executed. If any fails 3 executed.
example:>make && (echo -e "make ok\n"; .Cell)|| (echo -e "make error\n")
-e flag enables special characters
; allows several commands in one line
7) In order to change vhd disk location in the host OS modification of Oracle VM file required, it is impossible to do
via GUI (disconnecting disk, relocating it and connecting again yields 'the disk with number ... is already registered' error)
Go to C:\Users\$(USER_NAME)\VirtualBox VMs\$(VM_NAME) and change disk path in the .vbox file.
8) Installing SWAP disk (optionnaly may delete previous swap):
1) Add disk to virtual machine
2) Format it (was done via Disks GUI programm)
3) (NOT optionally for the swap disk:) set mount options (mount at startup, select label and mount point(folder))
4) In mounted point (/media/perser/swapDisk in my case) create a file with desired swap size):
>fallocate -l 21g /media/perser/swapDisk/swap
(if file size exceeds available space file will be created with all available space used)
5) >sudo chmod 600 /media/perser/swapDisk/swap
For security
6) >sudo mkswap /media/perser/swapDisk/swap
7) >sudo swapon /media/perser/swapDisk/swap
Now swap is set up but after reboot 'sudo swapon /media/perser/swapDisk/swap' will have to be repeated.
8) In order to set up swap at setup add line to /etc/fstab (i.g. via >sudo gedit /etc/fstab):
/media/perser/swapDisk/swap none swap sw 0 0
Beware that this line must go after /media/perser/swapDisk has been mounted (that's why 3rd point was required, note that
disk mount is listed in the /etc/fstab), because file can't be used as swap if system has not connected the disk
containing it yet. In case of automount of swap disk this line has no effect.
9) Setting environment variables and launching scripts at statup.
1) move .sh script to /etc/profile.d
Note that LD_LYBRARY_PATH is an exception and can only be set interactively in terminal or using /etc/ld.so.conf.d/*.conf
configuration files. (Required for Elmer for example)
2) Add files to /etc/ld.so.conf.d/*.conf with path to libraries, e.g.:
>sudo touch /etc/ld.so.conf.d/elmer.conf
add "/mnt/formerSwap/Elmer/install/lib" to that file
and >sudo ldconfig
(only once, not required at the system boot)
3) //UPD: does not work.// Also mounting is impossible in /etc/profile.d, so mounting shared with Host folder must be
done via
adding <name_of_share> /path/to/mountpoint vboxsf <options> 0 0
to the /etc/fstab file:
1) For mount of shared with host folder to be available user (perser in my case) must be int vboxsf group:
>sudo usermod -a -G groupName userName
>sudo usermod -a -G vboxsf perser
2) Next instead of
>sudo mount -t vboxsf SharedVirt /home/perser/Shared
use
SharedVirt /home/perser/Shared vboxsf auto 0 0
in the /etc/fstab
3) >sudo mount -t vboxsf SharedVirt /home/perser/Shared
Only this seems to work
10) For Eclipse remote debugging:
Make /proc/sys/kernel/yama/ptrace_scope permanent to 0 by setting ptrace_scope to 0 in /etc/sysctl.d/10-ptrace.conf
11) For Eclipse profiling (perf): //UPD: does not work at all
Install perf (google, via apt-get)
Determine current value: >cat /proc/sys/kernel/perf_event_paranoid
How to change /proc/sys/kernel/perf_event_paranoid (to 0 or 1) (otherwise permission denied error):
add line
kernel.perf_event_paranoid=1
to /etc/sysctl.conf (Persistant change)
OR
sudo -i
echo 1 >/proc/sys/kernel/perf_event_paranoid
exit (Per session change)
12) Archives:
create simple zip from "input" folder:
> zip -9 -r output.zip input
-r means recursion (zip subfolders). -9 is a mamimal compression level (slowest). default is -6 (from 0 to 9).
By default zip uses deflation algorithm. bzip2 may be better:
> zip -Z bzip2 -r output.bz2 input
But archive manager cannot view content of bz2 files.
Delete folder/files from existing archive (WILL unzip/create temporary .zip):
>zip -d foo foo/tom/junk foo/harry/\* \*.o
will remove the entry foo/tom/junk, all of the files that start with
foo/harry/, and all of the files that end with .o (in any path).
It is not recursive, so if archive has files in 191128/f1/data1.dat, data2.dat ...
use >zip -d archive archive/190228/f1/\* to detele these files
To add password pretection use -e flag:
>zip -e -9 -r output.zip input
13) Remote disk (at lab)
Conntcted via File Manager
smb://192.168.162.104/NAS2_Vol1/
To operate with it via bash mountpoint is required.
To get how File Manager set it: open it -> open in teminal.
In my case it's /run/user/1000/gvfs/smb-share:server=192.168.162.104,share=NAS2_Vol1/
Works as usual path.
14) Lost files restoration
TestDisk:
> sudo apt-get install testdisk
To run it on the main device run
> sudo testdisk /dev/nvme0n1p2
To get disk mount locations use
> sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
to list devices and
> mount
to get mountpoints
testdisk is quite smart and will highlight correct choices to select by default
Up until Partition menu with [Type] [Superblock] [List] ... on the bottom
Select [List] there and navigate to lost file/folfer
Select them and copy to location where they should be restored
Note that they will be put in folder with whole path!
> sudo chown -R $USER Folder
To change user for whole folder (after resoration the file will be be owned by root)
15) Profiling on Ubuntu using QtCreator:
Open QtCreator
Create new project - plain c++ console application
Build system - qmake
After that - .pro file contains projects setups
//For compiler flags use:
QMAKE_CXXFLAGS += -fPIC
QMAKE_CXXFLAGS += -pthread
QMAKE_LFLAGS += -fPIC
QMAKE_LFLAGS += -pthread
QMAKE_LFLAGS += -pipe
//For sources use:
SOURCES += \
src/ArgonParticle.cpp \
src/ArgonVanDerWaals.cpp \
... \
src/main.cpp
//Note that there is no '\' for the last file
//It you want to pass file as parameter to Qt-built console application, it is necessary to add this file:
DISTFILES += \
settings.xml
HEADERS += \
include/ArgonParticle.h \
include/ArgonVanDerWaalsParticle.h \
... \
include/ColoredInterval.h
unix:!macx: LIBS += -L$(HOME)/Software/root_v6.14.06/build/lib/ \
-lpthread \
-lGui \
-lCore \
-lRIO \
-lNet \
-lHist \
-lGraf \
-lGraf3d \
-lGpad \
-lTree \
-lRint \
-lPostscript \
-lMatrix \
-lPhysics \
-lMathCore \
-lThread \
-lMultiProc \
-lGeom \
-lm \
-lSpectrum \
-lThread
INCLUDEPATH += $(HOME)/Software/root_v6.14.06/build/lib
INCLUDEPATH += $(HOME)/Software/root_v6.14.06/build/include
INCLUDEPATH += $(HOME)/Software/boost_1_67_0
INCLUDEPATH += $(HOME)/Documents/QtThreeDimSimulation/QtThreeDimSimulation/include
DEPENDPATH += $(HOME)/Software/root_v6.14.06/build/lib
DEPENDPATH += $(HOME)/Software/root_v6.14.06/build/include
DEPENDPATH += $(HOME)/Software/boost_1_67_0
After project setup:
Build app to check that everything is all right
Setting up build configurations (Working directory/{Release, Debug, Profile}, etc):
Left menu->Projects
Profiling: Top Menu->Analyze->Performance Analyzer
16) convert all .*png to .pdf:
cd $folder_with_files
for f in $(find . -name '*.png'); do convert "$f" "${f%.*png}.pdf"; done
17) Checking SSD health:
sudo smartctl -a /dev/nvme0
Do not use /dev/nvme0n1p1 - namespace or partition, otherwise there will be NVMe Status 0x4002 error.
18) Finding and replacing every occurrence of oldtext with newtext in every text file under the /some/folder/ directory tree recursively:
grep -rl --include=\*.h oldtext . | xargs sed -i 's/oldtext/newtext/g'
19) Setting up gnome / dock interface:
# Docks (left panels) are separate for each wokspace
gsettings set org.gnome.shell.extensions.dash-to-dock isolate-workspaces true
# Remove trash icon from the Dock
gsettings set org.gnome.shell.extensions.dash-to-dock show-trash false
# Remove mounted discs from the Dock
gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false
20) Making global aliases: add
alias python='python3'
to /etc/bash.bashrc script (profile.d may be ignored)
21) Saving and loading terminal settings:
dconf dump /org/gnome/terminal/ > gnome_terminal_settings.txt
dconf load /org/gnome/terminal/ < gnome_terminal_settings.txt
22) Extend virtual drive from guest ubuntu
https://unix.stackexchange.com/questions/196512/how-to-extend-filesystem-partition-on-ubuntu-vm :
sudo growpart /dev/sda 1
sudo resize2fs /dev/sda1
23) Fix _apt missing write permissions (Download is performed unsandboxed as root as file '...' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied):
https://askubuntu.com/questions/908800/what-does-this-apt-error-message-download-is-performed-unsandboxed-as-root :
sudo chown -Rv _apt:root /var/cache/apt/archives/partial/
sudo chmod -Rv 700 /var/cache/apt/archives/partial/
24) Alt+Shift language changing:
# gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Alt>Shift_L']"
# gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "['<Alt>Shift_L', '<Shift>XF86Keyboard']"
# gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Alt>Shift_L', 'XF86Keyboard']"
UPD: Do not use above, it has language popup that forcefully exits fullscreen. Instead use:
1. Disable default combintation for layout switching in Settings => Keyboard Shortcuts => Typing
2. Install gnome-tweaks and turn on your new key layouts: gnome-tweaks => Additional Layout Options => Switching to another layout
25) For Hyper-V guest, to make ubuntu see virtual disk at its maximum capacity
sudo apt-get install cloud-guest-utils -y
sudo growpart /dev/sda 1
sudo resize2fs /dev/sda1