ตั้งค่าการอ่าน

ค่าเริ่มต้น

  • เลื่อนอัตโนมัติ
    Easy Programing

    ลำดับตอนที่ #2 : Command Line Ⅰ - File Structures

    • อัปเดตล่าสุด 31 ธ.ค. 61


    Moving Between Directories

    File Structure

              When using the command line, it is important to be aware of the file structure. In our example file structure below, we have many branches. For example, the progate directory contains files and directories like about.txt and the languages ​​directory. Inside the languages ​​directory is the index.txt file.


    Current Directory

              On the command line, the directory that you're currently in is called the current directory. When you execute the touch command, for example, the file is created in the current directory. If you want to create a new file in the html directory, you need to create it after changing the current directory to the html directory.


    cd

              You can use the cd command to move to other directories. By entering cd directory_name, you can move to the specified directory.


    The Current Directory

              The current directory is displayed to the left of $. (It is ~ in the progate directory, but don't worry about it for now. We'll explain it in detail later.)


    Error

    You'll get an error if you specify a directory that does not exist with the cd command. Also, note that you can only specify a directory name, not a file name.



    Checking the Current Directory

    Root Directory

              In the file structure of a computer, there is a root directory at the very top. The root directory is represented by /. (Note that the root directory is omitted in the file structure of the exercise screen.)


    Checking the Current Directory

              On the command line, it is important to know the directory you are currently working in. There is a command called pwd to check that. When you execute the pwd command as shown below, all directories from the root directory to the current directory are displayed.



    Displaying a list of files

    Displaying the Content of the Directory

              When moving between directories, it would be convenient if we could see the list of files and directories in the current directory. To do this, you can use the ls command as shown below.


    What is displayed by "ls"

              Note that the ls command will only display the directories and files that are directly under the current directory.



    The Parent Directory

              We've learned how to use the cd command, but you don't know how to move to the parent directory yet. If you want to move to the parent directory, you can use a special symbol .. , like cd .. .



    The Home Directory

    cd without Specifying a Directory

              If you execute cd without specifying a directory, you can move to what is called a home directory. The home directory is represented by ~ like in the image below.


    The Home Directory

              The home directory refers to the base directory for the user. Since it is important, moving to the home directory is made to be easy. /home/progate is the home directory for this lesson.





    ติดตามเรื่องนี้
    เก็บเข้าคอลเล็กชัน

    ผู้อ่านนิยมอ่านต่อ ดูทั้งหมด

    loading
    กำลังโหลด...

    อีบุ๊ก ดูทั้งหมด

    loading
    กำลังโหลด...

    ความคิดเห็น

    ×