dcsimg

There’s a Lot in the Dot: Filesystem Permissions and Pathnames (Part 2)

Still deeper into the dot (.) with an dive into access permissions. Study up because there's going to be a quiz.

Access Permissions

Once you see how pathnames work, understanding access permissions is simple. You’re probably familar with access permissions for files: read permission lets a program read the file’s contents, write permission allows modification, and execute permission is for executable programs. Notice that none of those permissions control whether you can rename or delete the file. Why? We’ll see soon.

A directory is actually just a special type of file, and a directory’s permissions are easy to understand when you realize that a directory holds entries for other files. So:

  • Read permission lets a program read the entries listed in the directory — for instance, with ls or a shell wildcard like *. (Some graphical filesystem browsers will say a directory is “unreadable” unless it also has execute permission, but that’s not strictly true.)
  • Write permssion lets you modify the entries in a directory. Think of the directory as a file in a word processor. To edit the file — to change the spelling or words, add or delete words — you need write permission. A directory is the same way. If you don’t have write permission, you can’t delete, rename, or add entries to the directory. So, to protect the contents of a directory, make the directory unwritable.
  • Execute permission lets you access the files linked from a directory. Note that you don’t need read permission; if a directory isn’t readable, you can still access an entry if you know its exact name. (That’s like denying index permission on a web server folder to prevent people from knowing its contents: you can still get a web page by using its exact URI.)

Pathnames and the shell PATH Pathnames work almost anywhere, with any command. One notable exception is specifying the program you want to use. If the program’s pathname contains a /, it will be followed. Otherwise, different rules apply.

For example, let’s say your current directory is /home/jpeek/bin. If you want to run the program prog from the current directory, here are three pathnames — three ways you can specify its location:

$ ls -l prog
-rwxr-xr-x 1 jpeek  238 2009-08-19 06:28 prog
$ /home/jpeek/bin/prog
$ ./prog
$ prog
bash: prog: command not found
$ echo $PATH
/usr/local/bin:/usr/bin:/bin

From ls -l, we can see that prog is a valid pathname: it’s an entry in the current directory. So why did bash say “command not found”? If you specify a program name only, without a slash, the shell will search through each directory in the PATH environment variable, looking for the program in that directory. As you can see from the last command, the current directory isn’t in $PATH. This is for security. In this case, to run a program from the current directory, you have to tell the shell ./prog. But, with other commands, the ./ is redundant; prog is simpler.

Quiz

Here’s a directory listing from ls -l, run by the superuser (who can access everything on the filesystem):

# ls -la /home/zoe
drwxrwx--x 2 zoe users  8192 2010-03-14 18:33 .
drwx--x--x 9 zoe users 16384 2010-03-11 08:00 ..
-rw-r--r-- 1 zoe users  2942 2010-03-16 13:45 afile
drwx------ 2 zoe users  4096 2010-03-14 18:33 dir
-rw-r--r-- 1 zoe users  4039 2009-11-22 08:18 .profile
  • Q: An attacker breaks into a non-superuser account that’s not a member of the users group. What does ls /home show?
    A: Permission denied because there’s no read permission on .. (/home, the parent of /home/zoe).
  • Q: The attacker knows that there’s a user named zoe. What does cd /home/zoe do?
    A: It succeeds because the parent directories both have execute permission. But listing would fail with ls: cannot open directory . because there’s no read permission.
  • Q: The attacker tries vim .profile to modify Zoe’s startup file. What happens?
    A: vim opens the file read-only because there’s read permission, but no write permission, on the file.
  • Q: jpeek, who’s a member of the users group, types cd /home/zoe, then ls, then rm afile. What happens?
    A: He can access the directory because he has execute permssion. He can list . because he has read permission. He removes afile because he has write permission on . (the directory containing the entry for afile).
  • Q: What if jpeek now types cd dir?
    A: It fails because he doesn’t have execute permission on dir.

If anything in that quiz surprised you, this might be a good time to open a terminal window and make up some exercises for yourself. Enjoy!

Comments on "There’s a Lot in the Dot: Filesystem Permissions and Pathnames (Part 2)"

As the admin of this website is working, no question very shortly it will be famous, due to its quality contents.

Also visit my page: cheap car insurance in california

bookmarked!!, I like your blog!

My web sitte – cheap car insurance california

You’re so interesting! I do not believe I’ve read through something like
that before. So wonderful to find another person with a
few genuine thoughts on this subject. Seriously.. thanks for starting this up.
This site is one thing that is required on the internet, someone with a bit of originality!

My site Car Insurance Companies

wyoah this weblog is fantastic i like reading youhr articles.
Keep up the great work! You understand, many individuals are searching round for this information, you could help them greatly.

Look att my blog cheap car insurance in nj

This article will heelp the internet viewers for creating
new weblog orr even a weblog from start to end.

Also visit my web page; cheap car insurance in ohio

Yoou really make it seem so easy along with your presentation however I inn finding this topic to bee really something that I believe I mkght by no
means understand. It sort of ferls too complex and very wide for me.
I am looking ahead for your next put up, I’ll attempt to get thhe cling of it!

Stop by mmy website … cheap liability car insurance

I am really thankful to the holder of this web site who
has shared this great paragraph at at this place.

My web-site; Cheap Car Insurance

Hi, after reading this remarkable post i am as well
glad to share my familiarity here with mates.

my weblog; cheap car insurance

Howdy! I’m at work browsing your blog from my
new iphone 3gs! Just wanted to say I love reading through your blog and look forward to all your posts!
Keep up the excellent work!

I was able to find good advice from your content.

I think this is a real great blog. Cool.

Thanks a lot for sharing this with alll folks you really recognize what you’re speaking approximately!

Bookmarked. Please additionally talk over wih my web ite =).
We may have a hyperlink exchange agreement among us

my site; World Chef Cheats

The facts mentioned in the article are a few of the very best out there.

For latest information you have to pay a visit internet and on world-wide-web I found this web site as a most excellent site
for most recent updates.

The Georgia Wedding Planners introduce a free guide for
wedding plans. If you are bottom-heavy, go on reading and the content below will give some tips to help you find a favorite
cocktail gown. You will find exclusive ladies’ evening dresses
at the boutiques and designer shops selling branded apparels.
Homecoming is a very popular celebration in high schools and
colleges. And remember, some costumes Dubai were not designed to wash.
Inexpensive plus-sized evening gowns are supplied on-line regarding best excellent along with crazy cost.

It’s remarkable for me to have a site, which is useful designed
for my knowledge. thanks admin

I think this is one of the most significant information for me.

And i’m glad reading your article. But should remark on some general things, The website style is wonderful, the articles is really excellent :
D. Good job, cheers

What’s Taking place i am new to this, I stumbled upon this I have discovered It positively
useful and it has aided me out loads. I’m hoping to contribute & aid other customers like its
helped me. Good job.

%Interval training is a varying of intensities within a workout, where you add a low-intensity session with a high-intensity session.

Look at my webpage … hiit training exercises

So let’s have a simple comparison with Kobe VII
and Kobe VI. Let’s evaluate each and every query a bit more thoroughly.
It is meant to provide comfort and proper support so you can compete at the top level.

Also visit my page – cheap giuseppe zanotti shoes

I’m truly enjoying the design and layout of your website.
It’s a very easy on the eyes which makes it much more
pleasant for me to come here and visit more often. Did you hire
out a designer to create your theme? Outstanding
work!

Here is my blog post … cialis from canada pharmacy

Attractive section of content. I just stumbled upon your site and in accession capital to
assert that I acquire actually enjoyed account
your blog posts. Anyway I will be subscribing to your feeds
and even I achievement you access consistently fast.

I got this web page from my friend wwho informed me aboht this site and
now this time I am visiting this web site and reading very informative postgs aat this
time.

Also visit my blog post – Online Casino Free Bet

If you would like to get much from this post then you havce to apply such methods
to your won blog.

Feel free to visit my webpage; online Rugby Union betting site

My partner and I stumbled over here coming ffom a different web page and thought I might as well check things out.
I like what I see so now i’m following you. Loook forward to looking over your web
page again.

Feel free to surf to mmy web blog; dyson fans

Hello there, I found your web site via Google even as searching for a similar topic, your
site got here up, it appears great. I have bookmarked it in my google bookmarks.

Hello there, just turned into aware of your blog thru Google, and found that it’s truly informative.
I’m going to watch out for brussels. I’ll be grateful if
you happen to continue this in future. A lot of other people will likely be benefited from
your writing. Cheers!

Take a look at my website; dyson vacuum parts

However, I’m all your family members will want to learn more about educate consumers in excess of going to be the a property inventory isn’t.
If you want to go for a mid-priced leather bag you could try brands like Ralph Lauren or DKNY.
Many times a classic black handbag can look harsh next to bright, warm weather colors and
a neutral handbag can seem obvious.

Here is my website … prada bags outlet

Here is a good Weblog You might Find Interesting that we encourage you to visit.

We came across a cool web page that you simply might take pleasure in. Take a search in the event you want.

Here are a few of the websites we suggest for our visitors.

This web site truly has all the info I wanted concerning this subject
and didn’t know who to ask.

Hi there to all, the contents existing at this web page
are genuinely awesome for people knowledge, well, keep up the nice work fellows.

Gifts ideas for her include an array of unusual items that will appeal to the recipients.
The shoes are also available in various colours like red, blue,
brown, green, yellow, gray etc. Do not buy footwear that fit absolutely:
Most people are perfect to go with a half dimension superior than whatever they typically
use.

Also visit my website; cheap louboutin shoes

I just want to say I am beginner to blogging and really liked your web-site. Almost certainly I’m want to bookmark your blog post . You really come with excellent well written articles. Thanks for sharing your webpage.

Wonderful story, reckoned we could combine a couple of unrelated data, nonetheless definitely really worth taking a look, whoa did one understand about Mid East has got extra problerms at the same time.

Leave a Reply