We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
New design
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.10.16. Useful console features

There are many useful features in the console, such as keyboard shortcuts or generic arguments, which are used to make commands more flexible.

There are two files in the Bash shell that allow you to customize the shell used in the CLI to suit your needs. For example, create certain aliases when connecting or set the necessary parameters, which is very useful for frequent work. Files:

  • .bash_profile - file processed automatically when connected to the console. Since usually all created shell parameters are placed in .bashrc, then a file call should be placed in this file .bashrc with code like this:
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi
  • .bashrc - file processed for unauthorized connections, for example, when connecting via WebSSH... Most often, this file is called from the side .bash_profileto create the same experience when connecting with or without authorization. The file contains all the parameters and commands that need to be executed after connecting.
  • Tab - auto-completion, usually used to auto-complete the name of a directory or file, if there are several files with a similar name, then double-clicking will display a list of suitable files.
  • Ctrl+R - interactive search by previously executed commands.
  • Ctrl+Alt - move to the beginning of the team.
  • Ctrl+E - move to the end of the command.
  • Ctrl+D - exit the current connection / command console.
  • pwd - displaying the path to the active directory.
  • cd - changing the active directory.
  • ls - displaying a list of files and directories in the active directory or at the specified path.
  • ll - the same as ls -l, output files and directories as a readable list.
  • cat - output the contents of the file.
  • head - output the first few lines of the file content.
  • tail - output the last few lines of file content, output new lines in real time when completing the file.
  • less - a page-by-page view of a file or command output. To exit you need to press Q.
  • touch - updating the date of the last file modification to the current one. Also creates a file if nonexistent is specified as a parameter.
  • mkdir - creating a directory.
  • rm - deleting a file or directory.
  • grep - a tool for searching files and directories by content. Described in this instructions.
  • find - a tool for searching files and directories. Described in this instructions.
  • diff - comparison of two files, the command output will only show the difference between the files.
  • man - get information about the team and its capabilities.
  • xargs - using the output of the previous command as an argument for the next one. Application: command1 | xargs command2 stdout_command1
  • ~/ - an indication of the user's directory, on the hosting it is /home/user/ Where user thisis hosting account name.
  • > - put the command output into a file, replacing all its contents. Redirecting output has more options than writing data to a file, but these are not covered here.
  • >> - put the command output into a file, appending it at the end. Redirecting output has more options than writing data to a file, but these are not covered here.
  • !! - substitution of the previous command.
  • !* - substitution of the key of the previous command.
  • !$ - substitution of the last argument of the previous command.
  • !abc - substitution of a previously executed command that begins with abc.
  • !?abc? - substitution of the last previously executed command, which contains the text abc.
  • example.file{,.bak} - reducing two lines to one if the second line uses the same text as the first, but with an ending .bak... For example, this is useful when creating a temporary copy of a file. cp config.php{,.bak}.
  • ; - execute a series of commands, separated by this symbol, sequentially, while the execution of the next command does not depend on the result of the previous one.
  • && - execute a series of commands, separated by this symbol, sequentially, but unlike the previous version, the next command will be executed only if the previous command did not return an error. The symbol is similar to the logical condition “AND (AND)».
  • || - execute a series of commands separated by this symbol, but the next command will be executed only if the previous command returned an error during execution. The symbol is similar to the logical condition “OR (OR)».
  • Example - search text in files
  • folder - the target directory within which the search will be performed.
grep -lr 'Example' ~/folder | xargs rm -f --