Ubuntu常用命令手册【自用笔记】

Ubuntu常用命令手册【自用】

1. 杂项

1. 删除进程中包含"smb"字段的所有进程
sudo kill -9 $(ps -aux | grep smb | awk '{print $2}')
2. 查看最近登录的ip
cat /var/log/audit/audit.log  | grep sshd | grep  -v "hostname=?" | grep -Eo "hostname=([0-9]{1,3}[\.]){3}[0-9]{1,3}" | awk -F '=' '{print $2}'| awk '!a[$0]++'

2. xargs

接受一个字符串作为命令参数使用。
正常条件下:命令参数 > 标准输入参数
-d 分隔符,默认是空格分隔,可以指定分隔符,例如 -d ‘@’
-n 分成n组执行,例如10个参数分成4组执行等等。
参考:xargs命令详解,xargs与管道的区别

ps -aux | grep smb | awk '{print $s}'|xargs kill -9

3. awk

$NF 输出最后一列
$1 输出第1列,可换
$2==? && $3=="?" 某一列等于数字 and 某一列等于字符串(&& ||)

# 查看最后一列
ps -aux | awk '{print $NF}'
# 查看七月30或31日,某几列的日志
awk '($2==31||$2==30) && $3=="Jul" {print $2,$3,$16,$17}' update_db.log 

4. find

根据文件的属性进行查找
如文件名,文件大小,所有者,所属组,是否为空,访问时间,修改时间
更多参数:
    !:不等于
    -and(-a) :和
    -or(-o) :或

# 查找etc目录下名称包含srm的文件,通配符可自定义
find /etc -name '*srm*'

5. grep

根据文件的内容进行查找
对文件的每一行按照给定的模式(patter)进行匹配查找
主要参数:
    -c:只输出匹配行的计数。
    -i:不区分大小写
    -h:查询多文件时不显示文件名。
    -l:查询多文件时只输出包含匹配字符的文件名。
    -n:显示匹配行及行号。
    -s:不显示不存在或无匹配文本的错误信息。
    -v:显示不包含匹配文本的所有行。
正则表达式主要参数:
    \: 转义,忽略正则表达式中特殊字符的原有含义。
    ^:匹配正则表达式的开始行。
    $: 匹配正则表达式的结束行。
    <:从匹配正则表达 式的行开始。
    >:到匹配正则表达式的行结束。
    [ ]:单个字符,如[A]即A符合要求 。
    [ - ]:范围,如[A-Z],即A、B、C一直到Z都符合要求 。
    . :所有的单个字符。
    * :有字符,长度可以为0。

(1)grep 'test' d*          #显示所有以d开头的文件中包含 test的行
(2)grep 'test' aa bb cc    #显示在aa,bb,cc文件中包含test的行
(3)grep '[a-z]\{5\}' aa    #显示所有包含每行字符串至少有5个连续小写字符的字符串的行
(4)grep magic /usr/src     #显示/usr/src目录下的文件(不含子目录)包含magic的行
(5)grep -r magic /usr/src  #显示/usr/src目录下的文件(包含子目录)包含magic的行
(6)grep -w pattern files     #只匹配整个单词,而不是字符串的一部分(如匹配’magic’,而不是’magical’),

参考链接:Linux 文本三剑客之 - grep 文本搜索工具
参考链接:Linux下的find文件查找命令与grep文件内容查找命令

6. sed

参考链接:Linux 文本三剑客之 - sed 字节流编辑器

7. timedatectl

  用来修改Linux的系统时间、硬件时间和时区。官方解释如下:

timedatectl [OPTIONS...] COMMAND ...

Query or change system time and date settings.
查询或更改系统时间和日期设置。

  -h --help                Show this help message
     --version             Show package version
     --no-pager            Do not pipe output into a pager
     --no-ask-password     Do not prompt for password
  -H --host=[USER@]HOST    Operate on remote host
  -M --machine=CONTAINER   Operate on local container
     --adjust-system-clock Adjust system clock when changing local RTC mode

Commands<命令>:
  status                   Show current time settings
  set-time TIME            Set system time
  set-timezone ZONE        Set system time zone
  list-timezones           Show known time zones
  set-local-rtc BOOL       Control whether RTC is in local time
  set-ntp BOOL             Enable or disable network time synchronization

具体使用🌰参考连接:【timedatectl】修改Linux系统时间、硬件时间和时区

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
手册Ubuntu官方手册PDF文件,非影音版文件。而且是Ubuntu最新版本文件 v14.04. 希望能对您有帮助。 Prologue 5 Welcome 5 Ubuntu Philosophy 5 A brief history of Ubuntu 6 Is Ubuntu right for you? 7 Contact details 8 About the team 8 Conventions used in this book 8 1 Installation 9 Getting Ubuntu 9 Trying out Ubuntu 10 Installing Ubuntu—Getting started 11 Finishing Installation 16 2 The Ubuntu Desktop 19 Understanding the Ubuntu desktop 19 Unity 19 The Launcher 21 The Dash 21 Workspaces 24 Managing windows 24 Unity’s Keyboard Shortcuts 26 Browsing files on your computer 26 Files file manager 27 Searching for files and folders on your computer 29 Customizing your desktop 30 Accessibility 32 Session options 33 Getting help 33 3 Working with Ubuntu 37 All the applications you need 37 Getting online 39 Browsing the web 46 Reading and composing email 55 Using instant messaging 59 Viewing and editing photos 64 Watching videos and movies 67 Listening to audio and music 68 Burning cds and dvds 72 Working with documents, spreadsheets, and presentations 75 4 Hardware 77 Using your devices 77 Hardware identification 77 Displays 77 Connecting and using your printer 79 4 getting started with ubuntu 14.04 Sound 80 Using a webcam 81 Scanning text and images 82 Keyboard and mouse 82 Other devices 83 5 Software Management 85 Software management in Ubuntu 85 Using the Ubuntu Software Center 86 Managing additional software 89 Manual software installation 93 Updates and upgrades 94 6 Advanced Topics 97 Ubuntu for advanced users 97 Introduction to the terminal 97 Ubuntu file system structure 99 Securing Ubuntu 100 Why Ubuntu is safe 100 Basic security concepts 101 Users and groups 101 System updates 104 Firewall 104 Encryption 105 Running Windows Programs on Ubuntu 106 7 Troubleshooting 111 Resolving problems 111 Troubleshooting guide 111 Getting more help 116 8 Learning More 117 What else can I do with Ubuntu? 117 Open source software 117 Distribution families 117 Choosing amongst Ubuntu and its derivatives 118 Finding additional help and support 120 The Ubuntu community 121 Contributing 122 A License 123 Creative Commons Attribution–ShareAlike 3.0 Legal Code 123 Creative Commons Notice 129

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值