{"id":106,"date":"2017-04-04T10:00:00","date_gmt":"2019-11-04T11:00:28","guid":{"rendered":"https:\/\/www.linuxpro.com.br\/2019\/11\/500-comandos-do-linux\/"},"modified":"2026-09-12T07:05:37","modified_gmt":"2026-09-12T10:05:37","slug":"500-comandos-do-linux","status":"publish","type":"post","link":"https:\/\/www.linuxpro.com.br\/en\/2017\/04\/500-comandos-do-linux\/","title":{"rendered":"500 Linux commands: task-based guide and PDF"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/09\/500-comandos-v2.webp\" width=\"1486\" height=\"856\" alt=\"Mascote LinuxPro consultando um livro de comandos em uma biblioteca, acompanhado do cachorro caramelo cyborg sentado\" \/><\/p>\n<div style=\"background:#fff8e1;border-left:4px solid #8b1a1a;padding:.8em 1em;margin:1em 0\">Note (2026): originally published in 2017, this guide has been revised for current reference; the archive PDF remains identified as historical material.<\/div>\n<p>You do not need to memorize hundreds of commands: you need to recognize the task, find the tool, and check what it will do. This page organizes a practical selection by topic, with a safe lab and documentation references. The title refers to the booklet of more than 500 commands available at the end; the page does not reproduce the entire PDF.<\/p>\n<h2>Before copying: understand the type of example<\/h2>\n<p>The examples use Bash and tools commonly found on Linux. Some programs are optional; package and service names vary between distributions. Follow the file lab in order; the other blocks are independent queries, not a script to run in its entirety as root.<\/p>\n<ul>\n<li>Query: displays information but may expose paths, users, and sensitive data. Review output before sharing it.<\/li>\n<li>Local change: creates or modifies practice files. Check the current directory before running it.<\/li>\n<li>Administration: installs, removes, restarts, or changes permissions on real systems. It requires planning, authorization, and a recovery path; it should not be the first troubleshooting attempt.<\/li>\n<\/ul>\n<h2>Discover commands and read help<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">type -a ls\ncommand -v python3\nhelp cd\nman tar\ntar --help\napropos archive\n<\/code><\/pre>\n<p>Use type to discover whether a name resolves to an alias, function, or executable. Bash help covers its built-ins; man opens manual pages. Apropos searches descriptions in the manual database, which must be installed and indexed. In common pagers, q quits and the slash starts a search.<\/p>\n<h2>Lab: navigate, create, and copy without touching your data<\/h2>\n<p>Run the following blocks in the same terminal as a regular user. You need the usual GNU tools, grep, sed, awk, tar, and diff. The working directory is new and resides under your home directory. If creating or entering it fails, the first block exits the shell instead of continuing elsewhere.<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">LAB_DIR=$(mktemp -d &quot;$HOME\/linux-commands.XXXXXX&quot;) || exit 1\ncd &quot;$LAB_DIR&quot; || exit 1\npwd\nmkdir -p data copies restored\nprintf &#x27;%s\\n&#x27; &#x27;alpha&#x27; &#x27;beta&#x27; &#x27;alpha&#x27; &gt; data\/words.txt\ncp -i data\/words.txt copies\/words.txt\nls -lah\nstat data\/words.txt\n<\/code><\/pre>\n<p>The listing shows the created structure; stat provides file metadata. Quotes protect paths containing spaces. The interactive copy option asks for confirmation when overwriting, but it does not make every operation safe.<\/p>\n<h2>Read text, filter lines, and count correctly<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">cat data\/words.txt\nhead -n 2 data\/words.txt\ntail -n 1 data\/words.txt\nwc -l data\/words.txt\ngrep -n &#x27;^alpha$&#x27; data\/words.txt\ngrep -c &#x27;^alpha$&#x27; data\/words.txt\nsort data\/words.txt | uniq -c\nsed &#x27;s\/beta\/gamma\/&#x27; data\/words.txt\nawk &#x27;{print NR, $0}&#x27; data\/words.txt\n<\/code><\/pre>\n<p>The file has 3 lines; the exact search for alpha finds 2. The grep count option counts selected lines, not all occurrences within a line. Sort groups equal values for uniq; the sed example changes only the output, not the original file.<\/p>\n<p>For large files, prefer a pager such as less instead of dumping everything onto the screen. To edit, choose an installed editor such as nano or vi, and learn to save and quit before opening an important configuration file.<\/p>\n<h2>Find files without deleting anything<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">find data -type f -name &#x27;*.txt&#x27; -print\nfind data -type f -exec grep -nH &#x27;alpha&#x27; {} +\nfind data -type f -mtime -1 -print\n<\/code><\/pre>\n<p>Quotes leave the filename pattern for find to interpret. Batch execution with separate arguments preserves filenames containing spaces. The time filter searches files modified within the last 24 hours; it does not necessarily mean since midnight. Inspect the selection first: a query should not contain a surprise deletion.<\/p>\n<ul>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/findutils\/find.1.en.html\">find manual: selection, time, and execution<\/a><\/li>\n<\/ul>\n<h2>Permissions, ownership, and links<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">id\ngroups\nchmod 640 data\/words.txt\nln data\/words.txt data\/words-hard.txt\nln -s words.txt data\/words-link.txt\nls -li data\/\nreadlink data\/words-link.txt\n<\/code><\/pre>\n<p>Permission 640 gives the owner read and write access, the group read access, and everyone else no access. The hard link shares the file inode; the symbolic link stores a path. In this lab, the temporary directory also restricts access: file bits alone do not demonstrate access by another user.<\/p>\n<p>Do not solve failures by granting everyone unrestricted permissions or recursively changing a production directory tree without understanding the effects. Ownership changes, ACLs, and sudo rules should be tested in a training environment with the correct users and directories.<\/p>\n<ul>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/coreutils\/ln.1.en.html\">Hard and symbolic link documentation<\/a><\/li>\n<\/ul>\n<h2>Archive, restore, and verify<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">tar -czf data.tar.gz data\/\ntar -tzf data.tar.gz\ntar -xzf data.tar.gz -C restored\ndiff -r data restored\/data\nsha256sum data.tar.gz\n<\/code><\/pre>\n<p>List the contents before extracting and use an empty directory. The comparison should show no differences in this exercise. This checks content, not every requirement of a complete backup. A hash helps compare files but establishes origin only when checked against a trusted reference.<\/p>\n<p>An archive-mode copy attempts to preserve attributes; the result depends on permissions and the filesystems involved. ACLs, extended attributes, links, and application data recovery need their own tests. Do not confuse an existing compressed archive with proven recoverability.<\/p>\n<ul>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/tar\/tar.1.en.html\">tar manual<\/a><\/li>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/coreutils\/cp.1.en.html\">cp manual and attribute preservation<\/a><\/li>\n<\/ul>\n<h2>Pipes, redirections, and exit statuses<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">printf &#x27;%s\\n&#x27; &#x27;first&#x27; &gt; output.txt\nprintf &#x27;%s\\n&#x27; &#x27;second&#x27; &gt;&gt; output.txt\ncat output.txt | tee copies\/output.txt\nif grep -q &#x27;^alpha$&#x27; data\/words.txt; then\n    printf &#x27;%s\\n&#x27; &#x27;Found&#x27;\nelse\n    printf &#x27;%s\\n&#x27; &#x27;Not found&#x27;\nfi\n<\/code><\/pre>\n<p>Single redirection overwrites; double redirection appends. A pipe connects one command\u2019s standard output to the next command\u2019s input. Standard error is separate. In Bash, a pipeline\u2019s result normally comes from its last command; scripts that need to detect earlier failures should consider pipefail and handle exit statuses deliberately.<\/p>\n<p>The lab is now complete. Keep the directory path to review the results. The following sections are independent references; they do not require deleting the files you created.<\/p>\n<ul>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/bash\/bash.1.en.html\">Bash manual: expansion, pipelines, and redirections<\/a><\/li>\n<\/ul>\n<h2>Processes and performance: inspect before terminating<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">ps -eo pid,ppid,user,comm\npgrep -a bash\nuptime\nfree -h\nvmstat 1 5\nuname -a\nlscpu\n<\/code><\/pre>\n<p>These queries help distinguish processes, load, memory, and architecture. The first vmstat sample has a different time basis from later samples; do not interpret every line as equivalent measurements of the last second. A slow system requires correlation, not merely inspecting one isolated number.<\/p>\n<p>Before terminating a process, identify its PID, user, and role. Normal termination allows the program to handle the request; forced termination does not provide the same cleanup opportunity. Avoid broad patterns that affect multiple processes and do not use forced termination as a universal recipe.<\/p>\n<h2>Disks: diagnose without formatting<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">df -h\ndf -i\ndu -sh &quot;$HOME&quot;\nlsblk -f\nfindmnt\n<\/code><\/pre>\n<p>Compare space, inodes, directory usage, and mounts. Querying the size of your home directory may take time. Free space and inode counts are different measurements; a deleted file still open in a process can also keep space allocated.<\/p>\n<p>Formatting, partitioning, and filesystem repair are excluded from this guide\u2019s copy-and-paste blocks. Practice on an empty virtual disk, identify the device, and confirm the tool\u2019s requirements. Do not assume that a disk name seen in a tutorial matches yours.<\/p>\n<h2>Networking and HTTP: address, route, socket, and response<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">ip -brief address\nip route\nss -ltn\nss -lun\ngetent hosts example.com\ncurl --head --max-time 10 https:\/\/example.com\ncurl --silent --show-error --output \/dev\/null --max-time 10 \\\n  --write-out &#x27;%{http_code}\\n&#x27; https:\/\/example.com\n<\/code><\/pre>\n<p>The first queries are local; name resolution and curl access external services. Seeing a listening port does not prove it is reachable from another machine. A DNS error, a missing route, and an unavailable application require different investigations.<\/p>\n<p>An HTTP status code is not the same as curl\u2019s exit status. Without an option to fail on HTTP errors, receiving an error page can still count as a successful transfer to the tool. Likewise, do not treat a missing ping reply as sufficient proof that a service is down.<\/p>\n<ul>\n<li><a href=\"https:\/\/curl.se\/docs\/manpage.html\">curl: options and failure handling<\/a><\/li>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/iproute2\/ss.8.en.html\">ss: socket queries<\/a><\/li>\n<\/ul>\n<h2>Services, logs, and scheduled tasks<\/h2>\n<p>On systems using systemd, begin with queries. Access to some logs may be restricted; an absence of visible messages does not necessarily mean no events occurred.<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">systemctl --failed --no-pager\nsystemctl list-units --type=service --state=running --no-pager\nsystemctl list-timers --all --no-pager\njournalctl -b -p err --no-pager\njournalctl --since &quot;1 hour ago&quot; --no-pager\njournalctl --disk-usage\ncrontab -l\n<\/code><\/pre>\n<p>The final query requires cron to be installed and may report that the user has no crontab. Do not confuse listing schedules with installing a task. A scheduled script needs defined paths, permissions, environment, and log destination.<\/p>\n<p>When administering a service, choose one action at a time. Starting, stopping, restarting, and reloading are not synonyms; reloading depends on service support. Boot enablement is another property. After editing a unit, reloading systemd definitions does not automatically restart the application.<\/p>\n<ul>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/systemd\/systemctl.1.en.html\">systemctl: states and actions<\/a><\/li>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/systemd\/journalctl.1.en.html\">journalctl: filters and journal access<\/a><\/li>\n<li><a href=\"\/en\/2026\/09\/dominando-o-systemd-comandos-essenciais\/\">LinuxPro systemd guide<\/a><\/li>\n<\/ul>\n<h2>Packages: use your distribution\u2019s package family<\/h2>\n<p>These examples query packages rather than updating them automatically. Use only the block matching your distribution. On Debian and Ubuntu:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">dpkg-query -W bash\ndpkg-query -L bash\napt-cache policy bash\n<\/code><\/pre>\n<p>On an RPM-based distribution with Bash installed:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">rpm -q bash\nrpm -ql bash\n<\/code><\/pre>\n<p>On Arch Linux with Bash installed:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">pacman -Qi bash\npacman -Ql bash\n<\/code><\/pre>\n<p>Installation, removal, and updates change the system. Read the proposed transaction and your distribution\u2019s documentation before confirming. Do not combine alternatives using slashes within a command line: that can pass unexpected arguments instead of representing a choice.<\/p>\n<ul>\n<li><a href=\"https:\/\/manpages.debian.org\/bookworm\/dpkg\/dpkg-query.1.en.html\">Debian: package database queries<\/a><\/li>\n<li><a href=\"https:\/\/rpm.org\/docs\/6.0.x\/man\/rpm.8\">RPM: official documentation<\/a><\/li>\n<li><a href=\"https:\/\/man.archlinux.org\/man\/pacman.8.en\">Arch Linux: pacman manual<\/a><\/li>\n<\/ul>\n<h2>SSH and copying: verify the destination before transferring<\/h2>\n<p>For SSH, confirm the user, host, port, and server identity through a trusted channel. Do not accept a changed host key without investigating, and never send the private key to the server. For step-by-step instructions, use the blog\u2019s key guide.<\/p>\n<ul>\n<li><a href=\"\/en\/2017\/04\/ssh-sem-senha\/\">SSH key authentication<\/a><\/li>\n<\/ul>\n<p>To practice rsync locally, return to the lab directory and use this dry run if the tool is installed:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">cd &quot;$LAB_DIR&quot; || exit 1\nrsync -ani data\/ copies\/data\/\n<\/code><\/pre>\n<p>The dry run shows changes without copying them. A trailing slash on the source means the directory contents. Removing the dry-run option performs the transfer; deletion options can erase destination files and require separate review. Archive mode does not automatically include every kind of metadata.<\/p>\n<ul>\n<li><a href=\"https:\/\/download.samba.org\/pub\/rsync\/rsync.1\">rsync: dry runs, trailing slashes, and preservation<\/a><\/li>\n<\/ul>\n<h2>Complementary tools and useful shortcuts<\/h2>\n<p>Tldr offers short examples, and ripgrep makes recursive searches with ignore rules convenient. They are complements, not universal replacements for manuals or traditional tools. Check each program\u2019s installation and defaults: ignored files may not appear in a search.<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/tldr-pages\/tldr\">tldr: project and clients<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/BurntSushi\/ripgrep\">ripgrep: behavior and documentation<\/a><\/li>\n<\/ul>\n<p>In Bash\u2019s default editing mode, Ctrl-R searches history, while Ctrl-A and Ctrl-E move to the start and end of the line. Ctrl-C interrupts the foreground task; Ctrl-Z suspends it. These are keystrokes, not commands to paste. Before repeating anything from history, read the entire line: the context and directory may have changed.<\/p>\n<h2>Habits that prevent accidents<\/h2>\n<ul>\n<li>Check the user, directory, source, and destination. Use quotes and do not infer disk or server paths from an example.<\/li>\n<li>Back up before editing and validate restoration. An untested snapshot or copy does not demonstrate recoverability.<\/li>\n<li>Do not assume every command has a dry-run or interactive mode. Check the manual and read the option\u2019s limitations.<\/li>\n<li>Avoid recursive deletions, formatting, broad permission changes, and automatic confirmation responses in generic recipes.<\/li>\n<li>Validate configurations before reloading and test the service afterward. Keep a rollback path and console access when changing networking or SSH.<\/li>\n<li>Do not paste commands from AI or unknown pages without reviewing them. Pay particular attention to downloads executed directly, redirections, and empty variables.<\/li>\n<\/ul>\n<h2>Historical PDF: more than 500 Linux commands<\/h2>\n<p>The archive retains the booklet by Bruno Andrade (GNU\/Linux \u2013 Brasil), whose cover indicates 2016. The document itself permits free downloading and sharing for noncommercial purposes. It remains in Portuguese and was not rewritten in this revision; the English version of this page does not turn the PDF into a translation.<\/p>\n<ul>\n<li><a href=\"\/dl\/guia_500_comandos_Linux.pdf\">Download the historical Portuguese booklet (PDF)<\/a><\/li>\n<\/ul>\n<p>Use the booklet as a historical catalog, not as authorization to run every example on a current system. Check versions and manuals before administrative commands. The revised selection above prioritizes understanding the task and verifying results rather than copying an entire list.<\/p>\n<h2>Keep practicing<\/h2>\n<ul>\n<li><a href=\"\/en\/2026\/09\/certificacao-lpic-1\/\">LPIC-1: study plan and lab<\/a><\/li>\n<li><a href=\"\/en\/2017\/04\/serie-servidores-linux\/\">Linux Server Series from the archives<\/a><\/li>\n<li><a href=\"\/en\/2017\/04\/usando-comando-wget-no-linux\/\">wget guide<\/a><\/li>\n<li><a href=\"\/en\/2026\/09\/assistentes-de-ia-no-terminal-linux\/\">AI terminal assistants: use with review<\/a><\/li>\n<\/ul>\n<p>Choose a task, perform it in a training environment, and record how you validated it. Knowing how to consult documentation and recognize a dangerous command is more valuable than memorizing a list of names.<\/p>","protected":false},"excerpt":{"rendered":"<p>Note (2026): originally published on 2017, this guide has been revised for current reference; the archive PDF remains identified as historical material. You don't need to memorize hundreds of commands: you need to recognize the task, find the tool, and check what \u2026 <a title=\"500 Linux commands: task-based guide and PDF\" class=\"read-more\" href=\"https:\/\/www.linuxpro.com.br\/en\/2017\/04\/500-comandos-do-linux\/\" aria-label=\"Read more about 500 comandos Linux: guia por tarefa e PDF\">Read more<\/a><\/p>","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[8,9,10,4],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-linux","tag-cli","tag-dev","tag-dicas","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":5,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":1587,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/106\/revisions\/1587"}],"wp:attachment":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}