$ ls -l
Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7 |
-rw-rw-rw- | 1 | root | staff | 28 | Jan 16 09:52 | README |
-rw------- | 1 | compjmd | staff | 4304 | Jun 24 12:21 | tabledict |
drwxrwxrwx | 2 | compjmd | staff | 512 | Jul 1 16:30 | testdir |
-rwxrwx--- | 1 | compjmd | system | 0 | Jul 1 16:30 | a.out |
... is a sample listing.
- Part 1: Permissions - see chmod for explanation of these. If the first field is set, then the file in question is not really a file at all, but something else, key:
- -: normal file
- d: directory
- l: symbolic link created by 'ln'
- c or b: device of some sort
- Part 2: Number of links to this file (directories always have 2+).
- Part 3: The owner of the file - e.g. If the owner is 'compjmd' and permissions are set to -rw------- then only the user 'compjmd' may read or write to that file. Again, if owner is "compjmd" and permissions are -r-x------ then only the user compjmd may read or execute that file. Only the owner of a file or root may chmod it.
- Part 4: The group ownership of the file - (bloody hell, this is getting complicated). On a unix system there are certain 'groups' which users can belong to, held in the file '/etc/group'. You will notice that in this file there will be a main group, e.g. 'staff' which contains every user. Which means that any user listed under staff is in that group.....right...every file has a group attached to it. Which means that if a file had permissions ----rw---- and a group reference of 'system', then only users who were part of the group system could modify that file. To see which groups the current user belongs to do id. Sorry if this wasn't comprehensible but you should never need to use this anyway(!).
- Part 5: Size of the file in bytes
- Part 6: Time of last modification
- Part 7: The name of the file
- ls -a show files starting with '.' too
- ls -A show files starting with '.' but not '.' or '..'
- ls -c must be used with either option l and/or t - displays/sorts by modification time
- ls -d do not show subdirectory listings
- ls -i display the i-node number of each file
- ls -t Put the listing in time order (see options u and c)
- ls -r Put the listing in reverse order - usually used with a -t
- ls -u must be used with either options l and/or t - displays/sorts by last-access time
$ vi +/"love it or loathe it" handycommands
Users new to vi hate it. I personally managed to get through University without using it ever (I used Joe's own editor instead). If I accidentally went into vi, I had to ^Z and kill the job. Sigh. Five years of using vi means that I'm getting a little better at it now... (I'm actually typing this now in a vi-clone for Windows).
$ grep D7523 mcall_reps.out # will find all the lines in mcall_reps.out that have the string "D7523" in it. Also incredibly useful for things like pipes,e.g.
$ du | grep cred # (in /home directory will show all users that have 'cred' in their title). You may use regular expression matching - e.g.
$ grep "main.*{" x.c # would match any line containing 'main' and an open curly brackets at any point in the line afterwards. There are two variations to grep - fgrep and egrep which do virtually the same things as grep, but are either faster (having less options) or more complex (but slower). See also section on Wildcards
Options:
- -v : show all lines that do not contain pattern.
- -y : don't bother matching case
- -i : don't bother matching case
- -c : show count of matching lines rather than the lines themselves
- -l : show filename's instead of matching lines.
$ man ps # will list the manual page for the command ps
No comments:
Post a Comment