Shell Enviornment

Posted by alex almazan Sun, 13 Apr 2008 08:11:00 GMT

This table represents the order in which shell attributes are inherited

/etc/skel default template for a new added users home directory
/etc/profile sets environmental variables used by all users
/etc/profile.d contains scripts specific to certain RPMS
/etc/bashrc contains global aliass and system settings
~/.bash_profile contains user environement settings and can be set to auto start programs at login
~/.bashrc contains user aliases and functions

Users and Groups

Posted by alex almazan Sun, 13 Apr 2008 07:53:00 GMT

/etc/passwd File contains the configuration info for loacl users in the following format(world readable):
username : x: UID:GID:GECOS:homedir:shell

/etc/shadow File contains the username (which must match /etc/passwd) and the users MD5 encrypted password (only readable by root)

/etc/group file contains the configuration for local groups in the following format

groupname :x: GID : secondary users

/etc/gshadow file contains a list of groups on the server and their MD5 encrypted passwords.

useradd used to add new users
usermod used to modify the attributes of the user
groupadd used to add new group to server
groupmod used to change group attributes
passwd used to create or change user passwords
chage command used to create/edit password aging

Locating files with Special Permissions/attributes

find . / -perm +4000 |less
find root owned
find / -perm +2000  | less
get all GID/SUiD
find / -perm +1000 (sticky bit)
can be (used to find 777)

Setuid Suid Set UserID is used on Unix systems for tasks that require higher privileges. Has greatest impact on executable files.

chmod u+s <file>
setgid
chmod g+s  
or
chmod 2770 /some/directory
assigns group ownership to directories

example

Configure the users mike,chris and jamie

make these users part of the ru group
useradd -s /sbin/nologin ru
useradd chris -G ru -p '    ' 
(grub-md5-crypt can be used to generate system passwords)

configure the directory /home/ru so that each user can read,create, and modify files.

chmod 2770 /home/ru 
or
chmod u+s /home/ru

CRON

Posted by alex almazan Sun, 13 Apr 2008 06:21:00 GMT

Cron

Five values are available for scheduling automated processes
minute  hour   day of month  month  day of week                       
0-58    0-23      1-31       1-12     0-7  (0 or 7 is Sun,3 ltr abrvs)
examples

1.) create a cronjob for the user root that checks the amount of availabe space on the system every friday at 12:34 pm

34     12     *     *     5     /bin/df -h >>root.out --to create a file
34     12     *     *     5     df -h 

will mail to crontab user (MAILTO=user to customize)

2.) Create a cronjob as a regular user that lists the contents of /tmp at 4:56 am on Monday,February 3

56 04 3 2 1 /bin/ls -alh /tmp >> /root/tmpspace.out

(this one will run on every monday and on the third. Day of week or day of month get applied when the condition is met) You will have to write the logic in the script or * for every monday or * from just the third

Mug Of VI

Posted by alex almazan Sun, 13 Apr 2008 04:19:00 GMT

FILE COMMANDS
vi filename(S) edit a file or files
vi -r filename retrieve saved file after crash
ZZ, :wq, :x save and exit
:q, :q! quit;quit without saving
:w. :w fn save file, save file as fn
:e filename edit filename
:r filename insert filename
:sh drop to shell
:!cmd run command cmd
:r !cmd execute cmd and insert output
!movement cmd pipe lines in movement through cmd
SEARCH AND REPLACE
/txt, ?txt find txt forward or backward
?^txt find next line that starts with txt
n, N repeat last search forward, backward
R replace text from current character
DELETING/INSERTING TEXT
dw w, dd, x delete word, line, character
ndd, nx delete n_ lines, _n characters
x, X delete character forward,backward
D, D$ delete to end of line
d motion delete from cursor to motion ($,0,etc.)
:>, :< indent, outdent line
S replace text with blank line
o, O insert new line below, above current line
u undo last change
. repeat last change
CUT/COPY/PASTE
nyy, nY copy n lines
yw, yy copy word line
p, P paste text after,before cursor
a, i insert text after ,before cursor
A, I insert text end, beginning of line
MOVING AROUND
nG move to line n
h, l, k, j left,right,up down one character
nb, nw left or right, n words
CTRL-B, F backward, forward one screen
CTRL-U, D up,down one screen
$, G go to end of line, end of file
O go to beginning of line (zero)
), ( move to next, previous sentence
},{ move to next,previous paragraph
w, b move forward, back one word
e go to end of current or next word
WICKED COOL STUFF
~ change case
xp transpose characters
j combine current line with next
mp create a mark called p
`p return to p
d`x, y`x del,copy text from mark to cursor
:>n indent n lines

Fuser

Posted by alex almazan Mon, 31 Dec 2007 21:11:55 GMT

The command ‘fuser’ can help identify processes and their ownership
fuser -n tcp 443

This will also identify the user and process bound to the specified port number.

Older posts: 1 2