All things considered, I’m a bit of a newbie when it comes to Linux. I only started using it in May of this year, but I’ve quickly fallen in love with it and much prefer using it over Windows. I’ve learned a lot in that short span of time, and a there are a lot of terminal commands I’ve had to learn to really get familiar with how Linux works.
I used to be terrified of using the terminal, but as a Linux user, it’s something you get accustomed to fairly quickly, and it’s extremely helpful to know your way around. So, if you’re new to Linux, here are some commands that have changed my perception of the Linux terminal and helped me get a grip on what I’m doing.
Related
Sudo
Start with th…
All things considered, I’m a bit of a newbie when it comes to Linux. I only started using it in May of this year, but I’ve quickly fallen in love with it and much prefer using it over Windows. I’ve learned a lot in that short span of time, and a there are a lot of terminal commands I’ve had to learn to really get familiar with how Linux works.
I used to be terrified of using the terminal, but as a Linux user, it’s something you get accustomed to fairly quickly, and it’s extremely helpful to know your way around. So, if you’re new to Linux, here are some commands that have changed my perception of the Linux terminal and helped me get a grip on what I’m doing.
Related
Sudo
Start with the basics
For a Linux user, even mentioning this may seem ridiculous, but for someone coming from Windows, it’s something you might not think of, and it’s extremely important to learn. Officially, sudo stands for "substitute user, do", though I remember hearing about it many years ago as "superuser do".
Sudo lets you run any terminal command as another user — hence "substitute user" — but the default and most common use for it is to run said command as the root user or superuser (the equivalent of a Windows administrator), so both meanings make sense.
A lot of Linux commands will require you to act with root permissions as a security measure to prevent systems from potentially breaking or being affected by malware. Something as simple as installing or updating an app using a package manager will require root-level permissions, so you have to be ready to use it in many cases.
You won’t use the sudo command by itself, though. It has to precede whatever command you actually want to use, and then you’ll be asked for the password for your root account.
Recently, Windows 11 has implemented a sudo-like feature for its terminal, but there are some differences, and it’s still disabled by default. As such, there’s a good chance you’re not familiar with it as a Windows user.
Related
You can use sudo in Windows 11, too — here’s how
This popular Linux feature is finally on Windows PCs
Updating packages
No two distros are the same
Linux is very different from Windows in many ways, and one of them is how you install apps on your computer. Linux uses a concept known as a package manager, but you’d be wrong if you think there’s only one or that they all work the same way.
Take Ubuntu, for example, as it’s one of the most popular Linux distros out there. It uses the APT package manager, so installing an app uses a command like sudo apt install AppName. It’s fairly straightforward and readable, and other package managers like DNF (which ships with Fedora) use similar language.
But then you have something like Arch, which comes with a package manager called pacman, and that’s quite different. To install an app with pacman, you use the command sudo pacman -S AppName, where the S stands for "sync". Not only is the format different since it mostly relies on initials, but pacman uses the term "sync" in lieu of "install", so you may feel like you’re poking around in the dark if you don’t do some reading first.
And it’s not just the syntax that changes. Packages on Linux are different across the different package managers, and they’re very different than they are on Windows. A package manager on Windows is really just downloading the same EXE or MSI installer, and those are universally supported across Windows PCs. On Linux, the same app may be in different packages depending on what package manager your distro uses.
Related
I’ve used loads of Linux packagers, but this is by far the best one
Pacman isn’t just a video game character, but it’s also one of the best Linux package managers.
Man pages
Read the manual
If you want to learn more about anything, reading the manual is often the best way to go, and Linux comes with a way you can do that right from the Linux terminal. Man pages (short for "manual pages") let you learn all kinds of things about your current operating system, and you can access them easily with the man command in your terminal.
On a distro like Arch, the package for man pages is actually not installed by default, so you’ll need to get it with sudo pacman -S man-db, but once you have it, simply entering the man command followed by the name of a package will get you a long, human-reasable page with all sort of information about that package, the commands it supports, and what they all do.
You can learn a lot about most commands by following them with –help, but man pages offer a much more detailed explanation of everything you need to know, down to the basics of how it works, so you really feel like you have a handle on that tool. Whether you’re new to Linux or not, man pages can make it way easier to figure out next steps in relation to anything you may be doing for the first time.
Related
6 Linux terminal habits I wish I learned years ago
These neat tricks make my Linux experiments a lot easier
Pipes
Commands can communicate with each other
A very useful tool in the Linux terminal is called pipes, and it’s very useful for combining different commands to get the results you want. Pipes are used with the | character (it’s a vertical slash, not a capital I or lowercase L), and you use them when you want to pass the output of a command to the next command, narrowing down the final terminal output.
As an example, let’s say you want to search for files in a specific folder. You can navigate to that folder using the cd command, and once you’re in that folder, type:
ls | grep
The ls command lists all the files in a directory, but instead of outputting that data in the terminal, the pipe is making it so that the output is that sent to the grep command, which is a search tool. This means grep will search for the filename you entered in the list of files generated by the ls command.
That’s just one basic example, but as you get familiar with more Linux commands, you’ll see that pipes often come in handy for all kinds of situations. A while back, I was having issues with my laptop occasionally getting stuck during boot, so a friend recommended using the command dmesg -T | grep i915. The dmesg is used to display kernel messages related to hardware detection and initialization, and here, the pipe allowed me to then search that message for the term "i915" — referring to Intel integrated graphics drivers — so I could spot any issues with loading said driver.
Related
6 Linux command line tricks everyone should know
Level up your Linux CLI experience with these cool tricks
File manipulation commands
You can do it all from the terminal
This part isn’t about a specific command, but rather a whole set of commands that Linux offers that allow you to manipulate and handles files on your system. There are a few ones worth mentioning, and we can start with grep, since that was mentioned above. This is a search tool that can find files with specific file names or using RegEx (regular expressions) for wildcards. Of course, as seen above, it can be combined with the ls command, which lists all the contents of a given directory.
But there are more commands that let you act on a specific file. For example, the cat command, short for concatenate, can be used to display the contents of a text file directly in the terminal. In fact, you can even use it to display the contents of multiple files together, and there are even options to show contents with line numbers and a few other things. Along with cat, there are also head and tail commands, which display only the first or last few lines of a file, respectively. There’s also the less command, which displays the contents of a file in page form rather than showing the entire content in one go.
Finally, the sort command lets you sort the lines inside a text file. By default, it sorts them alphabetically, with lines starting with a number at the top, though there are also multiple options to configure the output. It’s also worth noting that this doesn’t actually change the file you’re acting it, it just changes how the content is displayed in the terminal, though you can output a file with the sorted order if you so choose.
Related
4 next-generation file systems that you can actually use today
ZFS, BtrFS, Bcachefs, EROFS, these are the names of some next-generation file systems that you can actually use today.
Aliases are great, too
Multiple commands in one
Finally, I’d like to talk less about specific commands and more about commands you can make yourself. Aliases let you create custom commands you can use as stand-ins for much longer commands, for combinations of commands.
I wrote about this recently, and it’s incredibly useful. One of my favorite examples is creating an alias for running your last command with sudo permissions, since it can be easy to forget to type it out. You can create an alias, such as pls**,** to match the command sudo $(fc -ln -1), so every time you type pls, it will run your previous command with sudo permissions.
Aliases can be for anything you want, so you can combine multiple commands for anything you want to simply. It can make it easier to navigate to a specific directory, install updates, and much more.
Related
Learning the terminal means learning Linux
These are just some examples of things you can do with the Linux terminal that help you understand how it works and how to use it. Once you get familiar with it, it’s a very powerful tool, and these are great starting points for a lot of what you’ll be doing on your PC.