DEV Community

Cover image for Linux 101: Understanding Basic Commands and Concepts By: Bassey Ekpenyonganwan (NORA)
Nora Bassey
Nora Bassey

Posted on • Updated on

Linux 101: Understanding Basic Commands and Concepts By: Bassey Ekpenyonganwan (NORA)

___##INDEX

  1. Introduction
  2. Sudo
  3. cd
  4. ls
  5. rm
  6. nano
  7. cat
  8. mkdir
  9. grep
  10. echo
  11. head
  12. tail
  13. su
  14. man
  15. adduser
  16. touch

Introduction

Linux, the backbone of modern computing, is a powerful and versatile operating system that has revolutionized the way we interact with technology. With its robust architecture and extensive customization options, Linux has become the go-to choice for developers, system administrators, and power users alike. However, navigating the intricacies of Linux can be daunting, especially for those new to the ecosystem.

In this article, we’ll delve into the essential Linux commands that form the foundation of mastery, with examples using Windows Subsystem for Linux (WSL) running Ubuntu Debian. These commands are the building blocks of Linux expertise, and understanding them is crucial for unlocking the full potential of this incredible operating system. From navigating file systems to managing processes, we’ll explore 15 basic Linux commands that every user should know.

1. sudo Command

The sudo command runs a command with superuser privileges, prompting for your user password. It's used for tasks that require elevated permissions, like installing software or modifying system files.

Example:

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Update the package list to ensure you have the latest package information.

sudo apt-get upgrade
Enter fullscreen mode Exit fullscreen mode

Upgrade all installed packages to the latest version.

An instance of Updating and upgrading your software to the latest version using the sudo command


2. cd Command

The cd (change directory) command is used to navigate between directories in the file system. It allows you to move to different directories, making it easier to manage files and folders.

Example:

cd /mnt/c/Users/USER/Desktop/
Enter fullscreen mode Exit fullscreen mode

Change from the current directory to the windows desktop directory.

An instance of changing Directory using the ‘cd’ command.


3. ls Command

The ls command in Linux is used to list the contents of a directory. It displays a list of files and subdirectories in the current directory or the specified directory.

Example:

ls
Enter fullscreen mode Exit fullscreen mode

List the contents of the current directory.

the ls command listing out contents in the current directory


4. rm Command

The rm command is used to remove a file or directory. The command line doesn’t have a recycle bin or trash, so while using the rm command, one has to be careful.

Example:

rm -v file.txt
Enter fullscreen mode Exit fullscreen mode

Remove a file or directory with verbose output.

removing a file from a directory using the rm -v command


5. nano Command

The nano command is a lightweight text editor, ideal for quick edits and small files. It is user-friendly and easy to navigate.

Example:

nano NORA BASSEY.txt
Enter fullscreen mode Exit fullscreen mode

image showing how nano text editor looks like

6. cat Command

The cat command in Linux is used to display, combine, and create files. It can show the contents of a file, merge multiple files into one, or create a new file and allow you to enter text.

Example:

cat NORA BASSEY
Enter fullscreen mode Exit fullscreen mode

Display the contents of that file.

cat command being used to display the content of a file


7. mkdir Command

The mkdir command is used to create a new directory (folder). When you run mkdir followed by a name, it creates a new directory with that name in your current working directory.

Image description

8. grep Command

The grep command is used to search for a specific pattern or text within one or more files. It's a powerful tool for finding and filtering data in text files.

Example:

grep "pattern" file.txt
Enter fullscreen mode Exit fullscreen mode

Search for a specific pattern in a file.


9. echo Command

The echo command prints its arguments to the terminal, expanding variables and processing options. It outputs the text followed by a newline character and is used to append t file.

Example:

echo nora >> squad5
Enter fullscreen mode Exit fullscreen mode

Append the text "nora" to the file squad5.

An instance of echo command on the  terminal


10. head Command

The head command displays the first few lines of a file (default is 10 lines). It shows the top portion of a text file, helping you quickly view the beginning of a file without opening the entire file.

Example:

head -n 10 file.txt
Enter fullscreen mode Exit fullscreen mode

Display the first 10 lines of a file with the file name.

An instance of the head command in linux


11. tail Command

The tail command displays the last few lines of a file (default is 10 lines). It shows the end portion of a text file, helping you quickly view the latest entries or updates in a file, such as log files.

Example:

tail -n -5 file.txt
Enter fullscreen mode Exit fullscreen mode

Display the last 5 lines of a file.

An instance of the tail command in linux

12. su Command

The su command switches the current user to another user, typically the superuser (root), allowing you to execute commands with elevated privileges.

Example:

su -
Enter fullscreen mode Exit fullscreen mode

Switch to the root user.

su - username
Enter fullscreen mode Exit fullscreen mode

Switch to a specific user.

su command switching to another user


13. man Command

The man command displays the manual for a command, function, or system call, providing detailed documentation on its usage, options, and examples.

Example:

man ls
Enter fullscreen mode Exit fullscreen mode

Show the manual for the ls command.

Image description

14. adduser Command

The adduser command creates a new user account on a Linux system, allowing you to specify username, password, and other details. It's a simple way to add users without manually editing configuration files.

Example:

adduser bob
Enter fullscreen mode Exit fullscreen mode

Create a new user account named bob.

An instance displaying the application of adduser


15. touch Command

The touch command creates a new empty file or updates the timestamp of an existing file to the current date and time.

Example:

touch newfile.txt
Enter fullscreen mode Exit fullscreen mode

Create a new empty file named newfile.txt.

Image description


SUMMARY

In this article, I covered the basics of Linux commands, including navigating the file system, creating and editing files, and managing users. Practice these commands to become more comfortable with the Linux environment. For more advanced topics, explore online resources like the Linux Documentation Projects. Remember to always use the manual pages for detailed command information. Again I hope you found it helpful?

-- stay curious and keep learning!
_

Top comments (2)

Collapse
 
dheecloud profile image
Uduakabasi Umo-Odiong

nicely done!

Collapse
 
esther_etuk_85aee0a31114c profile image
Esther Etuk

Awesome 👏