094_Linux basic commands

1. Create an account

  useradd lisi
  useradd -d /home/ww wangwu

2. Set password: passwd account name
  passwd lisi

3. Delete account: userdel [option] account name
  userdel wangwu: just delete the account, the main directory remains
  userdel -r wangwu: delete the account, and delete his home directory at the same time 5.

4. Switch account: su root

================================================== ================================
Group management:
1. Create a group:
  groupadd dev
2. Delete a group:
  groupdel dev
3 , View the user's group: id account name
  id zhangsan
  |-> uid: user's logo
  |-> gid: user's main group id, the group assigned when creating the account
  |-> group: the user belongs to the ordinary Group
4. Add the user to the specified group: gpasswd -a user name group name
  gpasswd -a zhangsan dev
5. Remove the user from the specified group: gpasswd -d user name group name
6. Specify the group to which the user belongs when creating the user : Useradd -g group name user name
  useradd -g dev wangwu
===================================== ================================================
System operation Command:
1. Shutdown: 
    shutdown now:
    shutdown immediately- shutdown 1: scheduled shutdown

2. Restart: shutdown [option]
  shutdown -r now: restart immediately
  reboot: restart immediately

3. Synchronize the data in linux memory to disk: sync
===================================== ================================================
linux The help commands:
1, man: Check the usage of this command in the linux help documentation.
  man ls
Note: All help information is displayed in split screen, enter-turn a line, space-turn a page, q-exit the view.
2. help: View the help information built into the command.
  help cd
================================================ =====================================
Operation commands for files and directories:
1. View the current complete Directory: pwd
2. View all subdirectories and files in the current [/ specified] directory: ls [options] [directory]
  ls: normal view
  ls -l: display all subdirectories and files
  ls in the current directory in the form of a list -a: display all subdirectories and files (including hidden files) under the current directory
  ls -al:
3. Switch directory: cd directory name

  cd ..: switch to the previous directory

  cd ~: Switch to the root directory of the current user.
4. Create a directory: mkdir [options] directory name
  mkdir test2: create a first-level directory
  mkdir / opt / testDir / test3: create a first-level directory (opt / testDir these directories must exist)
  mkdir -p / opt / testDir / test4 / t1: create multi-level directory
5, delete empty directory: rmdir directory name
  rmdir test1
  rmdir / opt / testDir / test2
6, create file: touch file name list (can create multiple files at once) )
  touch test2.txt test3.txt test4.txt
7. Copy the file or directory: cp [options] source dest
  cp test3.txt test3
  cp -r test4 test3 (copy the test4 file to test3 recursively)
  \ cp test3.txt test3: Force copying, if files or directories already exist, force overwriting.
8. Delete files or directories: rm [options] file name / directory name
  rm test1.txt
  rm -f test2.txt (-f can force delete files)
  rm -r test4 (-r can force delete directories, rm cannot be deleted directly Directory)
  rm -rf test3
9, move directory or file: mv file name / directory name directory name
  mv test3.txt test1
  mv test2 test1
  mv test.txt test1.txt: rename the file
10, view the file contents:
  1), cat [options] file name: list all the contents of the file at once.
    cat test1.txt
    cat -n test1.txt
  2), more File name: Display the contents of the file on a split screen.
    more test1.txt
    Enter--turn a line, space--turn a page, q --- exit view.
  3) .less file name: display the content of the file in split screen, load the file in pages, more efficient, suitable for viewing large files.
    less file name
  4), head [options] file name: view the first lines of the file (the first 10 lines are displayed by default)
    head test1.txt
    head -n 15 test1.txt
  5), tail [option] file name: view the file How many lines after the end (10 lines after the default display)
    tail test1.txt
    tail -n 15 test1.txt
11, view the system constant or variable content: echo variable or constant name
   echo $ PATH
   echo Hello world!
12, view the command> file name: Overwrite the output of the view command to a file.
  ls> test4.txt ("Overwrite the original file directly")
  cat test4.txt> test1.txt: Copy the file contents
13, View command >> File name: Add the output of the view command to the file.
  ls >> test4.txt




Guess you like

Origin www.cnblogs.com/pogusanqian/p/12671115.html