sudo, gksudo and file access permission

When we normally open and use ubuntu. We use it as regular user which allows you to create and access folder in a temporary window within your our user account.  But To install, to create, to access and to run programs with root-level privileges, you have to be super user  or root account ( By default, the root acount is looked in ubuntu). This is where sudo for command line and gksudo for graphical applications come in – it allows authorized users (normally “Administrative” users). The command sudo also works for graphical applications. But it is advised to use gksudo for graphical applications instead of sudo. Sometimes using sudo for graphical applications does not give proper effect of application. As example.. We want to edit /etc/apt/sources.list (the list of sources from which you can easily install software).

To edit it in command line we use normally sudo

sudo nano /etc/apt/sources.list

To edit it in graphical interface, we use gksudo

gksudo gedit /etc/apt/sources.list

Now we want to access, or to create any folder in root level. I said it before, we have to use sudo (in command line ), gksudo ( graphically click or drag and drop) or have to chance the file permission explicitly.

Now we want to access the /var/www which is owned by the user root and belongs to the root group and create a folder in it. Accessing the file graphically (click or drag and drop), just type one line command

gksudo nautilus

now explore the file and then create folder by mouse clicking.  Same thing  we can access in command line

sudo cd /var/www

To create folder named abc

mkdir abc

Same thing we want to do it by file permission. Now we have to understand what is file permission and how to change it? In Linux as well as Unix everything is file. All of the files on a system have permissions that allow or prevent others from viewing, modifying or executing.  Each file has access restrictions for three  types of user like owner, group and other. When we set file permission, we have to give each user access restrictions. There are three types of access restriction: read, write and execute.Basic concept of access restrictions…

read –  4

write –  2

execute – 1

read + write  = 4+2 = 6

read  + execute = 4+1 = 5

read + write + execute = 7

Now we want to access the /var/www which is owned by the user root and belongs to the root group. Let change the file permission with all users with giving permission of all access restrictions .

To set permission

sudo chmod  777 /var/www

Now another example (picture) to make concept more clear clear

To access the folder

cd  /var/www

To create folder named abc

cd  /var/www

Eftakhairul Islam

Hi, I'm Eftakhairul Islam, a passionate Software Engineer, Hacker and Open Source Enthusiast. I enjoy writing about technical things, work in a couple of startup as a technical advisor and in my spare time, I contribute a lot of open source projects.


One thought on “sudo, gksudo and file access permission

  1. nice shearing man. help me to copy graphically….keep enrich ur blog to share knowledge. because shareing knowledge is power.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Read previous post:
Taking input in java programming language

Many juniors of my varsity ask me about how to take input in java programming language from user as well as...