cp file always getting overwrite prompt?
wondering why always getting overwrite prompt when use “cp” command with “-f” option
try this,
1. login as root
1 | vi /root/.bashrc |
2. comment out this line
1 | #alias cp='cp -i' |
3. logout and login again
wondering why always getting overwrite prompt when use “cp” command with “-f” option
try this,
1. login as root
1 | vi /root/.bashrc |
2. comment out this line
1 | #alias cp='cp -i' |
3. logout and login again
rsync can synchronizes files and directories from one server to another. It’s perfectly for backup or create a mirror site purpose.
This tutorial shows you step by step to create a rsync server and client server.
First of all, you must have rsync installed. For fedora, rsync should be included by default. If you don’t have it, run
1 | yum install rsync |
Setup rsync server
Create rsync configuration file:
1 2 3 4 5 6 7 | cd /etc mkdir rsyncd cd rsyncd touch rsyncd.conf touch rsyncd.motd touch rsyncd.user chmod 600 rsyncd.user |
edit rsyncd.user file:
vi /etc/rsyncd.user
1 | my_rsync_user_1:user_1_password |
edit rsyncd.conf file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | pid file=/var/run/rsyncd.pid port=873 uid=root gid=root use chroot=yes read only=yes # limit access to LANS hosts allow=192.168.2.0/255.255.255.0 #default, listen to lan server host deny=* max connections=5 motd file=/etc/rsyncd/rsyncd.motd log format=%t%a%m%f%b syslog facility=local3 timeout=300 [profile_1] #profile name path = /path/to/backup/directory ignore errors read only = false list = false hosts allow = 66.66.66.66 #listen to client server which use public ip hosts deny = 0.0.0.0/32 auth users = my_rsync_user_1 secrets file = /etc/rsyncd/rsyncd.user #[profile_1] #another profile name #path = /path/to/backup/directory/2 #ignore errors #read only = false #list = false #hosts allow = 88.88.88.88 #listen to client server which use public ip #hosts deny = 0.0.0.0/32 #auth users = my_rsync_user_2 #secrets file = /etc/rsyncd/rsyncd.user |
Next, create init start up script
vi /etc/init.d/rsyncd
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #!/bin/sh # # Startup script for rsyncd daemon # # chkconfig: 35 90 10 # description: Server data for sync to other server # processname rsync # Source function library . /etc/rc.d/init.d/functions prog=rsync conf=/etc/rsyncd/rsyncd.conf case "$1" in start) echo -n "Starting rsync daemon: " daemon /usr/bin/$prog --daemon --config=$conf RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/$prog ;; stop) echo -n "Shutting down $prog: " killproc -d 60 $prog RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog ;; status) status $prog ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 esac exit 0 |
make /etc/init.d/rsyncd executable, and register this service
3 4 5 | chmod +x /etc/init.d/rsyncd /sbin/chkconfig --add rsyncd /sbin/service rsyncd start |
Setup rsync client
first, of course you must have rsync installed on client server
make rsync password file
1 2 3 4 5 | cd /etc mkdir rsync cd rsync touch rsync.pwd chmod 600 rsync.pwd |
vi /etc/rsync/rsync.pwd
1 | user_1_password |
execute this command to start synchronize file to server
1 | rsync -vrtLogp --progress /path/to/directory/to/be/backup/* my_rsync_user_1@[SERVER_IP]::profile_1 --password-file=/etc/rsync/rsync.pwd |
where [SERVER_IP] is rsync server IP
Reload vhost.conf for single domain
1 | /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name= |
Update AWStats for only 1 domain in Plesk
1 | /usr/local/psa/admin/sbin/statistics --calculate-one --domain-name=you-domain.com |
My server backups over 20GB files everyday. It takes hours to tar those huge amount of files. I think this kind of stupid task is harmful to hard driver. One more stupid issue is that over 99% of files are not modified since last backup. So, here is the command to let me backup newly modified files only.
tar -zcvf /save/to/file.tar /filePath/* –newer-mtime ‘1 days ago’
You may want to change “1 days ago” to 2 days, or 5 days.
By the way, it’s better to do full backup monthly or bi-monthly.
find /filePath/* -mtime +7 -delete
or
find /filePath/* -mtime +7 -exec rm {} \;
Where “-mtime” parameter will look for file modified time older than “+7″ days. You may want to change “+7″ to longer days, for example “+30″ days, “+90″ days
“-exec” parameter allows you to call another command. The “{} \;” is required at the end.
1 | ffmpeg -i /my_video_file_dir/video.flv -y -f image2 -ss 8 -sameq -t 0.001 -s 320*240 /image_dir/screenshot.jpg |
320*240 : image dimension is 320 pixels width and 240 pixels height
-ss 8 : screenshot will be taken at 8 second after video starts.
Want to play MP3 files on your website? The best and most common way is using flash video file which compress audio and video better for internet use like YouTube. Here is the instruction I used ffmpeg to convert MP3 to FLV file.
ffmpeg – a program that allow convert audio in numerous formats.
Installing ffmpeg
edit / etc/yum.repos.d/CentOS-Base.repo , add following lines at the end of file
1 2 3 4 | [dag] name=Dag RPM Repository for Centos baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag enabled=1 |
run this command
1 | yum install ffmpeg |
Convert MP3 to FLV
1 | ffmpeg -y -i /home/song.mp3 -f flv -acodec mp3 -ab 64 -ac 1 /home/song.flv |
1 2 3 4 5 6 7 | #include <iostream> int main() { std::cout << "Hello world, compiled with g++ on linux" << std::endl; return 0; } |
compile this and move to your secured tmp partition and execute it. If you get a permission error, tmp partition is mounted correctly with noexec.
ntpdate synchronize and set computers’ date and time via Network Time Protocol (NTP) server(s).
1 | /usr/sbin/ntpdate -u 0.fedora.pool.ntp.org |
0.fedora.pool.ntp.org is NTP server. If this server is not working, find another one.
ncftpget is able to let you download entire ftp directory and sub directories from remote ftp server.
Install ncftp client
1 | yum install ncftp |
Start downloading
1 | ncftpget -R -v -u "username" -p "userpassword" ftp.someserver.com /home/save_at_here /downloads |
where,