积累linux常用的命令
来源:互联网 发布:个人信息管理系统源码 编辑:程序博客网 时间:2024/05/20 05:10
积累linux常用的命令
主要记录在日常生活中遇到的问题,进行记录:
- 创建linux下的用户
useradd -d home -s bash_path -p password -r name
- linux中文件中存在^M
使用shell命令tr可以实现去除,具体命令如下:
cat -v yourfile | tr -d "^M" > targetfile
VIM中选定某个单词
在ESC之后,使用w或者wi或者vwi可以选择某个单词在控制台中快速移动光标
1.删除
1.1 ctrl + d 删除光标所在位置上的字符相当于VIM里x或者dl
1.2 ctrl + h 删除光标所在位置前的字符相当于VIM里hx或者dh
1.3 ctrl + k 删除光标后面所有字符相当于VIM里d,shift+$
1.4 ctrl + u 删除光标前面所有字符相当于VIM里d,shift+^
1.5 ctrl + w 删除光标前一个单词相当于VIM里db
1.6 ctrl + y 恢复ctrl+u上次执行时删除的字符
1.7 ctrl + ? 撤消前一次输入
1.8 alt + r 撤消前一次动作
1.9 alt + d 删除光标所在位置的后单词
2.移动
2.1 ctrl + a 将光标移动到命令行开头相当于VIM里shift+^
2.2 ctrl + e 将光标移动到命令行结尾处相当于VIM里shift+$
2.3 ctrl + f 光标向后移动一个字符相当于VIM里l
2.4 ctrl + b 光标向前移动一个字符相当于VIM里h
2.5 ctrl + 方向键左键 光标移动到前一个单词开头
2.6 ctrl + 方向键右键 光标移动到后一个单词结尾
2.7 ctrl + x 在上次光标所在字符和当前光标所在字符之间跳转
2.8 在vim中的命令输入模式中,输入gg,可以快速跳转到文件开头
2.9 在vim中的命令输入模式中,输入GG,可以快速跳转到文件结尾
3.0 在vim中返回上一个的编辑的位置,在输入命令模式使用 ctrl+o
3.1 在vim中返回下一个的编辑的位置,在输入命令模式使用 ctrl+i
3.统计
3.1 例如在vim中统计某个字符串的数量,可以使用命令:%s/Name//gn
防止被某个文件被删除
1.使用一个shell命令来防止文件下的文件不能被删除
sudo chattr +a Downloadscd Downloadsrm Ngix.pdfmv: cannot move ‘Ngix.pdf’ to ‘/home/gpx/.trash/Ngix.pdf’: Operation not permittedsudo rm Ngix.pdfrm: cannot remove ‘Ngix.pdf’: Operation not permitted
2.使用alias命令来去除rm
alias rm='rm -i'oralias rm=trashtrash(){ mv "$@" trash/}oralias rm='cp $@ ~/backup; rm $@'
- 数据同步命令
#!/bin/sh date -d 'now' > /mnt/hd/data/log/rsync.log index=1while :do rsync -azvh --compress-level=0 --progress gpx@ip:/mnt/hd/data/PriceAdj_data/ /mnt/hd/data/PriceAdj_data/ >> /mnt/hd/data/log/rsync.log if [ $? -ne 0 ];then sleep 5m else break fi let "index++" if [ $index -eq 5 ];then curl -d "operator=alert&phone=number&msg=rsync-dell-data-Failed" "http://ip:port/sendmessage" echo "rsync data Failed !" >> /mnt/hd/data/log/rsync.log exit 1 fidonedate -d 'now' > /mnt/hd/data/log/log_save_dateData.log nohup python /mnt/hd/data/code/load_Today_Data.py >> /mnt/hd/data/log/log_save_dateData.log
- linux中去除文件中的重复行
sort -n Yourfile | uniq > save_path
- 更新Linux系统时间
sudo ntpdate cn.pool.ntp.org
亚洲地区的ntp服务器
1. Bangladesh — bd.pool.ntp.org
2. China — cn.pool.ntp.org
3. Hong Kong — hk.pool.ntp.org
4. India — in.pool.ntp.org
5. Indonesia — id.pool.ntp.org
6. Iran — ir.pool.ntp.org
7. Israel — il.pool.ntp.org
8. Japan — jp.pool.ntp.org
9. Korea — kr.pool.ntp.org
10. Malaysia — my.pool.ntp.org
11. Philippines — ph.pool.ntp.org
12. Singapore — sg.pool.ntp.org
13. Taiwan — tw.pool.ntp.org
14. Thailand — th.pool.ntp.org
15. Turkey — tr.pool.ntp.org
16. 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_pathexample: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:00name@host:/mnt/hd/data/code/shell$
- 积累linux常用的命令
- 积累linux常用的命令
- 常用linux命令积累
- Linux知识积累:一些常用的Linux命令
- 工作常用的命令积累
- Linux的一些命令积累
- linux下的命令积累
- 我常用的linux命令大全------知识和经验在于积累和总结
- 转载和积累系列 - 常用linux命令大全
- 工作中积累的Linux命令
- 积累那些linux下有用的命令
- Linux学习中遇到的命令积累
- Linux — 基本命令的积累(一)
- linux 常用指令积累
- Linux 命令积累
- linux 命令积累
- linux命令积累
- Linux命令--积累
- 【Linux】readv与writev
- 函数适配器
- 别被技术绑架
- 移动端混合型 App(hybrid app)自动化测试选型与实践
- 正则里的 /x7f-/xff 这样东西
- 积累linux常用的命令
- <T> T[] List.toArray(T[] a) static <T> List<T> Arrays.asList(T... a)
- WIN7/8 独立更新安装程序 安装时遇到错误
- 1、ls命令
- 静态路由配置中出现的问题:0
- 使用SecureCRT连接ubuntu
- 读书笔记之《深入浅出Node.js》(1)
- Java 构建工具:Ant vs Maven vs Gradle
- 7.01