Shell命令:操作系统的一个字符串操作(笔记)

1、关机:halt reboot poweroff

2、帮助手册:man

3、目录、文件操作:Linux采用的文件是ext3(树形结构)

        3.1路径表示法:

        绝对路径:(从根开始)/home/LF/桌面/test.txt

        相对路径:相对于当前的位置而言的一个位置

                ~/文件

        3.2查看当前所在位置:pwd   (print working directory)

        3.3改变目录:cd 位置  change diretory

         3.4遍历某文件的内容:

                ls [options] [FILE] (list)

                1、ls  遍历当前的位置(current directory)

                2、ls path 

                3、ls  -l 文件     文件的属性

                            -rw-rwr--  1    LF    LF    0   7月 1  01:19 abc (-文本)

                            t 权限     链接 创建  群组  大小 时间    时间  文件名

                            drw-rwr--  1    LF    LF    0   7月 1  01:19 0701 (-文件夹)

                            type: -普通文件  d文件夹  p管道  l链接  c字符   b块 

                4、ls   -  path   :遍历所有文件

                            .当前

                            ..父路径

                5、用户的主目录:系统为每一个用户分配一个活动的文件夹。/home

                            ~:当前用户的主目录

4.创建文件夹:mkdir   path   ( make directory )

5.创建文件/修改时间戳:touch 文件

                计算机的时间戳:1970:1:0:0:0

6、rm  Path    remove

                rm path  删除文件

                rm -r path 删除文件夹

7、mv  移动文件   move  file

8、lk  链接:符号链接,硬链接 link

                ln -s symbolic符号

                ln -L hard link硬链接

文本文档操作:

                1、cat /more  文档    读取文本文档:

                            cat  一次性读取   例: cat first.c

                            more 一屏一屏的读(n)

                2、wc  统计文本的行数,单词数量

9.遍历进程列表

                遍历进程:  ps -e

                筛选进程:  ps -e | grep (init是进程名)

                使用带有 -ef 选项的 ps,返回系统中所有用户的所有进程的完整列表。一般将此 ps 命令的结果传送到 grep 中,则该结果更易于查看。例如:

                

$ ps -ef | grep Oracle
UID PID PPID C STIME TTY TIME CMD
oracle 1633 1 0 13:58 ?00:00:00 ora_pmon_ora1
oracle 1635 1 0 13:58 ?00:00:00 ora_dbw0_ora1
oracle 1637 1 0 13:58 ?00:00:01 ora_lgwr_ora1
oracle 1639 1 0 13:58 ?00:00:02 ora_ckpt_ora1
oracle 1641 1 0 13:58 ?00:00:02 ora_smon_ora1
oracle 1643 1 0 13:58 ?00:00:00 ora_reco_ora1
oracle 1645 1 0 13:58 ?00:00:00 ora_cjq0_ora1
oracle 1647 1 0 13:58 ?00:01:18 ora_qmn0_ora1
oracle 1649 1 0 13:58 ?00:00:00 ora_s000_ora1
oracle 1651 1 0 13:58 ?00:00:00 ora_d000_ora1
-e : 在命令执行后显示环境
  -f : 完整显示输出
ps -ef | grep vim    //查找某个进程
root      3268  2884  0 16:21 pts/1    00:00:00 vim install.log
root      3370  2822  0 16:21 pts/0    00:00:00 grep vim

kill 3268
kill 3268    //杀死一个进程

猜你喜欢

转载自blog.csdn.net/superman___007/article/details/80955057
今日推荐