Solved

linux

Posted on 2011-03-14
9
337 Views
Last Modified: 2012-05-11
hi,

i was trying to edit one file in linux os (/proc/sys/kernel/sem) through vi and after editing tried to save but it says the file has been changed since reading , do you want to write anyway, i seletcted yes but still

0
Comment
Question by:kurajesh
9 Comments
 
LVL 17

Expert Comment

by:k_murli_krishna
ID: 35126630
Once all work is over on the contents of the file, escape from insert mode by pressing Esc butting if it is in insert mode. Now type : and then wq!, it will save the file (maybe create and save if it is first time generated file) and exit back to shell prompt.
0
 
LVL 17

Expert Comment

by:k_murli_krishna
ID: 35126637
: means colon  and wq! means wq followed by exclamation mark (!) to make things more clearer.
0
 
LVL 11

Expert Comment

by:Pieter Jordaan
ID: 35126697
Hi

The correct way to make changes to that file, is to use echo "values" > file

use cat to read it first:

cat /proc/sys/kernel/sem

Then echo the values back in the same format, with your changes.

# echo SEMMSL_value SEMMNS_value SEMOPM_value SEMMNI_value > /proc/sys/kernel/sem
echo 250 32000 100 128 > /proc/sys/kernel/sem'
0
 
LVL 5

Expert Comment

by:sreedhar2u
ID: 35126783
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 17

Expert Comment

by:Sikhumbuzo Ntsada
ID: 35126798
Make sure you are logged in as root account.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 35127256
All the proc files are volatile.  They do NOT persist after reboot.  All the partition is blown away when you reboot.  It depicts the current state of your system.

To make it persist after reboot, you will have to cat the value and put it in the file

/etc/rc.d/rc.local

So vi /etc/rc.d/rc.local

and add the following line in it

echo  VALUE > /proc/sys/kernel/sem
0
 
LVL 12

Accepted Solution

by:
upanwar earned 500 total points
ID: 35127262
I would suggest you to modify kernel parameter through /etc/sysctl.conf instead of modify the file directoly and it is the best practice. Because If you will require to to come to the default value, you just need to comment the line in sysctl.conf instead of modifying the file again and again.



Please follow the steps to modify the value through sysctl.conf.

#  vi /etc/sysctl.conf

append the value in the file (Please replace the values as per your need).

kernel.sem = 250 256000  32 1024

Then save the file through pressing Esc key to quit from insert mode to escape mode and then type : and then wq!, it will save the file.

Then run the below given command at shell prompt to change the values on the fly without rebooting your box.

# sysctl -p

Then execute the below given command to check whether value has been updated or not.

# ipcs -l

it will show sothing similar to:

------ Semaphore Limits --------
0
 
LVL 12

Expert Comment

by:mccracky
ID: 35137812
As mentioned, you don't edit the files under /proc with vi.

If you want to change the file use "echo"

e.g.  

echo "file contents" > /proc/sys/kernel/sem
0
 
LVL 1

Author Closing Comment

by:kurajesh
ID: 35186796
#  vi /etc/sysctl.conf and kernel.sem = 250 256000  32 1024 entries modification worked fine, thanks upanwar
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now