60 Useful and Interesting Linux Terminal Commands You Should Learn Today
The terminal is one of the first things you’ll need to familiarize yourself with if you’re using a Unix-based OS. While command-line tools are also available on other operating systems like Windows and MacOS, very few people actually use them or even know about them. If you’re a Linux user, however, it’s pretty difficult to get by without knowing your way around the terminal. In fact, it’s next to impossible because working with the terminal is such an essential part of the Linux experience.
If you’re new to the world of Linux, the prospect of working with command-line tools may seem a bit intimidating but don’t worry because it’s not as complicated as you may think. Commands are usually short and easy to remember, however, it’s not practical to try to memorize all of them. That’s why we put together a comprehensive list of useful Linux terminal commands that you can refer to whenever you need a bit of help. We also took the liberty of neatly sorting all commands by category in order to make things even easier for you, so let’s start with the first one.
1. Terminal Navigation and Directory Management Commands
Knowing how to quickly jump between directories and access their contents will make you a lot more efficient at using a Linux operating system. The first step in achieving that goal is to master the command-line terminal. Below you can find a few basic navigation commands to help you get started.
pwd is an acronym that stands for “print work directory” and can be used whenever you get lost or forget when you are on the system. The command simply shows the directory you’re currently navigating. Although basic, pwd is one of the most useful commands for Linux users of all skill levels.
Creating a new directory in Linux is as easy as typing the mkdir command in the terminal. If you want to keep everything neatly organized on your system, you’ll also want to give a name to each directory. This can be done by typing the mkdir command followed by a name. For example, “mkdir apples” will create a new folder called “apples.” What’s neat about this command is that you can use it to create multiple directories at the same time. For example, “mkdir apples oranges” will create two distinct folders called “apples” and “oranges.”
cd is short for “change directory” and does exactly what you might expect. After you create a new directory using the mkdir command, you can move to it by typing cd in the terminal. Sticking to the example we talked about earlier, you can use “cd apples” to jump to the “apples” directory. Alternatively, you can use the entire path of the folder instead of just its name.
New directories created with mkdir are by default empty but you’ll often find yourself working with folders that contain various files. If you want to list the contents of one of these folders, you’ll need to use the ls command. You can use cd to move to a directory and then ls to list the contents, however, it’s often easier to just use ls followed by the directory name. For example, “ls apples” will display all files and folders found in “apples” even if you’re currently in the “oranges” directory.
Whereas mkdir lets you create directors, rmdir is the command you’re going to use to delete them. The command works similar to its counterpart in the sense that it lets you delete one or multiple directories at once regardless of where you are on the system. However, the command only works as long as the folders you want to delete are empty.
As you may have already guessed based on its name, history shows you a list of all recently used commands. If you want to reuse a command you don’t have to type it in every single time because you can use the up and down arrow keys to cycle through all your recent commands.
man is used to display a comprehensive help page that tells you everything you need to know about a specific command and when or how to use it. The man command pulls help pages straight from the manual so expect the information to be quite technical in nature.
If you don’t want to be overwhelmed by all the information provided by man you can stick to whatis instead. This is essentially a simplified version of man that gives you brief descriptions of commands and their functions but leaves out most of the technical details.
2. File Management Commands
If you’re looking to create, delete, move or manage files in some other ways you’ll usually be able to do so without having to use the terminal. That’s because most Linux distributions feature a graphical interface that allows you to interact with files just like you would on Windows or MacOS. That said, you will be able to carry out complex tasks that involve files much faster if you do use the commands below.
If you want to delete files the rm command is your best friend. When used by itself, rm will immediately delete files without asking for confirmation. Be careful when using it because it’s next to impossible to recover the files afterward. You can use the “-i” option if you want to receive a confirmation prompt whenever you try to delete a file. For example, “rm -i apples”.
mv stands for “move” so this one is pretty self-explanatory. Moving a file requires that you specify both its current location and its new path. You can use the mv command to move files pretty much anywhere, including from one folder to another.
cp works pretty similar to mv but it lets you copy files instead of moving them altogether. When using the command you have to specify the name of the file as well as the name of the copy. For example, “cp apple new_apple”. You can also use cp to copy the entire contents of specific directories if you add the option “-r” after the command.
Your go-to command for renaming both individual files and multiple files at once. The command supports a variety of options, such the ability to rename files that share certain characteristics.
The command cat is primarily used to display the contents of files in the terminal window. With this command you can list the contents of one or multiple files and even combine several text files into one. The command has a couple of other functions as well but you’ll most probably use it in situations when you want to read files without opening them in a text editor.
Whereas cat can be used to create a new file by combining two or more existing ones, touch is the command that lets you create a brand new file from nothing. In addition, touch is also the most popular command for creating or modifying the timestamps of a file.
Another important command that Linux veterans are very familiar with, find lets you search your system for specific files. The command also works on directories and comes with a lot of options. For instance, you can use it to search for files that were created by certain users or files that were modified on a certain date. And, of course, find can also be used to search for multiple files at once.
Now you know how to search your system for files but how about searching for strings of text? There are a couple of commands that let you do that, with the most popular one being grep. This command is particularly valuable for programmers as it can be used to search for lines of code and comes with a lot of options, just like the find command. Possibly the most useful feature of grep is that it can search all files on the system that share the same type.
If you ever find yourself working with files that contain a lot of information you can use head to make things easier on yourself. The command can be used to display the first few lines of any file directly in the terminal. By default, head lists the first 10 lines of a file but you can change that number to any other value you want.
This is pretty much the complete opposite of the previous command as it can be used to list the last few lines of a file. The command works just like its counterpart so make sure to specify the number of lines you want to display, otherwise it will show you the last 10 by default. tail can come in handy by itself but it really shines when used in conjugation with the cat command.
wget is a command that allows you to download files from the internet. It can be used to download multiple files at once and comes with options that let you download files in the background, mirror remote websites, view headers, limit the bandwidth used for file downloads, and more.
This is the command most often used when comparing files. You can use comm to see if two files share the same lines of text, which comes in handy if you’re working with large amounts of files and want to check if some of them are identical.
The previous command can be very useful but it does have some limitations. For example, you can compare files but you can’t print the results. If you’re looking to print comparison results you’re going to need a similar yet slightly different command known as cmp.
A multi-purpose command, dd is primarily used to copy and convert files from one format to another. Among other things, dd can also be used to back up entire hard disks or just certain partitions, create or restore hard disk images, create bootable live USB flash drives, create ISO backups, and more.
This command is a bit more advanced that some of the others we’ve covered so far and is generally only used by sysadmins. The basic gist of alias is that it can be used to change the default name of a command to a custom one. The terminal will recognize both the original name and the new one. The great thing about alias is that it also works with command sequences. When used properly, this command can save you a lot of time and make certain tasks a lot easier. However, it’s worth noting that aliases disappear once you close the terminal window. If you want to set permanent aliases, you’ll need to modify the .bash_aliases file, which is located in the home directory.
3. System Management Commands
Now that you know how to use the Linux terminal to manipulate files it’s time to take things to the next level. In this next section we’re going to take a look at commands that that can be used to manage your system as a whole, or just certain parts of it.
If you’re transitioning from Windows, you may be surprised to learn that on Linux a lot of the time external devices like USB flash drives or SD cards won’t be instantly usable when you connect them to your machine. Instead, you’ll usually have to mount these types of devices manually using a terminal command. Conveniently, the command is known simply as mount. If you want to detach an external device, use the command unmount instead.
df is a very useful command that displays information related to disk space. You can use df to display how much free space is available on your system or to find out the size of a particular file.
Pretty much identical to df in its function but displays free and used RAM instead of disk space.
This one is a bit tricky because it doesn’t do anything by itself. Instead, apt can perform different functions when combined with other commands. For example, add-apt-repository is used to locate third-party packages while apt-get will allow you to install said packages. Meanwhile, apt-cache lets you search through all your repositories. It’s worth noting that not every Linux distro supports apt commands as some of them use yum, rpm or other alternatives.
sudo is one of the most useful Linux terminal commands out there, however, it can be somewhat situational. Use sudo if you want to run a command as a superuser, which will give you increased permissions for accessing and modifying files. You probably won’t need to use this if you’re a sysadmin but it can still come in handy when trying to test certain commands from a regular user account.
A very simple command that displays a list of all currently running processes on your system. The list doesn’t display processes started by other users, however, you can see those as well when used in combination with certain filtering options.
Another basic terminal command that’s almost always used alongside ps. Whereas ps lets you see currently running processes, this command allows you to immediately terminate them. The regular kill command only works on individual processes but you can use killall to terminate all processes that match given parameters.
Very similar to ps but arguably even more useful, top also displays a list of currently running process and sorts them by resource consumption. What sets top apart from ps is the fact that it updates in real time. There are a lot of variants to this command, most of which are used by sysadmins for monitoring purposes, but the regular version remains the most popular one. If you were looking for a Linux alternative to Windows’ Task Manager this is it.
uptime is exactly what it says on the tin. The command shows you for how long the system has been running and updates in real-time. uptime doesn’t really have any other special functions but it doesn’t need them either because it only has one job and it does it well.
A simple command for quickly sending a window or an application to the foreground. Often used in conjunction with fg, a similar but opposite command that sends tasks running in the background to the foreground.
Speaking of terminal commands that work great when combined, you’ll often have to use bg/fg alongside jobs. Just as its name indicates, this command presents you with a list of currently running jobs, which can represent either a single process or a set of processes.
This is the command you’ll most often use to display basic information related to your system. uname displays things like operating system name, kernel version, currently installed hardware, and more. Like many of the other commands on this list, uname supports certain parameters that you can use to display additional information.
A command that tells you the name of the account you’re currently using. Probably not very helpful if you’re using the same account all the time but can come in handy if you find yourself switching between accounts on a regular basis.
Fairly basic command generally used to display the location of executable files. In addition, whereis can also search for manual pages and configuration files, among other things.
Don’t want to use the mouse to turn off your computer? No problem, just use the shutdown command instead. Not the most useful terminal command on this list but still worth keeping in mind all the same.
Interesting and Fun Linux Terminal Commands
Linux often gets a bad rap for being more technically oriented and more difficult to work with than other operating systems. Sure, Linux is a bit more complicated than Windows or MacOS but that doesn’t mean the operating system is all work and no play. In fact, you can have plenty of fun with just the terminal alone if you know the right commands and we’re going to prove it in this last section.
This first one is more educational than fun but still worth including nevertheless. Wikit basically brings Wikipedia straight to your Linux terminal and allows you to look up things on the website without a browser. Pretty nifty, right? Simply type in the command “wikit” followed by any search term to pull up the corresponding Wikipedia page in your terminal. Unlike most of the commands we’ve covered so far, Wikit needs to be installed before you can use it and the tool has a couple of dependencies in the form of nodejs and npm.
fortune is a good command to use when you need a good chuckle. The program has been around for decades but was expanded over time to include more and more obscure jokes, random messages, and quotes from science fiction shows like Star Trek or Doctor Who. A lot of the fortunes can be hit or miss depending on your sense of humor but you’re sure to find some good ones in there as well.
Why open a browser when you can navigate the internet directly from the Linux terminal? While it may seem a bit impractical to do so, it’s definitely doable thanks to Browsh, an open source text-based browser that runs in the terminal. The UI doesn’t exactly look modern but the browser can render anything from HTML and JS to WebGL, videos, and more, all in full color. Browsh is a great little tool for saving bandwidth and battery life, especially on low-powered devices like Raspberry Pi.
If you only want to look up stuff on Google you don’t actually need a browser at all because you can access the search engine straight from the terminal. All you need is a command-line tool known as Googler, which can be used either as a standalone utility or in combination with a text-based browser like Browsh. The tool comes with most of the features offered by regular Google, including the ability to change languages, search by country or domain, and more.
This is a simple little command that reverses any words or sentences you type into the terminal. Perhaps not the most useful command out there but you can definitely have a bit of fun with it.
This one is exactly what it sounds like – a cow that says things. What kind of things? Well, anything you want of course. The cow looks like an ASCII art figure and has a dialogue cloud over its head. Pretty neat but this tool isn’t just for bovine lovers because you can replace the cow with a variety of other animals, dinosaurs, dragons, and even the Ghostbusters mascot.
Since we just mentioned ASCII code now would be the perfect time to talk about banner. Have you ever seen those cool ASCII code banners on forums or the comments section of YouTube? There are many ways of creating them but probably one of the easiest methods is by using the banner command. The tool converts anything you type in the terminal into an ASCII banner and can even be used to customize them to a certain extent.
Not a fan of simple text banners? How about locomotives? Type the sl command into the terminal to summon a steam locomotive that runs across your screen. No “choo-choo” sounds unfortunately.
I know what you’re thinking but toilet is actually another command that lets you create ASCII text banners. However, this one is a bit more advanced because it contains additional customization options like colored fonts and unicode support, among other things. Speaking of banners, you can also use the figlet command to achieve a somewhat similar result. Use figlet if you want your banner to be comprised of lines instead of letters and numbers.
This is the last ASCII-related command, we promise. This one works a bit different than the ones mentioned earlier as it allows you to convert pretty much any existing imagine into ASCII art. Some images may look better than others depending on how complex they are but, for the most part, asciiviewer works exactly as you would expect.
If you feel like the regular cat command looks a little bland you can spice things up by adding a little color to it. Or a lot of color actually. lolcat works similar to its counterpart but creates rainbow colored text instead of plain white one. It gets even better, though, because lolcat works alongside a large variety of other commands as well. For example, you can combine it with figlet to create rainbow colored ASCII banners or make cowsay’s roster of creatures even more colorful.
This one isn’t particularly funny but it is very useful. Just as its name indicates, the command outputs all the factors of any number you type into the terminal. Why use a calculator for your math homework when you can use Linux terminal commands instead?
No More Secrets and Hollywood
If you want to take a trip back memory lane and feel like a 90s movie hacker this is the perfect command for you. No More Secrets recreated the data encryption effect seen in the movie Sneakers starting Robert Redford. If you want to take things one step further, you can try a similar command known as Hollywood. These utilities don’t have any practical purposes but they’re a lot of fun to use and can make you feel like an old school hacker. Or at least the over-the-top Hollywood version of one.
Speaking of Hollywood movies, we couldn’t leave out the most famous encryption effect of them all. We’re talking of course about the raining green code seen in The Matrix movies starring Keanu Reeves. Not a whole lot more to say about this one. Put on your sunglasses, leather jacket, and enter the Matrix.
A simple and straightforward command that continuously repeats any string of text you type into the terminal. While it’s mainly just for show, yes does have some practical applications as well. For instance, you can use it to automate greetings and responses, especially if you’re a sysadmin.
xeyes is a great command to use when you’re bored or just want to waste some time. The command creates a pair of googly eyes that constantly follow the mouse pointer. Technically speaking, you can use the command for practical purposes, but it’s generally only good for a couple of laughs. Unless you manage to install it on someone else’s computer without them noticing. Then you could potentially have tons of laughs.
Chafa is one of the best utilities out there for converting images and animations into output that can run in the terminal. Unlike the ASCII tools, Chafa gives you a surprisingly accurate approximation of the original media, complete with colors and animations. The end result is often quite impressive and the tool is likely to get even better in the future.
eSpeak is an open source speech synthesizer that supports a wide variety of languages, including English of course. The tool attempts to convert any text found in the terminal into speech and works better than you might expect given its small size. Sure, the output doesn’t sound as good as what you can get with larger synthesizers but it’s still pretty impressive considering that it runs in the terminal.
Isn’t it annoying when you want to create an account on a website or forum and it asks you for all sorts of personal information? The worst part is when they ask you for your home address and phone number. Now, you could just give them your real information or you could use the rig command to generate a fake identity instead. I know the option I’d want to pick.
Last but not least we have Fork Bomb, a command that you should probably never use but is worth knowing just in case. Fork Bomb is essentially a piece of code that continuously multiplies itself until the system runs out of memory. It’s basically the equivalent of a DDoS attack. The code will eventually freeze your system but things will go back to normal once you restart your computer. We advise against using this one, but if you must, make sure to close all running programs before you run it.
The usefulness of some of the commands we discussed in this article is debatable, especially those found in the last section. However, many of them are essential and can come in handy in a lot of situations. If you’re just starting out with Linux, it’s probably a good idea to test some of the simpler ones and work your way up from there. The commands related to terminal navigation and file management are particularly helpful for beginners.
Once you’ve familiarized yourself with the terminal, we recommend checking out our list of best essential Linux apps for newcomers and veterans alike. As great as the terminal is, it does have its limits and sometimes you’ll have to resort to third-party utilities. Speaking of which, don’t miss out on our comprehensive article that covers the best remote desktop clients for Linux.
Best Linux Distros for Developers and Programmers as of 2022
Linux might not be the preferred operating system of most regular users, but it’s definitely the go-to choice for the majority of developers and programmers. While other operating systems can also get the job done pretty well, Linux is a more specialized OS that was…
How to Install Pip on Ubuntu Linux
If you are a fan of using Python programming language, you can make your life easier by using Python Pip. It is a package management utility that allows you to install and manage Python software packages easily. Ubuntu doesn’t come with pre-installed Pip, but here…