JavaRush /Java Blog /Random EN /Top 10 Most Needed Linux Commands

Top 10 Most Needed Linux Commands

Published in the Random EN group
Matthew Helmke, who has dedicated many years to the Ubuntu operating system, outlines 10 fundamental commands that he believes any Linux user should know. Top 10 most needed Linux commands - 1

Introduction

It's scary to start working with the Linux command line interface if you're used to doing everything through a nice graphical interface. There is a lot of information and sometimes it is not clear where to start. You'd like to discover the features you've heard so much about, but you don't even know how to list files in a directory or navigate the file system. In this post, I will write about ten fundamental commands that, in my opinion, any self-respecting Linux user should know. These are not “top 10 coolest commands”, or the most confusing ones, or those that will make you a command line genius. These are just the commands that I think you should learn first. I'm assuming you've already installed some Linux distribution, or been given a machine with Linux installed on it, and that you've managed to get to the command line by opening a terminal application. You then begin your work in your home (/home) directory with a command line prompt something like this: matthew@lovelace:~$ The first part is your username , in this example "matthew". It is followed by an @ symbol and then the name of the system you are logged into, in this case "lovelace". NOTE: I have a habit of naming my systems after people who played important roles in the history of computing. If the name Ada Lovelace isn't familiar to you, she deserves to be read about.
Top 10 most needed Linux commands - 2
Finally, the prompt includes a colon followed by your current location on the file system. The tilde " ~ " icon in Linux is short for "my home directory". In my case it is /home/matthew . The commands described below must be entered from this command line and completed by pressing the Enter key . For simplicity, I will assume that you are using the most common command line shell: bash . Don't worry if you don't know what it is.

List

  1. pwd

    pwd stands for "Print Working Directory". This command returns your file system location, such as /usr/share or /home/matthew. This can be helpful if you have sclerosis if you forget where you are.

  2. ls

    When used alone, the ls command lists all files and subdirectories in the current directory. You can also use ls to list the entire contents of any directory without navigating to it, by appending the directory's address to the command, for example: ls etc/python.

  3. CD

    Эта команда приводит к смене текущего каталога на заданный. Например, команда cd /var/log перенесет вас в подкаталог log, находящийся в каталоге var.

  4. touch

    Команда touch создает пустой файл с заданным именем. Создайте файл прямо сейчас и воспользуйтесь командой cd, чтобы убедиться, что он был создан в текущем каталоге: touch examplefile.

  5. rm

    Команда rm удаляет файл. Для удаления созданного вами выше file, введите: rm examplefile.

  6. mkdir

    Команда mkdir создает каталог. Создайте каталог прямо сейчас и воспользуйтесь командой cd, чтобы убедиться, что он был создан в текущем каталоге: mkdir exampledirectory.

  7. rmdir

    Команда rmdir удаляет каталог. Для удаления созданного вами выше каталога, введите: rm exampledirectory.

  8. mv

    Команда mv перемещает заданный файл or каталог в указанное место. Её можно также использовать для переименования файлов и каталогов. При желании, можно сделать и то, и другое одной командой. Например, давайте переместим файл с именем sample из текущего каталога в существующий подкаталог stuff с одновременным изменением имени этого file на example: mv sample stuff/example.

  9. cp

    Команда cp копирует заданный файл or каталог в указанное вами место, возможно, с заданным вами новым именем file/каталога. Воспользуемся тем же примером: cp sample stuff/example. Различие между mv и cp в том, что во втором случае исходный файл остается на своём месте.

  10. man

    Команда man отображает page справочника для заданной команды. Каждая из описанных выше команд способна на гораздо большее, чем мы уже узнали. На деле, это была лишь верхушка айсберга. У большинства команд есть опции, называемые параметрами, предназначенные для изменения их поведения по умолчанию. Например, если вы введете man ls и прочитаете page справочника для этой команды, то узнаете о существовании чрезвычайно удобных опций, таких How ls -al, которая позволяет вывести список не только с именами файлов и каталогов, но и очень полезными метаданными каждого file и каталога.

Дальнейшие шаги

These commands will help you get started with the Linux command line. But to really benefit from them, you will have to read and try a lot more. If you want to work on Linux, read about file permissions, which are file/directory-related settings that determine which users can work with those files/directories and what exactly they can do with them. To understand this, you first need to know what user accounts are and how they are used by system users, programs, and automated processes. After that, spend some time becoming familiar with the Linux file system. There is a set of standard directories and files located in the same places on all machines running the Linux operating system. Knowing where to look for something and what to look for can be very helpful, especially if you take the time to learn it before anything happens that needs fixing. It's also worth reading up on different command line shells. The most common shells are bash and dash, both of which use the above commands, but there are others. Each shell includes features that you may like or may simply be better suited to your needs. Take a look at tcsh, ksh and zsh. Source: http://www.informit.com/articles/article.aspx?p=2858803
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION