Linux Beginner Experience

Source: Internet
Author: User
Tags get ip parent directory tmp folder disk usage

The first essay, in fact, is to write homework, but the teacher's request is right, in fact, they are in the environment and the work of the industry will also be encountered in the resolution of the problem recorded, so that later to find convenient. This time to put those content here, but also share with you.

Saturday is the second time to listen to Liunx class, feel more relaxed than the first time to listen to, so review is very important.

The following is the course of your own note note: Definitely not the teacher's notes copied over! Finally have my homework to meet the summary of the problem!

1, HTTP address default does not write port number is 802, 127.0.0.1 and localhost are local 3, user management  $ is a normal user, #是管理员用户       Windows is a single user, Linux is multi-user, can support multi-user operation       ID: can view current user       WhoAmI  : View current user       who & nbsp;: or   View currently logged in user       W  : Also can see currently logged in user  4, add user useradd username   # Add user    & nbsp Password  passwd  password   #给添加的用户加密码 and reset password   Add user does not specify home directory, directory default home directory in/home/directory, display wavy line in home directory ~       CD ~      Quick Home directory   or   direct cd       Switch User:  SU user name (switch to root user directory) or  SU-username   (switch to normal user's home directory)          difference: Su-  will reload the user's environment variables         sudo: Get super User privileges         Add normal user sudo permissions:              use root user edit /etc/sudoers file, find root all= (all) All this line, under it add bestest all= (All) Nopasswd:all and then save. NOPASSWD does not enter a password when using sudo on behalf of the user?        Delete User: Userdel   user Name                      USERDEL-R   Delete users at the same time delete user home directory  5, group management &nbs P       Add Group: Groupadd name        Modify group:        Delete group: groupelname 6, Directory (folder) operations: Learn about the Linux file directory structure          PWD     Show your current path          CD       into which directory (folder)          CD/     root          /        is the top-level catalogue          CD.       Back to parent directory           CD. /.. /      go back to the top levels of the catalogue, on several levels.          CD-        go back to the previous action's directory           relative path:          Absolute path:          Create a folder: mkdir   The parent directory does not exist, then add-p to create the parent directory, and then create a subfolder under the parent directory. nbsp        mkdir--help   help     &NBSP     Delete folders: RM,  rmdir (delete empty folders)           Delete non-empty folders do not ask:rm-rf          Delete root directory: RM-RF/    It's over.           Find things under folders: LS, ll        &NBSP Move folder: MV Folder name destination path    MV besttest/tmp          Rename: MV folder name to change the file name    MV &nbsp ; besttest  linux          Creating empty files: Touch filename           File details are shown in front of Drwxr-xr-x is a D description is a folder, the previous D description is file           Create hidden file: Touch. Yincang     Create a file name preceded by a dot is created a hidden file           View hidden files:ls-a          Copy files: CP   filename & nbsp, Target path     CP besttest/tmp/          Copy directory: cp-r   folder   target path   cp-r be sttest/tmp/          Force copying of files/folders without asking whether to overwrite: Cp-f file name target path           al IAS is an alias for the command, can be made command   alias  CP=CP   modified  cp-f don't ask for mandatory overrides          alias command: 1, alias Hyh= ' CP '   input hyh bestest/tmp/  copy besttes T ask plus you clip to TMP, 2, alias  hyh= ' ETC/LAMMP '     Next input hyh go directly to that address  ------  Only valid for the current window           Make alias-made commands permanent: VI etc/profile   Add alias-made commands           Force copy any File (folder): CP -RF               7, file operation: VI or VIM (upgrade to VI)           VI Command mode: Use I, in the current position to enter the editing mode, o in the next line into the editing mode, a   less, in the current position of the next one into the editing mode          :Q   No modification of the direct exit & nbsp       : Wq   or  : x     Save and exit          :q! Do not save exit          /(Find content)   Find what you want to find               &NBS P   : Set nu     Show line numbers          :set Nonu   suppress line numbers         &NBSP: Digital     FAST channel a line           SHIFT+G   Skip to end of file           x     Delete single character       &N Bsp   DD   Delete entire line            19DD   Delete 19 lines           u   Undo           yy   copy line             19yy   copy 19 lines           p   paste          .     Repeat previous action           shift+$   cursor moves to end of line           shift+0 &NB Sp Cursor moves to the beginning of the line           :%s/What to replace/Replace with content/g  % all  s strings     Replace all strings          VI edit mode: ESC exits edit mode to command mode                   &NBS P Cat: View short file           MORE: View file split screen display, press ENTER line display           Less: View files, powerful, Can be manipulated before and after the page, up and down search            Dynamic View log: Tail   The default display after 10 lines;tail-5f  5 rows by default; tail-f   Watch dynamic log               Create soft Connect (shortcut): LN- s  source file (absolute path) created shortcut name    ln-s/OPT/LAMPP/XAMMP ~/hyh   Next input ll Hyh direct to xammp             Show current directory occupies hard drive size:du-sh            Show current directory each file/folder occupies hard disk size: Du-sh *  &N Bsp         disk usage: DF     or df-h             to see what's under the file: Ls-l = ll& nbsp           Modify permissions: chmod     x represents the execution of  W representatives write  R representative read         &N Bsp     Privileges: Text form                   chmod o+x  file name other users     & nbsp             chmod  g+x  filename   This group user             &N Bsp     chmod  u+x   file name   self                   chmod +xwr  file name   All rights                   chmod  a+x  file name   all &NB Sp            reduced rights:                  chmod o-wx file name   Write-down rights     change +--that is, minus permissions                           Modify permissions in digital form: r=4  w=2 x=1   rwx:4+2+1;    r-x:4+1;   rw-:4+2;   Maximum permissions 777     All user readable writable executable               only write one digit for other users, write two numbers for group and others, Write three numbers for all users                chmod-r   Recursive   put all files and folders under the directory and Permissions   & nbsp              chown: Change the owner of the file   chown filename user         &NBS P       If the folder you want to add-r:chown-r folder name user                CHFRP: Change the file Genus Group   CHGRP file name group               If it is a folder, add-r:chgrp -r folder name group                &NBSP ;      |: Pipe break, connect two command                ls |wc-l:ls put his results back on the command let him operate &nbsp ;              CAT file name |wc-l: Statistics file lines              &NBSP ;  &&amp: Two commands are executed at the same time, after execution of the previous execution                 role: can start a command while watching the log   Use && to execute two full commands                 For example:/opt/lammp/lammp restart && tail-f /logs/..... : The program will display the contents of the log                       &nbsp      . Find files/folders: Find/-name mysql                Find file contents: grep find content find filename   -w match Specify string;-V output does not match string, filter out specified information                 Watch log find log content with keywords: first tail-f log | grep keyword   &NBsp;                 REDIRECT:              &NBSP ; Cat Test > Cc.txt     See the contents of the test file, and then put it in Cc.txt, which is equivalent to copying, pointing to whom to write content                 echo "hehe" >cc.txt   View cc, the original content disappears, write hehe, the greater than the number before the content can be emptied cc.txt   can be used to clear the contents of the log file                echo "hehe" >>cc.txt   View cc, add new content               &NBS P      8, install software       upload, Download: FTP tool, set SFTP,RZ command, Sz command, but he can't upload folders       rz, SZ Command installation: Install,yum –y install lrzsz,      compile installation with Yum: http://blog.chinaunix.net/ uid-20639775-id-  154615.html       RPM installation package auto-Configure environment variables: RPM-IVH  **.rpm      & nbsp;      RPM-E: Uninstall, install with RPM to uninstall       RPM-QA: Query the installed packages, rpm-qa|grep MySQL   pipeline character behind Package name to look for        Yum installation: Download the installation package from the Yum source, download, install, add environment variables are not tube, directly to their own good       ***LIUNX installation package has two packages, 1 is the installation package, 2 is the Yum source       Common commands:      & nbsp;? Yum install httpd# apache       ? Yum-y Install httpd# If you have the option to all agree to the installation       ? Yum List|grep httpd# Find the software you need from the Yum list         Yum update httpd #yum升级Apache       ? Yum List installed |grep mysql# query to install mysql      ? Yum Remove mysql# uninstall Yum installed mysql         Source installation:        Source installation trilogy     & nbsp  ? 1. Generate makefile compiled files?/configure General installation Package There is a configure file below that is used to generate makefile compiled files? What are the common parameters? --prefix Specify the installation directory? --with-xx Specify the directory of dependent files       ? 2, make compile? The make command also needs to be installed, compiling a written C program according to the./configure generated makefile file, producing the executable files         3. Make install? The role of make install is to copy the compiled files to the specified directory, that is, the first step-prefix the specified directory, if there is no specified directory, or in the current directory   9, switch machine: General users do not normally switch machine permissions        shutdown:shutdown -h  30 #定时关机                 shutdown -H  now   #立即关机                Init 0   Immediate shutdown       Restart: Reboot later can add parameters, do not add, shutdown can also be restarted, the latter can add delay time shutdown -R 20 "I'm going to restart."---Timed restart 10, logout: Exit, Switch User: Exit switch to previous user  11, network         View IP address: ipconfig   or IP A (many high versions are not ifconfig)        VMNET8 is host only mode, VMNET1 is NAT mode        dhclient   # Auto Get ip 12, compress, unzip files        tar: Pack     C pack, x unzip, z with gzip compression       &NB Sp   Format: Tar cvf   file name. tar   file name to package---> Tar cvf liunx.tar liunx        compression: Tar zcvf liunx.gz  liunx      ----tgz and GZ end are all compressed         decompressed: Tar xvf liunx.gz liunx   &NBS P  XVF is generic, no matter if compression is uncompressed, ZXVF is uncompressed package         ZIP package: Zip linux.zip linux       Zip command to yum install, not bring your own         Unzip ZIP package: Unzip linux.zip           gzip can only compress files, cannot compress folders: gzip filename         Original File No , save only the zipped package, which can be used to back up the log         Gunzip extract: Unzip file name. GZ 13, Environment variables: ENV   View environment variables       Nbsp;whereis  ls: Display environment variable configuration         If you write a script that you want to execute in any directory, add it to the environment variable, view the directory where the environment variable file is added to the environment variable, and move the script over. You can also directly execute the         system environment variables: Everyone can use  /etc/profile        User environment variables: only for themselves, others cannot use   ~/.BASHRC 14, process        PS: View currently running processes (static)    -a or-e list all processes;-ef view relationships between processes        PS-EF |grep MySQL: filter mysql process        PS-EF |grep mysql|grep-v grep: Filter the MySQL process and remove GRE P itself process        KILL-9 process ID (can be followed by multiple processes): End process   Killall: End All processes         Top: View the currently running process (dynamic), the content display is many, and is dynamic, and PS distinguish open                The background run: Nohup. Jmeter-server &         background run, do not occupy the console, keep running, close the interface, CTRL + C and other operations will notImpact, do not close  14, custom tasks: Can be used for scheduled backup logs, databases, etc.        crontab: Edit timed tasks        CRONTAB-E, Enter the edit timed task interface        crontab file in the format "M H d M D cmd". where m stands for minutes (0~59), H for hours (0~23), D for Day (1~31), M for month (1~12), d for Day of week (0~6,0 for Sunday). CMD represents the program to run, * represents every minute of execution? Example:? * * * * * * sh/opt/lampp/test.sh means to execute test.sh this script every minute? */5 * * * * * sh/opt/lampp/test.sh means to execute test.sh this script every 5 minutes? * * * * */usr/local/apache/bin/apachectl restart 21:30 restart per night apache             &NBS P;CRONTAB-L: Check which scheduled tasks are currently  15, view port number netstat: View port number netstat  Nlpt|grep 8080: see if 8080 port number is occupied, see process ID with 8080 port number  16, Shell script: Multiple commands are written together, other content view ppt       Note: The shell definition variable cannot have spaces         take process Id:ps- Ef|grep jmeter|grep-v Grep|awk ' {print $} '         awk ' {print $} ' take the second column of data, save as a variable to use               End Process script         Write script content as: (Save As. Sh)       #! /bin/bash     #需要什么解释器来执行, liunx default interpreter is bash, if not write can also execute        count= ' ps-ef|grep jmeter|grep-v Grep|awk ' { Print $ ' |wc-1 '        pid= ' ps-ef|grep jmeter|grep-v Grep|awk ' {print $} '       &NBS p;if [$count-gt 0]   #count大于0          then           Kill -9 $pid            echo "JMeter stoped"       else        & nbsp echo "Jmeter-server not running ..."          startup scripts:        count= ' ps-ef|grep jmeter|grep-v Grep|awk ' {print $} ' | Wc-1 '         If [$count-gt 0]   #count大于0             then            echo "Jmeter-server is running. "        else           nphup/root/apache-jmeter-2.11/bin/ Jmeter-server &         &NBSp Restart script:          Absolute path to end script           startup script absolute path        &N Bsp  bash: Interpreter            bash   file name. SH: Specifies that the script be run with bash, which can be written in a script or placed outside the  17 , get to current time string        date +%y%m%d%h%m%s --------------------------------Below is the job----------------------------Daily 23:59 Backup The lampp access_log file, the file name of the backup is named at the time 201212241852_access.log to/tmp/logs back up to empty the original logs folder created under the TMP folder: mkdir Create a backup.sh file under the Logslogs folder: Touch backup.sh Create a script here's a little episode, and here's what it says:

#!/bin/sh
rm-rf/tmp/logs/*
cp/opt/lampp/logs/access_log/tmp/logs/' Date +%y%m%d%h%m%s ' _access_log

Then execute the script first.

Here I met the first problem: The script cannot be tab-complete, found that the script permissions are problematic, then directly

chmod 777 backup.sh #直接赋予最高权限

Continue execution of script with error:-bash:./backup.sh:/bin/sh^m:bad interpreter:no such file or directory

Here is the episode mentioned above, because I started editing the script created under Windows, so I'm prompted for this error

Baidu search after found method: VI Backup after input:: Set FF results: Fileformat=dos This is the reason why the script could not be executed, because he is a DOS format, in order to save things, directly delete the script to the Linux command to create scripts, write content, problem solving

Above, the contents of the script are created to complete the following writing timed tasks: CRONTAB-E Open the timed task Editor to write the following:

*/1 * * * * sh/root/backup.sh

Save exit

Go to the backup directory to see the results of the operation, file deletion and creation is normal, although I do not know whether to meet the teacher's requirements, but did follow the script I wrote to run.

--------------------------------------above is the content of Linux course learning-------------------------------

Linux Beginner Experience

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.