Académique Documents
Professionnel Documents
Culture Documents
# Linux
##crontab
/var/spool/cron
crontab
crontab
crontab
crontab
-e
-l
-r
-v
for logging
30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log
HOME=user s-home-directory
LOGNAME=user s-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
#fsck /dev/sda6
1.umount it first
2.fsck -N /dev/sda3 ( to show what will be done)
3.fsck -y
( to prompt yes to all)
4. tune2fs -l /dev/sda3 ( show the state) clean not clean
sudo touch /forcefsck
**
**
**
**
**
phase
phase
phase
phase
phase
0
1
2
4
8
16
32
128
1
2
3
4
5
Check
Check
Check
Check
Check
No errors
Filesystem errors corrected
System should be rebooted
Filesystem errors left uncorrected
Operational error
Usage or syntax error
Fsck canceled by user request
Shared-library error
# LVM
pvdisplay
vg
lv
pvscan
vg
lv
pvcreate
vgcreate
lvcreate
lvextend
lvreduce
/dev/sdb1 /dev/sdc1
testvg /dev/sdb1 /dev/sdc1
--name mylvm --size 1G testvg
-L 1.5G /dev/testvg/mylvm
-L 1.5G /dev/testvg/mylvm
# rpmdb_verify Packages
yum
yum
yum
yum
history
list installed
repolist
info subversion
Server1
createrepo directoryname
rsync -avz httpsite to directory
Server2
yum to network
create .repo /etc/yum.repo.d
[tecmint]
name=Example repo for Part 11 of the LFCE series on Tecmint.com
baseurl=http://192.168.0.17/repos/centos/6/6/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
every day beginning at 2:30 AM:Crontab
30 2 * * * rsync -avz rsync://centos.ar.host-engine.com/6.6/os/x86_64/ /var/www/
html/repos/centos/6/6/
find /path/to/files/ -type f -mtime +7 -exec rm -rf {} \;
What it all means:
find: the command that will search for the files
/path/to/files/: the top level directory to start searching
-type f: so we don t remove directories, only files
-mtime +7: files older than 7 days. Change to +14' to delete files older than 2 wee
ks.
-exec: what to do with the files we find
rm -rf: remove them recursively, force
{}: this represents each file we find
\;: the end of the exec
# Find
-name
-iname
-type d, f , f! -perm 777 (with/without)
# find / -perm /u=r
# find / -perm /a=x
# find / -type f -perm 0777 -print -exec chmod 644 {} \;
# find / -type d -perm 777 -print -exec chmod 755 {} \;
find / -amin -60
find / -mmin -60
-size
# Enable quota
# cat /etc/fstab
LABEL=/home
/home
Timezone
/usr/share/zoneinfo
date +%Z
ext2
defaults,usrquota,grpquota 1 2
#Iptables
# iptables -L OUTPUT -n -v --line-numbers
To insert rule between 1 and 2, enter:
# iptables -I INPUT 2 -s 202.54.1.2 -j DROP
#
#
#
#
iptables
iptables
iptables
iptables
-L
-L
-L
-L
INPUT -n --line-numbers
OUTPUT -n --line-numbers
OUTPUT -n --line-numbers | less
OUTPUT -n --line-numbers | grep 202.54.1.1
# Netstat
-a all
-t tcp
-u udp
-l listening
-p- pid
-i interface
# Kill
0
SIGNULL (NULL) Null
Check access to pid
1
SIGHUP (HUP)
Hangup Terminate; can be trapped
2
SIGINT (INT)
Interrupt
Terminate; can be trapped
3
SIGQUIT (QUIT) Quit
Terminate with core dump; can be trapped
9
SIGKILL (KILL) Kill
Forced termination; cannot be trapped
15
SIGTERM (TERM) Terminate
Terminate; can be trapped
24
SIGSTOP (STOP) Stop
Pause the process; cannot be trapped. This is de
fault if signal not provided to kill command.
25
SIGTSTP (STP) Terminal
Stop/pause the process; can be trapped
26
SIGCONT (CONT) Continue
Run a stopped process
Ext2 Ext3 Ext 4
EXT3 - Journaling
There are three types of journaling available in ext3 file system.
Journal
Metadata and content are saved in the journal.
Ordered Only metadata is saved in the journal. Metadata are journaled only after
writing the content to disk.
This is the default.
Writeback Only metadata is saved in the journal. Metadata might be journaled eit
her before or after the content is written to the disk.
FAstfsck EXT4
In ext4, unallocated block groups and sections of the inode table are marked as
such.
This enables e2fsck to skip them entirely on a check and greatly reduces the tim
e
it takes to check a file system of the size ext4 is built to support.
You can also mount an existing ext3 fs as ext4 fs
In ext4, you also have the option of turning the journaling feature
off
For multi-block allocation, a group of blocks are processed and written together
Since a larger number of blocks are being written at once, it is better so files
are not fragmented.
The group of blocks will be written in a contiguous section if available
The Delayed Allocation is when the data blocks are written at the Writeback Time
Interval. There are three advantages to Delayed Allocation:
Delayed allocation
Larger sets of blocks are processed before being written. This reduces the proce
sser utilization by performing the processing all at once, as discussed in Multi
-Block Allocation.
Reduces fragmentation by allocating a large number of blocks at once which are m
ost likely contiguous.
Reduces processor time and disk space for files that are short-term temporary fi
les wich are used and deleted in RAM/cache before they are written
#kernel
make menuconfig
Install libncurse5
make oldconfig
make
make modules_install
make install
mkinitramfs -o /boot/initrd.3.0.img
update-grub
# RAID
type fd
type 83 linux
mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb2
mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[ab]1
/etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
mdadm --add /dev/md0 /dev/sdb1
cat /proc/mdstat
mdadm --detail /dev/md0
c
mdadm --stop /dev/md0
mdadm --remove /dev/md0
.