仝 tóng

Linux上一些有用的Notes

Remove software
list software packages

$ rpm -qa|grep example

force remove

$ rpm -e --nodeps example

Hide and Prevent a folder and Directory Listing of Your Website
hide your folder and do not want directory files to show in browser

  • add a empty and no content "index.html" file in your folder or directory

  • add "Options -Indexes" to your .htaccess in your website directory .

  • change "Options Indexes FollowSymLinks" to "Options FollowSymLinks" in your httpd.conf file and restart apache.

Magento Log Cleaning

"System"->"Configuration"->"ADVANCED"->"System"->"Log Cleaning"

Repair mysql table crashed error

"mysqldump -uroot -p your_mysql_name"

your will get error: table_name' is marked as crashed and should be repaired when using LOCK TABLES
and then you can fix it

mysql> use your_mysql_name;
mysql> repair table your_error_table_in_this_mysql;

use tar&openssl to encrypt your files

Encrypt: tar -zcvf - iCloud|openssl des3 -salt -k your-password | dd of=iCloud.des3 (The first "iCloud" is your file name, please change your-password to your password)
Decrypt: dd if=iCloud.des3 |openssl des3 -d -k your-password|tar zxf - (do not forgot the "-").

use ley to login your remote linux server with key

ssh -i your-key-file-path [email protected]

copy remote file to your machine

scp -i your-key-file-path [email protected]:/file-path /server-path

查看特定文件夹下文件数量

find path_or_file |wc -l

移动文件夹下特定数量的文件至另一文件下

ls | head -number |xargs -I {} mv {}  new_file_path

ls |head -10000 |xargs -I {} mv {} /var/www/html/new

删除文件夹下大量文件,当使用rm -rf提示错误的时候

ls |xargs -n 100 rm -rf ls

清理centos缓存

$sync

$echo 3 > /proc/sys/vm/drop_caches

查找文件下文件包含的内容

find your_files_path -name "*.*" |xargs grep "search_content"