美文网首页
Linux OS 常规操作

Linux OS 常规操作

作者: 小米羊爱学术 | 来源:发表于2019-03-25 14:14 被阅读0次

    查看和配置网络设备:ifconfig

    yangyang@DESKTOP-SGNIV47:~$ ifconfig
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 1500
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x0<global>
            loop  (Local Loopback)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wifi0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.3.57.163  netmask 255.255.248.0  broadcast 10.3.63.255
            inet6 2001:da8:3008:2218:3168:ad88:b8b2:2b  prefixlen 64  scopeid 0x0<global>
            inet6 2001:da8:3008:2218:59ae:d751:e7a4:3674  prefixlen 128  scopeid 0x0<global>
            inet6 fe80::3168:ad88:b8b2:2b  prefixlen 64  scopeid 0x0<global>
            unspec 38-37-8B-F1-07-88-00-00-00-00-00-00-00-00-00-00  (UNSPEC)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    获得当前所在的工作目录的据对路径名称:pwd

    yangyang@DESKTOP-SGNIV47:~$ pwd
    /home/yangyang
    

    查看当前目录下的所有文件/文件夹,包括文件夹的权限,其他的信息:ll

    yangyang@DESKTOP-SGNIV47:~$ ll
    total 47900
    drwxr-xr-x 1 yangyang yangyang     4096 Dec 26 16:33 ./
    drwxr-xr-x 1 root     root         4096 Oct 28 00:53 ../
    -rw------- 1 yangyang yangyang    22672 Dec 26 23:47 .bash_history
    -rw-r--r-- 1 yangyang yangyang      220 Oct 28 00:53 .bash_logout
    -rw-r--r-- 1 yangyang yangyang     3771 Oct 28 00:53 .bashrc
    drwxrwxrwx 1 yangyang yangyang     4096 Dec 26 10:30 .cpan/
    drwxrwxrwx 1 yangyang yangyang     4096 Dec 26 11:45 .cpanm/
    drwxrwxrwx 1 yangyang yangyang     4096 Nov  8 23:42 .oracle_jre_usage/
    -rw-r--r-- 1 yangyang yangyang      807 Oct 28 00:53 .profile
    -rw-r--r-- 1 yangyang yangyang        0 Oct 28 11:22 .sudo_as_admin_successful
    drwxrwxrwx 1 yangyang yangyang     4096 Dec 26 17:26 .vep/
    -rw-rw-rw- 1 yangyang yangyang      165 Dec 20 19:45 .wget-hsts
    -rw-rw-rw- 1 yangyang yangyang  9887302 Dec 20 19:29 bedtools-2.25.0.tar.gz
    -rw-rw-rw- 1 yangyang yangyang 19581105 May 21  2017 bedtools-2.25.0.tar.gz.1
    drwxr-xr-x 1 yangyang yangyang     4096 Sep  3  2015 bedtools2/
    drwxrwxrwx 1 yangyang yangyang     4096 Dec 26 10:33 perl5/
    -rw-rw-rw- 1 yangyang yangyang        0 Nov 18 18:00 snnplist.avinput
    -rw-rw-rw- 1 yangyang yangyang 19586049 Dec 20 19:40 v2.25.0.tar.gz
    -rw-rw-rw- 1 yangyang yangyang     3195 Dec 20 19:45 wget-log
    -rw-rw-rw- 1 yangyang yangyang     8690 Dec 20 19:40 wget-log.1
    -rw-rw-rw- 1 yangyang yangyang        0 Dec 26 10:35 wget-log.2
    

    查看当前目录下的所有文件/文件夹名称:ls
    查看当前目录下包含隐藏文件在内的文件:ls -a

    yangyang@DESKTOP-SGNIV47:~$ ls
    bedtools-2.25.0.tar.gz    bedtools2  snnplist.avinput  wget-log    wget-log.2
    bedtools-2.25.0.tar.gz.1  perl5      v2.25.0.tar.gz    wget-log.1
    

    切换到当前目录的下一级目录:cd
    切换到当前路径的上级目录:cd ..
    切换到当前路径的上上级目录:cd ../..
    直接切换到Home目录:cd
    切换到根目录:cd /

    yangyang@DESKTOP-SGNIV47:~/test1$ cd /
    yangyang@DESKTOP-SGNIV47:/$ ls
    bin   dev  home  lib    media  opt   root  sbin  srv  tmp  var
    boot  etc  init  lib64  mnt    proc  run   snap  sys  usr
    yangyang@DESKTOP-SGNIV47:~$ cd
    yangyang@DESKTOP-SGNIV47:~$ ls
    bedtools-2.25.0.tar.gz    bedtools2  snnplist.avinput  test2           wget-log    wget-log.2
    bedtools-2.25.0.tar.gz.1  perl5      test1             v2.25.0.tar.gz  wget-log.1
    

    创建文件夹:mkdir

    yangyang@DESKTOP-SGNIV47:~$ mkdir test
    yangyang@DESKTOP-SGNIV47:~$ ls
    bedtools-2.25.0.tar.gz    bedtools2  snnplist.avinput  v2.25.0.tar.gz  wget-log.1
    bedtools-2.25.0.tar.gz.1  perl5      test              wget-log        wget-log.2
    

    新建空文件:touch

    yangyang@DESKTOP-SGNIV47:~/test$ touch file1 file2
    yangyang@DESKTOP-SGNIV47:~/test$ ls
    file1  file2
    

    删除空文件夹:rmdir

    yangyang@DESKTOP-SGNIV47:~$ rmdir test
    rmdir: failed to remove 'test': Directory not empty
    

    删除一个包含文件的文件夹:rm -r

    yangyang@DESKTOP-SGNIV47:~$ rm -r test
    yangyang@DESKTOP-SGNIV47:~$ ls
    bedtools-2.25.0.tar.gz    bedtools2  snnplist.avinput  wget-log    wget-log.2
    bedtools-2.25.0.tar.gz.1  perl5      v2.25.0.tar.gz    wget-log.1
    

    删除多个文件:rm

    文件拷贝:cp
    同名文件存在时,输出 [yes/no] 询问是否执行:cp -i
    强制复制文件,如有同名不询问:cp -f

    yangyang@DESKTOP-SGNIV47:~$ mkdir test1 test2 ##新建两个文件夹
    yangyang@DESKTOP-SGNIV47:~$ cd test1
    yangyang@DESKTOP-SGNIV47:~/test1$ touch file1-1 file1-2 ##新建文件
    yangyang@DESKTOP-SGNIV47:~/test1$ cd ../test2
    yangyang@DESKTOP-SGNIV47:~/test2$ touch file2-1 file2-2 ##新建文件
    yangyang@DESKTOP-SGNIV47:~/test2$ cp file2-1 ../test1 ##cp拷贝文件
    yangyang@DESKTOP-SGNIV47:~/test2$ cd ../test1
    yangyang@DESKTOP-SGNIV47:~/test1$ ls
    file1-1  file1-2  file2-1
    yangyang@DESKTOP-SGNIV47:~/test1$ cp -i file2-1 ../test2 ##cp -i拷贝重复文件询问
    cp: overwrite '../test2/file2-1'? no
    yangyang@DESKTOP-SGNIV47:~/test1$ cp -i file2-1 ../test2
    cp: overwrite '../test2/file2-1'? yes
    yangyang@DESKTOP-SGNIV47:~/test1$ cp -f file2-1 ../test2##cp -f强制拷贝文件
    

    文件剪贴:mv

    yangyang@DESKTOP-SGNIV47:~/test1$ mv file1-1 ../test2
    yangyang@DESKTOP-SGNIV47:~/test1$ cd ../test2
    yangyang@DESKTOP-SGNIV47:~/test2$ ls
    file1-1  file2-1  file2-2
    

    文件重命名:mv

    yangyang@DESKTOP-SGNIV47:~$ mv test1 test3 #把文件夹test1改名为test3
    

    查看文件类型:file

    yangyang@DESKTOP-SGNIV47:~/test1$ file file1-2
    file1-2: empty
    ##此处略vi给文件编辑上内容
    yangyang@DESKTOP-SGNIV47:~/test1$ file file1-2
    file1-2: ASCII text
    

    Linux 文件内容查看
    cat 由第一行开始显示文件内容
    tac 从最后一行开始显示,可以看出 tac 是 cat 的倒著写!
    nl 显示的时候,顺道输出行号!
    more 一页一页的显示文件内容
    **less 与 more 类似,但是比 more 更好的是,他可以往前翻页!
    head 只看头几行
    tail 只看尾巴几行

    相关文章

      网友评论

          本文标题:Linux OS 常规操作

          本文链接:https://www.haomeiwen.com/subject/ogkvvqtx.html