If you experience any difficulty in accessing content on our website, please contact us at 1-866-333-8917 or email us at support@chicagovps.net and we will make every effort to assist you.

Samantha Rattner
By
January 30, 2024

Unlocking Productivity: Easy Command Line Tricks for Linux

 

Linux tricks can enhance your efficiency, especially when they’re simple. This blog post shares useful tips to locate files, repeat previous commands, halt processes, and more.

In this section, we will delve into a series of fundamental Linux command tricks. Included are straightforward explanations and sample commands for you to experiment. These tricks are incredibly handy and can be deployed easily, no matter if the need arises frequently or occasionally.

The cd command (one of the most basic Linux commands) followed by any directory name will navigate you to that directory providing your access permissions permit it. If you want to navigate back to your home directory from any point in the file system, just key in cd without any arguments (cd). The command followed by two dots (cd ..) enables you to ascend one directory. However, if you wish to return to the directory where you were before you moved to your current location, make use of the cd command (cd -). Remember, if you keep using this command repeatedly, you will be toggling between two locations instead of moving further back.

With the more command (more myfile), you can view content of text files, the ends of those files can be examined with commands that redirect output to the tail command (tail -f filename), and the screenful of them can be examined with commands like less (less logfile).

You can easily clear a text file using the “>” symbol (> oldfile), or alter its most recent update time/date only with a touch command (touch myfile).

The history command lets you view the commands you have previously executed, or you can pipe the output to more (history | more) to view one page at a time. If your history buffer saves 1,000 or 5,000 commands, which is the norm in current times, then it’s more convenient to use the up arrow to go back through previous commands (starting with the latest) one by one. Hit return when you get to the one you want to execute again.

The tail command can be used in combination with the output of the history command to view a small section of the most recently entered commands (history | tail -20).

Two exclamation points (!!) will rerun the command you most recently entered. Use !$ (echo !$) to display or reuse your previous command’s final argument.

It’s possible to avoid adding every command into your history buffer. Initiating any command with a space bar hit first will lead to the command not being remembered. As an example, the command ‘ echo hello’ starting with a space will not be included in the history buffer. By implementing this, time can be saved when reviewing or reusing prior commands.

Specific commands can also be repeated, a process achieved by pressing the exclamation mark followed by the command characters. For instance, ‘!tail’ will rerun the ‘tail’ command.

Another tip is to utilize the history command output along with the grep function, listing only specific commands. The command ‘history | grep reset’ will only show commands containing ‘reset’ in the history buffer.

One powerful command is the find command. This feature aids in file discovery, through name, content, or other categories. The command ‘find . -mtime -10’ will locate files less than ten days old starting from the current location. A command resembling ‘find . -name fort*’ will look for files starting with ‘fort’.

You have the ability to suspend and reinitiate your command console using ^s (suspend) and ^q (reactivate). It’s important to understand that the ^s sequence equates to “holding down the control button and pressing an s” whereas ^q corresponds to “holding down the control button and pressing a q”. In a like manner, you can navigate to the start and finish of strings with ^a and ^e or obliterate the present string using ^u.

At any point you desire, you can cleanse your interface – a useful trait when it’s time to concentrate on a new matter – just by entering clear.

One can terminate a command that you’ve just begun by deploying the ^c command (hold down control button and press c), finish a command that’s operating independently of your console (in the background) by implementing the kill command followed by the process’s identification number (kill 2604), and end a running procedure by its name using pkill (pkill myloop).

Be sure to regularly review command manual pages to discover more of the available tools, or to utilise the –help feature (pkill –help) to receive a summarised rundown of the options.

Furthermore, consider transforming some of the more intricate commands you need to utilize into aliases to simplify them and prevent errors by including them in your .bashrc file (alias recent=”history | tail -10″).

This article offers a range of instructive tips for commands that you will probably find extremely useful and simple to operate.

 


ChicagoVPS is your gateway to unparalleled hosting solutions. Our state-of-the-art datacenters and powerful network ensures lightning-fast speeds and uninterrupted connectivity for your websites and applications. Whether you’re a startup looking for scalable resources or an enterprise in need of enterprise-grade hosting, our range of plans and customizable solutions guarantee a perfect fit. Trust in ChicagoVPS to deliver excellence, combining unmatched reliability and top-tier support.

For Inquiries or to receive a personalized quote, please reach out to us through our contact form here or email us at sales@chicagovps.net.

Subscribe Email

Top