------ file linux common commands the operation, file viewing, permissions, compression packing

1, the average company to linux as its application server, the application server and the deployment of the above

2, the test is generally used to package, compression, check the log, write a simple shell

  Way to get linux server

  a: online rent a cloud server

  b: install vmware

3, connected vmware virtual machine using tools such as xshell

  To see whether the virtual machine and the machine may ping the network, such as virtual machine ping www.baidu.com

  vmware network connection

  

 

  windows are multi-root

  belong to a single linux: / everything is a file under linux

4, linux directory

  bin directory: linux in the command execution, the program may be installed, can be placed inside

  sbin directory: command execution system

  etc directory: Profiles directory

  opt directory: Setup can put some

  tmp directory: temporary directory

  home directory: home directory

5, basic file operations command ----

  LS : View all current files ls -l directory: detailed file shows the current directory ls -h -l: M units to form detailed file information display

[besttest the root @ ~] # LS - L 
Total amount 139 124 
-rw -------. . 1 the root the root       1130. 10 dated 31 is  , 2015 anaconda- the ks.cfg
 -rw-R & lt -. r-- . 1 the root the root    4,992,339 dated. 7    . 6  , 2015 . bugfree_v3 0.4 .zip
 . -rwxrwxrwx . 1 the root the root      19049 . 6 dated   26 is  . 19 : 41 is dang.sql 
[besttest the root @ ~] # LS -H - L 
total volume 136M
 -rw -------. 1 root root 1 .2K Yue 10 31 2015 anaconda-ks.cfg
-rw-r--r--. 1 root root 4.8M 7月   6 2015 bugfree_v3.0.4.zip
-rwxrwxrwx. 1 root root  19K 6月  26 19:41 dang.sql

  Test mkdir : Create a directory test (i.e., create folders) mkdir -p test / a / b / c: recursively created, a directory is created multilayer

[root@besttest liyn_test]# mkdir -p a/b/c
[root@besttest c]# pwd
/root/liyn_test/a/b/c

  cd. : dot represents the current directory cd ..: represents the return to parent directory    

  test Touch : Create a test file

[root@besttest liyn_test]# touch test
[root@besttest liyn_test]# ls
a  test

  a test Music Videos : Move a test file to the directory

[root@besttest liyn_test]# mv test a
[root@besttest liyn_test]# ls
a
[root@besttest liyn_test]# cd a
[root@besttest a]# ls
b  test
[root@besttest a]# mv test test1 //将test重命名为test1
[root@besttest a]# ls
b  test1

   b test.txt CP /   : b copied to the directory test.txt

[root@besttest a]# cp test1 b/
[root@besttest a]# ls
b  test1
[root@besttest a]# cd b
[root@besttest b]# ls
c  test1

  -rf test.txt RM   : Do not prompt nor print any information, delete test.txt

[root@besttest b]# rm -rf test1

  *  : On behalf of all

[besttest the root @ A] LS # 
b is test2.txt test.txt 
[besttest the root @ A] # Music Videos * .txt b / txt file represents all the mobile directory to b   
[besttest the root @ A] LS # 
b 
[the root @ A besttest] CD # B 
[besttest the root @ B] LS # 
C is test2.txt test.txt

 

6, the base command ---- File Viewer

  ~ cd : Back to the current user's home directory

  test.txt CAT : view full file, the file is too large is not suitable only for small files View

[root@besttest liyn_test]# cat test.txt
1111111
22222
33333

  test.txt More : in proportion to view the file contents

  test.txt less : Press the arrow keys and press OK to view

  -100 test.txt head : from the beginning to see the first 100 lines test.txt file

  -100F test.txt tail : never Last dynamic view after test.txt file 100 lines

  > : Redirect    CAT test.txt> test1.txt : the test.txt file redirects to test1.txt

[root@besttest liyn_test]# cat test2.txt
[root@besttest liyn_test]# cat test.txt > test2.txt
[root@besttest liyn_test]# cat test2.txt
1111111
22222
33333

  >> : Append    

[root@besttest liyn_test]# cat test3.txt
1111111
22222
33333
[root@besttest liyn_test]# cat test.txt > test3.txt
[root@besttest liyn_test]# cat test3.txt
1111111
22222
33333
[root@besttest liyn_test]# cat test.txt >> test3.txt
[root@besttest liyn_test]# cat test3.txt
1111111
22222
33333
1111111
22222
33333

  echo 'Hello' : Print

[root@besttest liyn_test]# echo 'hello'
hello

 

7, linux permissions

  linux system is a multi-user, multi-tasking system. Any user wants to use system resources, must apply for an account to the system administrator, system administrator through this account, which can access the resource control

  / Etc / passwd: stores user information

[@ besttest the root /] CAT # / etc / the passwd 
the root: X: 0 : 0 : the root: / the root: / bin / the bash // each row is a user 
bin: X: . 1 : . 1 : bin: / bin: / sbin / nologin 
daemon: X: 2 : 2 : daemon: / sbin: / sbin / nologin 
ADM: X: . 3 : . 4 : ADM: / var / ADM: / sbin / nologin 
// username: password: a user identification number: group ID: annotated description: home directory: login shell

  / Etc / shadow: stored user password, each row is a user

[@ besttest the root /] head # - 2 / etc / Shadow 
the root: $ . 6 $ $ UL7fJDdCtKe3A1nwxcHgCEi3F40hFyq.x0vCX77KFk8vVlxsanKTT6uXSrfpCqmguG41cpJgrjY7azgREIwve d7VoqfSS7AdxTdZj /: 16739 : 0 : 99999 : . 7 ::: 
bin: *: 15628 : 0 : 99999 : . 7 ::: 
// username: encrypted password: . . . . .

  / Etc / group: Group User

[@ besttest the root /] CAT # / etc / Group 
the root: X: 0 : 
bin: X: . 1 : bin, daemon 
daemon: X: 2 : bin, daemon 
// Group name: Password: crew

  adduser tester1: Create a user

[root@besttest /]# adduser liyanan
[root@besttest /]# tail -1 /etc/passwd
liyanan:x:500:500::/home/liyanan:/bin/bash

  passwd liyanan: set a password to the user

[root @ besttest / ] # passwd liyanan 
change a user's password liyanan. 
The new password: 
Invalid Password: simplistic / systematic 
invalid password: too simple 
to re-enter the new password: 
passwd: all authentication tokens have been successfully updated. 
[root @ besttest usr] # cd / Home
[root @ besttest Home] # LS
besttest liyanan // View home directory, there are new user directory


  Competence

[root @ besttest liyn_test] # ll 
total volume . 4 
drwxr XR-2 X-dated the root the root. 6 4096 04:15 A 27.
 -rw-R & lt - r--. . 1 the root the root   0 . 6 dated   27  03 : 09 Test3. TXT
 . -rw-r - r-- 1 root root 20 6 Yue   27  03 : 07 test.txt
-rw-r - r--: the first representative of the type of the current file, d for directory, ~ represents a file, l represents the soft links 
       2-4 (u), on behalf of the current user permissions to the file, r (4) for read, w (2) on behalf of a write, x (1) executed on behalf of
       5-7 (g), representative of the belonging group permissions on the file
       8-10 (o), on behalf of other users permission to it
[root @ besttest liyn_test] the chmod 555 test.txt #
[@ besttest the root liyn_test] # LL
total volume. 8
drwxr XR-2 X-dated the root the root. 6 4096 04:15 A 27.
-rw-R & lt -. r-- the root. 1 0. 6 dated the root 03:03 is test2.txt 27
-rw-R & lt - r-- the root the root. 1 0. 6 03:09 test3.txt was dated 27.
-R & lt XR-XR-X-20 is the root. 1 the root. 6 dated 27 03:07 test. .txt // test.txt to read and execute permissions changed

  ./test.sh: execute a certain file in the current directory

8, compression packing

  Packing: a plurality of files in the file, generates a file

  {} .sh A..D Touch  : create multiple files

  cvf demo.tar A..D} {tar .sh   : packaging, c- represents the creation, v- information indicating the print pack, followed by f- representatives take the file name (can also be written tar cvf demo.tar * .sh )

  -tf demo.tar tar : View all the current package

  demo.tar -xvf tar : tar package unpacking the current directory, x- behalf of decompression

  ----------------------------------------------- zip compression -------------------------------------------------- -------------------

  demo.tar gzip : tar package will be compressed into a zip file

    demo.tar.gz gunzip   : Unzip the zip file to tar package

  cvzf demo2.tar.zip * .txt tar : compressed into a zip file

  -zxvf demo2.tar.zip tar : Unzip the zip file unpack

  ---------------------------------------------- bzip2 compression - -------------------------------------------------- ---------------------

   demo.tar bzip2 : bz2 compressed file

   -d demo.tar.bz2 bzip2 : tar packets decompress

  -cvjf demo.tar.bz2 * .txt tar : bz2 compressed file

  demo.tar.bz2 -xvf tar : solution bz2 file, unpack

[root@besttest liyn_test]# ls
test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# touch {a..d}.sh
[root@besttest liyn_test]# ls
a.sh  b.sh  c.sh  d.sh  test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# tar cvf demo.tar {a..d}.sh
a.sh
b.sh
c.sh
d.sh
[root@besttest liyn_test]# ls
a.sh  b.sh  c.sh  demo.tar  d.sh  test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# rm -rf *.sh  
[root@besttest liyn_test]# ls
demo.tar  test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# tar -tf demo.tar
a.sh
b.sh
c.sh
d.sh
[root@besttest liyn_test]# tar -xvf demo.tar
a.sh
b.sh
c.sh
d.sh
[root@besttest liyn_test]# ls
a.sh  b.sh  c.sh  demo.tar  d.sh  test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# gzip demo.tar
[root@besttest liyn_test]# ls
demo.tar.gz  test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# gunzip demo.tar.gz
[root@besttest liyn_test]# ls
demo.tar  test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# tar cvzf demo2.tar.zip *.txt
test2.txt
test3.txt
test.txt
[root@besttest liyn_test]# ls
demo2.tar.zip demo.tar test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# rm -rf *.txt
[root@besttest liyn_test]# ls
demo2.tar.zip  demo.tar
[root@besttest liyn_test]# tar -zxvf demo2.tar.zip
test1.txt
test2.txt
test3.txt
test.txt
[root@besttest liyn_test]# ls
demo2.tar.zip  demo.tar  test1.txt  test2.txt  test3.txt  test.txt
[root@besttest liyn_test]# rm -rf *.zip
[root@besttest liyn_test]# bzip2 demo.tar
[root@besttest liyn_test]# ls
a.sh  b.sh  c.sh  demo.tar.bz2  d.sh  test1.txt  test2.txt  test3.txt  test.txt



 

 

 

  

 

Guess you like

Origin www.cnblogs.com/hzgq/p/11411687.html