`
DavyJones2010
  • 浏览: 155156 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

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.

 

 

分享到:
评论

相关推荐

    Linux for Beginners: An Introduction to the Linux Operating System

    The basic Linux commands you'll use most often. Creating, renaming, moving, and deleting directories. Listing, reading, creating, editing, copying, and deleting files. Exactly how permissions work ...

    Linux for Developers

    ### Linux for ... this book provides a comprehensive introduction to Linux programming, covering a wide range of topics from command line basics to advanced scripting and programming techniques.

    Wiley.Publishing.Fedora.Linux.Toolbox.1000+.Commands.for.Fedora.CentOS.and.Red.Hat.Power.Users.and.Red.Hat.Power.Users.2008.pdf

    - **Understanding the Command Line**: Basic concepts and terminologies used in the shell environment. - **Navigating Directories**: Moving around the file system using commands like `cd`, `ls`, and `...

    The_Linux_Networking_Architecture

    Basic Structure of Traffic Control in Linux 367 Section 18.3. Traffic Control in the Outgoing Direction 367 Section 18.4. Kernel Structures and Interfaces 369 Section 18.5. Ingress Policing 378...

    Linux Shell Scripting Cookbook

    Introduction 7 Printing in the terminal 9 Playing with variables and environment variables 12 Doing math calculations with the shell 17 Playing with file descriptors and redirection 19 Arrays and ...

    The.Linux.Networking.Architecture

    Basic Structure of Traffic Control in Linux 367 Section 18.3. Traffic Control in the Outgoing Direction 367 Section 18.4. Kernel Structures and Interfaces 369 Section 18.5. Ingress Policing ...

    Linux System Administrator Guide Version0.9

    #### Introduction The Linux System Administrator’s Guide Version 0.9 is a comprehensive resource aimed at helping new and experienced system administrators understand the nuances of managing Linux ...

    Ubuntu Pocket Guide and Reference: A concise companion for day-to-day Ubuntu use

    - **Scripting Basics**: Introduction to basic scripting concepts and examples of simple scripts are included. **Software Management** - **Package Management**: The book covers package management ...

    unix power tools 3ed.pdf

    **1.1 引言 (Chapter 1: Introduction)** - **目标**: 介绍Unix的基本概念和发展历史。 - **内容**: 解释Unix的基本特性和优势,包括其对开发者友好性、稳定性和可移植性。 **1.2 获取帮助 (Chapter 2: Getting ...

    Linux高级bash编程

    A Detailed Introduction to I/O and I/O Redirection F. Standard Command-Line Options G. Important Files H. Important System Directories I. Localization J. History Commands K. A Sample .bashrc File L. ...

    geronimo-book.pdf

    #### Introduction Apache Geronimo is a robust and flexible open-source Java EE (previously known as J2EE) application server. The "geronimo-book.pdf" provides detailed guidance on installing, ...

    apache hbase reference guide

    - **Introduction**(介绍):Apache HBase 是一个分布式的、可扩展的大数据存储系统,基于Google的Bigtable论文实现。它提供了高可靠性、高性能、面向列的数据存储能力。适合于存储海量半结构化/非结构化数据。 - ...

    impala-2.8

    #### Introduction to Apache Impala (Incubating) Apache Impala is a high-performance, distributed SQL query engine that enables fast, interactive SQL queries on data stored in Apache Hadoop's HDFS, ...

    python3.6.5参考手册 chm

    PEP 389: The argparse Module for Parsing Command Lines PEP 391: Dictionary-Based Configuration For Logging PEP 3106: Dictionary Views PEP 3137: The memoryview Object Other Language Changes ...

    Python4DelphiPart-1-7139726.pdf

    - **Usage in Console Applications**: Python for Delphi can be used in console applications, making it suitable for command-line tools and scripts. - **Lazarus/FPC Support**: There is also support for ...

    Complete Guide to Open Source Big Data Stack-Apress(2018).pdf

    It would be useful to have some basic knowledge of Centos Linux and Scala. But don’t be deterred if you don’t; I believe that if you are interested in these topics and willing to learn, you will ...

Global site tag (gtag.js) - Google Analytics