Linux common commands, sum up by yourself

linux basic knowledge and operation

Query : ls

When there are too many files, you need to query the number
ls |wc -l

ctrl+s to lock the screen display (under Windows, ctrl+s is used to save, under linux, it causes linux to freeze, do not think it is a crash, and then restart the system, Only need ctrl+q to resume)
ctrl+q Unlock
ctrl+c End running programs [ping, telnet, etc.]
ctrl+d End input or exit shell
ctrl+s Pause screen output
ctrl+q Resume screen output
ctrl+ l Clear the screen, [is the lower case of the letter L] is equivalent to clear

shift+PageUp page up
shift+PageDown page down
Find files:
find -name apach*.conf
*.conf
apach*
apache.*

Change files and folders name
mv original file name new file name
mv original folder name new folder name
Example : mv text.php phpinfo.php

new folder (directory)
mkdir folder name

touch file name

Copy file:

delete directory:
It is very simple to delete a directory in Linux. Many people are still used to using rmdir, but once the directory is not empty, they will fall into deep distress. Now use the
rm -rf command.
Just rm directly, but you need to add two parameters -rf, namely: rm -rf directory name
-r is to recurse downwards, no matter how many levels of directories there are, delete
-f together is to delete forcibly directly without any prompting.


Partition Related:
/
  /boot
  /dev Hardware devices are stored in this directory in the form of files
  /usr
  /home
  /var is the default system for temporary data storage or cache data storage directory eg.email

ls -al

Example:
If there is a file The type permission data is "-rwxr-xr--", please explain its meaning?
Answer:
First, check the entire type of unauthorized data separately, and organize the ten characters into the following:
[-][rwx][rx][r--]
1 234 567 890
1 represents this file type-
: represents ordinary file
d: directory
b: block special file
c: character special file
l: symbolic link file
p: named pipe file FIFO
s: socket file
234 is: owner's authority, in this case, readable, writable, executable (rwx);
567 is: same group user authority, in this case, readable and executable (rx);
890 is: other users Power, in this case, it is readable (r)
and note that the location of rwx will not change. With this permission, characters will be displayed, and without this permission, it will become a minus
sign (-).

Example: -rw-r--r-- 1 root root 192 Nov 5 20:22 index.php
Interpretation: -document rw-owner permission readable, writable, but not executable r--same group can only read
    r-- Other user rights can only be read
    1 Indicates that there is 1 file name linked to
    the "owner account" of the first root of this file (or directory) The
    second root of the group to which this file belongs
    192 Capacity, the default is bytes
    Nov 5 20:22 Date of file creation or last modification date
   
  chgrp : Change the group the file belongs to
  chown : Change the owner of the file
  chmod : Change the permissions of the file, SUID, SGID, SBIT, etc.
   
Update time:
ntpdate -u 210.72.145.44 -u parameter can synchronize with the host across the firewall

Display time:
date +%y/%m/%d-%H:%M year/month/day-hour:minute 2015/11/5-11:51

Installation apache:
$ sudo apt-get install apache2

Restart the apache service, enter the following command in the command line terminal:
$ sudo /etc/init.d/apache2 restart

php error log: /var/log cat phperrors.log
apache error log: /var/ log/apache2 cat error.log

Ubuntu's system log is stored in the /var/log/syslog file, you can view it with the following command:
vi /var/log/syslog

to /var/www/html and then sudo cp ~ /index.php index.php to

see who is online: who
to see the network connection status: netstat -a
Command to write data to the hard disk synchronously: sync
Usual shutdown command: shutdown
Restart, shutdown: reboot, halt, poweroff

Newly installed system If the root password has not been set, you can enter:
sudo passwd root, press Enter and press the prompt to enter the root password twice.

Problem: Under Linux, the web page content of the php website cannot be displayed, and no error is reported, but it is blank. The solution
Generally speaking , the php page with blank content should be a php error. The default lamp configuration is relatively strict, and no errors are displayed. You can configure it like this:
1. Modify the php.ini (eg: /etc/php5/apache2/php.ini) file:
error_reporting = E_ALL
display_errors = On 2. Add error_reporting(E_ALL); ini_set("display_errors","On"); these two are start error prompts
in the php page . //Verified by test, invalid, I don't know where the problem is echo "<?php echo 'hello world';" > index.php <?php echo "hello world"; ?> echo outputs the things in quotation marks (<> ) Append to index.php cat index.php to display the entire file (index.php) at one time ls / file in the column directory cd /var/www into the var/www directory cd .. go back to the parent directory : q!





















  [ctrl]-X: Leave the naon software, if you have modified the file, you will be prompted whether you need to save it!
  [ctrl]-O: save files, if you have permission, you can save files;
  [ctrl]-R: read data from other files, you can paste the content of a file in this file;
  [ctrl]- W: Searching for strings, this is also a very helpful command!
  [ctrl]-C: Indicates the current number of lines and columns where the cursor is located;
  [ctrl]-_: You can directly input the line number to move the cursor to the line quickly;
  [alt]-Y: Correct the language Activate or close the function (click to open, then click to close)
  [alt]-M: can support the function of moving the cursor with the mouse
 
 
 
  apache2 file location:
  /etc/apache2
 
 
 
  ps aux|grep httpd
ps: view process
aux: display All processes and their status.
grep: means to search here (global search and print in regular notation)


ps aux output format
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 3342 0.0 0.2 9496 2236 tty1 S+ 9:23 0:00 grep - -color=auto httpd
user: process owner
PID: pid process id
%cpu: cpu usage
%MEM: The percentage of physical memory and total memory used by the
process VSZ: The virtual size of the process
RSS: The memory size occupied
TTY: The terminal name of the process that started the process
STAT: The state of the process.
START: Process start time
TIME: Execution time
MOMMAND: The name and parameters of the executed command

grep (global search regular expression (RE) and print out the line,
comprehensive search regular expression (RE) and print out the line)
is a powerful A text search tool that searches text using regular expressions and prints the matching lines.

STAT status:
(5 kinds: D uninterruptible (usually IO), R running (run), S sleep (sleep), T stop (stop), Z zombie (zombi))
D uninterruptible Uninterruptible sleep (usually IO)
    D unusable interrupt
    R running, or queued process
    S is dormant
    T stopped or tracked
    Z zombie process
    W enters memory swap (invalid since kernel 2.6)
    X dead process


    < high priority
    N low priority
    L Some pages are locked into memory
    s Contains child processes
    + process groups located in the background;
    l Multithreading, clone threads


Usually accumulated, welcome to leave a message for discussion and correction, I hope everyone can make progress together, and write me some comments and suggestions, thank you all

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326938647&siteId=291194637