This post tells you some useful Linux/Unix Commands.
References:Alphabetical Directory of Linux Commands
$rsync
rsync [options] sources dest
Transfer files; used frequently for updating files across a network. File transfer with rsync is fast and efficient because it checks local files against remote files in small chunks, or blocks, and transfers only the blocks that differ between the files.
$man logrotate
logrotate is designed to ease administration of systems that generate large numbers of log files. It allows auto-matic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly,monthly, or when it grows too large.
Funny usage that I found is someone uses "logrotate" tool for handling CVSroot folder management.
/home/someuser/folderA/cvsroot.tar.gz {
notifempty
missingok
}
***setting up cvs server and manage cvs account***
1. install cvs package.
$pkgadd -d
2. make sure PATH variable includes the cvs executable file path.
$set
3. create a group for CVS user and change cvs files group owner to "cvs".
$groupadd cvs
$chgrp cvs /{somewhere}/cvsroot /{somewhere}/cvsroot/CVSROOT /{somewhere}/cvsroot/CVSROOT/*
4. create a Linux system user(called "cvsuser") for a CVS user and grouped in of a cvs group.
-->create a user
$useradd -m -d {new user's home directory} -g cvs cvsuser
references:
-m "Create home directory for new user account"
-d "This option specifies the users home directory.If not specified, the default from /etc/default/useradd is used."
-g "The group name or number of the user's main group.The group name or number must refer to an already existing group.If not specified,the default from /etc/default/useradd is used."
-->set up a "auto_home" file
$touch /etc/auto_home??
$vi /etc/auto_home
cvsuser sunblade2:/export/home/cvsuser
-->change the "cvs" user's password setting in /etc/passwd by hand
$vi /etc/passwd
cvsuser:x:503:101::/home/cvsuser:/bin/sh
5. add a cvs user
$cd /{somewhere}/cvsroot/CVSROOT
$/usr/apache/bin/htpasswd -c passwd {$user name}
reference:
-c create a new file
-->create cvswrapper file under $CVSROOT/CVSROOT directory.
$vi cvswrappers
*.gif -k 'b'
*.jpg -k 'b'
*.jpeg -k 'b'
*.class -k 'b'
*.jar -k 'b'
reference:
"cvswrappers" file is...
"If the file $CVSROOT/CVSROOT/cvswrappers exists, any file whose names match the specifications in that file will be treated as packages and the appropriate filtering will be performed on the file/directory before being imported. see node wrappers' in theCVS manual."
The cvswrappers file discription is here(http://cvsman.com/cvs-1.12.12/cvs_183.php ).
-k "keyward expansion" this option value can be 'b' for specifing a file data type as "binary".
6. configuration of starting up the cvs server as part of the inetd service.
-->activate cvspserver service in "/etc/inet/service"
$vi /etc/service
cvspserver 2401/tcp # CVS Server
-->add its configuration in /etc/inetd.conf
$vi /etc/inetd.conf
cvspserver stream tcp nowait root /usr/local/bin/cvs cvs --allow-root=/data/cvsroot -f pserver
-->restart inetd
$pkill -HUP inetd
references:
$man pkill
"NAME pgrep, pkill - look up or signal processes based on name and other attributes..."
-HUP "(Hang UP) to tell a program a specified proram hanged up and need to get restarted.so obviously it causes the program to restart."
FTP:
Essential ftp Commands
Compress directory and transfer to remote machine at one time by shell programming.
* auto_transfer_backup.sh
1.tar zcf A B
2.ftp -n < somewhere/ftp_commands.txt
open $remote_ip
user $username $password
bin
prompt off
cd $remote_dir
lcd $local_dir
put cvsroot.tar.gz
quit
Reference:
prompt-Toggles interactive prompting.
Interactive prompting occurs during multiple file transfers
to allow the user to selectively retrieve or store files.
By default, prompting is turned on.
If prompting is turned off, any mget or mput transfers all files, and any mdelete deletes all files.
binary-Sets the “representation type” to “image”.
ftp> binary
200 Type set to I.
ftp> bin
200 Type set to I.
ftp> ascii
200 Type set to A.
ftp> asc
200 Type set to A.
ftp> prompt -h
usage: prompt [ on | off ]
CRONTAB:
Run a particular program(i.e. shell programming file) at every fixed time.
By the way, we can control specified user access by using /etc/cron.d/cron_deny or cron_allow.
--
A crontab file consists of lines of 6 fields each.
Each of these patterns can be either an asterisk (meaning all legal values) or a list of elements separated by commas.An element is either a number or two numbers separated by a minus sign (meaning an inclusive range).
1st field - minute (0-59),
2nd field - hour (0-23),
3rd field - day of the month (1-31),
4th field - month of the year (1-12),
5th field - day of the week (0-6 with 0=Sunday)
--
(i.e.)
when you want to run a command at 6am on Sundays and standard output and standard error go to a empty file, which means go into the air!.
0 6 * * 0 ${command or shell file path} /dev/null 2>&1
Reference:
/dev/null 2>&1
$man bash and go to see "redirection section".
http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/
http://en.wikipedia.org/wiki/Data_sink
http://blogs.sun.com/chrisg/entry/who_or_what_deleted_dev
The word following the redirection operator in the following descriptions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, pathname expansion, and word splitting. If it expands to more than one word, bash reports an error.Note that the order of redirections is significant. For example, the command
ls > dirlist 2>&1
directs both standard output and standard error to the file dirlist, while the command
ls 2>&1 > dirlist
directs only the standard output to file dirlist, because the standard error was duplicated as standard output before the standard output was redirected to dirlist.

No comments:
Post a Comment