{"id":3490,"date":"2023-11-16T16:20:53","date_gmt":"2023-11-16T08:20:53","guid":{"rendered":"https:\/\/www.servergigabit.com\/guide\/?post_type=kb&#038;p=3490"},"modified":"2023-11-16T16:29:49","modified_gmt":"2023-11-16T08:29:49","slug":"tips-and-tricks-for-linux-command-line","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/tips-and-tricks-for-linux-command-line","title":{"rendered":"Tips and Tricks For Linux Command Line"},"content":{"rendered":"<div id=\"primary\" class=\"content-area primary\">\n<p>Amidst the dominance of graphical user interfaces on our screens, the command line persists as a formidable, albeit overlooked, powerhouse. Welcome to the Linux command line universe, where the mastery of its tips and techniques can elevate you from a novice to a command line wizard. In this realm, we&#8217;ll uncover the hidden potential, unveiling strategies that empower users to maximize their computers beyond the confines of graphical interfaces.<\/p>\n<article id=\"post-17803\" class=\"post-17803 post type-post status-publish format-standard has-post-thumbnail hentry category-tutorials ast-article-single remove-featured-img-padding\">\n<div class=\"ast-post-format- single-layout-1 ast-no-date-box\">\n<div class=\"entry-content clear\">\n<h2 id=\"h-essential-linux-command-line-basics\" class=\"wp-block-heading\"><span id=\"essential-linux-command-line-basics\" class=\"uag-toc__heading-anchor\"><\/span><strong>Essential Linux Command Line Basics<\/strong><\/h2>\n<p>We&#8217;ll lay the groundwork for your exploration of the Linux command line in this chapter. In order to make sure you are comfortable using the terminal and carrying out commands successfully, we will start with the fundamentals.<\/p>\n<h3 id=\"h-accessing-the-terminal\" class=\"wp-block-heading\"><span id=\"accessing-the-terminal\" class=\"uag-toc__heading-anchor\"><\/span><strong>Accessing the Terminal<\/strong><\/h3>\n<p>Before you can embark on your command line adventure, you need to access the terminal.\u00a0This is practically the door to the world of command line magic. Once you&#8217;re in, you can enter and execute text commands in the terminal&#8217;s environment. Depending on your distribution, there are several ways to access the terminal on Linux systems.<\/p>\n<p>Maybe all you need to do is look up &#8220;Terminal&#8221; in your application menu or use keyboard shortcuts like Ctrl + Alt + T. There may be various terminal emulators available in some distributions, each with a unique set of features and functionalities. You can improve your efficiency and command-line experience by investigating these options.<\/p>\n<h3 id=\"h-basic-commands-recap\" class=\"wp-block-heading\"><span id=\"basic-commands-recap\" class=\"uag-toc__heading-anchor\"><\/span><strong>Basic Commands Recap<\/strong><\/h3>\n<p>With the terminal at your disposal, let&#8217;s examine some essential commands that constitute the basis of Linux command line communication. Gaining proficiency with these instructions will increase your self-assurance and output. They are the cornerstones of your journey. We&#8217;ll go over orders such as:<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>Command<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>ls<\/td>\n<td>Lists files and directories in the current directory.<\/td>\n<\/tr>\n<tr>\n<td>cd<\/td>\n<td>Changes the current directory.<\/td>\n<\/tr>\n<tr>\n<td>pwd<\/td>\n<td>Prints the current working directory\u2019s path.<\/td>\n<\/tr>\n<tr>\n<td>mkdir<\/td>\n<td>Creates one or more directories.<\/td>\n<\/tr>\n<tr>\n<td>touch<\/td>\n<td>Creates empty files or updates file timestamps.<\/td>\n<\/tr>\n<tr>\n<td>rm<\/td>\n<td>Removes files and directories.<\/td>\n<\/tr>\n<tr>\n<td>cp<\/td>\n<td>Copies files and directories.<\/td>\n<\/tr>\n<tr>\n<td>mv<\/td>\n<td>Moves or renames files and directories.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Despite their apparent simplicity, these commands on a Linux system carry out a variety of fundamental operations. We&#8217;ll guide you through their efficient use and offer real-world examples to help you grasp the concepts.<\/p>\n<h2 id=\"h-navigation-and-file-operations\" class=\"wp-block-heading\"><span id=\"navigation-and-file-operations\" class=\"uag-toc__heading-anchor\"><\/span><strong>Navigation and File Operations<\/strong><\/h2>\n<p>This chapter will cover file system navigation, managing directories and files, and copying and moving them. We&#8217;ll also go into understanding file ownership and permissions.<\/p>\n<h3 id=\"h-navigating-the-linux-filesystem\" class=\"wp-block-heading\"><span id=\"navigating-the-linux-filesystem\" class=\"uag-toc__heading-anchor\"><\/span><strong>Navigating the Linux Filesystem<\/strong><\/h3>\n<p>To switch to the directory at home:<\/p>\n<pre class=\"wp-block-code\"><code>cd ~<\/code><\/pre>\n<p>To access the directory \/var\/log:<\/p>\n<pre class=\"wp-block-code\"><code>cd \/var\/log<\/code><\/pre>\n<p>In order to show the current directory:<\/p>\n<pre class=\"wp-block-code\"><code>pwd<\/code><\/pre>\n<h3 id=\"h-how-to-manipulate-files-and-directories-in-linux-nbsp\" class=\"wp-block-heading\"><span id=\"how-to-manipulate-files-and-directories-in-linux\" class=\"uag-toc__heading-anchor\"><\/span><strong>How to Manipulate Files and Directories in Linux:<\/strong><\/h3>\n<p>To make &#8220;my_folder&#8221; a new directory:<\/p>\n<pre class=\"wp-block-code\"><code>mkdir my_folder<\/code><\/pre>\n<p>To start a fresh, blank file with the name &#8220;my_file.txt&#8221;:<\/p>\n<pre class=\"wp-block-code\"><code>touch my_file.txt<\/code><\/pre>\n<p>In order to delete the file &#8220;old_file.txt&#8221;:<\/p>\n<pre class=\"wp-block-code\"><code>rm old_file.txt\u00a0<\/code><\/pre>\n<h3 id=\"h-how-to-copy-and-move-files-and-directories-in-linux-nbsp\" class=\"wp-block-heading\"><span id=\"how-to-copy-and-move-files-and-directories-in-linux\" class=\"uag-toc__heading-anchor\"><\/span><strong>How to Copy and Move Files and Directories in Linux:<\/strong><\/h3>\n<p>One way to copy a file from &#8220;source.txt&#8221; to &#8220;destination\/&#8221; is as follows:<\/p>\n<pre class=\"wp-block-code\"><code>cp source.txt destination\/\u00a0<\/code><\/pre>\n<p>To relocate a file named &#8220;file.txt&#8221; to the directory &#8220;new_location\/&#8221;:<\/p>\n<pre class=\"wp-block-code\"><code>mv file.txt new_location\/\u00a0<\/code><\/pre>\n<p>Renaming &#8220;old_name.txt&#8221; to &#8220;new_name.txt&#8221; is how to do this:<\/p>\n<pre class=\"wp-block-code\"><code>mv old_name.txt new_name.txt\u00a0<\/code><\/pre>\n<h3 id=\"h-managing-file-permissions-and-ownership-nbsp-nbsp\" class=\"wp-block-heading\"><span id=\"managing-file-permissions-and-ownership\" class=\"uag-toc__heading-anchor\"><\/span><strong>Managing File Permissions and Ownership:<\/strong><\/h3>\n<p>Making a file &#8220;file.txt&#8221; readable, writable, and executable by the owner requires changing its permissions.<\/p>\n<pre class=\"wp-block-code\"><code>chmod u+rwx file.txt\u00a0<\/code><\/pre>\n<p>To assign the user &#8220;new_owner&#8221; as the new owner of the file &#8220;file.txt&#8221;:<\/p>\n<pre class=\"wp-block-code\"><code>chown new_owner file.txt\u00a0<\/code><\/pre>\n<p>To assign a group name of &#8220;new_group&#8221; to a file with the extension &#8220;file.txt&#8221;:<\/p>\n<pre class=\"wp-block-code\"><code>chown :new_group file.txt\u00a0<\/code><\/pre>\n<h2 id=\"h-how-to-work-effectively-in-the-linux-command-line-nbsp\" class=\"wp-block-heading\"><span id=\"how-to-work-effectively-in-the-linux-command-line\" class=\"uag-toc__heading-anchor\"><\/span><strong>How to Work Effectively in the Linux Command Line<\/strong><\/h2>\n<p>We&#8217;re going to look at some methods and resources that will help you work with the Linux command line environment more effectively and efficiently. As such, mastering these abilities is crucial to optimizing your process and developing your command line skills.<\/p>\n<h3 id=\"h-tab-completion-nbsp\" class=\"wp-block-heading\"><span id=\"tab-completion\" class=\"uag-toc__heading-anchor\"><\/span><strong>Tab Completion<\/strong><\/h3>\n<p>When it comes to reducing typing errors and saving time, tab completion is invaluable. The terminal can automatically complete filenames, directory names, and even commands by just pressing the &#8220;Tab&#8221; key.<\/p>\n<p>To access a directory named &#8220;my_long_and_complicated_directory_name&#8221;, for instance, all you have to do is type &#8220;cd my_&#8221;, hit &#8220;Tab&#8221;, and the terminal will finish the name for you. If there are more than one option, selecting &#8220;Tab&#8221; twice will bring up a list of them.<\/p>\n<h3 id=\"h-linux-command-history-and-recall\" class=\"wp-block-heading\"><span id=\"linux-command-history-and-recall\" class=\"uag-toc__heading-anchor\"><\/span><strong>Linux Command History and Recall<\/strong><\/h3>\n<p>What happens if you use a command and then realize you need it again in a few minutes?<\/p>\n<p>You can quickly access previously run commands with command history and recall. A list of recent commands, each with a number attached, is displayed by the history command. An exclamation point (!) followed by the command number can be used to rerun a command (e.g.,!42 will rerun the 42nd command in your history).<\/p>\n<p>You can also use Ctrl + R to search your command history by entering a keyword from the command you want to find. You won&#8217;t have to type lengthy, intricate commands again thanks to this feature.<\/p>\n<h3 id=\"h-using-aliases-in-the-linux-shell-nbsp\" class=\"wp-block-heading\"><span id=\"using-aliases-in-the-linux-shell\" class=\"uag-toc__heading-anchor\"><\/span><strong>Using Aliases in the Linux Shell\u00a0<\/strong><\/h3>\n<p>Similar to personalized shortcuts for your commands are aliases. You can design your own abbreviations for commonly used or intricate commands. For instance, you can make an alias like this if you frequently find yourself typing ls -l to list files in long format:<\/p>\n<pre class=\"wp-block-code\"><code>alias ll='ls -l'<\/code><\/pre>\n<p>The ls -l command will run once this alias has been defined. Type ll into the terminal to begin. If you would like aliases to be accessible each time you launch a terminal session, you can add them to your shell configuration file (for example, ~\/.bashrc for Bash). Using aliases to customize the command line to your liking and expedite time-consuming tasks is quite effective.<\/p>\n<h3 id=\"h-linux-command-line-shortcuts-nbsp\" class=\"wp-block-heading\"><span id=\"linux-command-line-shortcuts\" class=\"uag-toc__heading-anchor\"><\/span><strong>Linux Command Line Shortcuts\u00a0<\/strong><\/h3>\n<p>Quick key combinations known as &#8220;command line shortcuts&#8221; make it easier for you to manipulate, navigate, and control your terminal. The following are some crucial short cuts:<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>Keyboard Shortcut<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>CTRL + A<\/td>\n<td>Moves the cursor to the beginning of the line.<\/td>\n<\/tr>\n<tr>\n<td>CTRL + E<\/td>\n<td>Moves the cursor to the end of the line.<\/td>\n<\/tr>\n<tr>\n<td>CTRL + U<\/td>\n<td>Deletes text from the cursor to the beginning of the line.<\/td>\n<\/tr>\n<tr>\n<td>CTRL + K<\/td>\n<td>Deletes text from the cursor to the end of the line.<\/td>\n<\/tr>\n<tr>\n<td>CTRL + L<\/td>\n<td>Clears the terminal screen.<\/td>\n<\/tr>\n<tr>\n<td>CTRL + C<\/td>\n<td>Interrupts (stops) the current command.<\/td>\n<\/tr>\n<tr>\n<td>CTRL + D<\/td>\n<td>Exits the current shell or terminal session.<\/td>\n<\/tr>\n<tr>\n<td>CTRL + Z<\/td>\n<td>Suspends the current command (resumable with the fg command).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2 id=\"h-pipelines-and-redirections-nbsp-nbsp\" class=\"wp-block-heading\"><span id=\"pipelines-and-redirections\" class=\"uag-toc__heading-anchor\"><\/span><strong>Pipelines and Redirections<\/strong><\/h2>\n<p>Let&#8217;s now examine the fundamental ideas behind controlling input and output using the Linux command line. Fundamental skills include comprehending standard input, output, and error; combining commands with pipes (|); redirecting output to files (&gt; and &gt;&gt;); and redirecting input from files (\\).<\/p>\n<h3 id=\"h-understanding-linux-standard-input-output-and-error\" class=\"wp-block-heading\"><span id=\"understanding-linux-standard-input-output-and-error\" class=\"uag-toc__heading-anchor\"><\/span><strong>Understanding Linux Standard Input, Output and Error<\/strong><\/h3>\n<p>The Linux command line uses Standard Input (stdin), Standard Output (stdout), and Standard Error (stderr) as communication channels between commands. Gaining proficiency with these channels leads to an understanding of command behavior and problem diagnosis. This is how they function:<\/p>\n<ul>\n<li><strong>Standard Input (stdin):<\/strong> This is where a command reads input from. By default, it\u2019s your keyboard.<\/li>\n<li><strong>Standard Output (stdout):<\/strong> This is where a command sends its normal output. By default, it\u2019s your terminal.<\/li>\n<li><strong>Standard Error (stderr):<\/strong> This is where a command sends error messages. It\u2019s also directed to your terminal by default.<\/li>\n<\/ul>\n<p>It can be helpful to learn how to capture or reroute these streams.<\/p>\n<h3 id=\"h-combining-commands-with-pipes-nbsp-nbsp\" class=\"wp-block-heading\"><span id=\"combining-commands-with-pipes\" class=\"uag-toc__heading-anchor\"><\/span><strong>Combining Commands with Pipes <em>(|)<\/em>\u00a0<\/strong><\/h3>\n<p>By using the output of one command as the input for another, pipes (|) let you combine multiple commands. You can build strong data processing pipelines as a result. Here&#8217;s an easy illustration:<\/p>\n<pre class=\"wp-block-code\"><code>command1 | command2\u00a0<\/code><\/pre>\n<p>In this instance, command2 receives the output of command 1 as input. In order to create intricate workflows that process data step-by-step, you can chain as many commands as necessary.<\/p>\n<h3 id=\"h-redirecting-output-to-files-gt-and-gt-gt-nbsp\" class=\"wp-block-heading\"><span id=\"redirecting-output-to-files-and\" class=\"uag-toc__heading-anchor\"><\/span><strong>Redirecting Output to Files <em>(&gt; and &gt;&gt;)\u00a0<\/em><\/strong><\/h3>\n<p>Using &gt; (overwrite) or &gt;&gt; (append), you can reroute a command&#8217;s output to a file. This is useful for generating log files or storing command outcomes. This is how it operates:<\/p>\n<p>To overwrite a file with command output:<\/p>\n<pre class=\"wp-block-code\"><code>command &gt; output.txt\u00a0<\/code><\/pre>\n<p>To append command output to an existing file:<\/p>\n<pre class=\"wp-block-code\"><code>command &gt;&gt; output.txt\u00a0<\/code><\/pre>\n<p>This feature is especially useful when you want to capture the results of a long-running process or create detailed reports.<\/p>\n<h3 id=\"h-redirecting-input-from-files-lt-nbsp-nbsp\" class=\"wp-block-heading\"><span id=\"redirecting-input-from-files\" class=\"uag-toc__heading-anchor\"><\/span><strong>Redirecting Input from Files <em>(&lt;)\u00a0<\/em>\u00a0<\/strong><\/h3>\n<p>In addition to redirecting output, you can also redirect input from files using &lt;. This allows you to feed a command with data from a file instead of typing it manually. Here\u2019s an example:<\/p>\n<pre class=\"wp-block-code\"><code>command &lt; input.txt\u00a0<\/code><\/pre>\n<p>In this case, command reads its input from input.txt. This is handy for automating repetitive tasks and processing large datasets.<\/p>\n<h2 id=\"h-searching-and-manipulating-text-in-the-linux-shell-nbsp\" class=\"wp-block-heading\"><span id=\"searching-and-manipulating-text-in-the-linux-shell\" class=\"uag-toc__heading-anchor\"><\/span><strong>Searching and Manipulating Text in the Linux Shell\u00a0<\/strong><\/h2>\n<p>Let us look at powerful tools and techniques available in the Linux command line for searching and manipulating text. These skills are useful in parsing log files, extracting specific information, and performing various text-related tasks efficiently.<\/p>\n<h3 id=\"h-using-grep-for-text-search-in-the-linux-terminal\" class=\"wp-block-heading\"><span id=\"using-grep-for-text-search-in-the-linux-terminal\" class=\"uag-toc__heading-anchor\"><\/span><strong>Using <em>grep<\/em> for Text Search in the Linux Terminal<\/strong><\/h3>\n<p>The command-line utility grep is a flexible tool for searching text in files or streams. It lets you locate lines that fit a given regular expression or pattern. Here is an example of basic usage:<\/p>\n<pre class=\"wp-block-code\"><code>grep \"pattern\" file.txt\u00a0\u00a0<\/code><\/pre>\n<p>This command will look through file.txt for lines that contain the given &#8220;pattern,&#8221; displaying them. Grep is a vital tool for text analysis and data extraction since it provides a plethora of options for sophisticated text searching.<\/p>\n<h3 id=\"h-linux-text-manipulation-with-sed-and-awk-nbsp\" class=\"wp-block-heading\"><span id=\"linux-text-manipulation-with-sed-and-awk\" class=\"uag-toc__heading-anchor\"><\/span><strong>Linux Text Manipulation with <em>sed<\/em> and <em>awk<\/em>\u00a0<\/strong><\/h3>\n<p>Two effective text processing tools that let you work with text in a variety of ways are sed and awk.<\/p>\n<h4><strong>sed<\/strong>:<\/h4>\n<p>To replace, remove, and manipulate text, use the Stream Editor &#8211; sed command. Frequently utilized in scripts for automated text editing, it functions on a line-by-line basis. For instance, to change every instance of &#8220;old&#8221; to &#8220;new&#8221; in a file:<\/p>\n<pre class=\"wp-block-code\"><code>\u00a0sed 's\/old\/new\/g' file.txt\u00a0<\/code><\/pre>\n<h4><strong>awk<\/strong>:<\/h4>\n<p>Awk is a flexible text processing tool that works well with structured data, including CSV files. You can specify unique actions for every line or record in a file. To print the second field (column) of a CSV file, for example:<\/p>\n<pre class=\"wp-block-code\"><code>awk -F',' '{print $2}' file.csv\u00a0<\/code><\/pre>\n<h3 id=\"h-sorting-and-filtering-text-sort-cut-uniq-in-linux-nbsp\" class=\"wp-block-heading\"><span id=\"sorting-and-filtering-text-sort-cut-uniq-in-linux\" class=\"uag-toc__heading-anchor\"><\/span><strong>Sorting and Filtering Text (sort, cut, uniq) in Linux\u00a0<\/strong><\/h3>\n<p>Linux provides several built-in commands for sorting, cutting, and filtering text efficiently:<\/p>\n<h4><strong>sort<\/strong>:<\/h4>\n<p>Ordering lines by number or alphabet is possible with the sort command. To sort a text file with the name data.txt, for example:<\/p>\n<pre class=\"wp-block-code\"><code>\u00a0sort data.txt\u00a0<\/code><\/pre>\n<h4><strong>cut<\/strong>:<\/h4>\n<p>The cut command is helpful for parsing structured data because it lets you extract particular columns from text files. From a CSV file, extract the first and third columns as follows:<\/p>\n<pre class=\"wp-block-code\"><code>\u00a0 cut -d',' -f1,3 file.csv\u00a0\u00a0<\/code><\/pre>\n<h4><strong>uniq<\/strong>:<\/h4>\n<p>To remove duplicate lines from sorted text, apply uniq. To locate unique lines in a file, for instance:<\/p>\n<pre class=\"wp-block-code\"><code>\u00a0sort file.txt | uniq<\/code><\/pre>\n<p>These commands offer a comprehensive toolkit for text data processing, searching, and manipulation in the Linux command line when combined with grep, sed, and awk. Whether you work as a data analyst, programmer, or system administrator, becoming proficient with these text manipulation tools will greatly increase your productivity.<\/p>\n<h2 id=\"h-linux-system-information-and-troubleshooting-nbsp\" class=\"wp-block-heading\"><span id=\"linux-system-information-and-troubleshooting\" class=\"uag-toc__heading-anchor\"><\/span><strong>Linux System Information and Troubleshooting\u00a0<\/strong><\/h2>\n<p>This chapter will cover the fundamental tools and methods for obtaining system data, resolving typical problems, and keeping an eye on resource consumption in a Linux environment. These abilities come in handy for keeping the system healthy and finding efficient solutions to issues.<\/p>\n<h3 id=\"h-checking-system-information-uname-df-free-nbsp\" class=\"wp-block-heading\"><span id=\"checking-system-information-uname-df-free\" class=\"uag-toc__heading-anchor\"><\/span><strong>Checking System Information <em>(uname, df, free)\u00a0<\/em><\/strong><\/h3>\n<p>You can use a number of commands to get information about the configuration and resource usage of your system:<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>Command<\/td>\n<td>Description<\/td>\n<td>Example<\/td>\n<\/tr>\n<tr>\n<td>uname<\/td>\n<td>Displays basic system information such as the kernel version and system architecture.<\/td>\n<td>Uname -a<\/td>\n<\/tr>\n<tr>\n<td>df<\/td>\n<td>Shows disk space usage, including information about disk partitions and their available space.<\/td>\n<td>df -h<\/td>\n<\/tr>\n<tr>\n<td>free<\/td>\n<td>Displays memory (RAM) usage information, including total, used, and available memory.<\/td>\n<td>free -m<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h3 id=\"h-linux-system-logs-and-troubleshooting-journalctl-dmesg\" class=\"wp-block-heading\"><span id=\"linux-system-logs-and-troubleshooting-journalctl-dmesg\" class=\"uag-toc__heading-anchor\"><\/span><strong>Linux System Logs and Troubleshooting <em>(journalctl, dmesg)<\/em><\/strong><\/h3>\n<p>Troubleshooting system issues often involves examining logs and messages. Two key commands for this purpose are:<\/p>\n<h4><strong>journalctl<\/strong>:<\/h4>\n<p>You can view logs for different system services and events by using the journalctl command to access the systemd journal. This is a very useful tool for troubleshooting system problems because it allows you to view and filter log entries. To see the most current system logs:<\/p>\n<pre class=\"wp-block-code\"><code>journalctl -xe\u00a0<\/code><\/pre>\n<h4><strong>dmesg<\/strong>:<\/h4>\n<p>The dmesg command also shows kernel ring buffer messages, which are helpful in troubleshooting hardware-related issues. Specifically, it displays messages pertaining to system boot, driver initialization, and hardware detection. To see messages from the kernel:<\/p>\n<pre class=\"wp-block-code\"><code>dmesg | less\u00a0<\/code><\/pre>\n<h3 id=\"h-monitoring-resource-usage-htop-nbsp\" class=\"wp-block-heading\"><span id=\"monitoring-resource-usage-htop\" class=\"uag-toc__heading-anchor\"><\/span><strong>Monitoring Resource Usage <em>(htop)<\/em><\/strong><em>\u00a0<\/em><\/h3>\n<p>Htop is a feature-rich and interactive system monitor and process viewer. Moreover, it offers a real-time summary of how much CPU, memory, and process usage is occurring on the system.<\/p>\n<p>It appears as follows:<\/p>\n<figure class=\"wp-block-image size-full\"><picture><source srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2023\/09\/image-48.png.webp 1229w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2023\/09\/image-48-600x357.png.webp 600w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2023\/09\/image-48-768x457.png.webp 768w\" type=\"image\/webp\" sizes=\"(max-width: 1229px) 100vw, 1229px\" \/><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-17804 webpexpress-processed\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2023\/09\/image-48.png\" sizes=\"(max-width: 1229px) 100vw, 1229px\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2023\/09\/image-48.png 1229w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2023\/09\/image-48-600x357.png 600w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2023\/09\/image-48-768x457.png 768w\" alt=\"Linux Command Line - Tips and Tricks (htop)\" width=\"1229\" height=\"732\" \/><\/picture><\/figure>\n<p>To install htop use the following command:<\/p>\n<p>On Debian\/Ubuntu-based systems:<\/p>\n<pre class=\"wp-block-code\"><code>sudo apt-get install htop\u00a0<\/code><\/pre>\n<p>On Red Hat\/CentOS-based systems:<\/p>\n<pre class=\"wp-block-code\"><code>sudo yum install htop\u00a0<\/code><\/pre>\n<p>Once installed, simply run htop in your terminal:<\/p>\n<pre class=\"wp-block-code\"><code>htop\u00a0<\/code><\/pre>\n<p>Htop is a great substitute for the standard top command. Furthermore, it provides an easier-to-use interface along with extra capabilities for process and system resource management.s.<\/p>\n<h2 id=\"h-linux-command-line-security-best-practices-nbsp\" class=\"wp-block-heading\"><span id=\"linux-command-line-security-best-practices\" class=\"uag-toc__heading-anchor\"><\/span><strong>Linux Command Line Security Best Practices\u00a0<\/strong><\/h2>\n<p>Whether you&#8217;re a novice or an expert system administrator, protecting your system&#8217;s security is essential when using the Linux command line. In today&#8217;s digital world, knowing best practices for Linux security is essential.<\/p>\n<h3 id=\"h-user-privileges-and-sudo-nbsp\" class=\"wp-block-heading\"><span id=\"user-privileges-and-sudo\" class=\"uag-toc__heading-anchor\"><\/span><strong>User Privileges and Sudo\u00a0<\/strong><\/h3>\n<p>Effective user privilege management is crucial for controlling who can execute what on a Linux system. The sudo tool is frequently used for this purpose. It allows authorized users to execute commands with elevated privileges, providing temporary access to perform specific administrative tasks without requiring constant root access.<\/p>\n<p>This strategy reduces the risk of accidental system damage caused by unrestricted root access. However, exercising caution with sudo commands is vital to prevent unintended modifications or deletions of critical system files. Additionally, creating and assigning users to appropriate groups further refines access controls, limiting exposure to sensitive data and system resources.<\/p>\n<h2 id=\"h-customization-and-configuration-the-linux-command-line-nbsp\" class=\"wp-block-heading\"><span id=\"customization-and-configuration-the-linux-command-line\" class=\"uag-toc__heading-anchor\"><\/span><strong>Customization and Configuration the Linux Command Line<\/strong><\/h2>\n<p>Would you prefer to be unique? Next, examine the art of tailoring and setting up your Linux environment to meet your requirements and tastes. These abilities will make working more comfortable for you, from configuring your shell to managing environment variables and customizing the terminal.<\/p>\n<h3 id=\"h-nbsp-configuring-your-linux-shell-bashrc-nbsp\" class=\"wp-block-heading\"><span id=\"configuring-your-linux-shell-bashrc\" class=\"uag-toc__heading-anchor\"><\/span><strong>Configuring Your Linux Shell (.bashrc)\u00a0<\/strong><\/h3>\n<p>In addition to setting environment variables, your shell configuration file\u2014commonly called.bashrc for the Bash shell\u2014allows you to define aliases and alter the behavior of your shell. Let&#8217;s now explore how to personalize your Bash shell:<\/p>\n<p>Open your .bashrc file:<\/p>\n<pre class=\"wp-block-code\"><code>nano ~\/.bashrc\u00a0<\/code><\/pre>\n<p>Add an alias to simplify a common command:<\/p>\n<pre class=\"wp-block-code\"><code>alias ll='ls -l'\u00a0<\/code><\/pre>\n<p>Save your changes and apply them immediately:<\/p>\n<pre class=\"wp-block-code\"><code>source ~\/.bashrc\u00a0\u00a0<\/code><\/pre>\n<p>These customizations can make your shell more user-friendly and efficient.<\/p>\n<h3 id=\"h-how-to-customize-the-linux-terminal-color-schemes-fonts-nbsp\" class=\"wp-block-heading\"><span id=\"how-to-customize-the-linux-terminal-color-schemes-fonts\" class=\"uag-toc__heading-anchor\"><\/span><strong>How to Customize the Linux Terminal (color schemes, fonts)\u00a0<\/strong><\/h3>\n<p>Customizing your terminal can improve the whole experience. To make it aesthetically pleasing and easy to use, you can change the fonts and color schemes.<\/p>\n<h3 id=\"h-change-the-linux-terminal-color-scheme-nbsp\" class=\"wp-block-heading\"><span id=\"change-the-linux-terminal-color-scheme\" class=\"uag-toc__heading-anchor\"><\/span><strong>Change the Linux terminal color scheme\u00a0<\/strong><\/h3>\n<pre class=\"wp-block-code\"><code># To list available color schemes:\u00a0\r\ndconf list \/org\/gnome\/terminal\/legacy\/profiles:\/\u00a0\r\n# To set a new color scheme:\u00a0\r\ndconf write \/org\/gnome\/terminal\/legacy\/profiles:\/:&lt;profile-id&gt;\/background-color \"'#000000'\"\u00a0\r\ndconf write \/org\/gnome\/terminal\/legacy\/profiles:\/:&lt;profile-id&gt;\/foreground-color \"'#FFFFFF'\"<\/code><\/pre>\n<h3 id=\"h-adjust-the-linux-terminal-font-settings\" class=\"wp-block-heading\"><span id=\"adjust-the-linux-terminal-font-settings\" class=\"uag-toc__heading-anchor\"><\/span><strong>Adjust the Linux terminal font settings<\/strong><\/h3>\n<pre class=\"wp-block-code\"><code># To list available fonts:\u00a0\r\ndconf list \/org\/gnome\/terminal\/legacy\/profiles:\/\u00a0\r\n# To set a new font:\u00a0\r\ndconf write \/org\/gnome\/terminal\/legacy\/profiles:\/:&lt;profile-id&gt;\/font \"'&lt;font-name&gt; &lt;font-size&gt;'\"<\/code><\/pre>\n<p>Experiment with different colors and fonts to find the combination that suits you best.<\/p>\n<h3 id=\"h-managing-environment-variables-nbsp\" class=\"wp-block-heading\"><span id=\"managing-environment-variables\" class=\"uag-toc__heading-anchor\"><\/span><strong>Managing Environment Variables\u00a0<\/strong><\/h3>\n<p>Configuring your Linux environment is largely dependent on environment variables. Additionally, you can configure them in files like \/etc\/environment for your user or the entire system. Let&#8217;s now investigate setting an environment variable unique to a user:<\/p>\n<p>Open your .bashrc file:<\/p>\n<pre class=\"wp-block-code\"><code>nano ~\/.bashrc\u00a0<\/code><\/pre>\n<p>Add an environment variable:<\/p>\n<pre class=\"wp-block-code\"><code>export MY_VARIABLE=\"my_value\"\u00a0<\/code><\/pre>\n<p>Save your changes and apply them immediately:<\/p>\n<pre class=\"wp-block-code\"><code>source ~\/.bashrc\u00a0<\/code><\/pre>\n<p>Now, you can access your custom environment variable in your shell scripts and commands.<\/p>\n<h2 id=\"h-conclusion-recap-of-linux-command-line-key-tips-and-tricks\" class=\"wp-block-heading\"><span id=\"conclusion-recap-of-linux-command-line-key-tips-and-tricks\" class=\"uag-toc__heading-anchor\"><\/span><strong>Conclusion: Recap of Linux Command Line Key Tips and Tricks<\/strong><\/h2>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td>Key Tips and Tricks<\/td>\n<td>Summary<\/td>\n<\/tr>\n<tr>\n<td>Basic Navigation<\/td>\n<td>Covered commands like cd, ls, and pwd for navigating the file system.<\/td>\n<\/tr>\n<tr>\n<td>File Operations<\/td>\n<td>Explored file and directory creation, manipulation, and management with commands like touch, mkdir, cp, mv, and rm.<\/td>\n<\/tr>\n<tr>\n<td>Permissions and Ownership<\/td>\n<td>Discussed controlling file permissions and ownership using chmod and chown.<\/td>\n<\/tr>\n<tr>\n<td>Pipelines and Redirections<\/td>\n<td>Mastered combining commands with pipes \u201c|\u201d, redirecting input and output to files (\u201c&lt;\u201d, \u201c&gt;\u201d, \u201c&gt;&gt;\u201d, understanding standard input (stdin), standard output (stdout) and standard error (stderr)<\/td>\n<\/tr>\n<tr>\n<td>Monitoring and Managing Processes<\/td>\n<td>Learned how to view and manage running processes with ps, top, and kill.<\/td>\n<\/tr>\n<tr>\n<td>System Information and Troubleshooting<\/td>\n<td>Checked system information with uname, df, and free, accessed logs with journalctl and dmesg, and monitored resource usage with htop.<\/td>\n<\/tr>\n<tr>\n<td>Security Best Practices<\/td>\n<td>Explored the importance of system security, user privileges (sudo), and file permissions, with reference to in-depth articles.<\/td>\n<\/tr>\n<tr>\n<td>Customization and Configuration<\/td>\n<td>Discussed customizing the shell (bashrc), terminal appearance, and managing environment variables.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<\/div>\n<\/div>\n<\/article>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Amidst the dominance of graphical user interfaces on our screens, the command line persists as a formidable, albeit overlooked, powerhouse. Welcome to the Linux command line universe, where the mastery of its tips and techniques can elevate you from a novice to a command line wizard. In this realm, we&#8217;ll uncover the hidden potential, unveiling strategies that empower users to&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3494,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[1099],"kbtag":[],"class_list":["post-3490","kb","type-kb","status-publish","has-post-thumbnail","hentry","kbtopic-tutorials"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=3490"}],"version-history":[{"count":3,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3490\/revisions"}],"predecessor-version":[{"id":3493,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3490\/revisions\/3493"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media\/3494"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=3490"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3490"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}