I wrote this script, basically what it does is to drop the ram caches. I know it's messy - all the "echo '' that you see are just a work around to make it cleaner, I like some blank lines between the commands.
#!/bin/bash
free -m && wait
echo ''; echo ''
while true; do
read -p "Vuoi liberare la RAM? [y,n]" domanda
case $domanda in
y|Y) echo ''; sync; sudo echo 3 > /proc/sys/vm/drop_caches; echo ''; free -m; echo ''; break ;;
n|N) echo ''; echo 'Sei tu il saggio Jack ;)'; echo ''; break ;;
*) echo ''; echo 'Come prego?'; echo '' ;;
esac
done
Anyway, the script works. But in order to make it works I had to set the permissions as it follow:
sudo chown root.root <my script>
sudo chmod 4755 <my script>
As I said it works.
I created a sub-directory call: Bin, in my home, copied the script inside and then I added this line in my .profile
:
export PATH="/home/jacklapinza/.bin:$PATH"
So, the new path works properly but the script doesn't work anymore. I mean, it works if I choose 'no' but if I press 'y' an error pops out:
permission denied.
I've set the same permissions on the file.
What I'm doing wrong?
I think the problem here is that your filesystem does not support the setuid
flag.
You may want to check your mount options: if you are using ext4
, the nosuid
option might be set.
Anyway, I don't like the setuid
flag it is too dangerous and it offers little advantages: spare us from using sudo?
My recommendation is just ignore this and call the script using sudo. If that is not an option then you should check your mount flags.