DEV Community

Cover image for Comandos Essenciais do Linux (Nv-1)
Davi
Davi

Posted on

2 1 1 1 1

Comandos Essenciais do Linux (Nv-1)

galndaf

Torne-se um Mago do Terminal

O terminal Linux pode parecer intimidador para iniciantes, mas com o domínio de alguns comandos essenciais, você pode se tornar um verdadeiro "mago". Este artigo vai guiá-lo pelos fundamentos e comandos básicos que todo usuário de Linux precisa conhecer.


O Que É o Terminal?

O terminal é a interface de linha de comando usada para interagir com o sistema operacional. No Linux, ele geralmente utiliza o Bash (Bourne Again Shell) como shell padrão, mas existem outros tipos, como Zsh, Fish e Ksh. Aqui, usaremos exemplos do Bash, mas os conceitos são aplicáveis a outros shells.

Dica: se você usa o Zsh, pode personalizá-lo com plugins e temas (como o Oh My Zsh) para tornar seu uso mais prático e visualmente atraente. (meu caso)


1. Navegação no Sistema de Arquivos

Para se movimentar pelo sistema de arquivos, você usa comandos como ls e cd.

Comandos:

  • ls: Lista o conteúdo do diretório atual.
  ls
Enter fullscreen mode Exit fullscreen mode
  • ls -l: Mostra o conteúdo com mais detalhes (permissões, tamanho, etc.).
  ls -l
Enter fullscreen mode Exit fullscreen mode
  • ls -a: Mostra arquivos ocultos.
  ls -a
Enter fullscreen mode Exit fullscreen mode
  • cd: Altera o diretório atual.
  cd /caminho/do/diretorio
Enter fullscreen mode Exit fullscreen mode
  • cd ..: Retorna ao diretório anterior.
  cd ..
Enter fullscreen mode Exit fullscreen mode

2. Manipulação de Arquivos e Diretórios

Aprenda a criar, mover, copiar e deletar arquivos e diretórios com comandos simples.

Comandos:

  • touch: Cria um arquivo vazio.
  touch arquivo.txt
Enter fullscreen mode Exit fullscreen mode
  • mkdir: Cria um novo diretório.
  mkdir novo_diretorio
Enter fullscreen mode Exit fullscreen mode
  • cp: Copia arquivos ou diretórios.
  cp arquivo.txt copia_arquivo.txt
Enter fullscreen mode Exit fullscreen mode
  • mv: Move ou renomeia arquivos.
  mv arquivo.txt novo_nome.txt
Enter fullscreen mode Exit fullscreen mode
  • rm: Remove arquivos.
  rm arquivo.txt
Enter fullscreen mode Exit fullscreen mode
  • rm -r: Remove diretórios recursivamente.
  rm -r diretorio
Enter fullscreen mode Exit fullscreen mode

3. Visualização de Arquivos

Visualizar o conteúdo de arquivos é fundamental para depuração e leitura de logs.

Comandos:

  • cat: Mostra o conteúdo de um arquivo.
  cat arquivo.txt
Enter fullscreen mode Exit fullscreen mode
  • less: Permite navegar pelo conteúdo de um arquivo de forma interativa.
  less arquivo.txt
Enter fullscreen mode Exit fullscreen mode
  • head: Exibe as primeiras linhas de um arquivo.
  head arquivo.txt
Enter fullscreen mode Exit fullscreen mode
  • tail: Exibe as últimas linhas de um arquivo.
  tail arquivo.txt
Enter fullscreen mode Exit fullscreen mode

4. Buscas e Filtros

Localizar arquivos ou filtrar informações dentro deles pode ser incrivelmente útil.

Comandos:

  • find: Busca por arquivos no sistema.
  find / -name arquivo.txt
Enter fullscreen mode Exit fullscreen mode
  • grep: Pesquisa por um texto dentro de arquivos.
  grep "palavra" arquivo.txt
Enter fullscreen mode Exit fullscreen mode

5. Gerenciamento de Processos

Monitore e controle os processos em execução no seu sistema.

Comandos:

  • ps: Mostra processos em execução.
  ps aux
Enter fullscreen mode Exit fullscreen mode
  • top: Exibe processos em tempo real.
  top
Enter fullscreen mode Exit fullscreen mode
  • kill: Encerra um processo.
  kill PID
Enter fullscreen mode Exit fullscreen mode

6. Comandos Gerais

Alguns comandos adicionais que tornam sua vida no terminal mais fácil.

Comandos:

  • clear: Limpa a tela do terminal.
  clear
Enter fullscreen mode Exit fullscreen mode
  • history: Mostra o histórico de comandos executados.
  history
Enter fullscreen mode Exit fullscreen mode
  • man: Exibe o manual de um comando.
  man ls
Enter fullscreen mode Exit fullscreen mode

Um abraço e até o Nv-2

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay