积累linux常用命令大全

2019-09-23 09:25:10于海丽

linux中去除文件中的重复行


sort -n Yourfile | uniq > save_path

更新Linux系统时间


sudo ntpdate cn.pool.ntp.org

亚洲地区的ntp服务器


. Bangladesh — bd.pool.ntp.org . China — cn.pool.ntp.org . Hong Kong — hk.pool.ntp.org . India — in.pool.ntp.org . Indonesia — id.pool.ntp.org . Iran — ir.pool.ntp.org . Israel — il.pool.ntp.org . Japan — jp.pool.ntp.org . Korea — kr.pool.ntp.org . Malaysia — my.pool.ntp.org . Philippines — ph.pool.ntp.org . Singapore — sg.pool.ntp.org . Taiwan — tw.pool.ntp.org . Thailand — th.pool.ntp.org . Turkey — tr.pool.ntp.org . United Arab Emirates — ae.pool.ntp.org

在vim中进行完整单词的匹配

使用命令行输入模式

/<这里输入你要匹配的单词>

如果在单文件中使用进行查找和匹配

直接使用在命令输入模式下 对某个单词使用 *

使用scp和rsync进行数据的内网数据传输和备份


rsync -azvh --delete --compress-level=0 --progress username@hostname(ip):file_path save_path >> log_path

参数解释:

-v:
--verbose increase verbosity
--info=FLAGS fine-grained informational verbosity
--debug=FLAGS fine-grained debug verbosity
--msgs2stderr special output handling for debugging
-a:
--archive archive mode; equals -rlptgoD (no -H,-A,-X)
--no-OPTION turn off an implied OPTION (e.g. --no-D)
 -z:
--compress compress file data during the transfer
--compress-level=NUM explicitly set compression level
--skip-compress=LIST skip compressing files with suffix in LIST
-h:
--human-readable output numbers in a human-readable format
--progress show progress during transfer
--delete delete extraneous files from dest dirs
scp mode remote_username@remote_hostname(or ip):remote_file_path dest_file_path >> run_log_path
example:
name@host:/mnt/hd/data/code/shell$ scp sql_rsync.sh name@host:/tmp/
name@host's password:
sql_rsync.sh     100% 149 0.2KB/s 00:00
name@host:/mnt/hd/data/code/shell$


接下来给大家总结了10条linux常用命令

1.》将原文件清空,并且内容写入到文件中,》》将内容放到文件的尾部


 echo “aa” 》 test.txt 和 echo “bb” 》》 test.txt

2 给组用户和其他用户添加写的权限


chmod go+w -R /home/zhangy

 3. 列出归档内容


tar -tzvf test.tar.gz  
 

4.查看文件列表大小


du -ah

5. 查看所有文件的大小总和


du -sh

6.数学运算


echo ‘1+2'|bc -l

7. //查看linux内核等的一些信息


uname -a

8.坏道扫描时显示进度


badblocks -s /dev/sda