Xshell common commands

Xshell common commands

(1) ls - list files 

  ls -l give a long list of all files in the
  current directory ls a* list all files in the current directory starting with the letter a
  ls -l *.doc give all files in the current directory ending with .doc

(2) cp - copy file

  cp afile /home/bible/ Copy the file afile from the current directory to the /home/bible/ directory

  cp * /home/bible/ Copy all files in the current directory to the /home/bible/ directory

(3) mv - move and rename files

  mv aflie bfile rename afile to bfile

  mv afile /tmp move the afile in the current directory to the /tmp/ directory

(4) rm - delete files and directories

  rm afile delete file afile

  rm * delete all files in the current directory

  rm -rf domed removes the domed directory and everything it contains

  rm a* delete all files starting with the letter a in the current directory

(5) cd - change directory

  cd ~ Change to user directory

  cd ../ switch to the previous directory

  cd / to change to the root directory

(6) less - view file content 

  less redis.config View the contents of the redis.config file

(7) grep - search file content

  grep bible /etc/exports finds all lines containing bible in the file exports 

  tail -100 /var/log/apache/access.log|grep 404 Look for lines containing "404" in the last 100 lines of the web server log file access.log

(8) vi - edit file 

  vi /etc/bubby.txt Edit the bubby.txt file under etc

    Enter edit mode, press o to edit

    After editing, press ESC to jump to command mode, and then enter the exit command:

    :w saves the file without exiting vi edit

    :w! Force save, do not quit vi editing

    :w file saves changes to file without exiting vi editing

    :wq save the file and quit vi editing

    :wq! Force save the file and quit vi editing

    :q do not save the file and quit vi edit

    :q! do not save the file and force quit vi editing

    :e! Abandon all changes and start editing since the last time the file was saved

(9) ps - view process

  ps -ef|grep redis View the process of redis

(10) kill - kill the process 

  kill -9 [jobnumber] 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325193536&siteId=291194637