10 Useful Basic Linux Commands

10 Useful Linux Commands

When you first start using Linux, it can be overwhelming to attempt to understand all of the commands available. Usually, users learn commands slowly, over time, until the command use becomes second nature.

In this list of basic Linux commands, we’ll point out 10 interesting commands that you will most likely use consistently. The commands we’ll cover are:

  1. man
  2. sudo
  3. grep
  4. finger
  5. tree
  6. du and df (That’s two but get off my back, okay?)
  7. free
  8. uname
  9. wget
  10. ping

We assume you’ve already had some experience with the basics of Linux file managment, such as starting and stopping your system or creating, renaming, or deleting directories. Read on to see how you now might add to and enhance your Linux knowledge.

1. The man Command:

If you’re wondering how to use a particular Linux command, use man to prompt the on-screen manual. For example, to get details on how to use the top command for Linux process management, type:

man top

What if you know what you want to do, but you don’t know the exact name of the command? Linux has a solution for that, too.

The man -k command with a keyword related to your area of interest will return relevant snippets to you (you might like to try the apropos command too, for fuller information). For example, if you’d like to know more about your options for editing, try the keyword “editor” as in:

man -k editor

2. The sudo Command

When you need to run programs on your Linux system requiring administrator privileges, you may have two choices (depending on which Linux distribution you use).

The first is to log in as root or super-user. In this case, you wield huge power, but this could inadvertently lead to serious damage.  Please do not do this.

The second is to use sudo to run just one command that needs administrator authority, and then revert to your normal (non-super) user status.

For example:

sudo shutdown -r +10 "take a break while we reboot"

This will halt the system in 10 minutes and reboot it.

3. Using grep

Sometimes you ask Linux one question and you get back a whole phone directory of answers. The grep command lets you filter out pieces of information of particular interest to you.

For example, if you want to see if user “rocky” exists by searching the /etc/passwd file, then type:

grep rocky /etc/passwd

You can also combine the use of grep with a Linux pipe. For example, use the command ps-a. That on its own will list all running processes and pipe (|) the results into grep to get any specific process information about Firefox:

ps -a | grep firefox

4. Finding Out About Users Using finger Command

While Linux offers the who command for an overall listing of logged-in users, finger gives more information about an individual user.

This includes user login, username, home directory, shell information, and recent activity. If you’d like to know more about rocky for example, type:

finger rocky

5. The tree Command

As a human being rather than a computer, you’ll probably find it easier to see what’s going on in a directory if the content is laid out for you in a clear tree structure.

That’s what the tree command does for you. To see an easy-to-grasp diagram of what’s in the /etc directory, for example, type:

tree /etc

This command also has family over in Linux process management: pstree lists processes in a similar tree-fashion to show parent/child process relationships.

6. The du and df Commands

Having gotten acquainted with users of the system and its directory structures, it might be good see how much space is being used.

The command du will display a list of directories in the current directory, with their sizes and a figure for the total size of the current directory.

The df command lets you do this and lists the names of the file systems concerned, the amount of space corresponding to the file system, what has been used, and what is still available.

Both commands accept the -a option to list all information (du -a, for example) and the -h option to see the information in a more user-friendly form type with gigabytes and megabytes format, rather than l-o-o-o-n-g number of 1-kilobyte-blocks (df -h, for example).

Of course, you can also combine both options (as in du -ah).

7. Checking Your Memory with free

The live memory counterpart to the two commands above, free gives you information on the amount of RAM currently used or available.

The statistics printed out by using free include information on the amount of RAM being used for memory buffers and caching, as well as a figure for the amount of swap space, which is the amount of space set aside on a hard disk to simulate additional main memory.

8. Understanding Your System Setup with uname

By now, you may be getting to a point where you’re thinking about installing extra functionality into a Linux system, like tree above.

In that case, to know which version of the program is required, you’ll need to know which version of Linux is running on the system.

Use the uname -a (the -a option gives you complete information) command to print information about the current machine and the operating system running on it.

For example, uname -a gives an answer back that might be similar to Linux my-server 2.6.32-21-generic #32-Ubuntu SMP Mon Feb 17 09:04:45 UTC 2010 x86_64 GNU/Linux

In this case, Linux is the name of the kernel, Ubuntu is the name of the distribution, and 2.6.32-21-generic is the release version (corresponding to Ubuntu 11.04).

9. Getting Stuff from the Web with wget

See a webpage or a file out there that you want to download? Then wget can help because it handles the HTTP, HTTPS, and FTP protocols.

You can use it to grab a page, www.sample_site.com/index.html for example, like this wget www.sample_site.com/index.html

Advantages offered by wget including working in the background (you don’t have to be logged in as a user), automatically retrying downloads in case of network problems, and recursively downloading pages or files if you want the whole website or directory contents.

10. An Oldie But a Goodie: ping

Finally, if even wget can’t make the download happen, you might want to check that you can actually reach the other system over the net.

Way back when, ping (short for “Packet Internet Groper”) was invented as a simple test to verify that a remote system was online and capable of responding.

It worked so well that it continues to be the first check many people make to see if a network connection is working.

The basic format of the command is ping, where “” is an example of an IP address of another system.

If the packets are pinged back, you’ll see a series of notifications on your screen with the round-trip time to get the response. If packets are not pinged back, that’s where your (first) problem lies.

Final Note:

If a command is not already present on your system, you may need to install it using a command like sudo apt-get install (an example for Debian, Ubuntu, etc.).

Photo Sources: eligiblemagazine.com

Advertiser Disclosure

HostingAdvice.com is a free online resource that offers valuable content and comparison services to users. To keep this resource 100% free, we receive compensation from many of the offers listed on the site. Along with key review factors, this compensation may impact how and where products appear across the site (including, for example, the order in which they appear). HostingAdvice.com does not include the entire universe of available offers. Editorial opinions expressed on the site are strictly our own and are not provided, endorsed, or approved by advertisers.

Our Editorial Review Policy

Our site is committed to publishing independent, accurate content guided by strict editorial guidelines. Before articles and reviews are published on our site, they undergo a thorough review process performed by a team of independent editors and subject-matter experts to ensure the content’s accuracy, timeliness, and impartiality. Our editorial team is separate and independent of our site’s advertisers, and the opinions they express on our site are their own. To read more about our team members and their editorial backgrounds, please visit our site’s About page.