___##INDEX
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
Update the package list to ensure you have the latest package information.
sudo apt-get upgrade
Upgrade all installed packages to the latest version.
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/
Change from the current directory to the windows desktop directory.
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
List the contents of 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
Remove a file or directory with verbose output.
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
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
Display the contents of that 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.
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
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
Append the text "nora" to the file squad5
.
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
Display the first 10 lines of a file with the file name.
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
Display the last 5 lines of a file.
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 -
Switch to the root user.
su - username
Switch to a specific 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
Show the manual for the ls
command.
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
Create a new user account named bob
.
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
Create a new empty file named newfile.txt
.
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)
nicely done!
Awesome 👏