Linux is a powerful operating system with commands to help you manage and interact with your system. Whether you’re a beginner or an experienced user, mastering the most common Linux commands is essential for efficient and effective system administration. In this article, I tell you about my top 10 commands, and provide practical examples to get you started.

What’s a prompt?

Before getting started, you need to know what a “prompt” is. The command prompt on Linux usually looks like a dollar sign ($), and it’s the computer’s way of telling you that it’s ready to receive a command. If you don’t see a prompt, then the computer’s currently running a command and can’t take another one, at least in that terminal. When this article tells you to type a command, never type in the very first $ because that’s meant to represent your computer’s prompt.

1. ls for “list”

The ls command lists files and directories. It provides useful information like file size, ownership, and permissions. Open a terminal and type:

You can see hidden files and directories with the -a option:

Get detailed information about each file and directory:

And you can sort items by modification time with the -t option:

2. cd for “change directory”

The cd command permits you to change directories from your current directory to a new directory. It’s used to navigate through the file system.

You can move to a specific directory by providing the full path to where you want to go:

Move just one directory up:

Move two directories up:

3. mkdir for “make directory”

The mkdir command allows you to create directories within the file system.

You can make several directories at once, one inside the other, using the -p option:

Or you can make several directories at one, next to one another:

4. rm for “remove”

The rm command permanently removes files and directories. There is no un-remove command, so use this judiciously!

$ rm file.txt

Remove a directory:

5. cp for “copy”

The cp command copies files and directories to your specified destination:

Copy a whole directory and everything within it:

6. mv for “move” (and “rename”)

Use the mv command to move and rename files (renaming a file is really moving it to its same location but with a new name).

Rename a file:

7. grep for “filter”

The grep command is a powerful tool for finding patterns in text. You can search the output of the ls command to find a specific file in a long list:

Or search the output of ls for all files containing a specific pattern of letters:

Alternately, you can search the text within a file for specific words and patterns:

Search for a pattern in multiple files:

Search for a pattern recursively in a directory

8. chmod for “change mode”

The chmod command is used to change file and directory permissions.

Set read, write, and execute permissions for the user who owns the file:

Remove write permissions for the group and others:

Set read and execute permissions for all users:

9. sudo for administration

The sudo command allows you to execute a command with superuser privileges.

For example, when you need to edit a configuration file you don’t normally permission to edit as a regular user:

10. man for “manual”

The man‘command provides access to the user manual (documentation) for each command. These “man pages” provide detailed information on all the different options you have for a command.

Search for a keyword within manual pages:

To exit a man page, press Q on your keyboard.

More commands to discover

These 10 Linux commands are the bedrock of your journey as a Linux user. Familiarize yourself with these commands and their advanced options to gain greater control of your system. With great power comes great responsibility, too. Be careful how you use sudo and rm lest you wreak havoc on your system! And be sure you know where you are on the file system before executing a command. It’s always a good idea to use the pwd command, which provides a printout to your display of your current position within the file system.

And this is just the beginning. The more you use Linux, the more useful commands you’ll discover. Start learning more today, and then consider writing an article about what you’ve found for Sysadmin Signal!

Author

  • Don Watkins

    I'm an educator, entrepreneur, open source advocate, life long learner, Pythonista, writer, and refurbisher of old computers using Linux. M.A. in Educational Psychology, MSED in Educational Leadership, Linux system administrator.


Don Watkins

I'm an educator, entrepreneur, open source advocate, life long learner, Pythonista, writer, and refurbisher of old computers using Linux. M.A. in Educational Psychology, MSED in Educational Leadership, Linux system administrator.

0 Comments

Leave a Reply

Avatar placeholder

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