Have you ever been using nano to edit a long configuration file and when you've just finished you go to save and you get "Error writing /dir/somefile: Permission denied" as you've forgotten to use sudo or switch user if so this tutorial might just be your solution. What this does is it runs a script to check if you have write access on the file if you do it will continue and open nano as normal if you don't it will ask you do you want to continue so lets get started
- Save the following to /usr/bin/writecheck
#!/bin/bash FILE="$1" [ $# -eq 0 ] && exit 1 if [ -w "$FILE" ] then nano $FILE else echo "You Do Not Have Write Acess To $FILE" echo -n "Do You Want To Continue (y/n)?" read reply [ $reply == "y" ] && nano $FILE fi
- Allow the script to be executed
chmod +x /usr/bin/writecheck
- Finally we need to add a alias for it
echo "alias nano='writecheck'" >> /etc/bash.bashrc


This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.