Pinterest Stumbleupon Whatsapp
Ads by Google

If you want to become a true Linux master, having some knowledge of terminal commands is a good idea. Here are four different methods you can use to start teaching yourself.

Tip of the Day

learncommands_tipoftheday
A great way to gradually learn more about terminal commands is to have a “Tip of the Day” style message appear each time you open up the terminal. These messages can tell you about useful commands, as well as advanced tricks for certain commands you may already know. You can easily set this up by going into your .bashrc file (located at /home/<user>/.bashrc) and add the following to the end of the file on a new line:

echo "Did you know that:"; whatis $(ls /bin | shuf -n 1)

That’s all you have to do! If you’d like to make it slightly more entertaining, you can make a cow say all of these tips. To do so, run the command sudo apt-get install cowsay for Ubuntu/Debian or sudo yum install cowsay for Fedora. Then, instead of the code above, add the following to your .bashrc file:

cowsay -f $(ls /usr/share/cowsay/cows | shuf -n 1 | cut -d. -f1) $(whatis $(ls /bin) 2>/dev/null | shuf -n 1)

Sadly, this doesn’t work with all distributions, so your success with cowsay isn’t guaranteed. However, this entire tip uses “whatis” on random commands, which we’ll cover next.

Ads by Google

Using “whatis”

If you don’t want to learn random things, maybe you want to learn about commands you need to use right at that moment. To do this, simply prefix all of your commands with “whatis”. The command should then be able to tell you piece by piece what the command consists of.

learncommands_whatis

 

A great example whatis sudo yum install cheese, can be seen above. It tells you that sudo gives you administrative rights, yum is the package manager, install tells YUM to install a package, and cheese is the photo booth application you’re wishing to install. It doesn’t quite always work, especially on more complex or less common commands, but it’s still worthwhile to try out if you want to learn what a command actually does.

View All Available Command Options

learncommands_manpages
If you’re using a new command, there are two good ways to take a detailed look at it. The first way is to run the command “man <program>”, where <program> is the name of the program you’re running. So, running “man cp” will tell you all there is to know about the cp command in the man file viewer.

A quicker way to learn the major parts of the command is to run “<program> –help”, where <program> is the name of the program you’re running. So, running “cp –help” will also tell you a good deal of info about the cp command, printed right to the terminal. In other words, –help is the only flag that doesn’t have alternating meanings from program to program.

Crash Course – Yes, Now!

Lastly, you can learn something about command syntax…right here! Knowing the general syntax of terminal commands can help quite a bit in understanding all commands, so it’s worth studying and understanding before you look at specific commands as examples.

All commands share the following structure: [sudo] program [parameter] [parameter] … [parameter] [-flag] [parameter] [-flag] [parameter] … [flag] [parameter]

Let me break down what the above structure means:

  1. If a command requires administrative rights (known as root access), then they must be preceded with “sudo”, which requires you to enter in your password before the command executes.
  2. “program” is where the name of the application goes. Application names include yum, apt-get, cheese, tar, cp, mv, firefox, and much more. Unless additional configuration has been done, all programs that are accessible this way have an executable located in /usr/bin. This should apply to all installed applications on your system. For some applications, you just have to write it, and that’s all. For example, you can just type “firefox” and hit Enter, and it’ll launch Firefox.
  3. Following the program, you can start using parameters and flags. This varies greatly from program to program. For example, the command “cp file1 file2” copies the file “file1” and saves it in the same location with the name “file2”. Those are that command’s two parameters. Some also take flags that modify its behavior – for example, the command “sudo yum install cheese -y” has “install” as a parameter to yum, “cheese” as a parameter to install, and “-y” as a flag to yum saying that it should assume yes for all instances where it would normally ask you if you’d like to continue. While this example doesn’t show it, some flags don’t require their own parameters, and some flags do. Each program has its own set of flags and meanings, which you’ll learn over time through repetition.

Conclusion

Learning terminal commands really isn’t that hard – once you get going and understand how they generally work and are structured, learning others will become a lot easier. If it doesn’t make sense after a few hours, don’t give up. Repetition is your best friend, and you’ll start seeing the patterns eventually. From there, it’s all about memorization through practice. We also have various other resources for learning commands, such as this Linux command cheatsheet, the 40 essential Linux commands An A-Z of Linux - 40 Essential Commands You Should Know An A-Z of Linux - 40 Essential Commands You Should Know Linux is the oft-ignored third wheel to Windows and Mac. Yes, over the past decade, the open source operating system has gained a lot of traction, but it’s still a far cry from being considered... Read More , and another quick intro to Linux commands A Quick Guide To Get Started With The Linux Command Line A Quick Guide To Get Started With The Linux Command Line You can do lots of amazing stuff with commands in Linux and it's really not difficult to learn. Read More .

What tips do you have for others who are trying to learn? Do you know of a command that does something cool or is just for fun? Let us know in the comments!

  1. piyush
    January 8, 2015 at 1:44 pm

    spending a lot of time on askubuntu and using man command before everything worked for me.

    • PlaGeRaN
      February 3, 2015 at 10:37 am

      True, if I'm struggling with command line I usually look for the program's forum site (cyanogen/git/askubuntu) most of the issue's I've faced were already answered.

  2. Wantoo Sevin
    March 20, 2014 at 6:42 pm

    This is a great idea and a great way to implement it! I'm going to try it out right now.

    Also, it's so damned refreshing to see a tech journalist using Fedora and not, well...some other distribution. Not that any other distribution is bad, it's just refreshing to see a change.

  3. Miguel
    February 14, 2014 at 10:37 am

    So you simply wanna start to work full of adrenaline?
    Have you considered that this means you are not the target group anyway.
    I think it's a great Tip for people starting with Linux or the cli and just wanna play around a bit.
    And I also hate Tips of the day
    in programms I can grasp on my own.

  4. dragonmouth
    February 9, 2014 at 8:45 pm

    Tip of the Day is intrusive, disruptive and unrelated to the reason I started CLI.

    None of the 4 ways give examples of proper usage of the command and its options.

  5. Chun Tat David Chu
    February 8, 2014 at 3:54 am

    You forget to mention about explainshell.com.

    • Danny S
      February 28, 2014 at 11:44 pm

      Interesting website! Thanks for the tip!

  6. Mark
    February 8, 2014 at 12:09 am

    This is quit a good idea for anyone new to *nix.

  7. nalk
    February 7, 2014 at 7:25 pm

    The first suggestion about the tip of the day is really not a good idea.

    I open the terminal because I need to do a job "right now this second".

    A tip of the day means my focus would have to shift from wanting to finish the job - "action mode", to "learning mode" which would require a major change of my adrenalin-levels.

    My action modes and my learnig modes dont really work well together.

    Besides, some Windows programs have a feature like that and nobody I know read those. They just mark them "dont show this at start up" and never see them again. They are more of a nuissance than a leaning aide much akin to the famous nag screens.

    The way the Linux terminal uses tip of the day would make the tip "fade in to the background" after a very short while.

    The cow thingy is only funny for about half a second.

    • Danny S
      February 28, 2014 at 11:44 pm

      Eh, some people don't like it, and others do. At least with doing it this way (if people wanted to), they're opting in to learn something rather than having to opt out of learning about something they don't care quite as much. It's a suggestion that some might find useful, but certainly not everyone. People should feel free to try any combination.

  8. Anunnaki
    February 7, 2014 at 4:16 pm

    In order for the whatis command to work, one needs to make a whatis database first by entering "makewhatis"

    • Danny S
      February 28, 2014 at 11:42 pm

      Doing that might help to expand what whatis knows. I do agree that there's still a lot of things that it gets confused on.

Leave a Reply

Your email address will not be published. Required fields are marked *