- 3 lucrative side hustles you can start right now with OpenAI's Sora video generator
- How to use Microsoft's Copilot AI on Linux
- Protect 3 Devices With This Maximum Security Software
- I tested Samsung's 98-inch 4K QLED TV, and watching Hollywood movies on it left me in awe
- Apple is working on a doorbell that unlocks your door Face ID-style
Easy command line Linux tricks
In this post, we’ll take a look at a series of basic Linux command tricks. I’ve included short and easy descriptions and some example commands to try. All of these are very useful and can be easily put into use, whether you need them frequently or only from time to time.
Moving around the file system
The cd command (one of those most basic Linux commands) followed by the name of any directory takes you there as long as your access permissions allow. To move back into your home directory from anywhere in the file system, simply type cd without any arguments (cd). To move up one directory, use the command followed by two dots (cd ..). To return to whatever directory you were sitting in prior to your moving to your current location, use the cd command with a dash (cd -). Note that if you use this trick a number of times in a row, you will move back and forth between the two locations rather than backing up further and further.
Working with files
You can look at text file content using the more command (more myfile), examine the ends of those files with commands that pipe output to the tail command (tail -f filename), and examine them a screenful at a time with commands like less (less logfile).
You can empty a text file simply using the > symbol (> oldfile) or update its most recent update date/time using just a touch command (touch myfile).
Reusing prior commands
You can list the commands you have run previously with the history command, or show a screenful at a time by piping the output to more (history |more). If your history buffer saves 1,000 or 5,000 commands, as most do these days, that’s a bit too much to browse through. Instead, you can use the up arrow to move back through prior commands (starting with the most recent) one at a time. Press return when you reach the one you want to rerun.
You can also pipe the output of the history command to the tail command to see only a small range of the most recently entered commands (history | tail -20).