{"id":18297,"date":"2019-05-28T12:03:37","date_gmt":"2019-05-28T12:03:37","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=18297"},"modified":"2026-03-10T09:37:01","modified_gmt":"2026-03-10T09:37:01","slug":"linux-commands","status":"publish","type":"post","link":"\/ph\/tutorials\/linux-commands","title":{"rendered":"Top 60 Linux commands: What they are and how to use them effectively"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Linux commands are terminal-based instructions used to manage files, directories, users, processes, networking, and system services in Linux operating systems. This Linux commands guide provides a complete command list, grouped by category, with syntax structures and practical examples for each command.<\/p><p>There are various Linux utilities available in the command-line interface that send instructions to the system to perform different tasks. In general, Linux commands can be categorized into:<\/p><ul class=\"wp-block-list\">\n<li><strong>Filesystem browsing commands<\/strong>. Utilities for navigating directories and paths.&nbsp;<\/li>\n\n\n\n<li><strong>File and directory handling commands<\/strong>. Tools for organizing and processing files and folders.&nbsp;<\/li>\n\n\n\n<li><strong>User and access control commands<\/strong>. Command-line instructions for managing accounts and their permissions.&nbsp;<\/li>\n\n\n\n<li><strong>System and process monitoring commands. <\/strong>Tools for analyzing system performance and processes like services.&nbsp;<\/li>\n\n\n\n<li><strong>Network management commands. <\/strong>Utilities for adjusting network settings.&nbsp;<\/li>\n<\/ul><p>Let&rsquo;s review each category first, and then we&rsquo;ll explore the commands in more detail, along with their examples.<\/p><h2 class=\"wp-block-heading\" id=\"h-linux-commands-cheat-sheet\">Linux commands cheat sheet<\/h2><figure tabindex=\"0\" class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>What it does<\/th><\/tr><\/thead><tbody><tr><td>ls<\/td><td>List directory contents<\/td><\/tr><tr><td>pwd<\/td><td>Show current directory path<\/td><\/tr><tr><td>cd<\/td><td>Change directory<\/td><\/tr><tr><td>locate<\/td><td>Search files by name<\/td><\/tr><tr><td>find<\/td><td>Search files and directories<\/td><\/tr><tr><td>mkdir<\/td><td>Create a directory<\/td><\/tr><tr><td>rmdir<\/td><td>Remove an empty directory<\/td><\/tr><tr><td>rm<\/td><td>Delete files or directories<\/td><\/tr><tr><td>cp<\/td><td>Copy files or directories<\/td><\/tr><tr><td>mv<\/td><td>Move or rename files<\/td><\/tr><tr><td>touch<\/td><td>Create an empty file<\/td><\/tr><tr><td>file<\/td><td>Show file type<\/td><\/tr><tr><td>zip<\/td><td>Compress files into ZIP archive<\/td><\/tr><tr><td>unzip<\/td><td>Extract ZIP archive<\/td><\/tr><tr><td>tar<\/td><td>Archive files and directories<\/td><\/tr><tr><td>nano<\/td><td>Edit files with Nano<\/td><\/tr><tr><td>vi<\/td><td>Edit files with Vi<\/td><\/tr><tr><td>jed<\/td><td>Edit files with Jed<\/td><\/tr><tr><td>cat<\/td><td>Display file content<\/td><\/tr><tr><td>grep<\/td><td>Search text patterns in files<\/td><\/tr><tr><td>sed<\/td><td>Replace or modify text patterns<\/td><\/tr><tr><td>head<\/td><td>Show first lines of a file<\/td><\/tr><tr><td>tail<\/td><td>Show last lines of a file<\/td><\/tr><tr><td>awk<\/td><td>Process and analyze text<\/td><\/tr><tr><td>sort<\/td><td>Sort file content<\/td><\/tr><tr><td>cut<\/td><td>Extract sections of text<\/td><\/tr><tr><td>diff<\/td><td>Compare two files<\/td><\/tr><tr><td>tee<\/td><td>Output to terminal and file<\/td><\/tr><tr><td>sudo<\/td><td>Run command as administrator<\/td><\/tr><tr><td>su<\/td><td>Switch user account<\/td><\/tr><tr><td>whoami<\/td><td>Show current user<\/td><\/tr><tr><td>chmod<\/td><td>Change file permissions<\/td><\/tr><tr><td>chown<\/td><td>Change file ownership<\/td><\/tr><tr><td>useradd<\/td><td>Create new user<\/td><\/tr><tr><td>userdel<\/td><td>Delete user account<\/td><\/tr><tr><td>passwd<\/td><td>Set or change password<\/td><\/tr><tr><td>df<\/td><td>Show disk space usage<\/td><\/tr><tr><td>du<\/td><td>Show directory size<\/td><\/tr><tr><td>top<\/td><td>Display running processes<\/td><\/tr><tr><td>htop<\/td><td>Interactive process viewer<\/td><\/tr><tr><td>ps<\/td><td>Show process snapshot<\/td><\/tr><tr><td>uname<\/td><td>Show system information<\/td><\/tr><tr><td>hostname<\/td><td>Show or set hostname<\/td><\/tr><tr><td>time<\/td><td>Measure command execution time<\/td><\/tr><tr><td>systemctl<\/td><td>Manage system services<\/td><\/tr><tr><td>watch<\/td><td>Run command repeatedly<\/td><\/tr><tr><td>jobs<\/td><td>List shell background jobs<\/td><\/tr><tr><td>kill<\/td><td>Terminate a process<\/td><\/tr><tr><td>shutdown<\/td><td>Shut down or restart system<\/td><\/tr><tr><td>ping<\/td><td>Test network connectivity<\/td><\/tr><tr><td>wget<\/td><td>Download files from the web<\/td><\/tr><tr><td>curl<\/td><td>Transfer data via URL<\/td><\/tr><tr><td>scp<\/td><td>Copy files over SSH<\/td><\/tr><tr><td>rsync<\/td><td>Sync files between systems<\/td><\/tr><tr><td>ip<\/td><td>Manage network settings<\/td><\/tr><tr><td>netstat<\/td><td>Show network connections<\/td><\/tr><tr><td>traceroute<\/td><td>Trace network packet path<\/td><\/tr><tr><td>nslookup<\/td><td>Query DNS records<\/td><\/tr><tr><td>dig<\/td><td>Detailed DNS lookup<\/td><\/tr><tr><td>history<\/td><td>Show command history<\/td><\/tr><tr><td>man<\/td><td>Show command manual<\/td><\/tr><tr><td>echo<\/td><td>Print text to terminal<\/td><\/tr><tr><td>ln<\/td><td>Create file links<\/td><\/tr><tr><td>alias<\/td><td>Create command shortcut<\/td><\/tr><tr><td>unalias<\/td><td>Remove command shortcut<\/td><\/tr><tr><td>cal<\/td><td>Display calendar<\/td><\/tr><tr><td>apt<\/td><td>Manage packages (Debian-based)<\/td><\/tr><tr><td>dnf<\/td><td>Manage packages (RHEL-based)<\/td><\/tr><\/tbody><\/table><\/figure><h2 class=\"wp-block-heading\" id=\"h-file-and-folder-navigation-commands\">File and folder navigation commands<\/h2><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Command<\/strong><\/td><td><strong>Function<\/strong><\/td><\/tr><tr><td><a href=\"#ls-command\">ls<\/a><\/td><td>List the content of a directory<\/td><\/tr><tr><td><a href=\"#pwd-command\">pwd<\/a><\/td><td>Check a directory&rsquo;s path<\/td><\/tr><tr><td><a href=\"#cd-command\">cd<\/a><\/td><td>Change directory<\/td><\/tr><tr><td><a href=\"#locate-command\">locate<\/a><\/td><td>Search for a file and its path&nbsp;<\/td><\/tr><tr><td><a href=\"#find-command\">find<\/a><\/td><td>Find a file within the current directory<\/td><\/tr><\/tbody><\/table><\/figure><h2 class=\"wp-block-heading\" id=\"h-file-and-folder-operations-commands\">File and folder operations commands<\/h2><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Command<\/strong><\/td><td><strong>Function<\/strong><\/td><\/tr><tr><td><a href=\"#mkdir-command\">mkdir<\/a><\/td><td>Make a directory<\/td><\/tr><tr><td><a href=\"#rmdir-command\">rmdir<\/a><\/td><td>Remove a directory<\/td><\/tr><tr><td><a href=\"#rm-command\">rm&nbsp;<\/a><\/td><td>Delete a file<\/td><\/tr><tr><td><a href=\"#cp-command\">cp<\/a><\/td><td>Copy a file to another location<\/td><\/tr><tr><td><a href=\"#mv-command\">mv<\/a><\/td><td>Move or rename a file or a folder<\/td><\/tr><tr><td><a href=\"#touch-command\">touch<\/a><\/td><td>Create an empty file<\/td><\/tr><tr><td><a href=\"#file-command\">file<\/a><\/td><td>Check a file type<\/td><\/tr><tr><td><a href=\"#zip-unzip-command\">zip and unzip<\/a><\/td><td>Compress or extract a ZIP archive<\/td><\/tr><tr><td><a href=\"#tar-command\">tar<\/a><\/td><td>Bundle files into a tarball<\/td><\/tr><tr><td><a href=\"#nano-vi-jed-command\">nano, vi, and jed<\/a><\/td><td>Open up a text editor<\/td><\/tr><tr><td><a href=\"#cat-command\">cat<\/a><\/td><td>Print a file&rsquo;s content<\/td><\/tr><tr><td><a href=\"#grep-command\">grep<\/a><\/td><td>Find a specific line from a file<\/td><\/tr><tr><td><a href=\"#sed-command\">sed<\/a><\/td><td>Search and replace a pattern in a file<\/td><\/tr><tr><td><a href=\"#head-command\">head<\/a><\/td><td>Print the first few entries of a file<\/td><\/tr><tr><td><a href=\"#tail-command\">tail<\/a><\/td><td>Print the last few entries of a file<\/td><\/tr><tr><td><a href=\"#awk-command\">awk<\/a><\/td><td>Search and manipulate a pattern in a file<\/td><\/tr><tr><td><a href=\"#sort-command\">sort<\/a><\/td><td>Rearrange a file&rsquo;s content<\/td><\/tr><tr><td><a href=\"#cut-command\">cut<\/a><\/td><td>Select and print specific parts of a file<\/td><\/tr><tr><td><a href=\"#diff-command\">diff<\/a><\/td><td>Compare file content<\/td><\/tr><tr><td><a href=\"#tee-command\">tee<\/a><\/td><td>Print a command&rsquo;s output into a file and shell<\/td><\/tr><tr><td><a href=\"#echo-command\">echo<\/a><\/td><td>Print text in the shell<\/td><\/tr><tr><td><a href=\"#ln-command\">ln<\/a><\/td><td>Link files or folders<\/td><\/tr><tr><td><a href=\"#alias-unalias-command\">alias and unalias<\/a><\/td><td>Set or remove another name for a file or program<\/td><\/tr><tr><td><a href=\"#apt-dnf-command\">apt and dnf<\/a><\/td><td>Manage system repository and packages<\/td><\/tr><\/tbody><\/table><\/figure><h2 class=\"wp-block-heading\" id=\"h-user-and-permission-management-commands\">User and permission management commands<\/h2><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Command<\/strong><\/td><td><strong>Function<\/strong><\/td><\/tr><tr><td><a href=\"#sudo-command\">sudo<\/a><\/td><td>Run a command as a superuser<\/td><\/tr><tr><td><a href=\"#su-whoami-command\">su<\/a><\/td><td>Change user<\/td><\/tr><tr><td><a href=\"#su-whoami-command\">whoami<\/a><\/td><td>Check the current user<\/td><\/tr><tr><td><a href=\"#chmod-command\">chmod<\/a><\/td><td>Change an item&rsquo;s permission<\/td><\/tr><tr><td><a href=\"#chown-command\">chown<\/a><\/td><td>Change an item&rsquo;s ownership<\/td><\/tr><tr><td><a href=\"#useradd-passwd-userdel-command\">useradd and userdel<\/a><\/td><td>Add or remove a new user<\/td><\/tr><tr><td><a href=\"#useradd-passwd-userdel-command\">passwd<\/a><\/td><td>Set a new password for a user<\/td><\/tr><\/tbody><\/table><\/figure><h2 class=\"wp-block-heading\" id=\"h-system-monitoring-and-processes-commands\">System monitoring and processes commands<\/h2><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Command<\/strong><\/td><td><strong>Function<\/strong><\/td><\/tr><tr><td><a href=\"#df-command\">df<\/a><\/td><td>Check disk usage<\/td><\/tr><tr><td><a href=\"#du-command\">du<\/a><\/td><td>Check the size of a folder and its content<\/td><\/tr><tr><td><a href=\"#top-command\">top<\/a><\/td><td>Display running processes and their hardware consumption<\/td><\/tr><tr><td><a href=\"#htop-command\">htop<\/a><\/td><td>List and manage processes<\/td><\/tr><tr><td><a href=\"#ps-command\">ps<\/a><\/td><td>Summarize processes at a specific time<\/td><\/tr><tr><td><a href=\"#uname-command\">uname<\/a><\/td><td>Print system information<\/td><\/tr><tr><td><a href=\"#time-command\">time<\/a><\/td><td>Measure command or program execution time<\/td><\/tr><tr><td><a href=\"#systemctl-command\">systemctl<\/a><\/td><td>Manage services<\/td><\/tr><tr><td><a href=\"#watch-command\">watch<\/a><\/td><td>Run a command indefinitely<\/td><\/tr><tr><td><a href=\"#jobs-command\">jobs<\/a><\/td><td>Check running programs in the current shell<\/td><\/tr><tr><td><a href=\"#kill-command\">kill<\/a><\/td><td>Terminate a process<\/td><\/tr><tr><td><a href=\"#shutdown-command\">shutdown<\/a><\/td><td>Turn off your system<\/td><\/tr><tr><td><a href=\"#history-command\">history<\/a><\/td><td>Check previously run commands<\/td><\/tr><tr><td><a href=\"#man-command\">man<\/a><\/td><td>Displays the manual of another command<\/td><\/tr><tr><td><a href=\"#cal-command\">cal<\/a><\/td><td>Opens a calendar<\/td><\/tr><\/tbody><\/table><\/figure><h2 class=\"wp-block-heading\" id=\"h-networking-commands\">Networking commands<\/h2><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Command<\/strong><\/td><td><strong>Function<\/strong><\/td><\/tr><tr><td><a href=\"#hostname-command\">hostname<\/a><\/td><td>Check system hostname<\/td><\/tr><tr><td><a href=\"#ping-command\">ping<\/a><\/td><td>Send packets to a destination<\/td><\/tr><tr><td><a href=\"#wget-command\">wget<\/a><\/td><td>Download files from a URL<\/td><\/tr><tr><td><a href=\"#curl-command\">curl<\/a><\/td><td>Transfer data to and from a URL<\/td><\/tr><tr><td><a href=\"#ip-command\">ip<\/a><\/td><td>Manage the system network<\/td><\/tr><tr><td><a href=\"#netstat-command\">netstat<\/a><\/td><td>Display network information<\/td><\/tr><tr><td><a href=\"#traceroute-command\">traceroute<\/a><\/td><td>Track the packet during transmission<\/td><\/tr><tr><td><a href=\"#nslookup-command\">nslookup<\/a><\/td><td>Check DNS information<\/td><\/tr><tr><td><a href=\"#dig-command\">dig<\/a><\/td><td>Check information about a domain<\/td><\/tr><tr><td><a href=\"#scp-command\">scp<\/a><\/td><td>Copy items over a network<\/td><\/tr><tr><td><a href=\"#rsync-command\">rsync<\/a><\/td><td>Sync items between two systems over a network<\/td><\/tr><\/tbody><\/table><\/figure><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"ls-command\">1. ls command<\/h2><p>The <a href=\"\/ph\/tutorials\/ls-command\"><strong>ls<\/strong> command<\/a> lists the content of a folder, including files and directories. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">ls [options] [directory_or_path]<\/pre><p>Common options:<\/p><ul class=\"wp-block-list\">\n<li><code>-a<\/code> &rarr; show hidden files<\/li>\n\n\n\n<li><code>-l<\/code> &rarr; detailed list<\/li>\n<\/ul><p>Example:<\/p><pre class=\"wp-block-preformatted\">ls -Ra \/path\/to\/dir<\/pre><h2 class=\"wp-block-heading\" id=\"pwd-command\">2. pwd command<\/h2><p>The <strong>pwd<\/strong> command checks the full path of your current working directory. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">pwd [options]<\/pre><p>The <strong>pwd<\/strong> command has only two options. The<strong> -L<\/strong> option prints <a href=\"\/ph\/tutorials\/linux-environment-variables\">environment variable<\/a> content, like shortcuts, instead of the actual path of your current location. Meanwhile, <strong>-P<\/strong> outputs the exact location.<\/p><p>For example, <strong>\/shortcut\/folder<\/strong> is a shortcut for<strong> \/actual\/path<\/strong>, and you are currently in <strong>\/actual\/path\/dir<\/strong>. If you use the <strong>-L<\/strong> option, the output will be:<\/p><pre class=\"wp-block-preformatted\">\/shortcut\/folder\/dir<\/pre><p>Meanwhile, the <strong>-P<\/strong> option will print the exact canonical path:<\/p><pre class=\"wp-block-preformatted\">\/actual\/path\/dir<\/pre><h2 class=\"wp-block-heading\" id=\"cd-command\">3. cd command<\/h2><p>The <strong>cd<\/strong> command is used to navigate between directories in your Linux VPS. It doesn&rsquo;t have any options.<\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">cd [path_or_directory]<\/pre><p>Depending on your location, you might only need to specify the parent directory. For example, omit <strong>path <\/strong>from <strong>path\/to\/directory<\/strong> if you are already inside one. The <strong>cd<\/strong> command has several shortcuts:<\/p><ul class=\"wp-block-list\">\n<li><strong>cd<\/strong> &ndash; returns to the current user&rsquo;s home directory.<\/li>\n\n\n\n<li><strong>cd ..<\/strong> &ndash; moves a directory up.<\/li>\n\n\n\n<li><strong>cd &ndash;<\/strong> &ndash; goes back to the previous directory. <\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"mkdir-command\">4. mkdir command<\/h2><p>The <strong>mkdir <\/strong>command creates one or multiple directories. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">mkdir [options] directory_name1 directory_name2<\/pre><p>To create a folder in another location, specify the full path. Otherwise, this command will make the new item in your current working directory.<\/p><p>For example, enter the following to create <strong>new_folder<\/strong> in <strong>\/path\/to\/target_folder<\/strong>:<\/p><pre class=\"wp-block-preformatted\">mkdir path\/to\/target_folder\/new_folder<\/pre><p>By default, <strong>mkdir<\/strong> allows the current user to read, write, and execute files in the new folder. You can set custom privileges during the creation by adding the <strong>-m<\/strong> option. To learn more about permission management, read the <strong>chmod<\/strong> section below.<\/p><h2 class=\"wp-block-heading\" id=\"rmdir-command\">5. rmdir command<\/h2><p>The <strong>rmdir <\/strong>command <a href=\"\/ph\/tutorials\/how-to-remove-files-and-folders-using-linux-command-line\/\">deletes empty directories in your Linux system<\/a>. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">rmdir [options] directory_name<\/pre><p>The <strong>rmdir<\/strong> command won&rsquo;t work if the directory contains subfolders. To force the deletion, add the &ndash;<strong>p<\/strong> option. Note that you must own the item you want to remove or use <strong>sudo<\/strong> instead. Here&rsquo;s an example of how to use this command:<\/p><pre class=\"wp-block-preformatted\">rmdir -p folder-name<\/pre><h2 class=\"wp-block-heading\" id=\"rm-command\">6. rm command<\/h2><p>The <strong>rm<\/strong> command deletes files from a directory. You must have the write permission for the folder or use <strong>sudo<\/strong>. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">rm [options] file1 file2<\/pre><p>You can add the <strong>-r<\/strong> option to remove a folder and its contents, including subdirectories. Use the <strong>-i<\/strong> flag to display a confirmation message before the removal or <strong>-f<\/strong> to deactivate it completely:<\/p><pre class=\"wp-block-preformatted\">rm -rf folder-name<\/pre><p>    <p class=\"warning\">\n        <strong>Warning!<\/strong> Avoid using <strong>-r<\/strong> and <strong>-f<\/strong> unless necessary. Instead, add <strong>-i<\/strong> option to prevent accidental deletion.    <\/p>\n    \n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"cp-command\">7. cp command<\/h2><p>The cp command copies files from your current directory to another folder. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">cp file1 file2 [target_path]<\/pre><p>You can also use <strong>cp<\/strong> to duplicate the content of one file to another using this syntax. If the target is in another location, specify the full path like so:<\/p><pre class=\"wp-block-preformatted\">cp source_file \/path\/to\/target_file<\/pre><p>Additionally, <strong>cp<\/strong> lets you duplicate a directory and its content to another folder using the <strong>-R<\/strong> option:<\/p><pre class=\"wp-block-preformatted\">cp -R \/path\/to\/folder \/target\/path\/to\/folder_copy<\/pre><h2 class=\"wp-block-heading\" id=\"mv-command\">8. mv command<\/h2><p>The <strong>mv<\/strong> command moves a file or folder to another location. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">mv file_or_directory [target_directory]<\/pre><p>For example, we will move <strong>file1.txt<\/strong> from another location to the <strong>\/new\/file\/directory<\/strong> path using this command:<\/p><pre class=\"wp-block-preformatted\">mv \/original\/path\/file1.txt the\/target\/path<\/pre><p>You can also use the <strong>mv<\/strong> command to <a href=\"\/ph\/tutorials\/how-to-rename-files-in-linux\/\">rename files in your Linux system<\/a>. Here&rsquo;s an example:<\/p><pre class=\"wp-block-preformatted\">mv old_name.txt new_name.txt<\/pre><p>If you specify the full path, you can simultaneously rename files and move them to a new location, like this example:<\/p><pre class=\"wp-block-preformatted\">mv old\/location\/of\/old_name.txt new\/path\/for\/new_name.txt<\/pre><h2 class=\"wp-block-heading\" id=\"touch-command\">9. touch command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-touch-command-with-useful-examples\/\"><strong>touch<\/strong> command<\/a> creates a new empty file in a specific directory. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">touch [options] [path_and_file_name]<\/pre><p>If you omit the path, the <strong>touch<\/strong> command will create a new file in your current working directory. Here&rsquo;s an example:<\/p><pre class=\"wp-block-preformatted\">touch file.txt<\/pre><h2 class=\"wp-block-heading\" id=\"file-command\">10. file command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-file-command\/\"><strong>file<\/strong> command<\/a> checks a file type, such as TXT, PDF, or others. <\/p><p>Syntax<\/p><pre class=\"wp-block-preformatted\">file [file_name]<\/pre><p>If you use this command on a <a href=\"\/ph\/tutorials\/how-to-create-symbolic-links-in-linux\/\">symbolic link<\/a>, it will output the actual file connected to the shortcut. For example, this command will check which file <strong>hostinger_sym.txt<\/strong> points to:<\/p><pre class=\"wp-block-preformatted\">file hostinger_sym.txt<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99d1cdc\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"782\" height=\"62\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/file-command-shows-actual-file-of-a-symbolic-link.png\" alt=\"File command shows the actual file of a symbolic link\" class=\"wp-image-114104\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/file-command-shows-actual-file-of-a-symbolic-link.png 782w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/file-command-shows-actual-file-of-a-symbolic-link-300x24.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/file-command-shows-actual-file-of-a-symbolic-link-150x12.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/file-command-shows-actual-file-of-a-symbolic-link-768x61.png 768w\" sizes=\"(max-width: 782px) 100vw, 782px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>You can add the<strong> -k<\/strong> option to print more detailed information about the item.<\/p><h2 class=\"wp-block-heading\" id=\"zip-unzip-command\">11. zip and unzip commands<\/h2><p>The <strong>zip<\/strong> command compresses one or multiple files into a <strong>ZIP<\/strong> archive, reducing their size. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">zip [options] zip_file_name file1 file2<\/pre><p>To <a href=\"\/ph\/tutorials\/how-to-unzip-files-linux\/\">extract a compressed file<\/a> into your current working directory, use the <strong>unzip<\/strong> command like so:<\/p><pre class=\"wp-block-preformatted\">unzip [options] zip_file_name<\/pre><h2 class=\"wp-block-heading\" id=\"tar-command\">12. tar command<\/h2><p>The<strong> <\/strong><a href=\"\/ph\/tutorials\/linux-tar-command-with-examples\/\"><strong>tar <\/strong>command<\/a> bundles multiple files or directories into an archive without compression. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">tar [options] tar_file_name file1 file2<\/pre><p>To create a new <strong>TAR<\/strong> file, you must add the <strong>-c <\/strong>option. Then, use the<strong> -f <\/strong>flag to specify the archive&rsquo;s name.<\/p><p>If you want to enable compression, add a specific option based on your preferred method. For example, the following will bundle <strong>file1.txt<\/strong> and <strong>file2.txt <\/strong>with the <strong>gzip<\/strong> compression:<\/p><pre class=\"wp-block-preformatted\">tar -cfz archive.tar.gz fle1.txt file2.txt<\/pre><p>Remember that the archive&rsquo;s file format will differ depending on the compression method. Regardless of the extension, you can unpack a <strong>TAR<\/strong> file using this syntax:<\/p><pre class=\"wp-block-preformatted\">tar [options] tar_file_name<\/pre><h2 class=\"wp-block-heading\" id=\"nano-vi-jed-command\">13. nano, vi, and jed command<\/h2><p><a href=\"\/ph\/tutorials\/how-to-install-and-use-nano-text-editor\"><strong>nano<\/strong><\/a>, <strong>vi<\/strong>, and <strong>jed<\/strong> commands let you edit files. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">nano\/vi\/jed file_name<\/pre><p>If the target file doesn&rsquo;t exist, these commands will create a new one. Since your system might not have these text processing utilities pre-installed, configure them using your package manager.<\/p><p>We will explain how to set that up in the <strong>apt<\/strong> <strong>and dnf command<\/strong> section.<\/p><h2 class=\"wp-block-heading\" id=\"cat-command\">14. cat command<\/h2><p><span style=\"margin: 0px;padding: 0px\">The&nbsp;<strong>concatenate,&nbsp;<\/strong>or&nbsp;<a href=\"\/ph\/tutorials\/linux-cat-command-tutorial-and-examples\/\"><strong>cat&nbsp;<\/strong>command<\/a><\/span> prints the content of a file. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">cat file_name<\/pre><p>To print the content in reverse order, use<strong> tac<\/strong> instead. If you add the standard output operator symbol (<strong>&gt;<\/strong>), the <strong>cat<\/strong> command will create a new file. For example, the following will make <strong>file.txt<\/strong>:<\/p><pre class=\"wp-block-preformatted\">cat &gt; file.txt<\/pre><p>You can also use cat with the operator to combine the content of multiple files into a new item. In this command,<strong> file1.txt <\/strong>and <strong>file2.txt<\/strong> will merge into <strong>target.txt<\/strong>:<\/p><pre class=\"wp-block-preformatted\">cat file1.txt file2.txt &gt; target.txt<\/pre><h2 class=\"wp-block-heading\" id=\"grep-command\">15. grep command<\/h2><p><strong>Global regular expression print<\/strong> or <a href=\"\/ph\/tutorials\/grep-command-in-linux-useful-examples\/\"><strong>grep<\/strong> command<\/a> searches specific lines from a file using keywords. It is useful for filtering large data, like logs. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">grep [options] keyword [file]<\/pre><p>You can also filter data from another utility by piping it to the <strong>grep<\/strong> command. For example, the following searches <strong>file.txt<\/strong> from the <strong>ls<\/strong> command&rsquo;s output:<\/p><pre class=\"wp-block-preformatted\">ls | grep \"file.txt\"<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99d486c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"136\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/grep-command-filters-ls-output-1024x136.png\" alt=\"Grep command filters ls' output\" class=\"wp-image-114105\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/grep-command-filters-ls-output-1024x136.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/grep-command-filters-ls-output-300x40.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/grep-command-filters-ls-output-150x20.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/grep-command-filters-ls-output-768x102.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/grep-command-filters-ls-output.png 1061w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"sed-command\">16. sed command<\/h2><p>The <a href=\"\/ph\/tutorials\/how-to-use-linux-sed-command-examples\/\"><strong>sed<\/strong> command<\/a> is used to search and replace patterns in files quickly. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">sed [options] 'subcommand\/new_pattern\/target_pattern' input_file<\/pre><p>You can replace a string in multiple files simultaneously by listing them. Here&rsquo;s an example of a sed command that changes <strong>red<\/strong> in <strong>colors.txt<\/strong> and<strong> hue.txt<\/strong> with<strong> blue<\/strong>:<\/p><pre class=\"wp-block-preformatted\">sed 's\/red\/blue' colors.txt hue.txt<\/pre><h2 class=\"wp-block-heading\" id=\"head-command\">17. head command<\/h2><p>The <strong>head<\/strong> command prints the first few entries of a file. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">head [options] file_name<\/pre><p>You can also print the first few lines of another command&rsquo;s output by piping it like so:<\/p><pre class=\"wp-block-preformatted\">command | head [options]<\/pre><p>By default, <strong>head<\/strong> will show the <strong>first ten lines<\/strong>. However, you can change this setting using the <strong>-n <\/strong>option followed by your desired number. Meanwhile, use <strong>-c<\/strong> to print the first few entries based on the byte size instead of the line. For example, this command prints the first two bytes of a file:<\/p><pre class=\"wp-block-preformatted\">head -c 2 file.txt<\/pre><h2 class=\"wp-block-heading\" id=\"tail-command\">18. tail command<\/h2><p>The<strong> <\/strong><a href=\"\/ph\/tutorials\/how-to-use-tail-command\/\"><strong>tail<\/strong> command<\/a> is the opposite of <strong>head<\/strong>, allowing you to print the last few lines from files or another utility&rsquo;s output. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">tail [options] file_name<\/pre><pre class=\"wp-block-preformatted\">command | tail [options]<\/pre><p>The <strong>tail<\/strong> utility also has the same option as <strong>head<\/strong>. For example, we will extract the <strong>last five lines<\/strong> from the <strong>ping<\/strong> command&rsquo;s output:<\/p><pre class=\"wp-block-preformatted\">ping -c 10 8.8.8.8 | tail -n 5<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99d7054\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"940\" height=\"180\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/tail-command-prints-last-five-lines-from-ping.png\" alt=\"Tail command prints last five lines from ping\" class=\"wp-image-114106\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tail-command-prints-last-five-lines-from-ping.png 940w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tail-command-prints-last-five-lines-from-ping-300x57.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tail-command-prints-last-five-lines-from-ping-150x29.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tail-command-prints-last-five-lines-from-ping-768x147.png 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"awk-command\">19. awk command<\/h2><p>The <a href=\"\/ph\/tutorials\/awk-command\"><strong>awk<\/strong> command<\/a> searches and manipulates regular expression patterns in a file. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">awk '\/regex pattern\/{action}' input_file.txt<\/pre><p>Although similar to <strong>sed<\/strong>, <strong>awk<\/strong> offers more operations beyond substitution, including printing, mathematical calculation, and deletion. It also lets you run a complex task with an <strong>if<\/strong> statement.<\/p><p>You can run multiple actions by listing them according to their execution order, separated by a semicolon (<strong>;<\/strong>). For example, this <strong>awk<\/strong> command calculates the average student score and print names that are above that threshold:<\/p><pre class=\"wp-block-preformatted\">awk -F':' '{ total += $2; students[$1] = $2 } END { average = total \/ length(students); print \"Average:\", average; print \"Above average:\"; for (student in students) if (students[student] &gt; average) print student }' score.txt<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99da0eb\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"172\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/awk-prints-average-score-and-students-with-higher-than-average-score-1024x172.png\" alt=\"awk prints average score and students with the higher-than-average score\" class=\"wp-image-114107\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/awk-prints-average-score-and-students-with-higher-than-average-score-1024x172.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/awk-prints-average-score-and-students-with-higher-than-average-score-300x51.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/awk-prints-average-score-and-students-with-higher-than-average-score-150x25.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/awk-prints-average-score-and-students-with-higher-than-average-score-768x129.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/awk-prints-average-score-and-students-with-higher-than-average-score.png 1164w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p><div class=\"protip\">\n                    <h4 class=\"title\">Need help with a command?<\/h4>\n                    <p>Ask <strong>Kodee<\/strong>, Hostinger's AI assistant, to break down and explain complex commands.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"sort-command\">20. sort command<\/h2><p>The <strong>sort<\/strong> command rearranges a file&rsquo;s content in a specific order. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">sort [options] [file_name]<\/pre><p>An actual command would look like this:<\/p><pre class=\"wp-block-preformatted\">sort file.txt<\/pre><p>Note that this utility doesn&rsquo;t modify the actual file and only prints the rearranged content as an output.<\/p><p>By default, the <strong>sort<\/strong> command uses alphabetical order from <strong>A<\/strong> to <strong>Z<\/strong>,<strong> <\/strong>but you can add the<strong> -r <\/strong>option to reverse the order. You can also sort files numerically using the <strong>-n<\/strong> flag.<\/p><h2 class=\"wp-block-heading\" id=\"cut-command\">21. cut command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-cut-command\"><strong>cut<\/strong> command<\/a> selects specific sections of a file and prints them to the Terminal. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">cut options file<\/pre><p>Unlike other Linux utilities, the <strong>cut<\/strong> command&rsquo;s options are mandatory for file sectioning. Here are some of the flags:<\/p><ul class=\"wp-block-list\">\n<li><strong>-f <\/strong>&ndash; selects a specific row field.<\/li>\n\n\n\n<li><strong>-b<\/strong> &ndash; cuts the line by a specified byte size.<\/li>\n\n\n\n<li><strong>-c<\/strong> &ndash; sections the line using a specified character.<\/li>\n\n\n\n<li><strong>-d<\/strong> &ndash; separates lines based on delimiters.<\/li>\n<\/ul><p>You can combine multiple options for a more specific output. For example, this command extracts the <strong>third<\/strong> to <strong>fifth<\/strong> field from a comma-separated list:<\/p><pre class=\"wp-block-preformatted\">cut -d',' -f3-5 list.txt<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99dca54\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"716\" height=\"88\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/cut-command-extracts-sections-from-a-comma-separated-list.png\" alt=\"cut command extracts sections from a comma-separated list\" class=\"wp-image-114108\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/cut-command-extracts-sections-from-a-comma-separated-list.png 716w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/cut-command-extracts-sections-from-a-comma-separated-list-300x37.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/cut-command-extracts-sections-from-a-comma-separated-list-150x18.png 150w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"diff-command\">22. diff command<\/h2><p>The<strong> diff<\/strong> command compares two files and prints their differences. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">diff file_name1 file_name2<\/pre><p>By default, the <strong>diff<\/strong> command only shows the differences between the two files. To print all the content and highlight the discrepancies, enable the context format using the<strong> -c <\/strong>option. You can also ignore case sensitivity by adding <strong>-i<\/strong>.<\/p><p>For example, run the following to show only the differences between<strong> 1.txt<\/strong> and <strong>2.txt<\/strong>:<\/p><pre class=\"wp-block-preformatted\">diff -c 1.txt 2.txt<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99df1cb\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"822\" height=\"506\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/diff-command-shows-differences-between-files-in-context-format.png\" alt=\"diff command shows differences between files in context format\" class=\"wp-image-114109\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/diff-command-shows-differences-between-files-in-context-format.png 822w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/diff-command-shows-differences-between-files-in-context-format-300x185.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/diff-command-shows-differences-between-files-in-context-format-150x92.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/diff-command-shows-differences-between-files-in-context-format-768x473.png 768w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"tee-command\">23. tee command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-tee-command-with-examples\/\"><strong>tee<\/strong> command<\/a> outputs another command&rsquo;s results to both the Terminal and a file. It&rsquo;s helpful if you want to use the data for further processing or backups. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">command | tee [options] file_name<\/pre><p>If the specified file doesn&rsquo;t exist, <strong>tee<\/strong> will create it. Be careful when using this command since it will overwrite the existing content. To preserve and append existing data, add the <strong>-a<\/strong> option.<\/p><p>For example, we will save the ping command&rsquo;s output as new entries in the <strong>test_network.txt<\/strong> file:<\/p><pre class=\"wp-block-preformatted\">ping 8.8.8.8 | tee -a test_network.txt<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99e170c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"902\" height=\"288\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/tee-command-prints-ping-output-in-terminal-and-a-file.png\" alt=\"tee-command-prints-ping-output-in-terminal-and-a-file\" class=\"wp-image-114111\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tee-command-prints-ping-output-in-terminal-and-a-file.png 902w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tee-command-prints-ping-output-in-terminal-and-a-file-300x96.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tee-command-prints-ping-output-in-terminal-and-a-file-150x48.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/tee-command-prints-ping-output-in-terminal-and-a-file-768x245.png 768w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"locate-command\">24. locate command<\/h2><p>The <a href=\"\/ph\/tutorials\/how-to-use-find-and-locate-commands-in-linux\/\"><strong>locate<\/strong> command<\/a> searches the system database for file paths. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">locate [options] [keyword]<\/pre><p>If you use the<strong> -r<\/strong> option to search files using regular expressions, omit the <strong>[keyword] <\/strong>argument. The <strong>locate<\/strong> command is case-sensitive by default, but you can turn off this behavior using the <strong>-i<\/strong> flag, like so:<\/p><pre class=\"wp-block-preformatted\">locate -i filename.txt<\/pre><p>Note that <strong>locate<\/strong> searches its database for files. While this behavior speeds up the search process, you must wait for the list to refresh before finding newly created items. Alternatively, enter the following to reload the data manually:<\/p><pre class=\"wp-block-preformatted\">updatedb<\/pre><h2 class=\"wp-block-heading\" id=\"find-command\">25. find command<\/h2><p>The<strong> find<\/strong> command searches for a file within a specific directory. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">find [path] [options] expression<\/pre><p>If you don&rsquo;t specify the path, the <strong>find<\/strong> command will search your current working directory. To find files using their name, add the <strong>-name<\/strong> option followed by the keyword.<\/p><p>You can specify the type of item you are looking for using the<strong> -type<\/strong> flag. The &ndash;<strong>type f<\/strong> option will search files only, while <strong>-type d<\/strong> will find directories. For example, we will check <strong>file.txt <\/strong>in <strong>path\/to\/folder<\/strong>:<\/p><pre class=\"wp-block-preformatted\">find path\/to\/folder -type f -name \"file\"<\/pre><p>Unlike locate, the <strong>find<\/strong> command searches through folders in real time. While it slows down the process, you can look for new items immediately without waiting for the system database to refresh.<\/p><h2 class=\"wp-block-heading\" id=\"sudo-command\">26. sudo command<\/h2><p><strong>superuser<\/strong> <strong>do <\/strong>or<strong> sudo<\/strong> enables non-root users who are part of the <a href=\"\/ph\/tutorials\/sudo-and-the-sudoers-file\/\">sudo group<\/a> to execute administrative commands. Simply add it at the beginning of another utility like so:<\/p><pre class=\"wp-block-preformatted\">sudo [options] your_command<\/pre><p>For example, enter the following to open a file using <strong>nano<\/strong> as an administrator:<\/p><pre class=\"wp-block-preformatted\">sudo nano file.txt<\/pre><p>The Terminal will prompt you to enter the user&rsquo;s password before executing the command. By default, you must re-enter it after five minutes of inactivity.<\/p><p>Typically, you don&rsquo;t add any options to sudo, but you can check them by entering:<\/p><pre class=\"wp-block-preformatted\">sudo --help<\/pre><p>    <p class=\"warning\">\n        <strong>Warning!<\/strong> Since users with <strong>sudo<\/strong> privileges can change various settings of your system, use this command with caution.    <\/p>\n    \n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"su-whoami-command\">27. su and whoami commands<\/h2><p>The <strong>su<\/strong> command swithces to another user in the Terminal session. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">su [options] [username]<\/pre><p>If you don&rsquo;t specify any option or username, this command will switch you to the <strong>root<\/strong> user. In this case, you must enter the password before changing the account.<\/p><p>You can check the currently logged-in user from the Linux command-line shell. Alternatively, use the <strong>whoami<\/strong> command:<\/p><pre class=\"wp-block-preformatted\">whoami<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99e427d\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"480\" height=\"62\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/whoami-command-shows-the-currently-logged-in-user.png\" alt=\"whoami command shows the currently-logged in user\" class=\"wp-image-114112\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/whoami-command-shows-the-currently-logged-in-user.png 480w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/whoami-command-shows-the-currently-logged-in-user-300x39.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/whoami-command-shows-the-currently-logged-in-user-150x19.png 150w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"chmod-command\">28. chmod command<\/h2><p><strong>Chmod<\/strong> <a href=\"\/ph\/tutorials\/how-to-change-linux-permissions-and-owners\">changes the permissions of files or directories<\/a>. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">chmod [options] [permission] [file_or_directory]<\/pre><p>In Linux, there are three folder and file permissions &ndash; read (<strong>r<\/strong>), write (<strong>w<\/strong>), and execute (<strong>x<\/strong>). You can assign them to three parties: the <strong>owner<\/strong>, a <strong>group<\/strong>, or <strong>other accounts<\/strong> belonging to neither category. Consider this example:<\/p><pre class=\"wp-block-preformatted\">chmod -rwx---r-&ndash; file1.txt<\/pre><p>The spot after the first hyphen (<strong>&ndash;<\/strong>) specifies the permission for the owner of <strong>file1.txt<\/strong>. In the previous example, we granted them the <strong>rwx<\/strong> privilege.<\/p><p>The next spot is for groups. Since we won&rsquo;t grant them any privilege, we put three hyphens to indicate emptiness. The last slot is for other users who only have <strong>read<\/strong> or <strong>r<\/strong> permission.<\/p><h2 class=\"wp-block-heading\" id=\"chown-command\">29. chown command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-chown-command\/\"><strong>chown<\/strong> command<\/a> changes the ownership of files, directories, or symbolic links. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">chown [options] newowner:newgroup file1 file2<\/pre><p>If you want to assign a user as the new owner of an item, leave the group name empty. For example, we will make<strong> admin-vps<\/strong> the owner of <strong>file1.txt<\/strong>:<\/p><pre class=\"wp-block-preformatted\">chown admin-vps file1.txt<\/pre><p>Conversely, omit the username to make all group members the owner. Remember to write the colons (<strong>:<\/strong>) like so:<\/p><pre class=\"wp-block-preformatted\">chown :newgroup file1.txt<\/pre><h2 class=\"wp-block-heading\" id=\"useradd-passwd-userdel-command\">30. useradd, passwd, and userdel command<\/h2><p>The <strong>useradd<\/strong> command creates a new account in your Linux system. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">useradd [options] new_username<\/pre><p>By default, the <strong>useradd<\/strong> command doesn&rsquo;t prompt you to give the new user a password. You can add or change it manually later with the <a href=\"\/ph\/tutorials\/how-to-change-password-in-linux\/\"><strong>passwd<\/strong> command<\/a>:<\/p><pre class=\"wp-block-preformatted\">passwd new_username<\/pre><p>To remove a user, use the <strong>userdel <\/strong>command followed by the account name like the syntax in the example:<\/p><pre class=\"wp-block-preformatted\">userdel new_username<\/pre><p>Since managing other users requires a <strong>superuser<\/strong> privilege, run these commands as <strong>root <\/strong>or with the <strong>sudo<\/strong> prefix. <\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>To set up a password and other details during the account creation process, use the <strong>adduser<\/strong> command instead.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"df-command\">31. df command<\/h2><p>The <strong>df <\/strong>command <a href=\"\/ph\/tutorials\/vps\/how-to-check-and-manage-disk-space-via-terminal\">checks your Linux system&rsquo;s disk usage<\/a>, displaying the used space in percentage and <strong>kilobyte <\/strong>(<strong>KB<\/strong>). <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">df [options] [file system]<\/pre><p>Note that the <strong>df<\/strong> command operates at the file system level. If you don&rsquo;t specify one, the utility will display all the active file systems.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99e6d57\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"910\" height=\"252\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/df-command-prints-file-system-usage.png\" alt=\"df command prints files system usage\" class=\"wp-image-114113\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/df-command-prints-file-system-usage.png 910w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/df-command-prints-file-system-usage-300x83.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/df-command-prints-file-system-usage-150x42.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/df-command-prints-file-system-usage-768x213.png 768w\" sizes=\"(max-width: 910px) 100vw, 910px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"du-command\">32. du command<\/h2><p>The <strong>du<\/strong> command checks the size of a directory and its content. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">du [directory]<\/pre><p>The command will check your working directory if you don&rsquo;t specify a path or folder. By default, it breaks down each subfolder&rsquo;s disk usage, but you can add the <strong>-s<\/strong> option to summarize the total usage in one output.<\/p><p>You can also use the <strong>-M<\/strong> option to change the information from <strong>KB<\/strong> to <strong>MB<\/strong>.<\/p><h2 class=\"wp-block-heading\" id=\"top--command\">33. top command<\/h2><p>The <strong>top<\/strong> command displays all running processes in your system and their hardware consumption. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">top [options]<\/pre><p>The <strong>top<\/strong> command has various options. For example, <strong>-p<\/strong> lets you check a specific process by specifying its ID. Meanwhile, add the <strong>-d<\/strong> flag to change the delay between screen updates.<\/p><h2 class=\"wp-block-heading\" id=\"htop-command\">34. htop command<\/h2><p>The <strong>htop<\/strong> command, like <strong>top<\/strong>, displays and <a href=\"\/ph\/tutorials\/vps\/how-to-manage-processes-in-linux-using-command-line\">manages processes in your Linux server<\/a>. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">htop [options]<\/pre><p><strong>htop<\/strong> has options similar to <strong>top<\/strong>, but you can add additional ones. For example, <strong>-C<\/strong> enables the monochrome mode, while &ndash;<strong>-tree<\/strong> shows processes in a hierarchical view.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99e9656\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"594\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/htop-command-shows-server-performance-monitor-1024x594.png\" alt=\"htop command shows server performance monitor\" class=\"wp-image-114114\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/htop-command-shows-server-performance-monitor-1024x594.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/htop-command-shows-server-performance-monitor-300x174.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/htop-command-shows-server-performance-monitor-150x87.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/htop-command-shows-server-performance-monitor-768x445.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/htop-command-shows-server-performance-monitor.png 1176w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"ps-command\">35. ps command<\/h2><p>The <strong>ps<\/strong> command summarizes the status of all running processes in your Linux system at a specific time. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">ps [options]<\/pre><p>You can print a more detailed report by adding other options. For example, use <strong>-A<\/strong> to list all processes in your system, <strong>-r<\/strong> to check only the running ones, or <strong>-u<\/strong> username to query those associated with a particular account.<\/p><h2 class=\"wp-block-heading\" id=\"uname-command\">36. uname command<\/h2><p>The <strong>unix name<\/strong> or <strong>uname<\/strong> command displays detailed information about your Linux machine, including hardware, name, and operating system kernel. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">uname [options]<\/pre><p>Without any option, the command will print your system&rsquo;s kernel name. To check all information about your machine, add the <strong>-a<\/strong> option.<\/p><h2 class=\"wp-block-heading\" id=\"hostname-command\">37. hostname command<\/h2><p>The <strong>hostname<\/strong> command checks your VPS hostname and other related information. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">hostname [options]<\/pre><p>If you leave the option empty, the command will print your hostname. Add <strong>-i<\/strong> to check your server&rsquo;s IP address, <strong>-a<\/strong> to print the hostname alias, and <strong>-A<\/strong> to output the system&rsquo;s fully qualified domain name (FQDN).<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Check VPS information using Kodee<\/h4>\n                    <p>You can check detailed information about your VPS, including its hostname, by simply asking <strong>Kodee<\/strong>. It can also directly change several settings of your server, like its hostname.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"time-command\">38. time command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-time-command\/\"><strong>time <\/strong>command<\/a> measures the execution time of commands or scripts to gain insights into your system performance. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">time command_or_script<\/pre><p>You can measure a series of commands by separating them using double ampersands (<strong>&amp;&amp;<\/strong>) or semicolons (<strong>;<\/strong>) like so:<\/p><pre class=\"wp-block-preformatted\">time command; command; command<\/pre><h2 class=\"wp-block-heading\" id=\"systemctl-command\">39. systemctl command<\/h2><p>The<strong> systemctl<\/strong> command manages services in your Linux system. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">systemctl subcommand [service_name][options]<\/pre><p>The subcommands represent your task, like listing, restarting, terminating, or enabling the services. For example, we will <a href=\"\/ph\/tutorials\/manage-and-list-services-in-linux\">list Linux services<\/a> using this:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl list-unit-files --type service --all<\/pre><p>Note that this command might not work with older distributions since they use another service manager.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99ebf59\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"482\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/systemctl-command-lists-all-services-1024x482.png\" alt=\"systemctl command lists all services\" class=\"wp-image-114115\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/systemctl-command-lists-all-services-1024x482.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/systemctl-command-lists-all-services-300x141.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/systemctl-command-lists-all-services-150x71.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/systemctl-command-lists-all-services-768x361.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/systemctl-command-lists-all-services.png 1084w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"watch-command\">40. watch command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-watch-command\/\"><strong>watch<\/strong> command<\/a> continuously runs a utility at a specific interval to monitor changes in the output.<\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">watch [options] command_name<\/pre><p>An actual <strong>watch<\/strong> command would look like this:<\/p><pre class=\"wp-block-preformatted\">watch netstat<\/pre><p>By default, <strong>watch<\/strong> will run your command every <strong>two seconds<\/strong>, but you can change the interval using the <strong>-n<\/strong> option followed by the delay. If you want to highlight changes in the output, add the <strong>-d<\/strong> flag.<\/p><h2 class=\"wp-block-heading\" id=\"jobs-command\">41. jobs command<\/h2><p>The <strong>jobs<\/strong> command checks jobs or tasks that are running in your current shell.<\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">jobs [options] [Job_ID]<\/pre><p>Running this command without any arguments will show all jobs running in the Terminal&rsquo;s foreground and background. If you don&rsquo;t have any ongoing tasks, it will return an empty output.<\/p><p>You can display more detailed information about each job by adding the <strong>-l<\/strong> option. Meanwhile, use <strong>-n<\/strong> to show only tasks whose status has changed since the last notification.<\/p><h2 class=\"wp-block-heading\" id=\"kill-command\">42. kill command<\/h2><p>The <a href=\"\/ph\/tutorials\/how-to-kill-a-process-in-linux\/\"><strong>kill<\/strong> command<\/a> terminates a process using its ID. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">kill [signal_option] Process_ID<\/pre><p>To obtain the process ID, run the following command:<\/p><pre class=\"wp-block-preformatted\">ps ux<\/pre><p>The kill command has 64 termination signals. By default, it uses the<strong> SIGTERM<\/strong> method that lets the program save its progress before closing.<\/p><h2 class=\"wp-block-heading\" id=\"shutdown-command\">43. shutdown command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-shutdown-command\/\"><strong>shutdown <\/strong>command<\/a> turns off or restarts your Linux system at a specific time. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">shutdown [option] [time] [message]<\/pre><p>If you run the command without any arguments, your system will shut down immediately. You can specify the schedule in 24-hour format or in relative format. For example, enter <strong>+5<\/strong> to shut down the system after <strong>five minutes<\/strong>. To restart the machine, add the <strong>-r<\/strong> option.<\/p><p>The <strong>message<\/strong> argument specifies the notification that other users in your system will receive before the server shuts down.<\/p><h2 class=\"wp-block-heading\" id=\"ping-command\">44. ping command<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-ping-command-with-examples\"><strong>ping <\/strong>command<\/a> sends packets to a target server and fetches the responses. It is helpful for network diagnostics. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">ping [option] [hostname_or_IP_address]<\/pre><p>By default, <strong>ping<\/strong> sends infinite packets until the user manually stops it by pressing <strong>Ctrl + C<\/strong>.<\/p><p>However, you can specify a custom number using the <strong>-c<\/strong> option. You can also change the interval between transfers by adding <strong>-i<\/strong>.<\/p><p>For instance, let&rsquo;s send 15 packets every <strong>two seconds<\/strong> to Google&rsquo;s server:<\/p><pre class=\"wp-block-preformatted\">ping -c 15 -i 2 google.com<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99eea5d\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"246\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/ping-command-sends-packets-to-google-with-custom-settings-1024x246.png\" alt=\"ping command sends packets to google with custom settings\" class=\"wp-image-114116\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ping-command-sends-packets-to-google-with-custom-settings-1024x246.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ping-command-sends-packets-to-google-with-custom-settings-300x72.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ping-command-sends-packets-to-google-with-custom-settings-150x36.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ping-command-sends-packets-to-google-with-custom-settings-768x184.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ping-command-sends-packets-to-google-with-custom-settings.png 1184w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"wget-command\">45. wget command<\/h2><p>The <a href=\"\/ph\/tutorials\/wget-command-examples\/\"><strong>wget <\/strong>command<\/a> downloads files from the internet via HTTP, HTTPS, or FTP protocols. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">wget [options] [URL]<\/pre><p>By default, the <strong>wget<\/strong> command will download an item to your current working directory. For example, run this command to retrieve the latest WordPress installer:<\/p><pre class=\"wp-block-preformatted\">wget https:\/\/wordpress.org\/latest.zip<\/pre><h2 class=\"wp-block-heading\" id=\"curl-command\">46. cURL command<\/h2><p>The <a href=\"\/ph\/tutorials\/curl-command-with-examples-linux\/\"><strong>cURL<\/strong> command<\/a> transfers data from or to a server by specifying its URL. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">curl [options] URL<\/pre><p>Running cURL without any options will print the website&rsquo;s HTML content to your Terminal. If you add the <strong>-O<\/strong> or <strong>-o<\/strong> option, the command will download files from the specified link.<\/p><p>The cURL command is also helpful for testing API or server endpoints. You can do so by adding the &ndash;<strong>X <\/strong>option followed by an HTTP method, depending on whether you want to fetch or upload data.<\/p><p>For example, the following command will retrieve data from a specific API endpoint:<\/p><pre class=\"wp-block-preformatted\">curl -X GET https:\/\/api.example.com\/endpoint<\/pre><h2 class=\"wp-block-heading\" id=\"scp-command\">47. scp command<\/h2><p>The <a href=\"\/ph\/tutorials\/using-scp-command-to-transfer-files\/\"><strong>scp<\/strong> command<\/a> copies files and directories between systems over a network. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">scp [option] [source username@IP]:\/[directory and file name] [destination username@IP]:\/[destination directory]<\/pre><p>If you are copying items to or from your local machine, omit the IP and path. When transferring a file or folder from a local machine, specify its name after the options.<\/p><p>For example, we will run the following to copy <strong>file1.txt<\/strong> to our VPS&rsquo;s <strong>path\/to\/folder <\/strong>directory as root:<\/p><pre class=\"wp-block-preformatted\">scp file1.txt root@185.185.185.185:path\/to\/folder<\/pre><p>You can change the default SCP port by specifying its number after the <strong>-P<\/strong> option. Meanwhile, use the <strong>-l<\/strong> flag to limit the transfer bandwidth and add &ndash;<strong>C <\/strong>to enable compression.<\/p><h2 class=\"wp-block-heading\" id=\"rsync-command\">48. rsync command<\/h2><p>The <a href=\"\/ph\/tutorials\/how-to-use-rsync\"><strong>rsync<\/strong> command<\/a> syncs files or folders between two destinations to ensure they have the same content. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">rsync [options] source destination<\/pre><p>The source and destination can be a folder within the same system, a local machine, or a remote server. If you are syncing content with a VPS, specify the username and IP address like so:<\/p><pre class=\"wp-block-preformatted\">rsync \/path\/to\/local\/folder\/ vps-user@185.185.185.185:\/path\/to\/remote\/folder\/<\/pre><p>You can add the <strong>-a<\/strong> option to sync the file or folder&rsquo;s attributes as well, including their symbolic links. Meanwhile, use the <strong>-z<\/strong> flag to enable compression during the transfer.<\/p><h2 class=\"wp-block-heading\" id=\"ip-command\">49. ip command<\/h2><p>The <strong>ip<\/strong> command utility lists and manages your system&rsquo;s network parameters, similar to the <strong>ifconfig <\/strong>command in older <a href=\"\/ph\/tutorials\/best-linux-distro\">Linux distros<\/a>. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">ip [options] object command<\/pre><p>Running this command without any arguments will print the manual, including an explanation about acceptable options and objects.<\/p><p>To manage a network parameter, specify the action in the <strong>command<\/strong> argument. For example, run this to show your system&rsquo;s IP address:<\/p><pre class=\"wp-block-preformatted\">ip address show<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f99f18ce\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"444\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/ip-command-shows-the-system-ip-address-information-1024x444.png\" alt=\"ip command shows the system IP address information\" class=\"wp-image-114117\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ip-command-shows-the-system-ip-address-information-1024x444.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ip-command-shows-the-system-ip-address-information-300x130.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ip-command-shows-the-system-ip-address-information-150x65.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ip-command-shows-the-system-ip-address-information-768x333.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/ip-command-shows-the-system-ip-address-information.png 1180w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"netstat-command\">50. netstat command<\/h2><p>The <a href=\"\/ph\/tutorials\/netstat-command\"><strong>netstat <\/strong>command<\/a> displays information about your system&rsquo;s network configuration. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">netstat [options]<\/pre><p>Add an option to query specific network information. Here are several flags to use:<\/p><ul class=\"wp-block-list\">\n<li><strong>-a<\/strong> &ndash; displays listening and closed sockets.<\/li>\n\n\n\n<li><strong>-t<\/strong> &ndash; shows TCP connections.<\/li>\n\n\n\n<li><strong>-u<\/strong> &ndash; lists UDP connections.<\/li>\n\n\n\n<li><strong>-r<\/strong> &ndash; displays routing tables.<\/li>\n\n\n\n<li><strong>-i<\/strong> &ndash; shows information about network interfaces.<\/li>\n\n\n\n<li><strong>-c<\/strong> &ndash; continuously outputs network information for real-time monitoring.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"traceroute-command\">51. traceroute command<\/h2><p>The <a href=\"\/ph\/tutorials\/traceroute-command\"><strong>traceroute<\/strong> command<\/a> traces a packet&rsquo;s path between hosts, providing information such as the round-trip time and the routers involved. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">traceroute [options] destination<\/pre><p>You can use a hostname, domain name, or IP address as the destination. If you don&rsquo;t specify an option, traceroute will run the test using the default settings.<\/p><p>Change the maximum packet hops using the <strong>-m<\/strong> option. To prevent traceroute from resolving IP addresses, add <strong>-n<\/strong>.<\/p><p>You can also enable a timeout in seconds using the <strong>-w<\/strong> flag followed by the duration.<\/p><h2 class=\"wp-block-heading\" id=\"nslookup-command\">52. nslookup command<\/h2><p>The<strong> nslookup<\/strong> command requests a <a href=\"\/ph\/tutorials\/what-is-dns\">Domain Name System<\/a> (DNS) server to check a domain linked to an IP address or vice versa. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">nslookup [options] domain-or-ip [dns-server]<\/pre><p>If you don&rsquo;t specify a DNS server, <strong>nslookup<\/strong> will use your Internet service provider&rsquo;s default resolver. <\/p><p>For example, use the <strong>-type=<\/strong> option to specify the information you want to check, such as the DNS records.<\/p><p>You can also set up automatic retry with the <strong>-retry= <\/strong>flag and add<strong> -port=<\/strong> to use a specific port.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f9a001ba\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"630\" height=\"202\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/nslookup-command-resolves-a-domain-name-to-ip-addresses.png\" alt=\"nslookup command resolves a domain name to an IP address\" class=\"wp-image-114118\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/nslookup-command-resolves-a-domain-name-to-ip-addresses.png 630w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/nslookup-command-resolves-a-domain-name-to-ip-addresses-300x96.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/nslookup-command-resolves-a-domain-name-to-ip-addresses-150x48.png 150w\" sizes=\"(max-width: 630px) 100vw, 630px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"dig-command\">53. dig command<\/h2><p>The <a href=\"\/ph\/tutorials\/how-to-use-the-dig-command-in-linux\/\"><strong>dig<\/strong> command<\/a> displays information about a domain. It is similar to <strong>nslookup<\/strong> but more comprehensive. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">dig [options] [server] [type] name-or-ip<\/pre><p>Running <strong>dig<\/strong> without an argument will check <strong>A records<\/strong> of the specified domain using the operating system&rsquo;s default resolver. You can query a particular record by specifying it in the <strong>[type]<\/strong> argument like the following example:<\/p><pre class=\"wp-block-preformatted\">dig MX domain.com<\/pre><p>To run a reverse DNS lookup, add the &ndash;<strong>x<\/strong> option and use an IP address as the target.<\/p><h2 class=\"wp-block-heading\" id=\"history-command\">54. history command<\/h2><p>The<strong> history <\/strong>command checks previously run utilities. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">history [options]<\/pre><p>Add the <strong>-r<\/strong> option if you want to clear the Terminal history. To rerun a specific utility from the list, enter an exclamation mark followed by its ID.<\/p><p>For example, use the following to run the <strong>145th<\/strong> command:<\/p><pre class=\"wp-block-preformatted\">!145<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f9a02bcf\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"802\" height=\"118\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/history-command-prints-terminal-history.png\" alt=\"history command prints Terminal history\" class=\"wp-image-114120\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/history-command-prints-terminal-history.png 802w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/history-command-prints-terminal-history-300x44.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/history-command-prints-terminal-history-150x22.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/history-command-prints-terminal-history-768x113.png 768w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"man-command\">55. man command<\/h2><p>The <strong>man<\/strong> or <strong>manual <\/strong>command displays a comprehensive guide to another utility. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">man [options] [section_number] command_name<\/pre><p>If you specify only the command name, <strong>man<\/strong> will display the entire manual. Alternatively, you can select one of the <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/man-pages.7.html\" target=\"_blank\" rel=\"noreferrer noopener\">nine sections<\/a> using their IDs to print more specific information. <\/p><p>For example, run the following to check the <strong>library call <\/strong>section of the <strong>ls<\/strong> command&rsquo;s manual:<\/p><pre class=\"wp-block-preformatted\">man 3 ls<\/pre><h2 class=\"wp-block-heading\" id=\"echo-command\">56. echo command<\/h2><p>The<strong> echo<\/strong> command prints the text you provide to the Terminal. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">echo [options] [text]<\/pre><p>Note that if the text you want to print using <strong>echo <\/strong>contains a whitespace, it has to be enclosed in double quotation marks, like so. Otherwise, it will be treated as two separate arguments:<\/p><pre class=\"wp-block-preformatted\">echo \"This will be printed in one line\"<\/pre><p>You can also add the redirection symbol (<strong>&gt;<\/strong>) to print the text in a file instead of the terminal. If you use two symbols (<strong>&gt;&gt;<\/strong>), it will append the existing content. The command syntax looks like this:<\/p><pre class=\"wp-block-preformatted\">echo [options] [text] &gt; [file_name]<\/pre><h2 class=\"wp-block-heading\" id=\"ln-command\">57. ln command<\/h2><p>The <strong>ln<\/strong> command creates a symbolic link to a file or directory. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">ln [options] source target<\/pre><p>This command will automatically create the shortcut, meaning you don&rsquo;t need to make one manually. For example, the following will enable you to open <strong>file.txt<\/strong> using <strong>shortcut.txt<\/strong>:<\/p><pre class=\"wp-block-preformatted\">ln target.txt shortcut.txt<\/pre><h2 class=\"wp-block-heading\" id=\"alias-unalias-command\">58. alias and unalias commands<\/h2><p>The <a href=\"\/ph\/tutorials\/linux-alias-command\"><strong>alias<\/strong> command<\/a> assigns another name to a string that belongs to a file, text, program, or command.<\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">alias name='string'<\/pre><p>For example, the following will assign <strong>k <\/strong>as the alias for the <strong>kill<\/strong> command, allowing you to use the letter instead of the full name.<\/p><pre class=\"wp-block-preformatted\">alias k='kill'<\/pre><p>To check a command&rsquo;s alias, run <strong>alias<\/strong> followed by an alternative name. For example, we will check the previous snippet:<\/p><pre class=\"wp-block-preformatted\">alias k<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69df1f9a0578a\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"468\" height=\"58\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/08\/alias-commands-shows-a-letter-associated-with-a-command.png\" alt=\"alias commands shows a letter associated with a command\" class=\"wp-image-114122\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/alias-commands-shows-a-letter-associated-with-a-command.png 468w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/alias-commands-shows-a-letter-associated-with-a-command-300x37.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/08\/alias-commands-shows-a-letter-associated-with-a-command-150x19.png 150w\" sizes=\"(max-width: 468px) 100vw, 468px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>You can remove an alias by running this syntax:<\/p><pre class=\"wp-block-preformatted\">unalias [name]<\/pre><h2 class=\"wp-block-heading\" id=\"cal-command\">59. cal command<\/h2><p>The <strong>cal <\/strong>command displays a calendar in your Linux command-line interface. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">cal [options] [month] 2026<\/pre><p>If you don&rsquo;t add any argument, the command will show the current date. Alternatively, you can enter a specific month and year in a numerical format.<\/p><p>You can also add the <strong>-3 <\/strong>option to show the current, previous, and next month.<\/p><h2 class=\"wp-block-heading\" id=\"apt-dnf-command\">60. apt and dnf command<\/h2><p>The <strong>apt <\/strong>command manages <strong>advanced package tool<\/strong> (APT) libraries in Debian-based operating systems such as Ubuntu and <a href=\"\/ph\/tutorials\/what-is-kali-linux\">Kali Linux<\/a>. <\/p><p>Syntax:<\/p><pre class=\"wp-block-preformatted\">apt [options] subcommand<\/pre><p>The subcommands define the action, like updating the library, upgrading software, installing an application, or removing a package. For example, we will install the <strong>Vim<\/strong> text editor:<\/p><pre class=\"wp-block-preformatted\">apt install vim<\/pre><p>In Linux, package management commands differ across distributions. For example, Red Hat Enterprise Linux-based distros like CentOS and AlmaLinux use <strong>dnf<\/strong>. It has the same syntax and options as <strong>apt<\/strong>.<\/p><p>Running both <strong>apt<\/strong> and <strong>dnf<\/strong> requires <strong>superuser<\/strong> privileges, which you can only obtain with <strong>sudo<\/strong> or via <strong>root<\/strong>.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>If you want to check a command&rsquo;s usage, syntax, and options, use the <strong>--help<\/strong> flag. For example, enter <strong>ls --help<\/strong> to display the <strong>ls<\/strong> utility guide.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-should-you-learn-next-after-mastering-linux-commands\">What should you learn next after mastering Linux commands?<\/h2><p>Mastering Linux commands allows you to manage a remote <a href=\"\/ph\/vps-hosting\">virtual private server platform<\/a> from the terminal efficiently. While these utilities are sufficient by themselves, learning <a href=\"\/ph\/tutorials\/bash-scripting-tutorial\">how to write Bash scripts<\/a> will further improve your workflow, given the benefits:<\/p><ul class=\"wp-block-list\">\n<li><strong>Automation and efficiency<\/strong>. A Bash script combines multiple commands into a single executable file, allowing you to automate multi-step tasks using a single execution.&nbsp;<\/li>\n\n\n\n<li><strong>Consistency and reduced human error. <\/strong>Commands in a Bash script always run and behave consistently across executions, which significantly reduces human error.<\/li>\n\n\n\n<li><strong>Reusability<\/strong>. Developers can easily copy and transport Bash scripts to different UNIX operating systems, making it easy to replicate tasks in other environments.&nbsp;&nbsp;<\/li>\n<\/ul><p>Given its importance, learning how to create a Bash script is the natural next step for aspiring system administrators after mastering various Linux commands.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux commands are terminal-based instructions used to manage files, directories, users, processes, networking, and system services in Linux operating systems. This Linux commands guide provides a complete command list, grouped by category, with syntax structures and practical examples for each command. There are various Linux utilities available in the command-line interface that send instructions to [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ph\/tutorials\/linux-commands\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":127849,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"60 essential Linux commands every user should know","rank_math_description":"60 most commonly used Linux commands: 1. ls command \u00b7 2. pwd command \u00b7 3. cd command \u00b7 4. mkdir command \u00b7 5. rmdir command \u00b7 6. rm command + more.","rank_math_focus_keyword":"linux commands","footnotes":""},"categories":[22639],"tags":[],"class_list":["post-18297","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/linux-commands","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/comandos-linux","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/commandes-linux","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/linux-comandos","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/perintah-dasar-linux","default":0},{"locale":"de-DE","link":"https:\/\/www.hostinger.com\/de\/tutorials\/linux-befehle","default":0},{"locale":"it-IT","link":"https:\/\/www.hostinger.com\/it\/tutorial\/comandi-linux","default":0},{"locale":"nl-NL","link":"https:\/\/www.hostinger.com\/nl\/tutorials\/linux-commands","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/linux-commands","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/linux-commands","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/linux-commands","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/linux-comandos","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/joomla-vs-wordpress-cms-utilizar-22","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/linux-comandos","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/comandos-linux","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/linux-commands","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/linux-commands","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/linux-commands","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/linux-commands","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/18297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/comments?post=18297"}],"version-history":[{"count":113,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/18297\/revisions"}],"predecessor-version":[{"id":127848,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/18297\/revisions\/127848"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media\/127849"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media?parent=18297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/categories?post=18297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/tags?post=18297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}