Experimental Building Linux Learning

Source: Internet
Author: User
Tags gz file extract rar file rar stdin unpack rsyslog

Experimental Building Linux Learning    Linux User Management 1. View user who am I//who mom likeswhoami ====--------====== The first column of the input indicates the user name of the user who opened the current pseudo-terminal (to see the user name of the currently logged-in user, to remove the space directly using WhoAmI), and the second column pts/0 in the pseudo-terminal, so-called pseudo is relative to the/dev/tty device, Remember the last section of the terminal when the seven using [CTRL]+[ALT]+[F1]~[F7] to switch the/dev/tty device, this is the "real terminal", pseudo-terminal is when you use the GUI in the graphical user interface/dev/tty7 each open terminal will produce a pseudo terminal, pts/ 0 after that number is the open pseudo-terminal number, you can try to open a terminal, and then enter the Who am I, see if the second column becomes PTS/1, the third column indicates the current pseudo-terminal start time = = =---------=====2. Create user sudo AddUser Lilei//wear a user  ====---------= = Follow the prompts to enter the Shiyanlou password (Linux password input is usually not visible), and then to the Lilei user set the password, Some content of the following options you can choose to use the default value for direct return: = = = = = =--------====  su-l lilei switch to User state  3. How do user groups know which user groups they belong to in Linux? Method One: Use the groups command groups Shiyanlou method Two: View/etc/group file Cat/etc/group | sort  add other users to sudo user group #su-l lilei#sudo lssu shiyanlougroups lileisudo usermod-g sudo lileigroups lilei remove user sudo delus Er lilei--remove-home  Second, Linux file permissions 1. View file permissions ls-a view hidden files ls-al ls-dl < directory name >//View the full properties of a directory, Instead of displaying the file attributes in the directory: LS-ASSH displays all file sizes and renders in a way that ordinary humans can understand, where small s is the size of the display file, big STo sort by file size, if you need to know how to sort by other means, use the "man" command to query. 2. change file owner sudo chown shiyanlou iphone6 3. modify file permissions chmod iphone6 linux directory structure and file basic operation one, Linux directory structure 1. FHS Standard//File system hierarchy Standard FHS defines the two layer specification, the first layer is,/below the directory should be put what file data, such as/etc should be placed in the settings file,/bin and/sbin should be placed executable files and so on. The second tier is defined for sub-directories of the/USR and/var directories. For example,/var/log places system login files,/usr/share places shared data, and so on.  2. Directory path Absolute path//about absolute path, simply is the full path starting with the root "/" directory, with the directory you want to end, the representation of the form, such as:/usr/local/bin, which represents the bin directory in the local directory in the USR directory under the root directory. Relative path//relative path, that is, relative to your current directory path, relative path is in the current directory. For starting point   Two, basic operation of Linux files 1. New CD ~touch test  new directory//Folder Mkdir-p father/son/grandson2. Copy and copy files CP [file] [target address]  Copy the directory cp-r [folder] [target folder/No will create]3. Delete delete directory, folder rm-f [files/folders]4. Move file and file rename move file mv [file] [target address] rename file mv [old file] [new file] Bulk Rename 5. View files using the CAT,TAC and NL commands to view files both commands are used to print the file contents to standard output (terminal), where cat is a positive sequence display, and TAC is displayed in reverse order. NL command, add line number and print, this is a more professional line number than cat-n Print command. Nl-b A [file] -b: Specifies the way to add line numbers, there are two main:-B A: The line number is also listed, whether or not it is a blank line ("Cat-n" Is this way)-B T: List only the number of non-empty rows and list (this way)-N: Sets the style of the line number, There are three main types:-N-LN: The leftmost display of the line number field is-N RN: The rightmost line of the line Number field is displayed with no 0-n RZ: The line Number field is displayed at the far right, plus 0-W: Number of digits occupied by the line Number field (default 6 bits) use the more and less commands to page through the file more [file]less [file] use the head and tail commands to view the file tail [file]tail-n 1 [file] These two commands those who are more anxious people should prefer, because they are only the first few lines of view (the default is 10 lines, less than 10 lines show all) and the last few lines * about the tail command, have to mention that it is a very good parameter-F, this parameter can be implemented to read the contents of a file and display. This allows us to dynamically view the log as a function of real-time monitoring, but I will not introduce it in this basic course approached more details, interested users can get to know. 6. View file type [file]  call Xeyesnohup Xeyes &////platform   environment variable and file lookup one, environment variable file comparison Vimdiff [file 1] [file 2] [file 3]3. Command lookup path and order echo $PATH view the contents of the PATH environment variable:  gcc-o hello_world hello_world.c  Second, search for files and search-related commands commonly used are the following Whereis,which, Find,locate. Whereis simple Fast Whereis [file]locate fast and full Locate/home/shiyanlou/\*.cwhich small and fine which [File]find Fine and fine-list the home directory, the same day (24 Hours) files that have changed: Find ~-mtime 0 lists the new files in the user home directory than the Code folder: Find ~-newer/home/shiyanlou/code   file package with compression one, File packaging and decompression 1.zip Compression Packager zip-r-q-o shiyanlou.zip/home/shiyanloudu-h shiyanlou.zipfile shiyanlou.zip above command will Shiyanlou home The file is packaged as a file and looks at the size and type of files that are packaged. The-r parameter indicates that the recursive package contains the entire contents of the subdirectory, and the-Q parameter is expressed in quiet mode, that is, not outputting information to the screen,-O, representing the output file, followed by the packaging of the output filename. Later, use the DU command to see the size of the file after packaging (this command is described later).   Create an encrypted ZIP package using the-e parameter to create an encrypted compressed package: Zip-R-E-O shiyanlou_encryption.zip/home/shiyanlou 2. Extract the zip file using the unzip command unzip shiyanlou.zip  use Quiet mode, Extract the files to the specified directory: unzip-q shiyanlou.zip-d ziptest The above specified directory does not exist and will be created automatically. If you don't want to unzip just want to view the contents of the compressed package you can use the-l parameter: unzip-l Shiyanlou.zip 3.rar package Compression Command * * NOTE: rar command parameters do not-if added will be error  rar a Shiyanlou.rar. rar A [compression name. rar] [Compress directory]  remove a file from the specified package file rar d shiyanlou.rar. Zshrcrar d [zip package name. rar] [file to delete] View decompression file: rar l [Zip package name .rar]  use Unrar extract rar file Unrar x [Compress package]  Remove path decompression: mkdir tmpunrar E [compress package] [path/tmp] 4. The Tar packaging tool is the first to master the tar command in some basic way, that is, do not compress just to package (create archive) and unpack the operation to create a tar package: TAR-CF shiyanlou.tar ~tar-cf [compression name. tar] [directory to be compressed] The above command,-C means to create a tar package file,-F to specify the file name created, note that the file name must be immediately after the-f parameter, such as cannot be written as TAR-FC Shiyanlou.tar, can be written tar-f shiyanlou.tar-c ~. You can also add the-v parameter to output the packaged file in a visual way. The absolute path is automatically removed from the above, and you can also use-p to retain the absolute path character. Unpack a file (-x parameter) to the directory that already exists for the specified path (-c parameter): mkdir tardirtar-xf shiyanlou.tar-c tardir View only the package file-T parameter: TAR-TF shiyanlou.tar  For a file that creates a different compressed format, it's pretty simple for tar, just another parameter, so let's use the Gzip tool to create a *.tar.gz file as an example to illustrate that we just need to add the-Z parameter to the build of the tar file and use gzip to compress the file: Tar -czf shiyanlou.tar.gz ~tar-czf [compression name. tar.gz] [directory to be compressed]  unzip *.tar.gz file: Tar-xzf shiyanlou.tar.gztar-xzf [Zip package name. tar.gz]& nbsp; fun sudo apt-get install libaa-binaafire  file system operations with Disk Management one, simple file system operations 1. View disk and directory capacity use the DF command to view the capacity of the disk dfdf-h using Du command to view the directory's capacity dudu-h-d parameter specifies the depth of the view directory Du-h-D 0 ~//1-level Du-h-D 1 ~//2-level   Two, simple Disk Management 1. Introduction to the creation of the virtual Disk DD command (some instructions from the DD (Unix) wiki)) DD default from the standard The quasi-input is read and written to the standard output, but can be changed with the options if (input file, input files) and the of (output file, export files). # output to file dd of=test bs=10 count=1 # or DD if=/dev/stdin of=test bs=10 count=1  output to standard output DD If=/dev/stdin of=/dev/stdout BS =10 count=1  linux Help commands the use of helper, man, Info command, and the distinction between built-in commands and external commands, built-in commands and external commands type exit  II, use of the Help command 1. Help command This experiment environment is zsh, and the zsh built in and does not have the command, we can go into bash, in bash built in the command bashhelp LS that if the external command what to do, can't just abandon it. In fact, the external command basically has a parameter--help, so you can get the corresponding help, see what you want. Try the following command to see what you want. LS--help 2. Man command man ls 3. Info Command  linux Task Scheduler crontab One, crontab use crontab Introduction crontab commands are common in Unix and UNIX-like operating systems (Linux is a Unix-like operating system) and are used to set the periodic executed Make. This command reads the instruction from the input device and stores it in the CROntab file for later reading and execution. Typically, crontab stored instructions are activated by the daemon, Crond for its daemon, Crond often runs in the background, and every minute checks to see if any scheduled jobs need to be executed. With the crontab command, we can execute specified system instructions or shell script scripts at a fixed interval of time. The unit of time interval can be any combination of minutes, hours, days, months, weeks  crontab preparation crontab In this experiment environment need to do some special preparation, first we will start Rsyslog, So that we can use the information in the log to understand whether our task is really executed (in this lab environment need to start manually, and in their own local Ubuntu will default self-booting does not need to start manually)  sudo service Rsyslog start  In this experimental environment crontab is also not the default startup, and can not be managed in the background by upstart, so we need to start it (also in this experimental environment need to manually start, their local Ubuntu environment does not need to manually start)  sudo cron-f & crontab use the following will begin the use of crontab, we add a scheduled task by the following command */1 * * * * touch/home/shiyanlou/$ (date +\%y\%m\%d\%h\%m\%s) crontab-l  Although we added the task, but if the cron daemon does not start, it will not monitor the task, of course, will not help us execute, we can use 2 ways to determine whether our cron successfully in the background to start, silently help us do things , if not, you have to perform the second step in the preparation above.  ps aux | grep Cronorpgrep cron  We can view the feedback in the log after executing a task command by such a command sudo tail-f/var/log/syslog  When we don't need this task, we can use a command to remove the task crontab-r . crontab   Command execution sequence control and pipeline order execution, select execution, pipe, cut command, grep command, WC command, sort commands, and so on, the skills to use Linux efficiently. I. Control of order execution sequence 1. Sequential execution of multiple commands   simple text processing two, textThe command 1.tr Command TR command can be used to delete some text from a textual message. or convert it. TR [option] ... SET1 [SET2] commonly used options are:-D delete and Set1 match the characters, note not the whole word match also is not in character order match-s remove set1 specified in the input text in the continuous and repeated characters  # delete "Hello Shiyanlou" in all the ' O ', ' l ', ' H ' $ echo ' Hello Shiyanlou ' | Tr-d ' Olh ' # will be "Hello" in the ll, go back to a l$ echo ' Hello ' | Tr-s ' l ' # will input text, convert all to uppercase or lowercase output $ cat/etc/passwd | TR ' [: Lower:] ' [: Upper:] ' # above ' [: Lower:] ' [: Upper:] ' You can also simply write ' [A-z] ' [A-z] ', which, of course, turns the capitalization into lowercase is also possible  2.col Command usage: col [option] common options are:-X converts the tab to a space-H to tab (the default option) Cat-a/etc/protocols use Col-x to convert tab in/etc/protocols to a space, and then use Cat view, you find ^i missing Cat/etc/protocols | Col-x | Cat-a 3.join command join [option] ... file1 file2 commonly used options are:-t specifies the delimiter, the default is space-I ignores case differences-1 indicates which field the first file is to compare with, and the default compares the first one to 2 Indicates which field the second file is to compare with, and by default compares the first fields # to create two files $ Echo ' 1 Hello ' > file1$ echo ' 1 Shiyanlou ' > file2$ join File1 file2# will/etc/pas SWD merges with/etc/shadow two files, specifying ': ' As delimiter $ sudo join-t ': '/etc/passwd/etc/shadow# merges/etc/passwd with/etc/group two files, specified with ': ' As delimiters, respectively, than the 4th and 3rd fields $ sudo join-t ': '-1 4/etc/passwd-2 3/etc/group&nBsp;4.paste command Paste This command is similar to the join command, where you simply merge multiple files together, tab-delimited, without comparing the data. Paste [option] file...  common options are: Option Description-D specifies the merged delimiter, default is tab-s not merged to one line, each file is a row  $ echo Hello > file1$ echo Shiyanlou & Gt file2$ echo www.shiyanlou.com > file3$ paste-d ': ' file1 file2 file3$ paste-s file1 file2 File3   linu A preliminary understanding of the X-process, conceptual understanding 1.1 process and program concept understanding   Process Properties 2.1 process Classification  2.2 process derivation just like we started the terminal, we started a bash process and we can enter bash in bash. Then a bash process is started, and the second bash process is created by the first bash process, and what is their direct relationship? We generally call the first bash process to be the parent of the second bash process, the second bash process is the child of the first bash process, how is this layer of relationship derived? About the parent process and the child process will refer to both system calls fork () and exec () fork-exec is created by Dennis M. Ritchie Fork () is a system call, and its primary function is to create a new process for the current process , this new process is its child process, the child process in addition to the parent process return value and PID other than the same, such as the execution of the process code snippet, memory information, file description, register status and so on exec () is also a system call, The function is to toggle the execution program in the child process, which is to replace the code snippet that was copied from the parent process with the data segment  pstree  linux process management control One, the Process View 1.1 top tool use top # View the number of physical CPUs Cat/proc/cpuinfo |grep "Physical id" |sort |uniq|wc-l# cores per CPU Cat/proc/cpuinfo |grep "Physical id" |grep "0" | Wc-l&nbSp Linux log system A common log   bashbash Hello world 

Lab Building Linux Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.