Most Linux users learn basic commands like cd, mv, and ls pretty early on.You're going to use them often, but there are other short and useful commands that I like to teach my trainees and students right away.Here are 4 short commands that are not only useful, but they have names so short, you'll remember them forever.
Cat lets you do some amazing stuff with text in a terminal Look into a file's contents without opening it Close Out of all the short, easy to remember commands, I like cat best (and not just because I love cats).When you use it, it displays the contents of a file right there in the terminal.You could just use it to display a file.
Or you can do other things, like make a list with -b or show all the characters with -A.In my example, I used: cat notes.txt for the standard content display.For the list, I used cat -b notes.txt and for all the characters being displayed, I used cat -A notes.txt.
It's a short and fun command that saves a ton of time.It can also be used to display the contents of multiple files by typing cat file1 file2 (and adding as many other files as you like).But the of this command is the ability to make new files right in the terminal, which is something I do a lot, especially for taking notes or keeping track of things.
Don't forget to hit CTRL + D to save your file afterward.And just for fun, you can always display the content of the file backwards if you want, using tac, which is a pretty fun thing to do sometimes.Grep is a powerful search command Finding content inside files from the shell The grep command is one of those multipurpose commands that makes using Linux easier.
It's used to search for patterns in a file.When it finds what you're searching for, it'll print it in the terminal.If I want to find a phrase, sentence, pattern among my files, I use grep followed by -i so it ignores uppercase/lowercase sensitivity.
Using -r will do a recursive search, which is pretty handy.Using -l is another useful option, as it'll show you filenames without the actual text.A typical command would look something like this: grep -i 'search-term' *.txt if you want to search all text files that might contain those words.
You can sub in a specific file name or type as well.Grep is fast and can do a lot more than just search for patterns, so it's worth learning inside and out.I recommend taking a look at its man pages and taking it for a test spin in your own terminal.
df is basically a Linux power tool Monitoring disk space and usage quickly If you want to know anything about the used or free space on your disk partition, df is the command you'll use.It stands for "disk free" and it gives you quick access to some very important information.Just typing "df" into your terminal will bring up a bunch of information.
To make more sense of the information on the screen, add -h or -H, which displays information in "powers of 1024" or "powers of 1000" respectively (you can read more about this at the Ubuntu Wiki), according to the (page 92 if you're curious).Running df --total gives you basic information about the total space used and remaining.This command works on all three distros I use (Debian, Mint, Ubuntu), but it might not be available in distros.
I check my disk space often and always use this command first.I recommend using df -h most, because its output is, well, readable by humans.pwd is a short but helpful command Find your file paths in seconds This one is one of my favorites and makes copying or moving files super easy.
It has a very basic, but in my opinion, very useful function: to print the current directory.I use it most often if I'm syncing files between Termux on my phone to one of my Linux desktops.If I don't remember the directory, I just execute this command, copy the path, and then move the files.
Let's say I want to move an entire directory of Phish albums from my phone to my PC, but I don't quite remember the path to their folder.I know they're buried deep within the mpd folder on my phone.So I'll search for the folder and use pwd to find its file path.
From there, it's a matter of either moving it somewhere else on my phone or syncing it to my Mint PC.Related 7 essential keyboard shortcuts every Linux Mint user should know Mint is designed to be used with a mouse, but don't dismiss the keyboard out of hand.Posts 3 By Nick Lewis Learning short terminal commands can make learning and navigating Linux easier, especially if you're new to the OS.
My recommendation, though, is to learn about your distro and keep a Linux reference book around.I like and O'Reilly's I also like to create handwritten reference notes that I tack on the wall in my office.Half the fun of Linux is learning as you go, but you can't do that without understanding what the commands you use actually do.
Read More