Linux: Basic Command Introduction

1. File Name convention:

    1) All characters except '/' are regarded as legal as '/' is used for file path delimeter.

    2) Space, Tab, Backspace, @, #, $, &, (, ) and - are not recommanded to be used as file name.

    3) Do not use '.' as the first character of file name. Because file name starts with '.' is regarded as hidden file.

    4) File name is case sensitive. Linux is case sensitive.

 

2. Basic comman format:

    1) Command -Options Params

        Eg: ls -al /etc

        1) When we have multiple options, we can put them together.

        2) . represents current folder and .. represents parent folder.

    2) Command can be categorized into two kinds:

        1) root command

            usually stored in /sbin or /usr/sbin folder with the format of binary file.

        2) user command

            usually stored in /bin or /usr/bin folder with the format of binary file.

 

3. Command Intro:

    1) Command Name: ls

        Command Derived From: list

        Command Path: /bin/ls

        Command Permission: all users

        Command Description: show all the dirs and files in current path

        Command Syntax: ls [-ald] [file or dir]

                                    a: Show all files including hidden files.

                                     l: Show detail information

                                    d: Show current folder properties

         Result Sample:

                   drwxrwxr-x  6 administrator administrator      4096 Aug 17 23:25 apache-maven-3.1.0

                   -rw-rw-r--  1 administrator administrator   5439122 Aug 17 23:24 apache-maven-3.1.0-bin.tar.gz

         Explaination:

             1) The first letter: Means the file format.

                  'd' means Directory.

                  '-' means Binary file.

                  'l' means soft link file.

             2) The following 9 letters: Means the authority of three kind of user.

                  File owner(u) -> The user that created the file/folder. And it can also be transfered to another person.

                  User group(g) -> The user group that has the right of controlling this file.

                  Others(o) -> ...

             3) The digit 6 or 1 means the hard link count. Will explain later.

             4) The following 'administrator' means the owner of this file.

             5) The following 'administrator' means the belonged group of this file.

             6) The following '4096' and '5439122' means the size of this file/folder. But this is not accurate when applied with folder size.

             7) The timestamp means the file creation date or last modified date.

 

    2) Command Name: cd

        Command Derived From: change directory

        Command Path: shell imbeded command

        Command Permission: all users

        Command Description: change current directory

        Command Syntax: cd [path]

        Example:

              cd /      change to root folder

              cd ..     change to parent folder

 

    3) Command Name: pwd

        Command Derived From: print working directory

        Command Path: /bin/pwd

        Command Permission: all users

        Command Description: show current direcory

        Command Syntax: pwd

       

    4) Command Name: mkdir

        Command Derived From: make directories

        Command Path: /bin/mkdir

        Command Permission: all users

        Command Description: create new directory/folder

        Command Syntax: mkdir [dir name]

        Example:

             mkdir /test -> Make directory under the context of root folder.

             mkdir test -> Make directory under the context of current working directory.

   

    5) Command Name: touch

        Command Path: /bin/touch

        Command Permission: all users

        Command Description: create a new blank file

        Command Syntax: touch [file name]

        Example:

              touch newfile

 

    6) Command Name: cp

        Command Derived From: copy

        Command Path: /bin/cp

        Command Permission: all users

        Command Description: copy file or folder

        Command Syntax: cp  -R [source folder name] [dest folder name]

                                              [source file name] [source file name] ... [dest folder name] [dest folder name] ...

        Example:

              cp Test.java ..

              cp Test1.java Test2.java Test3.java ..

    7) Command Name: mv

        Command Derived From: move

        Command Path: /bin/mv

        Command Permission: all users

        Command Description: move file/folder location; rename file/folder

        Command Syntax: mv [source folder name] [dest folder name]

                                              [source file name] [source file name] ... [dest folder name] [dest folder name] ...

         Example:

              mv Test.java Test1.java --> Rename

              mv /home/administrator/Test/Test1.java  /home/administrator/Test2.java --> Move & Rename

              mv Test Test1 --> Rename folder

    8) Command Name: rmdir

        Command Derived From: remove directory

        Command Path: /bin/rmdir

        Command Permission: all users

        Command Description: delete empty folder

        Command Syntax: rmdir [source folder name]

        Example:

              rmdir Test --> It is only applied to empty folder. So its usage is highly restricted.

 

    9) Command Name: rm

        Command Derived From: remove

        Command Path: /bin/rm

        Command Permission: all users

        Command Description: delete file or folder

        Command Syntax: rm  -r [source folder name or source file name]  -> When we remove some files, there may be a prompt that ask for confirmation.

                                              -f [source folder name or source file name]  -> Mean 'force delete', there is no prompt for confirmation. It benefits the automatic scription.

        Example:

              rm Test.java  --> Delete single file

              rm -r Test1    --> Delete folder that may not be empty. But there may be prompts for every single file inside this folder asking for confirmation which is annonying.

              rm -rf Test1   --> Delete folder that may not be empty.

P.S

    1) The minimum store unit in Linux is data block with the size of 512Byte.

         But we can customize the data block size.

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值