defaults write in mac os doesn't really work anymore. It never writes or changes the value in defaults - terminal

i have been trying to change value for this command and it doesn't work.
This is what it shows:-
vbabbar#VBabbar-Macbook ~ % defaults read -g com.apple.swipescrolldirection
1
vbabbar#VBabbar-Macbook ~ % defaults write -g com.apple.swipescrolldirection 0
vbabbar#VBabbar-Macbook ~ % defaults read -g com.apple.swipescrolldirection
1
vbabbar#VBabbar-Macbook ~ % defaults write -g com.apple.swipescrolldirection -bool True
vbabbar#VBabbar-Macbook ~ % defaults read -g com.apple.swipescrolldirection
1
vbabbar#VBabbar-Macbook ~ % defaults write -g com.apple.swipescrolldirection -bool False
vbabbar#VBabbar-Macbook ~ % defaults read -g com.apple.swipescrolldirection
1
The read value always shows 1 and never changes to 0. i have tried using 0,True and Falsse in default write. So is the function for changing DEFAULTS in mac os has been changed since MAc OS X - CATALINA and Above OS 11/12 n 13?
pls tell a Correct method to change Defaults via Terminal with an example
defaults write .GlobalPreferences_m
or
defaults read Analytics Option"
"HostWindowGeometry/.FullScreen" = 0;
OR
defaults read com.apple.keyboard.fnState" = 0

I’ve been trying to figure out the same thing. It looks like you have to kill the process you’re working on with killall so the default doesn’t get automatically overwritten by a running process. I’m not there yet though. This guy has a decent page about it.

Related

How to change kernel security level from 0 to 1 after `sysctl kern.securelevel`

When I run sysctl kern.securelevel on my Mac, it gives me a value of 0.
I'd like to increase the kernel security level on my computer. I want it to give me a 1.
Can I do that?
Have you tried:
sysctl kern.securelevel=1

How to make cpuset.cpu_exclusive function of cpuset work correctly

I'm trying to use the kernel's cpuset to isolate my process. To obtain this, I follow the instructions(2.1 Basic Usage) from kernel doc cpusets, however, it didn't work in my environment.
I have tried in both my centos7 server and my ubuntu16.04 work pc, but neither did work.
centos kernel version:
[root#node ~]# uname -r
3.10.0-327.el7.x86_64
ubuntu kernel version:
4.15.0-46-generic
What I have tried is as follows.
root#Latitude:/sys/fs/cgroup/cpuset# pwd
/sys/fs/cgroup/cpuset
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.cpus
0-3
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.mems
0
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.cpu_exclusive
1
root#Latitude:/sys/fs/cgroup/cpuset# cat cpuset.mem_exclusive
1
root#Latitude:/sys/fs/cgroup/cpuset# find . -name cpuset.cpu_excl
usive | xargs cat
0
0
0
0
0
1
root#Latitude:/sys/fs/cgroup/cpuset# mkdir my_cpuset
root#Latitude:/sys/fs/cgroup/cpuset# echo 1 > my_cpuset/cpuset.cpus
root#Latitude:/sys/fs/cgroup/cpuset# echo 0 > my_cpuset/cpuset.mems
root#Latitude:/sys/fs/cgroup/cpuset# echo 1 > my_cpuset/cpuset.cpu_exclusive
bash: echo: write error: Invalid argument
root#Latitude:/sys/fs/cgroup/cpuset#
It just printed the error bash: echo: write error: Invalid argument.
Google it, however, I can't get the correct answers.
As I pasted above, before my operation, I confirmed that the cpuset root path have enabled the cpu_exclusive function and all the cpus are not been excluded by other sub-cpuset.
By using ps -o pid,psr,comm -p $PID, I can confirm that the cpus can be assigned to some process if I don't care cpu_exclusive. But I have also proved that if cpu_exclusive is not set, the same cpus can also be assigned to another processes.
I don't know if it is because some pre-setting are missed.
What I expected is "using cpuset to obtain exclusive use of cpus". Can anyboy give any clues?
Thanks very much.
i believe it is a mis-understanding of cpu_exclusive flag, as i did. Here is the doc https://www.kernel.org/doc/Documentation/cgroup-v1/cpusets.txt, quoting:
If a cpuset is cpu or mem exclusive, no other cpuset, other than
a direct ancestor or descendant, may share any of the same CPUs or
Memory Nodes.
so one possible reason you have bash: echo: write error: Invalid argument, is that you have some other cgroup cpuset enabled, and it conflicts with your operations of echo 1 > my_cpuset/cpuset.cpu_exclusive
please run find . -name cpuset.cpus | xargs cat to list all your cgroup's target cpus.
assume you have 12 cpus, if you want to set cpu_exclusive of my_cpuset, you need to carefully modify all the other cgroups to use cpus, eg. 0-7, then set cpus of my_cpuset to be 8-11. After all these cpus configurations , you can set cpu_exclusive to be 1.
But still, other process can still use cpu 8-11. Only the tasks that belongs to the other cgroups will not use cpu 8-11
for me, i had some docker container running, which prevents me from setting my cpuset cpu_exclusive
with kernel doc, i do not think it is possible to use cpus exclusively by cgroup itself. One approach (i know this approach is running on production) is that we isolate cpus, and manage the cpu affinity/cpuset by ourselves

How to set limit for Nginx log files on Mac OS?

Nginx occupies all the available disk space. How to set limit for log files on Mac OS?
Rotate the log files. On OS X, newsyslog is the preferred utility to do that. Set up a file like this in /etc/newsyslog.d/nginx.conf:
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/nginx.log deceze:wheel 644 2 1024 * J
Read https://www.newsyslog.org/manual.html for more information.
Building on #deceze's answer, here's an adapted version of Apple's Apache configuration for a Homebrew-installed nginx:
#logfilename [owner:group] mode count size when [flags] [/pid_file] [sig_num]
/opt/homebrew/var/log/nginx/access.log _nginx:_nginx 644 10 20480 * Z /opt/homebrew/var/run/nginx.pid 30
This is assuming you're running as user:group _nginx:_nginx. It sends the correct SIGUSR1 signal (30 on macOS) to nginx. Also changed to using gzip instead of bzip2.

Running parallel simulations (using the Command Line)

How can I run the simulation with different configurations? I am using omnet++ version 4.6.
My omnetpp.ini file looks as below :
[General]
[Config Dcn2]
network = Dcn2
# leaf switch
#**.down_port = 2
**.up_port = 16 #12 # 4
# spine switch
**.port = 28 # 20 #2048
# crossconnect
**.cross_down_port = 28 # 20 #2048
**.cross_up_port = 28 # 20 #2048
# to set destination of packet
**.number_leaf_switch = 28 # 20 #2048
# link speed
#**.switch_switch_link_speed = 40 Mbps
**.interArrivalTime = ${exponential(.0001),exponential(0.0002),exponential(0.0003)}
**.batch_length = 10
**.buffer_length = 10
sim-time-limit = 1000s
I want to run the code with different values of interArrivalTime. But I can neither run with different configs (one after another), nor can I run individual runs in parallel on separate cores.
I have tried with cmdev option in run configurations but the different runs doesn't show up apart from the 1st one. When I try mentioning the number of processes to be more than one then also only the first run gets simulated. I really cannot find out the reason.
Config Examinataion
In your case you can perform config examination. OMNeT++ offers different options for that. They are explained under the Parameter Studies section of the OMNeT++ manual.
So you can try one of the following options to examine your configs and thus config file:
./run –a - will show all the configurations in the omnet.ini
./run -x <config_name> - will give more info about a specific config
./run -x <config_name> -g - see all the combinations of configs
First you will have to navigate to your example folder, and there execute one of the aforementioned commands.
I executed: ./run -x Dcn2 -g and got the following resuls
OMNeT++ Discrete Event Simulation (C) 1992-2014 Andras Varga, OpenSim Ltd.
Version: 4.6, build: 141202-f785492, edition: Academic Public License -- NOT FOR COMMERCIAL USE
See the license for distribution terms and warranty disclaimer
Setting up Tkenv...
Config: Dcn2
Number of runs: 3
Run 0: $0=exponential(.0001), $repetition=0
Run 1: $0=exponential(0.0002), $repetition=0
Run 2: $0=exponential(0.0003), $repetition=0
End.
This confirms indeed that you have 3 different runs for the simulation parameter you are trying to modify. However, variable name you are using for the interArrivalTime parameter is assigned to $0 by default because you have not specified it.
If you change the following line in your config:
**.interArrivalTime = ${exponential(.0001),exponential(0.0002),exponential(0.0003)}
to
**.interArrivalTime = ${interArrivalTime = exponential(0.0001),exponential(0.0002),exponential(0.0003)}
you will get a more descriptive output for ./run -x Dcn2 -g
Running different runs of a config:
Next step for you would be to run the different runs for your config. You can do that by navigating to your example directory and execute:
./run -c <config-name> -r <run-number> -u Cmdenv
Note that the <config-name> would be Dcn2 for you, and the -r specifies which of the runs given above you would like to execute.
In other words you can open three terminal windows and navigate to your example directory and do:
./run -c Dcn2 -r 0 -u Cmdenv - for interArrivalTime = exponential(0.0001)
./run -c Dcn2 -r 1 -u Cmdenv - for interArrivalTime = exponential(0.0002)
./run -c Dcn2 -r 2 -u Cmdenv - for interArrivalTime = exponential(0.0003)
Distinguishing Different run results
To be able to distinguish between the output result files of the different runs for your given config you can modify the default name of the output file.
The "how-to" is given in the 12.2.3 Result File Names section of the OMNeT++ manual.
output-vector-file = "${resultdir}/${configname}-${runnumber}.vec"
output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca"
As you can see by default your output files will be distinguished by the ${runnumber} variable. You can further improve it by adding the interArrivalTime to the output file name.
Example:
output-scalar-file = "${resultdir}/${configname}-${runnumber}-IAtime=${interArrivalTime}.sca/vec"
I have not tested the final approach. So you might get some error along the path.

xdotool and keyboard layout

Problem
I am trying to do:
xdotool type 'date;'
but instead of the expected
date;
I get:
dateq
I have a greek keyboard, but when I issue the command the language is set to US. A note: when greek language is used, the key 'q' of the keyboard is used for the semicolon ';' (this is the default behavior/mapping)
Question
What can I do to get a semicolon with xdotool's type?
Some info
I am on Xfce 4.8 on XUbuntu
$ xfce4-terminal -V
xfce4-terminal 0.4.8 (Xfce 4.8)
$ setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Applied rules from evdev:
rules: evdev
model: pc105
layout: us,gr
variant: ,
options: grp:caps_toggle
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+us+gr:2+inet(evdev)+capslock(grouplock)
geometry: pc(pc105)
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+gr:2+inet(evdev)+capslock(grouplock)" };
xkb_geometry { include "pc(pc105)" };
};
$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04
Codename: precise
try
setxkbmap <yourlocale>
before calling xdotool
This is a known bug. One thing you can try is upgrading to the newest version of xdotool. If that doesn't work, then check out this page, especially answer #29:
http://code.google.com/p/semicomplete/issues/detail?id=13
The issue was resolved by this pull request on 2014-04-07 (which is more than 3 years ago now). If anybody is still having this issue today, I think your best bet is upgrading xdotool.
These work for me:
echo "date;" | xvkbd -xsendevent -file -
xvkbd -xsendevent -text 'date;'
(remove the -xsendevent option and you get the same problem as with xdotool)
extending fazae's answer:
I have the latest version of xdotool, it seems. But the bug is still there:
$ xdotool --version
xdotool version 2.20110530.1
$ xdotool type ';'
$
'$' is typed instead of ';'.
$ xdotool type ':'
^
'^' is typed instead of ':'
FIX (example for the us and ru locales, alt+shift for toggling layouts): set locale to us, enable layout toggling with alt+shift:
$ setxkbmap us && xdotool type ':' && setxkbmap -option grp:alt_shift_toggle us,ru
:

Resources