zoukankan      html  css  js  c++  java
  • linux常用命令

    1.ls命令

    ls命令是列出目录内容(List Directory Contents)的意思。运行它就是列出文件夹里的内容,可能是文件也可能是文件夹。

    1 root@tecmint:~# ls
    2  
    3 Android-Games                     Music
    4 Pictures                          Public
    5 Desktop                           Tecmint.com
    6 Documents                         TecMint-Sync
    7 Downloads                         Templates

    “ls -l”命令以详情模式(long listing fashion)列出文件夹的内容。该命令功能同"ll"。

     1 root@tecmint:~# ls -l
     2  
     3 total 40588
     4 drwxrwxr-x 2 ravisaive ravisaive     4096 May  8 01:06 Android Games
     5 drwxr-xr-x 2 ravisaive ravisaive     4096 May 15 10:50 Desktop
     6 drwxr-xr-x 2 ravisaive ravisaive     4096 May 16 16:45 Documents
     7 drwxr-xr-x 6 ravisaive ravisaive     4096 May 16 14:34 Downloads
     8 drwxr-xr-x 2 ravisaive ravisaive     4096 Apr 30 20:50 Music
     9 drwxr-xr-x 2 ravisaive ravisaive     4096 May  9 17:54 Pictures
    10 drwxrwxr-x 5 ravisaive ravisaive     4096 May  3 18:44 Tecmint.com
    11 drwxr-xr-x 2 ravisaive ravisaive     4096 Apr 30 20:50 Templates

    "ls -a"命令会列出文件夹里的所有内容,包括以"."开头的隐藏文件。

     1 root@tecmint:~# ls -a
     2  
     3 .           .gnupg          .dbus           .goutputstream-PI5VVW       .mission-control
     4 .adobe                  deja-dup                .grsync                 .mozilla                    .themes
     5 .gstreamer-0.10         .mtpaint                .thumbnails             .gtk-bookmarks              .thunderbird
     6 .HotShots               .mysql_history          .htaccess       .apport-ignore.xml          .ICEauthority          
     7 .profile                .bash_history           .icons                  .bash_logout                    .fbmessenger
     8 .jedit                  .pulse                  .bashrc                 .liferea_1.8                .pulse-cookie           
     9 .Xauthority     .gconf                  .local                  .Xauthority.HGHVWW      .cache
    10 .gftp                   .macromedia             .remmina                .cinnamon                       .gimp-2.8
    11 .ssh                    .xsession-errors    .compiz                 .gnome                          teamviewer_linux.deb         
    12 .xsession-errors.old    .config                 .gnome2                 .zoncolor

    注意:在Linux中,文件以“.”开头的就是隐藏文件,并且每个文件,文件夹,设备或者命令都是以文件对待。ls -l 命令输出:

    1. d (代表了是目录).
    2. rwxr-xr-x 是文件或者目录对所属用户,同一组用户和其它用户的权限。
    3. 上面例子中第一个ravisaive 代表了文件文件属于用户ravisaive
    4. 上面例子中的第二个ravisaive代表了文件文件属于用户组ravisaive
    5. 4096 代表了文件大小为4096字节
    6. May 8 01:06 代表了文件最后一次修改的日期和时间
    7. 最后面的就是文件/文件夹的名字

    2.sudo命令

    sudo”(super user do)命令允许授权用户执行超级用户或者其它用户的命令。通过在sudoers列表的安全策略来指定。

    1 root@tecmint:~# sudo add-apt-repository ppa:tualatrix/ppa

    注意:sudo 允许用户借用超级用户的权限,然而"su"命令实际上是允许用户以超级用户登录。所以sudosu更安全。

    并不建议使用sudo或者su来处理日常用途,因为它可能导致严重的错误如果你意外的做错了事,这就是为什么在linux社区流行一句话:

    ''To err is human, but to really foul up everything, you need root password.''

    “人非圣贤孰能无过,但是拥有root密码就真的万劫不复了。”

    3.mkdir命令

    mkdir”(Make directory)命令在命名路径下创建新的目录。然而如果目录已经存在了,那么它就会返回一个错误信息"不能创建文件夹,文件夹已经存在了"("cannot create folder, folder already exists")

    root@tecmint:~# mkdir tecmint

    注意:目录只能在用户拥有写权限的目录下才能创建。mkdir:不能创建目录`tecmint`,因为文件已经存在了。(上面的输出中不要被文件迷惑了,你应该记住我开头所说的-在linux中,文件,文件夹,驱动,命令,脚本都视为文件)

    4.pwd 命令

    pwd”(print working directory),在终端中显示当前工作目录的全路径。

    1 root@tecmint:~# pwd
    2  
    3 /home/user/Desktop

    注意: 这个命令并不会在脚本中经常使用,但是对于新手,当从连接到nux很久后在终端中迷失了路径,这绝对是救命稻草。

  • 相关阅读:
    codec功能简介
    dtmf原理说明
    linux的vm.overcommit_memory的内存分配参数详解
    Hibernate与Sleep的区别
    简单的读写-simple_read_from_buffer
    linux delay sleep
    Linux系统上的popen()库函数
    Linux中popen函数的作用小结
    ulimit 命令详解
    LTE Cat1有什么用?基于4G LTE打造cat1,弥补NB-IoT和5G的空缺
  • 原文地址:https://www.cnblogs.com/songshu120/p/4930375.html
Copyright © 2011-2022 走看看