ubuntu Linux operating system tutorial (study notes)

This article "Ubuntu Linux operating system Guide" (Posts and Telecom Press) personal study notes.

Chapter 1 - Introduction System

The relationship between Linux, GNU, GPL, the major release of Linux, the Linux system characteristics and differences with Windows, slightly

Chapter 2 - System Deployment

  1. Installation - slightly, with reference to the virtual machine installation and dual system (win10 + ubuntu) Installation and other
  2. About --Grub Grub program is a boot loader
    • Grub configuration - set the default startup system such as that, sudo gedit /etc/default/grub(using gedit to edit the corresponding file); modified file is saved using sudo update-grubupdate
    • Grub Repair - After installing a new system covers the needs repair Grub bootloader; U starting from the reference disk ubuntu-- ubuntu mounting portion - and then execute the following commands:
    grub
    find /boot/grub/stage1
    root (hdx,y)
    setup (hd0)
    quit
    
    Specific meaning not much explanation, I have not used, reference books P19 (version 2017)
  3. Linux initialization, hardware settings, desktop environment, graphics operations, slightly simple.

Chapter 3 - Application Management

office, browser, multimedia, e-mail, printers and other use, simple slightly.

Chapter 4 - Basic Commands

1. combine personal understanding

Everything is a file in Linux, Linux supports multiple users, user is the user files of any of the files that the user has three categories - owner, is a group of users with other users (of course on top of these three classes of users also there is a super user root, root user has all permissions of all files), each type of user has permission to perform different operations on the file. File permissions to perform operations there are three r, w, x, are read (Read), writing (Write), execution (eXecute) permission.

Different types of files (the last chapter has introduced seven types of files), these three rights meaning there are some differences -

  1. For directory files, read permission means you can list the current directory permissions to all subdirectories and files, write means you can create, delete file permissions, execute permission means you can enter the directory (cd command to enter the directory), so execute permissions is the most basic of rights;
  2. For ordinary files, read permission means you can read the contents of the file, write permission means you can write to the file, execute permission means you can execute the file - an executable file common file (ie binary machine instructions, etc.) to is called the user, the user needs to have execute permissions; and general than its executable file execute permission does not make sense.

User access to a file can ls -lsee when it lists file -lparameter specifies the detailed information about the file that is listed first letter string 10, for example drwxr-xr--, the first letter indicates the type of file, as described in commonly used commands the seven types; the next three letters user rights owner, after a group of users is three permissions, user privileges after the other. Change the file's owner, is a group can refer to frequently used commands , user management (add, delete, group) can refer to Chapter 5 command.

2. The list of frequently used commands (memory)

  1. man command - the command line to view the manual, man 命令see the command usage

  2. Directory Operations

    • Create a directory--mkdir

    • Delete the directory -rmdir

    • Modify Create a file -touch

    • Delete Files--rm

    • mobile--mv

    • copy--cp

    • Jump directory - cd(Print Catalog pwd)

  3. File Viewer ls- cat, head, tail, more, ,less

  4. authority management

    • Permissions represent - nine characters, three octal, binary number nine - meaning access to the directory and file
    • Change authority - chmodauthority digital file name
    • Add or delete a user group permissions, give permission - chmod [u/g/o/a][+/-,=][r/w/x] 文件名- chmod g+w fileto other users write access to the file increases the file (otherwise -the usage of minus authority); chmod u=rwx fileto owner user permissions to rwx; chmod g=u fileto a group of users and set permissions owner users same
    • Only the root user and file owner has to change the permissions of qualifications
    • Changing ownership change group (only the root user has the authority) - chown,chgrp
  5. Link file - create a link:ln -s file file-link

    There are seven file types -

    • Regular file (-);
    • Directory (D);
    • Character device file (c);
    • Block device file (B);
    • This local socket (S);
    • Named pipe (P);
    • Symbolic links (l)
  6. File redirection -

    • Input Redirection - <Instant input; <<block input;
    • Output redirection - >coverage output; >>additional output
  7. File search

    • File Finder - find 路径 -name 文件名 -type 文件类型in front
    • Find --which command command
  8. Pipe - redirected expansion, as the output of a command input of another command - such as ls|grep ay, the file name of the current directory are listed, and as the input of a command; a command to find the file name contains ay of character

View more use man command usage!

A personal understanding supplement -
for example, the following command with a general user useradd aliceto add a user alice (of course, in accordance with common sense knows the add operation user is not a general user can perform) found it impossible to execute, execute which useraddto view the command in that folder ( in the /usr/sbin/case), then ls -l /usr/sbin/useraddview the executable file permissions to rwxr-xr-xexplain even the general users also have execute permissions, but can not be executed. Observation error when the command is executed -

useradd:Permission denied
useradd:无法锁定 /etc/passwd,请稍后再试

Can be found with the /etc/passwdpermissions of the file related to the use of ls -l /etc/passwdits file permissions for the rw-r--r--description of the file for the average user has only read access. In fact here because useraddthe command needs to /etc/passwdadd content ( /etc/passwdthe system to save the user's account, password, id, groups and other profile information), and the general users of the file does not have write permission. Linux, everything is a file, the command is executed files, so no permission to execute a command is actually no permission to execute this command script, or the command during the execution of the required changes to a user's files without permission change.

Chapter 5 - User Management

  • Add User - sudo useradd [-g 组id] -m 新用户名- M represents the creation of the home directory is not created you can not use the graphical interface
  • change the password--sudo passwd 用户名
  • View user names and group names -id 用户名
  • Delete user - - sudo userdel 用户名add parameters -rindicate also delete the user's home directory, to determine the home directory is not important files
  • Add Group -sudo groupadd [-g gid] 组名
  • Delete Group -sudo groupdel 组名
  • Add users to the group -sudo usermod -g 组名 用户名
  • Switch the current user - - /bin/su 用户名without a user name to switch to the root user; ubuntu can not switch to the root user, it can only be used sudoto borrow root user privileges
  • Switch back to the original user - exit- suSwitching to switch users only, and has not changed environment
  • Switch to another user to perform identity - - sudo [-u 用户名] 执行的命令does not give the user name to switch execution to the root user, /etc/sudoersfile determines what each user can switch to the user on which machines which commands execution
  • View user and group - cat /etc/passwdandcat /etc/group
  • Print command history history [n]- --N n indicates the most recent command

Chapter VI - Process Management

  • Process display -
    • ps aux- Show all processes
    • ps lax- show all processes, the field is not the same, there is the parent process and humility of information
    • top- Real-time (in fact 3s refresh) display and memory before occupancy CPIU few
    • Display process field --USER create user; PID process ID;% CPU,% MEM as a percentage of CPU and memory footprint; VSZ the virtual memory size; the number of RSS pages in memory (a typically 4K); TTY terminal id number; STAT process state (R running, D sleep, S sleep, T terminates, Z zombie, notation: <, N, L, s); sTART start time; the tIME CPU time; the cOMMAND command and parameters
  • Kill the process -
    • kill pid- kill process id of pid, but sends a signal to the pid process EXIT, exit in most cases; however this process may capture the signal and ignore (if you do not capture the default process exits), such as command line command the default is ctrl + c to send a command to the current process INT (interrupt) signal, but the execution bccommand that captures the signal and ignore
    • kill 信号 pid- sends a signal process pid, ( kill -llisted signals may be sent to the process, these signals are beginning SIG, case-insensitive when used, can be omitted and the preceding SIG)
    • sudo kill -KILL pidAlternatively sudo kill -SIGKILL pidor sudo kill -9 pidkernel-level "kill" process, the signal can not be captured, so the vast majority of cases can kill the process; not enough can only be restarted
    • killall -HUP pnameKill name pname process
  • Priority setting process
    • nice -n 谦让度 执行的命令- Set command execution of humility, where a degree of humility value opposite (relative to the parent process), the higher the priority of humility lower
    • renice 谦让度 -p pid- to reset the process of humility, here is the absolute value of humility
      • Humility is an integer of from -20 to 19 degrees, and can only increase its priority to reduce the degree of humility, humility not reduce the degree of priority is increased (prevented from subprocess higher priority than the parent process occurs); however with root privileges can increase its priority level
  • PROCFile system - in at runtime /procdirectory (which exists only in memory, no external memory on the computer catalog) has named digital folder, save process-related information, the folder name is the process id, by changing here the relevant documents can change the course of acts (here is equivalent to process the file, the access to relevant professional books); pscommand that is accessing the file information acquisition process

Chapter 7 - Disk Management

  • See partition - device information stored in the file / dev directory, SCSI hard disk file in the directory name of the file is sd, a second hard disk SDA, the second block so sdb; hard disk partition is sda1, sda2 such primary partitions 1 to 4, after five logical partition; available ls /etc/|grep sdto view the hard disk partition information
  • Partition - fdiskThis command is an interactive command-line operation, enter the appropriate command partition ( n), print partition type ( print), change the partition type ( type), to view the available commands ( m), view the partition type numbers ( L), etc., each execution command may need to ask the user the appropriate command parameters during execution (such as the partition from which the fan start, whether primary partition, etc.); need to enter after the completion of the partition writecommand to take effect written to disk, and then qquit fdiskthe interactive command - directly install U disk partition easier visualization
  • Check each domain disk space usage -df
  • Check each directory size -du

Chapter VIII - Package Management

  • RPM (Red Hat Package Manager) and DEB (Debian) - are package management tools
  • APT package management tool - is the most mature package management tool that can automatically download, install software, and resolve their dependencies (Download source /etc/apt/sources.listfile is specified, you can view this file to see what there is to add download source and modify custom Download source); the main apt-getcommand and apt-cachecommand, use sudoadd the following command:
    • apt-get install 软件名--installation
    • apt-get upgrade 软件名- Update existing software
    • apt-get remove 软件名- to uninstall the software
    • apt-get purge 软件名- Remove and purge files
    • apt-get source 软件名- Get software source code
    • apt-get clean 软件名- Clean the downloaded package file

Chapter 9 - Task Scheduler

  • at- setting the timing of a single task, such as
    • at 16:00--enter After you enter the command to be executed, will perform at 16:00
    • at now +5 minutes- will perform in five minutes
    • at 17:00 -f ~/alarm- executes the script in the current directory alarm at 17:00
    • at 3:00 12/09/2019- After you enter the command at that point in time
    • atq- lists all current-time regular tasks
    • atrm n- Clear number within a single timer task
  • crontab-- in /etc/crontabadding the file system management tasks related to the timing, i.e. effective to save the file; in /etc/cron.d/adding the timer task application directory, the job file and the application timing of the same name as the system configuration as a timing task; in var/spool/cron/crontabs/CV's user directory Timing task profile, as follows:
    • crontab filename- The installation file filename for the user's crontab file (to be re-installed after each change to take effect)
    • crontab -e- edit the user's crontab file
    • crontab -l- List the contents of the user's crontab file
    • crontab -r- delete the user's crontab file
    • About editing crontab file - usually in the first few lines of the file comment will explain (such as / etc / cron file), the general line of a task, each task each column are provided m h dom mon dow user command(ie, minutes, hours, day of the month, the first few months, days of the week, the identity of the user to perform tasks, command execution) per week, as 0 0 * * * root (tar czf /media/disk/passwd.tar.gz /etc/passwd)that is a daily 0:00 packages as root / etc / passwd file backup files on the disk tray passwd.tar.gz

Chapter X - Network Management

I do not understand, the original reference books or other articles.

Chapter XI - to build the network services

Chapter XII - Security Settings

Chapter 13 - Programming Development

Published 28 original articles · won praise 14 · views 20000 +

Guess you like

Origin blog.csdn.net/liyunxin_c_language/article/details/103362824