Summary of SHELL commands from beginner to small white

Source: Internet
Author: User
Tags touch command

Summary of Common shell commands

This article summarizes some of the common shell commands, hoping that Linux small white like me in the familiar with these commands, can basically cope with the small white phase encountered problems

1.cd

After the CD followed by the directory name, you can enter this directory, the directory is written with absolute path and relative path

Absolute path: Starts with the root and explicitly indicates the full name of the directory to be reached, such as

[Email protected] mycode]$ cd/home/zhaozhao/mycode/c_plus_program/

Absolute paths seem relatively cumbersome

Relative paths: Relative paths allow users to find other directories based on the current directory

(.) indicates the current directory

(.. ) represents the parent directory of the current directory

[email protected] c_plus_program]$ CD. [[Email protected] mycode]$ CD. /c_plus_program/

If you want to enter the root directory, CD ~ can take you directly to the directory

2.ls

LS The most basic format will show the current directory of files and directories

ls blog_plan.c  mycode  Qt5. 6.2  Qt_programme  QT installation package  public  template  video  picture  document  download  music  Desktop

The general Linux version will be color to distinguish file types, such as my Linux on the normal file is green, the directory file is blue. If your version does not support color

You can use the-f parameter to differentiate between files and directories

[Email protected] ~]$ ls-fblog_plan.c  qt5.6.2/       qt installation Package/  template/  picture/  Download/  Desktop/mycode/      qt_programme/  Public/      video/  documentation/  Music/

Can be seen, so the directory files are followed with/.

The LS command displays the files in the current directory, but Linux long uses some hidden files to save the configuration information. Cannot display hidden files directly using LS

You can then add the-a option

ls -A.              . Bash_profile  . config    . Esd_auth      mycode        qt installation package      . VIMRC  picture  Desktop             ... BASHRC        . Designer  . Iceauthority.  PKI          . Test. SH . SWP  Public    documentation. Bash_history  blog_plan.c    . Emacs.     local         Qt5. 6.2        . Vim          template    download. bash_logout   . Cache.         EMACS.D   . Mozilla       qt_programme  . Viminfo      video    Music

Use the-r parameter to view the files in the directory that the current directory contains

ls -r.:c_plus_program  c_program  _linux  struct  system_fun. /C_plus_program:. /C_program:. /_linux:. /struct:. /system_fun:close  close.c  myfile  myfile2  open  open.c  read  read.c   Write  write. c

LS is simply a list of files and directories, if we want to get more information about the files contained in the directory, you can add the-l option

or directly using LL

[Email protected] mycode]$ls-L Total Dosage4DRWXRWXR-X.2Zhaozhao Zhaozhao6March -  A: WuC_PLUS_PROGRAMDRWXRWXR-X.2Zhaozhao Zhaozhao6March in  -: -C_PROGRAMDRWXRWXR-X.2Zhaozhao Zhaozhao6March -  A: Wu_LINUXDRWXRWXR-X.2Zhaozhao Zhaozhao6March -  A: WuSTRUCTDRWXRWXR-X.2Zhaozhao Zhaozhao4096March in  -: -System_fun

Using this method, you output a lot of information about the file.

LS By default displays the current directory contains the file, you can also follow LS after the directory name (absolute path, relative path can be), then the terminal will

Displays the files that the directory contains.

ls blog_plan.c  mycode  Qt5. 6.2   qt_programme  Qt installation package  public  template  video  picture  document  download  music   ls mycode/c_plus_program  c_program  _linux  struct  ls ./mycode/C_plus _program  c_program  _linux  struct  ls /home/zhaozhao/mycode/c_plus_ Program  c_program  _linux  struct  system_fun

LS can recognize standard wildcard characters, for example? can match any single character, * can match 0 or more characters

ls system_fun/close  close.c  myfile  myfile2  open  open.c  read  read.c   Write  Write  ls system_? unclose  close.c  myfile  myfile2  open  open.c  read  read.c   Write  write. c
ls system_fun/close  close.c  myfile  myfile2  open  open.c  read  read.c   Write  Write  ls syst*close  close.c  myfile  myfile2  open  open.c  read  READ.C   Write  write. c
3.touch

Touch commands are often used to create files, and after touch with a file name, you can create a file in the current directory (you can, of course, specify the directory you want to create)

ls C_plus_program  C_program  _linux  struct  touchlsc_plus_program  C_program  _linux  new_file  struct  10 March  :  New_file

This file is created when the file does not exist in the back of the touch, and the touch command changes the file's access time and modification time if the file is present.

1 0 March  :sitouch10 March  £ º new_file

After the file is touch, the time value is updated in real time, you can also specify a time to give it, use the-t option

Touch 201703292100  10 March   new_file

The file time was modified by us

  

Summary of SHELL commands from beginner to small white

Related Article

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.