The default file permissions (umask):
Each user has a default set of permissions which apply to all files created by that user, unless the software explicitly sets something else. This is often called the 'umask', after the command used to change it. It is either inherited from the login process, or set in the .cshrc or .login file which configures an individual account, or it can be run manually.
Typically the default configuration is equivalent to typing 'umask 22' which produces permissions of:
-rw-r--r-- for regular files, or
drwxr-xr-x for directories.
In other words, user has full access, everyone else (group and other) has read access to files, lookup access to directories.
When working with group-access files and directories, it is common to use 'umask 2' which produces permissions of:
-rw-rw-r-- for regular files, or
drwxrwxr-x for directories.
For private work, use 'umask 77' which produces permissions:
-rw------- for regular files, or
drwx------ for directories.
The logic behind the number given to umask is not intuitive.
The command to change the permission flags is "chmod". Only the owner of a file can change its permissions.
The command to change the group of a file is "chgrp". Only the owner of a file can change its group, and can only change it to a group of which he is a member.
See the online manual pages for details of these commands on any particular system (e.g. "man chmod").
Examples of typical useage are given below:
chmod g+w myfile
give group write permission to "myfile", leaving all other permission flags alone
chmod g-rw myfile
remove read and write access to "myfile", leaving all other permission flags alone
chmod g+rwxs mydir
give full group read/write access to directory "mydir", also setting the set-groupID flag so that directories created inside it inherit the group
chmod u=rw,go= privatefile
explicitly give user read/write access, and revoke all group and other access, to file 'privatefile'
chmod -R g+rw .
give group read write access to this directory, and everything inside of it (-R = recursive)
chgrp -R medi .
change the ownership of this directory to group 'medi' and everything inside of it (-R = recursive). The person issuing this command must own all the files or it will fail.
WARNINGS:
Putting 'umask 2' into a startup file (.login or .cshrc) will make these settings apply to everything you do unless manually changed. This can lead to giving group access to files such as saved email in your home directory, which is generally not desireable.
Making a file group read/write without checking what its group is can lead to accidentally giving access to almost everyone on the system. Normally all users are members of some default group such as "users", as well as being members of specific project-oriented groups. Don't give group access to "users" when you intended some other group.
Remember that to read a file, you need execute access to the directory it is in AND read access to the file itself. To write a file, your need execute access to the directory AND write access to the file. To create new files or delete files, you need write access to the directory. You also need execute access to all parent directories back to the root. Group access will break if a parent directory is made completely private.
taken from http://www.dartmouth.edu/~rc/help/faq/permissions.html
Thursday, 5 February 2009
the 'free' command
A useful tool when you want to check how much physical and virtual and overall memory you have on the system;
free -mt (for mb)
free -kt (for kb)
and on later OS you can also get it in gb;
free -gt
free -mt (for mb)
free -kt (for kb)
and on later OS you can also get it in gb;
free -gt
Basic power path commands
With EMC's PowerPath product it may be useful to check the status of what is available as far as PowerPath is concerned.
Use the "powermt display" command for this.
EXAMPLE:
# powermt display
total emcpower devices: 94, highest device number: 93
==============================================================================
------------ Adapters ------------ ----- Device Paths ------ --- Queued ---
## Switch Name Summary Total Closed IOs Blocks
==============================================================================
0 Enabled sbus@1f/fcaw@0 Optimal 94 0 0 0
1 Enabled sbus@1f/fcaw@2 Optimal 94 0 0 0
This shows us that there are 2 paths that PowerPath is using and both of them are online and functioning at optimal performance.
It is possible to search further by using the "powermt display dev=" command.
EXAMPLE:
# powermt display dev=c1t0d93
emcpower91: state=operational, policy=symm_opt, priority=0, IOs in progress=0
Symmetrix ID=0184502576
==============================================================================
------ Adapter ------ --------- Device Path ---------- Serial Queued Errs
## Name Mode Link ID State Number IOs
==============================================================================
0 sbus@1f/fcaw@0 Active c1t0d93 sd2681 Open 7611D000 0 0
1 sbus@1f/fcaw@2 Active c2t1d93 sd2572 Open 7611D000 0 0
To see all devices use the following command :"powermt display dev=all"
Use the "powermt display" command for this.
EXAMPLE:
# powermt display
total emcpower devices: 94, highest device number: 93
==============================================================================
------------ Adapters ------------ ----- Device Paths ------ --- Queued ---
## Switch Name Summary Total Closed IOs Blocks
==============================================================================
0 Enabled sbus@1f/fcaw@0 Optimal 94 0 0 0
1 Enabled sbus@1f/fcaw@2 Optimal 94 0 0 0
This shows us that there are 2 paths that PowerPath is using and both of them are online and functioning at optimal performance.
It is possible to search further by using the "powermt display dev=
EXAMPLE:
# powermt display dev=c1t0d93
emcpower91: state=operational, policy=symm_opt, priority=0, IOs in progress=0
Symmetrix ID=0184502576
==============================================================================
------ Adapter ------ --------- Device Path ---------- Serial Queued Errs
## Name Mode Link ID State Number IOs
==============================================================================
0 sbus@1f/fcaw@0 Active c1t0d93 sd2681 Open 7611D000 0 0
1 sbus@1f/fcaw@2 Active c2t1d93 sd2572 Open 7611D000 0 0
To see all devices use the following command :"powermt display dev=all"
Wednesday, 19 November 2008
Print a process tree in UNIX
To print a process tree:
ps -ejH xx (where xx is the pid)
ps axjf xx (where xx is the pid)
or in solaris
pstree xx (where xx is the pid0
ps -ejH xx (where xx is the pid)
ps axjf xx (where xx is the pid)
or in solaris
pstree xx (where xx is the pid0
Tuesday, 18 November 2008
How to read a text file into a command
so you have a text file (users.txt) and you want to read that into a script that prints out the users status using the getent command
while read line
do
getent passwd | $line
done < users.txt
and thats it!
while read line
do
getent passwd | $line
done < users.txt
and thats it!
Subscribe to:
Posts (Atom)
