Learning Linux

3 篇文章 0 订阅

基础知识

  • Background Process

CTRL+Z挂起进程并放入后台

jobs 显示当前暂停的进程
bg %N 使第N个任务在后台运行(%前有空格)
fg %N 使第N个任务在前台运行
默认bg,fg不带%N时表示对最后一个进程操作!

kill %N : 杀死第N个后台进程

  • Command

bc - An arbitrary precision calculator language

cat - concatenate and print files

cmp - compare two files byte by byte

cut - remove sections from each line of files

# 截取PATH中第3个和第5个,以':'分割
echo ${PATH} | cut -d ':' -f 3,5
# 截取export变量12个字符后的字符串
export | cut -c 12-
# 截取export变量第12个到第20个字符
export | cut -c 12-20

df - report file system disk space usage

diff - compare files line by line

du - estimate file space usage

env - run a program in a modified environment

env 显示当前shell的环境变量和自定义变量(不包含父进程未export的自定义变量)
export 显示由父进程共享出来的变量
set 显示所有环境变量、自定义变量、shell自身描述变量

file - determine file type

gawk - pattern scanning and processing language

grep, egrep, fgrep - print lines matching a pattern

head - output the first part of files

iconv - 转换给定文件的编码。将繁体字转为简体字示例:

iconv -f utf8 -t big5 vi.utf8 | iconv -f big5 -t gb2312 | iconv -f gb2312 -t utf8 -o vi.gb.utf8

id - return user identity

info - read Info documents

less - file reading

locale - display locale settings

locate - find files by name

od - dump files in octal and other formats

>  echo abcdefghiklmnopqrstuvwxyz | od -A d -w10 -t xCoCdCc
0000000   61   62   63   64   65   66   67   68   69   6b
         141  142  143  144  145  146  147  150  151  153
          97   98   99  100  101  102  103  104  105  107
           a    b    c    d    e    f    g    h    i    k
0000010   6c   6d   6e   6f   70   71   72   73   74   75
         154  155  156  157  160  161  162  163  164  165
         108  109  110  111  112  113  114  115  116  117
           l    m    n    o    p    q    r    s    t    u
0000020   76   77   78   79   7a   0a
         166  167  170  171  172  012
         118  119  120  121  122   10
           v    w    x    y    z   \n
0000026

rsync - a fast, versatile, remote (and local) file-copying tool

localhost > ls -lrt /tmp/test/
-rw-r--r--  1 zyd  staff  11  4 22 16:15 1.txt

192.168.17.53 > ls -lrt /tmp/test/
-rw-r--r--. 1 root root  2 4月  15 13:09 1.txt
-rw-r--r--. 1 root root 10 4月  22 16:42 2.txt

# 同步两边目录,规则:不覆盖,多删少补;
rsync -v -r --ignore-existing --delete /tmp/test 192.168.17.53:/tmp

192.168.17.53 > ls -lrt /tmp/test/
-rw-r--r--. 1 root root  2 4月  15 13:09 1.txt

# 可以看到:1.txt没有被覆盖;2.txt被删除;


sed - stream editor for filtering and transforming text

sort - sort lines of text files

split - split a file into pieces

stty - set the options for a terminal device interface

tac - concatenate and print files in reverse

tail - output the last part of files

tee - read from standard input and write to standard output and files

test - check file types and compare values

time - calculate execute time

>  time ls
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

real	0m0.003s
user	0m0.001s
sys	0m0.002s

tr - translate or delete characters

type - query command type

>  type -a ls
ls 是 `ls --color=auto' 的别名
ls 是 /usr/bin/ls

uname - print system information

uniq - report or omit repeated lines

wc - print newline, word, and byte counts for each file

xargs - build and execute command lines from standard input

  • 快捷键

Ctrl + D 键盘输入结束(End of file,EOF,End of input)

Ctrl + Z : 将任务中断,但是此任务并没有结束,他仍然在进程中他只是维持挂起的状态,可以使用fg/bg操作继续前台或后台任务。

  • Help

man

info

  • 需要注意的点

  • 双引号和单引号的区别:
>  name=zyd
>  myname='my name is ${name}'
>  echo ${myname}
my name is ${name}
>  myname="my name is ${name}"
>  echo ${myname}
my name is zyd

网络方面

  • 使用nc测两台机子udp连通性

A:nc -vul 12121

B:nc -vu A 12121现在A 和 B能互相通信

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值