Linux入门级概念理解和tips

本文深入解析了Linux操作系统的组成,包括GNU项目、Linux内核与shell的关系,以及主流发行版如Debian和RedHat的衍生系统。阐述了文件权限、路径指定等基本操作,并介绍了.bashrc和.bash_profile文件的使用,最后详细说明了top命令的功能与用法。
  1. Linux General Info:
    Linux OS is actually a combination of the GNU project (providing all the quirks and features wrapping around the kernel such as file systems and package managers) and the Linux shell.
    So, when referring to Linux, it generally means the Linux shell + GNU features. 

  2. The linux hierarchy: Forks and distributions 
    Forks are on a higher level, different forks each contain their own hierarchy of distros.
    Main forks originate from the very early GNU Linux are: Debian, Red Hat, Packman, Gentoo, Slackware
    The most popular forks, i.e. Debian & Red Hat, contains distros of:
    (1) Debian: 
    Ubuntu, Mint, BackTrack, Kali
    (2) Red Hat: 
    CentOS, Fedora, OpenSUSE, ManDrake;
    Different forks may have different commands. For instance, for Debians (Ubuntu) the package is installed with apt-get, while for Red Hat, it is yum.

  3. The Permissions of files (users, groups):
    Groups in linux are groups of users, each group specifies a special set of permissions, users in the group conform to that set of permissions of the group.
    Each file or folder has a _ _ _ three digits, each ranging from 1 to 7. They denote the permission for the file owner, the group owner, and everybody, respectively;
    1 - 7 is actually the sum of:
    1= execute;
    2= write;
    4= read;
    So, if a file is marked as 7, then 7 = 1 + 2 + 4 meaning u can do anything to this file;
    To change the permission on a file,
    $ sudo chmod 7 file_A, give file_A the maximum permision

  4. Specify the path within Linux file system:
    FIrstly of all, think of the path as a string, which is a concatenation of characters & directory names.
    There are four important characters which denote specific directories:
    (1) / denotes the root directory (cd / will take your to the root directory, if cd /some_directory, then this directory must be directly located within the root directory) (NOTED: if / appears in front, then it means root: /home means the home directory which directly locates in the root directory; yet if it appears in the back, i.e. home/, it means the home directories and all its sub-directories)
    (2) ~ the user's home directory (cd ~ will take me to /home/jasper/ on my machine)
    (3) . the current directory (cd . will do nothing, just stay in the current directory) (NOTED: if ./, it means the current directory and all its subdirectories, yet if .file_name, it means this file is hidden, need to be shown with $ls -a)
    (4) .. the directory one level higher (cd .. will take you one-step higher into the file hierarchy)
    For instance, ~/.bashrc means the hidden bashrc file stored directly in the home directory

  5. About the .bashrc and .bash_profile files:
    These two files are both hidden files, containing executable shell commands to configure your bash (Bourne Again Shell, when you open up a terminal on a Linux machine, a shell is activated. A shell is a program (with its own commands) to help your communication with the linux kernel.)
    .bashrc is interactive non-login shells while .bash_profile is for login shells, meaning whenever you log-into your system with username and passwords, shell commands stored in the .bash_profile will be sequentially executed. While for .bashrc, commands contained within need to be executed via type in the following command into your terminal $ source ~/.bashrc (.bash_profile can be executed similarly as well)
    The most common usage of .bashrc and .bash_profile files are to modified the $PATH (use command $ echo $PATH to see the PATH of your own system) of the system. $PATH is a list of directories that contains binary executables of commands(applications) (such as ls, python, python3, etc). The shell will check over directories in $PATH to look for the executable to execute a particular command(application) when it is called.
    Applications can be installed in different locations in the system (all kinds of /bin directories that are for binary executable, such as /bin, /usr/bin, /usr/local/bin/, /home/user_name/anaconda3/bin, etc), through different methods (sudo apt-get install, pip install, conda install, install with downloader installers, etc)
    If one application (say your have multiple python installed on you machine through different sources) has multiple executables exist on your machine, then the one whose directory appears more earlier in the $PATH will be called, things come after will not be examined. 
    So, whenever a new application is installed, the $PATH should be modified using .bashrc or .bash_profile. paths that are exported later near the bottom within the .bashrc file will appear more early in $PATH, thus the corresponding executable has higher priority to be called.

  6. The top command usage:
    the top command is a linux buit-in application to monitor the processes being run on the machine. this command has various arguments. It can be called directly with an argument, such as top -u user_name, or start-up by calling top, then directly type in the argument u, then type in the following parameters.
    (1) top -u user_name:shows the processes of one particular user;
    (2) top -c :show absolute path of processes;
    (3) top -k PID then hit Enter twice, kill a process with the given PID;
    (4) top -p PID: shows details of a process with PID;
    (5) = : return normal state within top after execute a particular argument, without exiting top altogether. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值