Tricks to make learning the Linux Command Line Easier

Configurare noua (How To)

Situatie

Solutie

Pasi de urmat

The first thing you should do is make your learning environment as comfortable as possible. You don’t want to spend too much time tweaking every last setting, but getting the basics right can make everything that follows a little bit smoother.

The settings will vary depending on your distro, but things to look out for include:

  • Light/dark mode: pick whichever you’re most comfortable reading text in.
  • Font: you’ll want to use something monospaced with clear differences between similar characters e.g. “0” (zero) and “O” (uppercase “oh”).
  • Whether to open new terminals in tabs or windows.
Ubuntu terminal preferences showing settings for text and background color.

You’ll also want to know how to use keyboard shortcuts since 99% of your work on the command line will involve typing. Don’t be afraid to open several terminal windows (or tabs) to run commands simultaneously and organize your tasks.

Ubuntu terminal preferences showing keyboard shortcuts for common operations.

Once you’ve customized your terminal app, you should make a couple of small changes to your shell. This is typically bash, although you can change it to an alternative shell, like fish or zsh.

One of the best quick upgrades you can make is to customize your prompt, the text your shell displays at the beginning of each line. The default is quite useful, but you can make it more useful for learning Linux. I like to use this setup:

export PS1="\n[\$PWD] \$ "

This will remove things like your username and host, which you probably won’t care about when starting. It also displays the full path of your current directory rather than just its name, making it easier to see your current location at a glance:

A Linux terminal showing a custom prompt containing the full path of the current directory.

You can make this setting permanent by adding it to your .bashrc (or similar) file. That file is also a great place to set up aliases, which act like shortcuts for commands. If you find it difficult to remember a command’s name, or its most useful default options, set up an alias, e.g.

alias list='ls -l'

Each command you’ll need to learn has built-in documentation that you can read using the man tool. These “man pages” explain what a command does, different modes of operation, what files it requires, etc.

The Linux man page for the rmdir command showing various options and other details.

The man pages are comprehensive, but they can be a bit overwhelming, especially when you’re getting to know the system. Fortunately, there are alternatives.

Each command will usually support a -h or –help option, which explains how to use it in a simpler form:

The Linux pwd command with the --help option showing brief usage information.

The tldr tool condenses long man pages into more manageable summaries. Here’s a comparison of a classic man page on the left alongside the tldr equivalent on the right:

A Linux man page alongside a tldr equivalent which is much briefer, with clear examples.

tldr shows minimal information, following it up with clear examples for the most common uses of each command. You can install it using your system’s package manager.

Linux commands often have short, abbreviated names for historical reasons. It can be tricky to remember your “chown” from your “sudo.”

First, try exploring the directories listed in your PATH variable. These will contain programs you can run on the command line. Run:

echo $PATH

That shows a set of directories with colon (:) characters between them. Then run:

ls dirname

This will show the contents of one of these directories.

If you’re still having trouble identifying a command, try apropos, a search tool for man pages. Use it when you’re looking for a specific command, but you’re not sure what it’s called. Just run:

apropos keyword

That will search for a keyword and see relevant man pages.

Output from the Linux apropos command showing other commands related to the keyword "pdf."

For further reading, there are plenty of online resources you can consult for free. Find a reliable source that caters to your level of experience and work through everything it has to offer.

Tip solutie

Permanent

Voteaza

(1 din 2 persoane apreciaza acest articol)

Despre Autor