Sponsored Content
Top Forums Shell Programming and Scripting Modify existing values in a file Post 302896888 by darling on Wednesday 9th of April 2014 04:48:44 PM
Old 04-09-2014
Modify existing values in a file

Hi,
I am trying to write a shell script which will modify existing values and take backup of old values.

file trying to modify is : /etc/sysctl.conf

script name: modify.sh

execute
Code:
./modify.sh
enter ref no: 123

add below values in file sysctl.cnf

Code:
kernel.shmall = 4194304

kernel.shmmax = 2147483648

kernel.sem = 1280 512000 250 10240

kernel.msgmni = 1024

kernel.shmmni = 4096

fs.file-max = 524288

kernel.pid_max = 120000

net.ipv4.tcp_max_syn_backlog = 8192

net.core.somaxconn=4096

net.core.netdev_max_backlog=16384

net.ipv4.tcp_max_syn_backlog=8192

net.ipv4.tcp_syncookies=1

net.ipv4.tcp_tw_reuse=1

net.ipv4.tcp_keepalive_time = 120

and take backup of sysctl.cnf with ref no
Code:
sysctl.cnf_123

and take copy of old values in files by adding "#" infront of old values

Code:
/etc/sysctl.conf



#kernel.shmall = 130

#kernel.shmmax = 140

#kernel.sem = 2000 

#kernel.msgmni = 24

#kernel.shmmni = 96

#fs.file-max = 242

#kernel.pid_max = 110

#net.ipv4.tcp_max_syn_backlog = 19

#net.core.somaxconn=09

#net.core.#netdev_max_backlog=638

#net.ipv4.tcp_max_syn_backlog=19

#net.ipv4.tcp_syncookies=0

#net.ipv4.tcp_tw_reuse=0

#net.ipv4.tcp_keepalive_time = 2

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to modify an existing pdf with unix shell commands

Hi, I know that to create a pdf file I can use the txt2pdf command. But if I would change an existing pdf file, by inserting lines in particular positions of this file, what can I use? And How? (3 Replies)
Discussion started by: fandwick
3 Replies

2. Shell Programming and Scripting

folder existing and file existing

I want to look into a folder to see if there are any folders within it. If there are, I need to check inside each folder to see if it contains a .pdf file So If /myserver/myfolder/ contains a folder AND that folder conatins a .pdf file do X Else do Z I may have multiple folders and... (4 Replies)
Discussion started by: crowman
4 Replies

3. Solaris

Add existing user into an existing group

Pre: no gpasswd/adduser there is just usermod can be used, also there is no -a option for usermod. How should I add a user into a group? (4 Replies)
Discussion started by: a2156z
4 Replies

4. Shell Programming and Scripting

insert pipes for existing and non-existing records

I have a source file like this, L4058S462 34329094 F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690 L4058S462 34329094 F51020141FIRST CLEARING, LLC A/C 3432-9094 L4058S462 34329094 F51030141JOHAN HOLMQVIST ... (1 Reply)
Discussion started by: saravanamr
1 Replies

5. Shell Programming and Scripting

modify Existing MS excel workbook in perl

Hi I need to modify an excel file in perl and for which I installed perl in Linux 1. Open a existing excel file 2. delete an unwanted Sheet called "summary" 3. and i want to insert some data into range of cells ( B1:B11) 4. Remove unwanted value called "Sum" repeated in the... (1 Reply)
Discussion started by: luke_devon
1 Replies

6. Shell Programming and Scripting

modify a file by inserting a conditional values

Hi, input file CCCC 1204 215764.85 9405410.40 1189 DDDD 4498 1503 4617 1507 4723 1517 4829 1528 4996 1540 DDDD 5199 1556 5278 1567 5529 1603 5674 1614 6076 1915 DDDD 6605 2371 7004 2779 CCCC ... (4 Replies)
Discussion started by: Indra2011
4 Replies

7. Shell Programming and Scripting

how to modify existing env var

greetings, i have the following env variable: LSB_HOSTS='t70cra102 t70cra102 t70cra108 t70cra108'the variable could be any number of host names and sometimes the same name several times. i was hoping there's a way to turn it into the following: NEW_LSB_HOSTS=,,,]always appreciate the help... (2 Replies)
Discussion started by: crimso
2 Replies

8. Shell Programming and Scripting

Adding columns with values dependent on existing columns

Hello I have a file as below chr1 start ref alt code1 code2 chr1 18884 C CAAAA 2 0 chr1 135419 TATACA T 2 0 chr1 332045 T TTG 0 2 chr1 453838 T TAC 2 0 chr1 567652 T TG 1 0 chr1 602541 ... (2 Replies)
Discussion started by: plumb_r
2 Replies

9. Shell Programming and Scripting

Need to implement new CRON job or modify the existing one in MDM PROD in coming days, which will sen

Need to implement new CRON job or modify the existing one in MDM PROD in coming days, which will send email of SQL statement running from past 1 minute.Currently there is one CRON job in PROD, which send below email. there is one cron job which send email, when there is long running... (0 Replies)
Discussion started by: dampu
0 Replies

10. Shell Programming and Scripting

Pattern search and modify the values

I have one file and the file may contain 500 to 15,000 records. I need to search pattern ^F509= and then increment the corresponding value by one and print the entire line. Please note that Its not a fixed length file. Can anyone please help? ex: ^F509=204656 ^F509=204656 ... (6 Replies)
Discussion started by: vinus
6 Replies
SYSCTL.D(5)							     sysctl.d							       SYSCTL.D(5)

NAME
sysctl.d - Configure kernel parameters at boot SYNOPSIS
/etc/sysctl.d/*.conf /run/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf DESCRIPTION
At boot, systemd-sysctl.service(8) reads configuration files from the above directories to configure sysctl(8) kernel parameters. CONFIGURATION FORMAT
The configuration files contain a list of variable assignments, separated by newlines. Empty lines and lines whose first non-whitespace character is "#" or ";" are ignored. Note that either "/" or "." may be used as separators within sysctl variable names. If the first separator is a slash, remaining slashes and dots are left intact. If the first separator is a dot, dots and slashes are interchanged. "kernel.domainname=foo" and "kernel/domainname=foo" are equivalent and will cause "foo" to be written to /proc/sys/kernel/domainname. Either "net.ipv4.conf.enp3s0/200.forwarding" or "net/ipv4/conf/enp3s0.200/forwarding" may be used to refer to /proc/sys/net/ipv4/conf/enp3s0.200/forwarding. The settings configured with sysctl.d files will be applied early on boot. The network interface-specific options will also be applied individually for each network interface as it shows up in the system. (More specifically, net.ipv4.conf.*, net.ipv6.conf.*, net.ipv4.neigh.* and net.ipv6.neigh.*). Many sysctl parameters only become available when certain kernel modules are loaded. Modules are usually loaded on demand, e.g. when certain hardware is plugged in or network brought up. This means that systemd-sysctl.service(8) which runs during early boot will not configure such parameters if they become available after it has run. To set such parameters, it is recommended to add an udev(7) rule to set those parameters when they become available. Alternatively, a slightly simpler and less efficient option is to add the module to modules-load.d(5), causing it to be loaded statically before sysctl settings are applied (see example below). CONFIGURATION DIRECTORIES AND PRECEDENCE
Configuration files are read from directories in /etc/, /run/, and /lib/, in order of precedence. Each configuration file in these configuration directories shall be named in the style of filename.conf. Files in /etc/ override files with the same name in /run/ and /lib/. Files in /run/ override files with the same name in /lib/. Packages should install their configuration files in /lib/. Files in /etc/ are reserved for the local administrator, who may use this logic to override the configuration files installed by vendor packages. All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence. It is recommended to prefix all filenames with a two-digit number and a dash, to simplify the ordering of the files. If the administrator wants to disable a configuration file supplied by the vendor, the recommended way is to place a symlink to /dev/null in the configuration directory in /etc/, with the same filename as the vendor configuration file. If the vendor configuration file is included in the initrd image, the image has to be regenerated. EXAMPLES
Example 1. Set kernel YP domain name /etc/sysctl.d/domain-name.conf: kernel.domainname=example.com Example 2. Apply settings available only when a certain module is loaded (method one) /etc/udev/rules.d/99-bridge.rules: ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", RUN+="/lib/systemd/systemd-sysctl --prefix=/net/bridge" /etc/sysctl.d/bridge.conf: net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 This method applies settings when the module is loaded. Please note that, unless the br_netfilter module is loaded, bridged packets will not be filtered by Netfilter (starting with kernel 3.18), so simply not loading the module is sufficient to avoid filtering. Example 3. Apply settings available only when a certain module is loaded (method two) /etc/modules-load.d/bridge.conf: br_netfilter /etc/sysctl.d/bridge.conf: net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 This method forces the module to be always loaded. Please note that, unless the br_netfilter module is loaded, bridged packets will not be filtered with Netfilter (starting with kernel 3.18), so simply not loading the module is sufficient to avoid filtering. SEE ALSO
systemd(1), systemd-sysctl.service(8), systemd-delta(1), sysctl(8), sysctl.conf(5), modprobe(8) systemd 237 SYSCTL.D(5)
All times are GMT -4. The time now is 06:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy