Saturday, May 13, 2006

Linux quick notes



chmod

to change access mode of a file (file permissions)


u = the user who owns the file

g = the group the file belongs to

o = others

a = all of the above (ab abbreviation for ugo)


example: to prevent outsiders from executing archive.sh before : -rwxr-xr-x archive.sh

command: chmod o=r archive.sh

after : -rwxr-xr-- archive.sh


example : to take away all permissions for the group for topsecret.inf, leave the permissions part of the command empty.

Before : -rw-r----- topsecret.inf

command : chmod g= topsecret.inf

after : -rw------- topsecret.inf


example:

chmod go=rx wordmatic.txt

chmod go-w wordmatic.txt

chmod a+wx calcmatic.bak


To kill non responding application:

ctrl-alt-Esc


move or rename files:

mv


whatis

information on a topic


makewhatis

creates an updated whatis database

umask

the default permission given to new files created


suid and sgid

special permissions given to program so when it runs by a user, it inherits the rights of the owner of the pprogram, not the user running it.

eg. /etc/passwd


setting & removing suid & sgid

for eg.:

# chmod u+s /usr/bin/myapp

# chmod g-s /home/drobbins


Directory permissions:

Directory permissions are a bit different that file permissions.

For a directory, if the “read” (r)flag is set, you may list the contents of the directory.

“write” (w) means you may create files in the directory; and “execute” (x) means you may enter the directory and access any sub-directory inside.

Without the “execute” (x) flag, the filesystem objects inside the directory aren't accessible.

Without the “read” ( r ) flag, the filesystem objects inside the directory aren't viewable but can still be accessible as long as someone knows the full path to the object.


If a directory has the “sgid” flan enabled, any filesystem objects created inside it will inherit the group of the directory. This particular feature come in handy when you need to create a directory tree to be used by a group of people that all belong to the same group.


simply do this:

# mkdir /home/groupspace

# chgrp mygroup /home/groupspace

#chmod g+s /home/groupspace


now any users in the group mygroup can creat files or directories inside /home/groupspace, and they will be automatically assigned a group ownership if mygroup as well. Depending on the users' umask settings, new filesystem objects may or may not be readable, writable, or executable by other members of th mygroup group.


after installing Windows server 2003 on an available partition, the previous grub was destroyed from from MBR by Windows.

solution:

restart from rescue cd

reinstall grub: /sbin/grub-install /dev/hda


symbolic link:

ln -s [target] [link_name]


rsync

eg.:

rsync -av –delete /home/user/ username@server:/backup/home/user


If a directory is being backed up, remember to use / at the end of the directory name.

rsync uses ssh



Users & Groups


newgrp


useradd


groupadd


usermod


userdel -r (-r to remove user home directory too)


groupdel



ACL

acl shou be in the /etc/fstab

# getfacl

# setfacl


VNC

start vnc server:

vncserver


change password:

vncpasswd


connect to server from client by specifying the ip address/hostname and desktop

eg.:

192.168.123.10:1


configuration file:

.vnc/xstartup


default window manager is TWM, you can change it

eg.:

startkde or startgnome


to kill vnc:

vncserver -kill :1


default vnc viewer port: 5901

Java based viewer: 5801


No comments: