We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

unix command

negahdar
negahdar asked
on
Medium Priority
1,928 Views
Last Modified: 2013-12-26
please let me know if there is a difference between:

chmod 776 ~/filename

and

chmod 776 filename


And what exactly  do I get with

ls -l ~\ filename

Thanks
Comment
Watch Question

Top Expert 2005
Commented:
> chmod 776 ~/filename # should be: chmod 0776 ~/filename
changes permissions of file 'filename' placed in Your home directory ($HOME/filename)
> chmod 776 filename # should be: chmod 0776 filename
does the same, but it looks for file in current directory (execute 'pwd' to get current dir)
> ls -l ~\ filename # should be 'ls -l ~/filename' or 'ls -l ~/ filename'
first shows long listing fr file 'filename' in Your HOME ir, the second prints long listing of all files in Your HOME (except hidden) and the file 'filename' in current dir.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
what's the exact meaning for:

chmod 776 ~/filename?

chmod 511 *.c

chmod 711 ~/*

Thanks
Top Expert 2005

Commented:
negahdar, I'm answering this, but don't ask for more commands - You should ask in the very first Q

> chmod 776 ~/filename?
changes permissions of files in Your HOME directory (~ stands for $HOME) that maches the pattern filename? - where ? may be any character
> chmod 511 *.c
as above, but looks for files in current dir, and matches all filenames(dirs also) which ends with .c ('.c' matches also)
> chmod 711 ~/*
as above, but matches al filenames(and dirs in fact) in Your $HOME.

Also note, that none of the above will match filenames(dirs) that are hidden. Hidden files/dirs are those which names starts with dot (eg: .hdden_name)
Please read 'man sh' chapter 'Pattern Matching'

Author

Commented:
OK, thanks a lot.
In your answers,
 what's ir in :
Your HOME ir

Then what is the purpose of adding ? in
chmod 776 ~/filename?
Is it if I have filename1
filename2...
then it matches filename+ whatever
Top Expert 2005

Commented:
Your HOME dir - sorry, mispelled
> then it matches filename+ whatever
Yes, but '?' maches one char only (any char), while '*' maches any string (including empty)
CERTIFIED EXPERT

Commented:
Just a bit more comemt to this question

chmod -- change the permissions mode of a file.
to leran more details about the usage and permission, do a:

man chmod

in commandline. that's the best way to learn, and create a dummy file/dir, try all
combination to leran how it work.

>> ls -l ~\ filename # should be 'ls -l ~/filename' or 'ls -l ~/ filename'
.. or ls -l \~filename

negahdar, no offence, but all you question sound like homework
would it not be better if you get a book (paper work) about shell basics? somthing like "sh for dummies"
then spend a few minutes to get used to the very basics of a shell, then you may ask about some special things like ~ which is in fact very special 'cause it depends on the shell and the shells configuration. Same applies to the usage of some other special chars like ? * / \ ' ! $ & and "

experts here really try to help you, but it's wasting time and resources if you ask such basics, in particular when you don't give more details about your used environment (type of OS, shell, etc.)

again: 3 days try&error can save 30 minutes reading ;-)

Author

Commented:
dear ahoffmann
yes you are rigt ,.....
3 days try&error can save 30 minutes reading
can you send me the name of the book which you suggest to read please?
i tried in amozon.com for that book (which u said a bove ) but i couldn't find it?
can u send me more Details about that book like isbn number , Author or publisher  
thanks
oops, my "sh for dummies" was just an example, I hadn't a particular book in mind, sorry for confusion.
I's hard to suggest books for beginners 'cause it depends on your current skill level, may be "UNIX for Dummies Quick Reference" is a good starter, then you can search amazon for "unix shells" and pick what you feel good with.
About shells, there exists one reference which covers most common used shells (bash, csh, ksh, sh, zsh, etc.), but can't remember its title, something like: "Unix shells: csh, bash, ..." ...
Top Expert 2005

Commented:
> sh for dummies
And I already suggested: man sh # man bash
CERTIFIED EXPERT

Commented:
Have a look at the links in:

http:Q_20626712.html
http:Q_20665909.html
http:Q_20684016.html

or do a serach on the web or EE you can find a lot more
Unix tutorials.

Good night !
Brian BushSolutions Architect

Commented:
This is a great book about Unix Shell Commands, no matter what your exposure is:
http://www.amazon.com/gp/product/0672324903/sr=8-8/qid=1143818332/ref=pd_bbs_8/104-9973086-0983938?%5Fencoding=UTF8

--brian
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.