Shell Enviornment
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
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 |lessfind root owned
find / -perm +2000 | lessget 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+sor
chmod 2770 /some/directoryassigns group ownership to directories
example
Configure the users mike,chris and jamie
make these users part of the ru groupuseradd -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/ruor
chmod u+s /home/ru
CRON
Cron
Five values are available for scheduling automated processesminute 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
| 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 |
| /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 |
| 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 |
| 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 |
| 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 |
| ~ | 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
fuser -n tcp 443
This will also identify the user and process bound to the specified port number.
Older posts: 1 2