Console for the beginner. Part 1.

    Part 1. Part 2 .

    In this post, I will try to get to know newcomers to the Linux console based not so much on theory as on practical examples.

    In order to get to the console, you can press Ctrl + Alt + F1, and to go back to your graphical environment - Alt + F7. Or simply use the graphically proposed solution in your main menu.

    And so dear reader, you entered the console. The first thing to feel more comfortable is to look around, for this we will execute the pwd command :
    vir @ home: ~ $ pwd
    / home / vir

    With this command, we determined in which directory we are currently located (i.e. which directory is currently working). In my case, this is my home directory. By the way, pwd, if my memory serves me, is decrypted exactly as - print work directory (print / display the working directory)

    Further, it would be nice to know what we have in it? To do this, use the ls utility :
    vir @ home: ~ $ ls
    Images Other Work Desktop

    After executing the ls command, we see a list of files and directories located in the same (/ home / vir) working directory. And the ls command is called, from the abbreviated list (list).
    Probably, it is here that it is worth noting that most of the commands can be used with keys (options) and parameters. Again, let's look at an example:
    vir @ home: ~ $ ls -l
    total 0
    drwxr-xr-x 3 vir vir 80 2008-07-06 11:30 Images
    drwxr-xr-x 3 vir vir 72 2008-07-06 14:30 Other
    drwxr-xr -x 3 vir vir 80 2008-07-06 11:59 Work
    drwxr-xr-x 2 vir vir 48 2008-07-15 11:41 Desktop

    Here I used the -l switch , which let ls know that I want a detailed answer, i.e. in this case, in addition to the list of directories, I also received such data as: attributes of rights, owner, date of the last change, and so on. Now let's try passing the parameter to the ls command:
    vir @ home: ~ $ ls / var /
    backups cache crash games lib local lock log mail opt run spool tmp

    As a parameter, I passed the directory / var /. Those. the result of the command was to display all the directories and files that are in the / var directory. Thus, you may notice that it is not necessary to be in a specific directory in order to view its contents.

    Now, without moving far from the ls command, we can talk about file and directory paths in Linux. Linux paths can be relative and absolute. The root (parent) of the entire directory tree is the " / " directory . It is from her that everything begins (for example, / home / vir). Now for an example:
    vir @ home: ~ $ ls
    Images Other Work Desktop
    vir @ home: ~ $ ls Images /
    Wallpapers
    vir @ home: ~ $ ls / home / vir / Images /
    Wallpapers

    The first command, I again look at the list of directories and files that are in my home directory, one of them is the Images directory. The second time I look at the list of files and directories for Images using the relative path, the path that starts from my working directory (pwd). That is, being in the directory / home / vir / I can specify the relative path for Images. And in the third example, I specify the full (absolute) path from the root (/ home / vir / Images), which does not depend on my working directory.

    To change our working directory, we will use the cd command . Example:
    vir @ home: ~ $ cd Images /
    vir @ home: ~ / Images $ pwd
    / home / vir / Images
    vir @ home: ~ / Images $ cd / var
    vir @ home: / var $ pwd
    / var

    I think everything is clear here, the only thing worth saying is that to go up one directory above, we don’t need to indicate its hard path, we can freely use two points " .. ". Example:
    vir @ home: ~ / Images $ pwd
    / home / vir / Images
    vir @ home: ~ / Images $ cd ...
    vir @ home: ~ $ pwd
    / home / vir


    Now you can safely drift through the open spaces of your file system using the console. This concludes the first part of a series of articles entitled “Console for a Beginner”. Wait for the sequels. Thanks for attention.

    Also popular now: